arturo 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e275461050b9b145ee015ef8344c75c5acdaef28
4
- data.tar.gz: 32ddd85665d038f1edf89a82542f85d8f321a3b0
3
+ metadata.gz: 4e9f81e2563e07812dc7a9b810dab0962f595d1e
4
+ data.tar.gz: df8febe2d13852e7ac498e6cf62ce3b7b9ac2223
5
5
  SHA512:
6
- metadata.gz: 5fc9a22f85c3e363c4c5364181d655ba67b62018c6d7ec9dc93fbdfd5c46bfb53f3c41fb1839c97bf4f61d50c6903ecb2532bcae88f220ed71c6b8b17c6f5a9f
7
- data.tar.gz: 69f0ca4bd8b469737eba1289b492250f8924b29cf84a729f171cf7f060236eafa868dbdf699491615d5a0601a54b33b81bfd2de56afd5d57cf3dfee82c45d0f5
6
+ metadata.gz: 130abc91076a6b2733c0e16e8f883a1244ac5ad860608eb6aa01f05eda9fc5c7e67e0cc704972e94c1f8714e6f93cd1513236072701ac30b14a0dcdf4183ca28
7
+ data.tar.gz: 635ddae0758b15185767ad4094f5d91f44828bb6cde56b8f85289f9ba52aebb72af04c89f74b7da126cd7b0f48390d139e501244f32c017e9dac59fc623a888d
@@ -1,3 +1,21 @@
1
+ ## v2.2.0
2
+
3
+ Bug fix: making a feature-update request that fails strict params checks now returns a sensible error instead of throwing an exception
4
+
5
+ Improvement: better failed-to-update error messages
6
+
7
+ Support Matrix changes: add Rails 5.0, drop Rails 3.2, add Ruby 2.1.7, add Ruby 2.2.3, drop Ruby 1.9.3
8
+
9
+ ## v2.1.0
10
+
11
+ Bug fix: `Arturo::SpecialHandling` always compares symbols as strings
12
+
13
+ Improvmement: Rails 4.2 compatibility
14
+
15
+ Improvement: relax minitest version constraints
16
+
17
+ Improvement: add `set_feature!` method to complement `enable_feature!`and `disable_feature!`
18
+
1
19
  ## v2.0.0
2
20
 
3
21
  Bug fix: add missing require to initializer.
data/README.md CHANGED
@@ -219,7 +219,7 @@ does not have the `:hold_book` feature.
219
219
  end
220
220
 
221
221
  `require_feature` accepts as a second argument a `Hash` that it passes on
222
- to `before_filter`, so you can use `:only` and `:except` to specify exactly
222
+ to `before_action`, so you can use `:only` and `:except` to specify exactly
223
223
  which actions are filtered.
224
224
 
225
225
  If you want to customize the page that is rendered on 403 Forbidden
@@ -15,14 +15,13 @@ module Arturo
15
15
 
16
16
  unloadable
17
17
  respond_to :html, :json, :xml
18
- before_filter :require_permission
19
- before_filter :load_feature, :only => [ :show, :edit, :update, :destroy ]
20
18
 
21
- if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 0
22
- def arturo_engine
23
- self
24
- end
25
- helper_method :arturo_engine
19
+ if respond_to?(:before_action)
20
+ before_action :require_permission
21
+ before_action :load_feature, :only => [ :show, :edit, :update, :destroy ]
22
+ else
23
+ before_filter :require_permission
24
+ before_filter :load_feature, :only => [ :show, :edit, :update, :destroy ]
26
25
  end
27
26
 
28
27
  def index
@@ -80,7 +79,7 @@ module Arturo
80
79
  flash[:notice] = t('arturo.features.flash.updated', :name => @feature.to_s)
81
80
  redirect_to arturo_engine.feature_path(@feature)
82
81
  else
83
- flash[:alert] = t('arturo.features.flash.error_updating', :name => @feature.to_s)
82
+ flash[:alert] = t('arturo.features.flash.error_updating', :name => @feature.name, :errors => @feature.errors.full_messages.join("\n"))
84
83
  render :action => 'edit'
85
84
  end
86
85
  end
@@ -110,4 +109,3 @@ module Arturo
110
109
  end
111
110
 
112
111
  end
113
-
@@ -35,7 +35,7 @@ en:
35
35
  created: "Created %{name}"
36
36
  error_creating: "Sorry, there was an error creating the feature."
37
37
  updated: "Updated %{name}"
38
- error_updating: "Could not update feature #%{id}: %{errors}."
38
+ error_updating: "Could not update %{name}: %{errors}."
39
39
  removed: "Removed %{name}"
