feature-toggles 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Njc2ZjFjYTY1ZDFhMGEwNjNhOWVjMmUwYTJiZmJmZDVhY2ViMDk1NA==
5
- data.tar.gz: !binary |-
6
- NWZmMjI1ODY0OGE1ODlhNTViMzE3YjAxZjdiNmQ3ZDI1ZmZhNjA4ZQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YjYwYTY5ZmNjYThhZGEzOWU4ZjU4ZGY3ZDJlOWFlMTdjYTIzOWU0MjMwNzM0
10
- MGU5ZjBkMTMwNDJmOWEzYTBlNGRiZTg4MmRlNzYyNTliMzc3ZWQxYWI2OGUw
11
- YmVmZDE5YzQ2MjYzMTdmYjY2ZjQ1ZWQ3N2IxZjYyMTI1YWFjMTM=
12
- data.tar.gz: !binary |-
13
- ZWRjNDlkZjNmZjQwMjczMWE4ZWE0MjhmOWZkMWQ5MGMwY2MwYjY2ZmVkZjU0
14
- MWM1MzQ0NTE3NjNkYzE4ODNiZjVmMDJhN2Y3ZTU4MmU2N2I5YTQzZGQ2NzAw
15
- NTU3NTg4YzVlYTFmNmI4YWEyM2JjNDgzMmEzM2VkNTJkNzU0MjM=
2
+ SHA1:
3
+ metadata.gz: 120c5dcd13d0ffa5f73096aff1341216aeb5c154
4
+ data.tar.gz: 5eb638c832448fa51599269c9c829cd28a8d470e
5
+ SHA512:
6
+ metadata.gz: afa8df45e06c0adf7989a35f27d3375cec86d48ddaa6fb3454430c37ceca88ceb6577258cfcf0e46b905db94e3ff0c2578d557a5e45f4ac7bba7360447379fbf
7
+ data.tar.gz: 7ad5c7a0270f90e42151db3e7fb163fd4cdf0fef7e9e0ad864f4a3d7a02563ab6e5abfe60011b888d765e1b3b4b95cc496e81a1ba3eea486663573080fe569f8
@@ -1,10 +1,32 @@
1
1
  class FeatureToggles::Feature
2
2
 
3
- def self.is_enabled?(feature_name)
4
- feature_toggle_data[feature_name][:enabled]
3
+ def self.is_enabled?(feature_name, user_type=nil)
4
+ if user_type && has_user_specific_permission?(feature_name, user_type)
5
+ enabled_for_user?(feature_name, user_type)
6
+ else
7
+ enabled_generally?(feature_name)
8
+ end
5
9
  end
6
10
 
7
11
  private
12
+
13
+ def self.enabled_generally?(feature_name)
14
+ !!feature_permissions(feature_name)[:enabled]
15
+ end
16
+
17
+ def self.has_user_specific_permission?(feature_name, user_type)
18
+ feature_permissions(feature_name).key?(user_type)
19
+ end
20
+
21
+ def self.enabled_for_user?(feature_name, user_type)
22
+ !!Hash(feature_permissions(feature_name)[user_type])[:enabled]
23
+ end
24
+
25
+ def self.feature_permissions(feature_name)
26
+ Hash(feature_toggle_data[feature_name])
27
+ end
28
+
29
+
8
30
  def self.default_feature_toggles_file_name
9
31
  'feature_toggles.yml'
10
32
  end
@@ -14,4 +36,4 @@ class FeatureToggles::Feature
14
36
  @feature_toggle_data ||= @loader.load(default_feature_toggles_file_name)
15
37
  end
16
38
 
17
- end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module FeatureToggles
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature-toggles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Sayers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-18 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,56 +28,56 @@ dependencies:
28
28
  name: rspec-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry-nav
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Turn features on or off in various rails environments
@@ -95,7 +95,7 @@ files:
95
95
  - MIT-LICENSE
96
96
  - Rakefile
97
97
  - README.rdoc
98
- homepage: https://github.com/forward-labs/feature-toggles
98
+ homepage: https://bitbucket.org/driftrock/feature_toggles
99
99
  licenses:
100
100
  - MIT
101
101
  metadata: {}
@@ -105,17 +105,17 @@ require_paths:
105
105
  - lib
106
106
  required_ruby_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ! '>='
113
+ - - '>='
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
117
  rubyforge_project:
118
- rubygems_version: 2.0.7
118
+ rubygems_version: 2.0.5
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Feature Toggles for Rails