arturo 0.2.3.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ require 'active_support/core_ext/module'
2
+
3
+ module Arturo
4
+
5
+ # A block that, when bound to a Controller instance, returns
6
+ # true iff the current user can manage features.
7
+ mattr_writer :permit_management
8
+ @@permit_management = lambda { false }
9
+
10
+ # A block that, when bound to a Controller or Helper instance,
11
+ # returns an object (probably a User, Person, or Account),
12
+ # that may or may not have features enabled.
13
+ mattr_writer :feature_recipient
14
+ @@feature_recipient = lambda { nil }
15
+
16
+ # Get or set Arturo's permission block.
17
+ # @param [block] block
18
+ # @return [block]
19
+ # @see Arturo.permission_block
20
+ def self.permit_management(&block)
21
+ if block
22
+ @@permit_management = block
23
+ end
24
+ @@permit_management
25
+ end
26
+
27
+ def self.permit_management?(controller)
28
+ block = self.permit_management
29
+ block && block.call(controller)
30
+ end
31
+
32
+ # Get or set Arturo's block for retrieving the
33
+ # thing that may or may not have features enabled.
34
+ # @param [block] block
35
+ # @return [block]
36
+ def self.feature_recipient(&block)
37
+ if block
38
+ @@feature_recipient = block
39
+ end
40
+ @@feature_recipient
41
+ end
42
+
43
+ end
@@ -18,7 +18,7 @@ module Arturo
18
18
 
19
19
  module ClassMethods
20
20
 
21
- def require_feature(name, options = {})
21
+ def require_feature!(name, options = {})
22
22
  before_filter options do |controller|
23
23
  unless controller.feature_enabled?(name)
24
24
  controller.on_feature_disabled(name)
data/lib/arturo/engine.rb CHANGED
@@ -1,15 +1,9 @@
1
- ActionController::Base.class_eval do
2
- include Arturo::FeatureAvailability
3
- helper Arturo::FeatureAvailability
4
- include Arturo::ControllerFilters
5
- helper Arturo::FeatureManagement
6
- helper Arturo::RangeFormSupport::HelperMethods
1
+ module Arturo
2
+ class Engine < ::Rails::Engine
3
+ ActiveSupport.on_load(:action_controller) do
4
+ include Arturo::FeatureAvailability
5
+ helper Arturo::FeatureAvailability
6
+ include Arturo::ControllerFilters
7
+ end
8
+ end
7
9
  end
8
-
9
- ActionView::Helpers::FormBuilder.instance_eval do
10
- include Arturo::RangeFormSupport::FormBuilderMethods
11
- end
12
-
13
- require 'rails_generator'
14
- generators_path = File.expand_path('../../generators', __FILE__)
15
- Rails::Generator::Base.sources << Rails::Generator::PathSource.new(:arturo, generators_path)
@@ -12,7 +12,8 @@ module Arturo
12
12
  def feature_enabled?(symbol_or_feature)
13
13
  feature = ::Arturo::Feature.to_feature(symbol_or_feature)
14
14
  return false if feature.blank?
15
- feature.enabled_for?(feature_recipient)
15
+ thing = ::Arturo.feature_recipient.bind(self).call
16
+ feature.enabled_for?(thing)
16
17
  end
17
18
 
18
19
  def if_feature_enabled(symbol_or_feature, &block)
@@ -23,15 +24,6 @@ module Arturo
23
24
  end
24
25
  end
25
26
 
26
- # By default, returns current_user.
27
- #
28
- # If you would like to change this implementation, it is recommended
29
- # you do so in config/initializers/arturo_initializer.rb
30
- # @return [Object] the recipient of features.
31
- def feature_recipient
32
- current_user
33
- end
34
-
35
27
  end
36
28
 