40
40
  error_removing: "Sorry, there was an error removing %{name}"
41
41
  no_such_feature:
@@ -1,13 +1,4 @@
1
- if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 0
2
- Rails.application.routes.draw do
3
- scope "/arturo" do
4
- resources :features, :controller => "arturo/features"
5
- put 'features', :to => 'arturo/features#update_all', :as => 'features'
6
- end
7
- end
8
- else
9
- Arturo::Engine.routes.draw do
10
- resources :features, :controller => 'arturo/features'
11
- put 'features', :to => 'arturo/features#update_all', :as => 'features_update_all'
12
- end
1
+ Arturo::Engine.routes.draw do
2
+ resources :features, :controller => 'arturo/features'
3
+ put 'features', :to => 'arturo/features#update_all', :as => 'features_update_all'
13
4
  end
@@ -4,7 +4,7 @@ module Arturo
4
4
  require 'arturo/feature_availability'
5
5
  require 'arturo/feature_management'
6
6
  require 'arturo/feature_caching'
7
- require 'arturo/engine' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
7
+ require 'arturo/engine' if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR >= 3
8
8
 
9
9
  class << self
10
10
  # Quick check for whether a feature is enabled for a recipient.
@@ -13,13 +13,14 @@ module Arturo
13
13
  end
14
14
 
15
15
  def on_feature_disabled(feature_name)
16
- render :text => 'Forbidden', :status => 403
16
+ render (Rails::VERSION::MAJOR < 5 ? :text : :plain) => 'Forbidden', :status => 403
17
17
  end
18
18
 
19
19
  module ClassMethods
20
20
 
21
21
  def require_feature(name, options = {})
22
- before_filter options do |controller|
22
+ method = respond_to?(:before_action) ? :before_action : :before_filter
23
+ send(method, options) do |controller|
23
24
  unless controller.feature_enabled?(name)
24
25
  controller.on_feature_disabled(name)
25
26
  end
@@ -40,7 +40,7 @@ module Arturo
40
40
 
41
41
  # Create a new Feature
42
42
  def initialize(*args, &block)
43
- args[0] = DEFAULT_ATTRIBUTES.merge(args[0] || {})
43
+ args[0] = DEFAULT_ATTRIBUTES.merge(args[0].try(:to_h) || {})
44
44
  super(*args, &block)
45
45
  end
46
46
 
@@ -18,9 +18,23 @@ module Arturo
18
18
  # to use a shared cache like Memcached.
19
19
  module FeatureCaching
20
20
 
21
+ module PrependMethods
22
+ # Wraps Arturo::Feature.to_feature with in-memory caching.
23
+ def to_feature(feature_or_symbol)
24
+ if !caches_features?
25
+ super
26
+ elsif feature_or_symbol.kind_of?(Arturo::Feature)
27
+ feature_or_symbol
28
+ else
29
+ symbol = feature_or_symbol.to_sym
30
+ feature_caching_strategy.fetch(feature_cache, symbol) { super(symbol) }
31
+ end
32
+ end
33
+ end
34
+
21
35
  def self.extended(base)
22
36
  class << base
23
- alias_method_chain :to_feature, :caching
37
+ prepend PrependMethods
24
38
  attr_accessor :cache_ttl, :feature_cache, :feature_caching_strategy
25
39
  end
26
40
  base.send(:after_save) do |f|
@@ -35,18 +49,6 @@ module Arturo
35
49
  self.cache_ttl.to_i > 0
36
50
  end
37
51
 
38
- # Wraps Arturo::Feature.to_feature with in-memory caching.
39
- def to_feature_with_caching(feature_or_symbol)
40
- if !caches_features?
41
- to_feature_without_caching(feature_or_symbol)
42
- elsif feature_or_symbol.kind_of?(Arturo::Feature)
43
- feature_or_symbol
44
- else
45
- symbol = feature_or_symbol.to_sym
46
- feature_caching_strategy.fetch(feature_cache, symbol) { to_feature_without_caching(symbol) }
47
- end
48
- end
49
-
50
52
  def warm_cache!
51
53
  warn "Deprecated, no longer necessary!"
52
54
  end
@@ -18,14 +18,16 @@ module Arturo
18
18
  PERMITTED_ATTRIBUTES = [ :symbol, :deployment_percentage ]
19
19
 
20
20
  def feature_params
21
- params.permit(:feature => PERMITTED_ATTRIBUTES)[:feature]
21
+ if feature = params[:feature]
22
+ feature.permit(PERMITTED_ATTRIBUTES)
23
+ end
22
24
  end
23
25
 
