| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
```ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips"
end
Benchmark.ips do |x|
x.report('+@') { +"" }
x.report('dup') { "".dup }
x.compare!
end
```
```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
+@ 282.289k i/100ms
dup 187.638k i/100ms
Calculating -------------------------------------
+@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s
dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s
Comparison:
+@: 6775299.3 i/s
dup: 3320400.7 i/s - 2.04x slower
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
to customize year
names. Lambda should be passed to use this option. Example:
date_select('user_birthday', '', start_year: 1998, end_year: 2000, year_format: ->year { "Heisei #{year - 1988}" })
The HTML produced:
<select id="user_birthday__1i" name="user_birthday[(1i)]">
<option value="1998">Heisei 10</option>
<option value="1999">Heisei 11</option>
<option value="2000">Heisei 12</option>
</select>
/* The rest is omitted */
|
|
|
|
| |
Related to https://github.com/rails/rails/commit/d4eb0dc89ee6b476e2e10869dc282a96f956c6c7#r27830891
|
|
|
|
|
|
| |
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.
References #32028
|
| |
|
|
|
|
| |
Follow up of #31390.
|
|
|
|
| |
And enable `context_dependent` of Style/BracesAroundHashParameters cop.
|
| |
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
|\
| |
| |
| | |
Enforce frozen string in Rubocop
|
| | |
|
|/
|
|
| |
Plus a couple of related ActionPack patches.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The test using mathn was first introduced in f1d9179 to check that the
`distance_of_time_in_words` properly doesn't use the `Fixnum#/` method
by explicitly requiring this library as it redefines this method.
Given that `mathn` has been gemified in Ruby 2.5 and is deprecated since
version 2.2, we can certainly safely assume that people will most-likely
not require this library in their application.
However, to make sure that we don't regress, let's add a test similar to
the one before f1d9179.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Internally all input is converted to time so that it can be treated
uniformly.
Remove now-unneeded condition
* Now that all input is treated is converted to time, we no longer need
to type check it.
Rename variables to clarify their purpose
Extract private method to normalize distance_of_time args to time
Update actionview changelog
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently `ActiveSupport::Duration` implicitly converts to a seconds
value when used in a calculation except for the explicit examples of
addition and subtraction where the duration is the receiver, e.g:
>> 2 * 1.day
=> 172800
This results in lots of confusion especially when using durations
with dates because adding/subtracting a value from a date treats
integers as a day and not a second, e.g:
>> Date.today
=> Wed, 01 Mar 2017
>> Date.today + 2 * 1.day
=> Mon, 10 Apr 2490
To fix this we're implementing `coerce` so that we can provide a
deprecation warning with the intent of removing the implicit coercion
in Rails 5.2, e.g:
>> 2 * 1.day
DEPRECATION WARNING: Implicit coercion of ActiveSupport::Duration
to a Numeric is deprecated and will raise a TypeError in Rails 5.2.
=> 172800
In Rails 5.2 it will raise `TypeError`, e.g:
>> 2 * 1.day
TypeError: ActiveSupport::Duration can't be coerced into Integer
This is the same behavior as with other types in Ruby, e.g:
>> 2 * "foo"
TypeError: String can't be coerced into Integer
>> "foo" * 2
=> "foofoo"
As part of this deprecation add `*` and `/` methods to `AS::Duration`
so that calculations that keep the duration as the receiver work
correctly whether the final receiver is a `Date` or `Time`, e.g:
>> Date.today
=> Wed, 01 Mar 2017
>> Date.today + 1.day * 2
=> Fri, 03 Mar 2017
Fixes #27457.
|
|
|
|
| |
empty lines
|
| |
|
|
|
|
|
|
|
|
| |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
|
|
|
|
|
| |
This is based on https://github.com/kangax/html-minifier/blob/6b2d4536d82819143b468b41a89c700b6c61631f/src/htmlminifier.js#L197 and
spec from https://www.w3.org/TR/html51/single-page.html.
Couple of other changes to tests due to support update:
- autobuffer has been dropped in favour of preload attribute, ref: https://msdn.microsoft.com/en-us/library/ff974743(v=vs.85).aspx
- pubdate attribute has been dropped from spec, ref: https://www.w3.org/html/wg/tracker/issues/185
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`date_select` helper `:with_css_classes` option now accepts a hash of strings
for `:year`, `:month`, `:day`, `:hour`, `:minute`, `:second` that will extend
the select type with the given css class value.
```erb
<%= f.date_select :birthday, with_css_classes: { month: "my-month", year: "my-year" } %>
```
```html
<select id="user_birthday_3i" name="user[birthday(3i)]">…</select>
<select id="user_birthday_2i" name="user[birthday(2i)]" class="my-month">…</select>
<select id="user_birthday_1i" name="user[birthday(1i)]" class="my-year">…</select>
```
Optional, add global `html_options` to modify every select tag in the set.
```erb
<%= f.date_select :birthday, with_css_classes: { month: "my-month", year: "my-year" }, { class: "my-date optional" } %>
```
Supported DateHelper methods: `select_day`, `select_month`, `select_year`,
`select_hour`, `select_minute`, `select_second`, `select_datetime`, `select_time`,
`time_select`, `date_select` and `datetime_select`.
`:with_css_classes` option was added to the `date_select` with #7975.
|
|
|
|
|
|
| |
of html_safe in favour of raw() in AV helpers.
Also changed usage of html_safe to make use of raw() instead so that the intended behaviour is verified with raw()
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
{day: params[:day].to_i, month: params[:month].to_id}
Adds in test test_date_select_with_selected_in_hash and change log
fixes typo in CHANGELOG
|
| |
|
|
|
|
|
|
|
|
|
| |
Running Action View test case currently printing out this warning:
lib/mathn.rb is deprecated
This should silence the warning since we really want to require this
file in this test.
|
|
|
|
|
| |
Since real timezone is loaded anyway in `#utc_offset`
which is called during `#create`
|
| |
|
| |
|
| |
|
|
|
|
| |
ASCII-8BIT.
|
| |
|
|
|
|
|
| |
with_css_classes: true option overwrites other html classes.
Concatenate day month and year classes rather than overwriting.
|
|
|
|
| |
#13618]
|
|
|
|
|
|
|
|
| |
MRI reimplemented Date in C so it doesn't hit this division anymore
while JRuby still uses the old stdlib implementation of Date so
it will always hit this.
With this change the actionview date_helper_test.rb tests should pass on JRuby.
|
|
|