37
29
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+
3
+ module Arturo
4
+ class AssetsGenerator < Rails::Generators::Base
5
+ def self.source_root
6
+ File.join(File.dirname(__FILE__), 'templates')
7
+ end
8
+
9
+ def copy_assets
10
+ copy_file 'arturo.css', 'public/stylesheets/arturo.css', :force => true
11
+ copy_file 'arturo_customizations.css', 'public/stylesheets/arturo_customizations.css', :skip => true
12
+ copy_file 'arturo.js', 'public/javascripts/arturo.js'
13
+ copy_file 'semicolon.png', 'public/images/semicolon.png'
14
+ end
15
+
16
+ end
17
+ end
18
+
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module Arturo
4
+ class InitializerGenerator < Rails::Generators::Base
5
+ def self.source_root
6
+ File.join(File.dirname(__FILE__), 'templates')
7
+ end
8
+
9
+ def copy_initializer_file
10
+ copy_file "initializer.rb", "config/initializers/arturo_initializer.rb"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Arturo
5
+ class MigrationGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ def self.source_root
9
+ File.join(File.dirname(__FILE__), 'templates')
10
+ end
11
+
12
+ # Implement the required interface for Rails::Generators::Migration.
13
+ # taken from
14
+ # http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
15
+ def self.next_migration_number(dirname) #:nodoc:
16
+ if ActiveRecord::Base.timestamped_migrations
17
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
18
+ else
19
+ "%.3d" % (current_migration_number(dirname) + 1)
20
+ end
21
+ end
22
+
23
+ def create_migration_file
24
+ migration_template 'migration.rb', 'db/migrate/create_features.rb'
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+
3
+ module Arturo
4
+ class RoutesGenerator < Rails::Generators::Base
5
+
6
+ def add_mount
7
+ if Arturo::Engine.respond_to?(:routes)
8
+ route "mount Arturo::Engine => ''"
9
+ else
10
+ puts "This version of Rails doesn't support Engine-specific routing. Nothing to do."
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -43,12 +43,12 @@ output.deployment_percentage:after { content: "%"; }
43
43
  display: block;
44
44
  }
45
45
 
46
- .feature_new label + input, .feature_new label + textarea, .feature_new label + select,
46
+ .feature_new label + input, .feature_new label + textarea, .feature_new label + select,
47
47
  .feature_edit label + input, .feature_edit label + textarea, .feature_edit label + select {
48
48
  margin-top: 0.5em;
49
49
  }
50
50
 
51
- .feature_new input + label, .feature_new textarea + label, .feature_new select + label,
51
+ .feature_new input + label, .feature_new textarea + label, .feature_new select + label,
52
52
  .feature_edit input + label, .feature_edit textarea + label, .feature_edit select + label {
53
53
  margin-top: 1.5em;
54
54
  }
@@ -16,7 +16,7 @@ if (typeof(jQuery) === 'function') {
16
16
  }
17
17
  }
18
18
  };
19
-
19
+
20
20
  jQuery(function() {
21
21
  jQuery.arturo.linkAndShowOutputs();
22
22
  });
@@ -1,29 +1,21 @@
1
1
  require 'arturo'
2
2
 
3
- # Configure who may manage features here.
4
- # The following is the default implementation.
5
- # Arturo::FeatureManagement.class_eval do
6
- # def may_manage_features?
7
- # current_user.present? && current_user.admin?
8
- # end
9
- # end
3
+ Arturo.permit_management do
4
+ # current_user.present? && current_user.admin?
5
+ end
10
6
 
11
- # Configure what receives features here.
12
- # The following is the default implementation.
13
- # Arturo::FeatureAvailability.class_eval do
14
- # def feature_recipient
15
- # current_user
16
- # end
17
- # end
7
+ Arturo.feature_recipient do
8
+ # current_user
9
+ end
18
10
 
19
11
  # Whitelists and Blacklists:
20
12
  #
21
- # Enable feature one for all admins:
22
- # Arturo::Feature.whitelist(:feature_one) do |user|
13
+ # # Enable feature one for all admins:
14
+ # Arturo::Feature.whitelist('feature one') do |user|
23
15
  # user.admin?
24
16
  # end
25
17
  #
26
- # Disable feature two for all small accounts:
27
- # Arturo::Feature.blacklist(:feature_two) do |user|
18
+ # # Disable feature two for all small accounts:
19
+ # Arturo::Feature.blacklist('feature two') do |user|
28
20
  # user.account.small?
29
21
  # end
metadata CHANGED
@@ -1,178 +1,124 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: arturo
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.3.8
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - James A. Rosen
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-10-12 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2010-10-24 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 2.3.8
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
25
+ requirements:
27
26
  - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 2.3.8
30
- - !ruby/object:Gem::Dependency
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 3
30
+ - 0
31
+ version: "3.0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
31
35
  name: mocha
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 0.13.0
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 0.13.0
46
- - !ruby/object:Gem::Dependency
47
- name: rake
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
36
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: bump
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: minitest
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - <
84
- - !ruby/object:Gem::Version
85
- version: '5'
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ version: "0"
86
45
  type: :development
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
87
49
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - <
92
- - !ruby/object:Gem::Version
93
- version: '5'
94
- - !ruby/object:Gem::Dependency
95
- name: minitest-rg
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
102
58
  type: :development