24
26
  def features_params
25
- permitted = PERMITTED_ATTRIBUTES
26
27
  features = params[:features]
27
28
  features.each do |id, attributes|
28
- features[id] = ActionController::Parameters.new(attributes).permit(*permitted)
29
+ attributes = attributes.to_unsafe_h if attributes.respond_to?(:to_unsafe_h)
30
+ features[id] = ActionController::Parameters.new(attributes).permit(*PERMITTED_ATTRIBUTES)
29
31
  end
30
32
  end
31
33
  end
@@ -35,4 +37,3 @@ module Arturo
35
37
  end
36
38
 
37
39
  end
38
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arturo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - gem-public_cert.pem
12
- date: 2015-01-03 00:00:00.000000000 Z
12
+ date: 2016-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '3.2'
21
21
  - - <
22
22
  - !ruby/object:Gem::Version
23
- version: '5.0'
23
+ version: '5.1'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '3.2'
31
31
  - - <
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '5.1'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rails
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: '3.2'
41
41
  - - <
42
42
  - !ruby/object:Gem::Version
43
- version: '5.0'
43
+ version: '5.1'
44
44
  type: :development
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  version: '3.2'
51
51
  - - <
52
52
  - !ruby/object:Gem::Version
53
- version: '5.0'
53
+ version: '5.1'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: mocha
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -195,6 +195,24 @@ executables: []
195
195
  extensions: []
196
196
  extra_rdoc_files: []
197
197
  files:
198
+ - CHANGELOG.md
199
+ - LICENSE
200
+ - README.md
201
+ - app/assets/images/colon.png
202
+ - app/assets/javascripts/arturo.js
203
+ - app/assets/stylesheets/arturo.css
204
+ - app/controllers/arturo/features_controller.rb
205
+ - app/helpers/arturo/features_helper.rb
206
+ - app/views/arturo/features/_feature.html.erb
207
+ - app/views/arturo/features/_form.html.erb
208
+ - app/views/arturo/features/edit.html.erb
209
+ - app/views/arturo/features/forbidden.html.erb
210
+ - app/views/arturo/features/index.html.erb
211
+ - app/views/arturo/features/new.html.erb
212
+ - app/views/arturo/features/show.html.erb
213
+ - config/locales/en.yml
214
+ - config/routes.rb
215
+ - lib/arturo.rb
198
216
  - lib/arturo/controller_filters.rb
199
217
  - lib/arturo/engine.rb
200
218
  - lib/arturo/feature.rb
@@ -207,7 +225,6 @@ files:
207
225
  - lib/arturo/no_such_feature.rb
208
226
  - lib/arturo/special_handling.rb
209
227
  - lib/arturo/test_support.rb
210
- - lib/arturo.rb
211
228
  - lib/generators/arturo/assets_generator.rb
212
229
  - lib/generators/arturo/initializer_generator.rb
213
230
  - lib/generators/arturo/migration_generator.rb
@@ -215,23 +232,6 @@ files:
215
232
  - lib/generators/arturo/templates/arturo_customizations.css
216
233
  - lib/generators/arturo/templates/initializer.rb
217
234
  - lib/generators/arturo/templates/migration.rb
218
- - app/assets/images/colon.png
219
- - app/assets/javascripts/arturo.js
220
- - app/assets/stylesheets/arturo.css
221
- - app/controllers/arturo/features_controller.rb
222
- - app/helpers/arturo/features_helper.rb
223
- - app/views/arturo/features/_feature.html.erb
224
- - app/views/arturo/features/_form.html.erb
225
- - app/views/arturo/features/edit.html.erb
226
- - app/views/arturo/features/forbidden.html.erb
227
- - app/views/arturo/features/index.html.erb
228
- - app/views/arturo/features/new.html.erb
229
- - app/views/arturo/features/show.html.erb
230
- - config/locales/en.yml
231
- - config/routes.rb
232
- - README.md
233
- - CHANGELOG.md
234
- - LICENSE
235
235
  homepage: http://github.com/jamesarosen/arturo
236
236
  licenses:
237
237
  - APLv2
@@ -245,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
245
  requirements:
246
246
  - - '>='
247
247
  - !ruby/object:Gem::Version
248
- version: '0'
248
+ version: '2.0'
249
249
  required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  requirements:
251
251
  - - '>='
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  version: '0'
254
254
  requirements: []
255
255
  rubyforge_project:
256
- rubygems_version: 2.0.14
256
+ rubygems_version: 2.5.1
257
257
  signing_key:
258
258
  specification_version: 2
259
259
  summary: Feature sliders, wrapped up in an engine