1. 21 5月, 2018 12 次提交
    • G
      Merge pull request #32936 from jacobsmith/image-variant-allow-disabling-options · 6c574ac5
      George Claghorn 提交于
      [ActiveStorage] Disable variant options when false or nil present
      6c574ac5
    • K
      Merge pull request #32523 from kaspth/enumerable-index-with-extension · 41147e3e
      Kasper Timm Hansen 提交于
      Add Enumerable#index_with.
      41147e3e
    • K
      [ci skip] Add documentation/changelog entry. · 429f15ff
      Kasper Timm Hansen 提交于
      429f15ff
    • K
      Add Enumerable#index_with. · 39c22303
      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.
      39c22303
    • K
      Merge pull request #32946 from coryjb/patch-1 · db485a8d
      Kasper Timm Hansen 提交于
      Exception wording change
      db485a8d
    • J
      Disable variant options when false or nil present · 0210ac0b
      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
      0210ac0b
    • K
      Rename exception variable to error. · ba07b5fc
      Kasper Timm Hansen 提交于
      Follows the change from 6fac9bd5, so the naming is consistent.
      ba07b5fc
    • C
      Exception wording change · 61ca9266
      Cory Becker 提交于
      61ca9266
    • R
      Merge pull request #32923 from yahonda/bump_sqlite3_version_to_38 · 054893d5
      Ryuta Kamizono 提交于
      Bump minimum SQLite version to 3.8
      054893d5
    • R
      Enable `Lint/StringConversionInInterpolation` rubocop rule · a77447f4
      Ryuta Kamizono 提交于
      To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008
      automatically in the future.
      a77447f4
    • Y
      Bump minimum SQLite version to 3.8 · d1a74c1e
      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
      d1a74c1e
    • R
      `SqlTypeMetadata` is :nodoc: class [ci skip] · 15d00f04
      Ryuta Kamizono 提交于
      So do not expose `PostgreSQLTypeMetadata` in the doc too.
      15d00f04
  2. 20 5月, 2018 1 次提交
  3. 19 5月, 2018 6 次提交
  4. 18 5月, 2018 6 次提交
  5. 17 5月, 2018 10 次提交
  6. 16 5月, 2018 2 次提交
  7. 15 5月, 2018 3 次提交