59
+ version_requirements: *id003
60
+ - !ruby/object:Gem::Dependency
61
+ name: redgreen
103
62
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
63
+ requirement: &id004 !ruby/object:Gem::Requirement
105
64
  none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: sqlite3-ruby
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
65
+ requirements:
115
66
  - - ~>
116
- - !ruby/object:Gem::Version
117
- version: '1.3'
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 2
71
+ version: "1.2"
118
72
  type: :development
73
+ version_requirements: *id004
74
+ - !ruby/object:Gem::Dependency
75
+ name: sqlite3-ruby
119
76
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
77
+ requirement: &id005 !ruby/object:Gem::Requirement
121
78
  none: false
122
- requirements:
79
+ requirements:
123
80
  - - ~>
124
- - !ruby/object:Gem::Version
125
- version: '1.3'
126
- - !ruby/object:Gem::Dependency
127
- name: factory_girl
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
133
- version: '1.3'
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 1
84
+ - 3
85
+ version: "1.3"
134
86
  type: :development
87
+ version_requirements: *id005
88
+ - !ruby/object:Gem::Dependency
89
+ name: factory_girl
135
90
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ~>
140
- - !ruby/object:Gem::Version
141
- version: '1.3'
142
- - !ruby/object:Gem::Dependency
143
- name: timecop
144
- requirement: !ruby/object:Gem::Requirement
91
+ requirement: &id006 !ruby/object:Gem::Requirement
145
92
  none: false
146
- requirements:
93
+ requirements:
147
94
  - - ~>
148
- - !ruby/object:Gem::Version
149
- version: '0.3'
95
+ - !ruby/object:Gem::Version
96
+ segments:
97
+ - 1
98
+ - 3
99
+ version: "1.3"
150
100
  type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ~>
156
- - !ruby/object:Gem::Version
157
- version: '0.3'
101
+ version_requirements: *id006
158
102
  description: Deploy features incrementally to your users
159
103
  email: james.a.rosen@gmail.com
160
104
  executables: []
105
+
161
106
  extensions: []
107
+
162
108
  extra_rdoc_files: []
163
- files:
109
+
110
+ files:
111
+ - lib/arturo/configuration.rb
164
112
  - lib/arturo/controller_filters.rb
165
113
  - lib/arturo/engine.rb
166
114
  - lib/arturo/feature_availability.rb
167
- - lib/arturo/feature_caching.rb
168
115
  - lib/arturo/feature_factories.rb
169
- - lib/arturo/feature_management.rb
170
- - lib/arturo/middleware.rb
171
- - lib/arturo/range_form_support.rb
172
116
  - lib/arturo/special_handling.rb
173
- - lib/arturo/test_support.rb
174
117
  - lib/arturo.rb
175
- - lib/generators/arturo/arturo_generator.rb
118
+ - lib/generators/arturo/assets_generator.rb
119
+ - lib/generators/arturo/initializer_generator.rb
120
+ - lib/generators/arturo/migration_generator.rb
121
+ - lib/generators/arturo/routes_generator.rb
176
122
  - lib/generators/arturo/templates/arturo.css
177
123
  - lib/generators/arturo/templates/arturo.js
178
124
  - lib/generators/arturo/templates/arturo_customizations.css
@@ -190,33 +136,40 @@ files:
190
136
  - app/views/arturo/features/new.html.erb
191
137
  - app/views/arturo/features/show.html.erb
192
138
  - config/locales/en.yml
193
- - rails/init.rb
139
+ - config/routes.rb
194
140
  - README.md
195
- - HISTORY.md
196
- homepage: http://github.com/jamesarosen/arturo
141
+ has_rdoc: true
142
+ homepage: http://jamesarosen.com
197
143
  licenses: []
144
+
198
145
  post_install_message:
199
146
  rdoc_options: []
200
- require_paths:
147
+
148
+ require_paths:
201
149
  - .
202
150
  - lib
203
- required_ruby_version: !ruby/object:Gem::Requirement
151
+ required_ruby_version: !ruby/object:Gem::Requirement
204
152
  none: false
205
- requirements:
206
- - - ! '>='
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ segments:
157
+ - 0
158
+ version: "0"
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
210
160
  none: false
211
- requirements:
212
- - - ! '>='
213
- - !ruby/object:Gem::Version
214
- version: '0'
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ segments:
165
+ - 0
166
+ version: "0"
215
167
  requirements: []
168
+
216
169
  rubyforge_project:
217
- rubygems_version: 1.8.25
170
+ rubygems_version: 1.3.7
218
171
  signing_key:
219
- specification_version: 3
172
+ specification_version: 2
220
173
  summary: Feature sliders, wrapped up in an engine
221
174
  test_files: []
222
- has_rdoc:
175
+