- 23 5月, 2018 2 次提交
-
-
由 Rafael França 提交于
Allow Range#=== and Range#cover? on Range
-
由 Rafael França 提交于
Speed up xor_byte_strings by 70%
-
- 22 5月, 2018 2 次提交
-
-
由 utilum 提交于
-
由 utilum 提交于
ruby/ruby@989e07c features switching `Range#===` to use internal `r_cover_p` instead of rubyland `include?`. This breaks expected behavior of `ActiveSupport::CoreExt::Range` documented since at least 8b67a022. This patch adds overrides on `Range#cover?` and `Range#===` and places all three in a single module, `CompareWithRange`. *Requiring core_ext/range/include_range now causes a deprecation warnning*
-
- 21 5月, 2018 12 次提交
-
-
由 George Claghorn 提交于
[ActiveStorage] Disable variant options when false or nil present
-
由 Kasper Timm Hansen 提交于
Add Enumerable#index_with.
-
由 Kasper Timm Hansen 提交于
-
由 Kasper Timm Hansen 提交于
In the app I'm working on I've wished that index_by had a buddy that would assign the hash value instead of the key multiple times. Enter index_with. Useful when building a hash from a static list of symbols. Before you'd do: ```ruby POST_ATTRIBUTES.map { |attr_name| [ attr_name, public_send(attr_name) ] }.to_h ``` But now that's a little clearer and faster with: ````ruby POST_ATTRIBUTES.index_with { |attr_name| public_send(attr_name) } ``` It's also useful when you have an enumerable that should be converted to a hash, but you don't want to muddle the code up with the overhead that it takes to create that hash. So before, that's: ```ruby WEEKDAYS.each_with_object(Hash.new) do |day, intervals| intervals[day] = [ Interval.all_day ] end ``` And now it's just: ```ruby WEEKDAYS.index_with([ Interval.all_day ]) ``` It's also nice to quickly get a hash with either nil, [], or {} as the value.
-
由 Kasper Timm Hansen 提交于
Exception wording change
-
由 Jacob Smith 提交于
In response to https://github.com/rails/rails/issues/32917 In the current implementation, ActiveStorage passes all options to the underlying processor, including when a key has a value of false. For example, passing: ``` avatar.variant(resize: "100x100", monochrome: false, flip: "-90") ``` will return a monochrome image (or an error, pending on ImageMagick configuration) because it passes `-monochrome false` to the command (but the command line does not allow disabling flags this way, as usually a user would omit the flag entirely to disable that feature). This fix only passes those keys forward to the underlying processor if the value responds to `present?`. In practice, this means that `false` or `nil` will be filtered out before going to the processor. One possible use case would be for a user to be able to apply different filters to an avatar. The code might look something like: ``` variant_options = { monochrome: params[:monochrome], resize: params[:resize] } avatar.variant(*variant_options) ``` Obviously some sanitization may be beneficial in a real-world scenario, but this type of configuration object could be used in many other places as well. - Add removing falsy values from varaints to changelog - The entirety of #image_processing_transformation inject block was wrapped in `list.tap` to guard against the default `nil` being returned if no conditional was called. - add test for explicitly true variant options
-
由 Kasper Timm Hansen 提交于
Follows the change from 6fac9bd5, so the naming is consistent.
-
由 Cory Becker 提交于
-
由 Ryuta Kamizono 提交于
Bump minimum SQLite version to 3.8
-
由 Ryuta Kamizono 提交于
To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008 automatically in the future.
-
由 Yasuo Honda 提交于
These OS versions have SQLite 3.8 or higher by default. - macOS 10.10 (Yosemite) or higher - Ubuntu 14.04 LTS or higher Raising the minimum version of SQLite 3.8 introduces these changes: - All of bundled adapters support `supports_multi_insert?` - SQLite 3.8 always satisifies `supports_foreign_keys_in_create?` and `supports_partial_index?` - sqlite adapter can support `alter_table` method for foreign key referenced tables by #32865 - Deprecated `supports_multi_insert?` method
-
由 Ryuta Kamizono 提交于
So do not expose `PostgreSQLTypeMetadata` in the doc too.
-
- 20 5月, 2018 1 次提交
-
-
由 yuuji.yaginuma 提交于
Follow up of #32418.
-
- 19 5月, 2018 7 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
Finalize transaction record state after real transaction
-
由 Eugene Kenny 提交于
After a real (non-savepoint) transaction has committed or rolled back, the original persistence-related state for all records modified in that transaction is discarded or restored, respectively. When the model has transactional callbacks, this happens synchronously in the `committed!` or `rolled_back!` methods; otherwise, it happens lazily the next time the record's persistence-related state is accessed. The synchronous code path always finalizes the state of the record, but the lazy code path only pops one "level" from the transaction counter, assuming it will always reach zero immediately after a real transaction. As the test cases included here demonstrate, that isn't always the case. By using the same logic as the synchronous code path, we ensure that the record's state is always updated after a real transaction has finished.
-
由 Jeremy Evans 提交于
Benchmark: ```ruby require 'benchmark' require 'benchmark/ips' require 'securerandom' def xor_byte_strings(s1, s2) # :doc: s2_bytes = s2.bytes s1.each_byte.with_index { |c1, i| s2_bytes[i] ^= c1 } s2_bytes.pack("C*") end def xor_byte_strings_new(s1, s2) # :doc: s2 = s2.dup size = s1.bytesize i = 0 while i < size s2.setbyte(i, s1.getbyte(i) ^ s2.getbyte(i)) i += 1 end s2 end s1 = SecureRandom.random_bytes(32) s2 = SecureRandom.random_bytes(32) Benchmark.ips do |x| x.report("current"){xor_byte_strings(s1, s2)} x.report("new"){xor_byte_strings_new(s1, s2)} x.compare! end 100000.times do |i| s3 = SecureRandom.random_bytes(32) s4 = SecureRandom.random_bytes(32) raise unless xor_byte_strings(s3, s4) == xor_byte_strings_new(s3, s4) end ``` Results on ruby 2.5.1: ``` Warming up -------------------------------------- current 6.519k i/100ms new 10.508k i/100ms Calculating ------------------------------------- current 84.723k (_ 0.4%) i/s - 423.735k in 5.001456s new 145.871k (_ 0.3%) i/s - 735.560k in 5.042606s Comparison: new: 145870.6 i/s current: 84723.4 i/s - 1.72x slower ```
-
由 Rafael França 提交于
Don't generate yarn's contents in `app:update` task if it's skipped
-
由 Rafael França 提交于
Fix documentation for ActionController::Params#fetch
-
由 Rafael Mendonça França 提交于
Fixes #32928.
-
- 18 5月, 2018 6 次提交
-
-
由 Linus Marton 提交于
Make it clear that the return value is converted to an instance of ActionController::Parameters if possible
-
由 George Claghorn 提交于
-
由 Rafael França 提交于
Generate ActiveStorage attachment getter and setter methods in mixin
-
由 Rafael Mendonça França 提交于
-
由 Josh Susser 提交于
Generated attachment getter and setter methods are created within the model's `GeneratedAssociationMethods` module to allow overriding and composition using `super`. Includes tests for new functionality. Co-authored-by: NJosh Susser <josh@hasmanythrough.com> Co-authored-by: NJamon Douglas <terrildouglas@gmail.com>
-
由 Rafael França 提交于
Fix user_input_in_time_zone to coerce non valid string into nil
-
- 17 5月, 2018 10 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
Active storage: Image variant options not correct in docs [ci skip]
-
由 lucfranken 提交于
### Steps to reproduce Using Rails 5.2.0 When following this example: http://api.rubyonrails.org/classes/ActiveStorage/Variant.html `avatar.variant(resize: "100x100", monochrome: true, flip: "-90")` ### Expected behavior Image should be rendered as flipped. ### Actual behavior I get an error: > failed with error: gm mogrify: Unrecognized option (-90). ### Fix: According to: https://github.com/minimagick/minimagick the option should be called rotate: `avatar.variant(resize: "100x100", monochrome: true, rotate: "-90")` So **flip** changed to **rotate**. ### System configuration **Rails version**: 5.2.0 **Ruby version**: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
-
由 Ryuta Kamizono 提交于
-
由 George Claghorn 提交于
-
由 George Claghorn 提交于
-
由 George Claghorn 提交于
-
由 George Claghorn 提交于
[David Robertson & George Claghorn]
-
由 Annie-Claude Côté 提交于
Before it was coercing an invalid string into "2000-01-01 00:00:00".
-
由 Annie-Claude Côté 提交于
Inside user_input_in_time_zone we call in_time_zone on the value and value can be a String.
-