flagship 0.2.0 → 0.3.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: 152c5eda261cabe740a9ffc0b42c86aa43f98365
4
- data.tar.gz: ffe613bc7a54e1f473570705b30a36fca4dbbfac
3
+ metadata.gz: 3cc791479b0f25f7d381e01b9dd1a34b214f4d7e
4
+ data.tar.gz: f485f304352532299eb3757ca01bcb1d9978cfc1
5
5
  SHA512:
6
- metadata.gz: 12fee08a5382b52a4dd31dbaecebfdd454204167c6520370cf7481e3dba517b115a1cd84942cf81e72b1eff20d12ddce61c51e78be31cee4a9bd90c80fb92452
7
- data.tar.gz: a9b877654a436dc9fe154c8849d6fbc3afcef2db6e713a35f71fbc0af7afdd02d00e32dd50fad070464e2db337f5b5f45587ef4e84088af438d474e10abc63dd
6
+ metadata.gz: 42632f27ed80b517a0662dc2ac8df22566aa3ae41a1ec80bcf7630ca46abdd19d52b0ce3f9ed83112d7ccf7120b580e3cbeb49d7abc299ad94819d1b1d1d7e94
7
+ data.tar.gz: 2a28a9460e250b90d43837c56d56e0ec9189cc3dc0df5a6e3dfc6e20c0982d0c34a10af5bac4b7b61000736e8ce8cc9b74ce0a65d95b8e27cf4d054e079c37f0
data/.travis.yml CHANGED
@@ -2,6 +2,6 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 2.2.5
5
- - 2.3.1
5
+ - 2.3.3
6
6
 
7
7
  before_install: gem install bundler --no-document
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## [0.3.0] - 2016-11-24
4
+
5
+ ### Added
6
+
7
+ - `with_tags` method to DSL
8
+
9
+ ### Fixed
10
+
11
+ - Tags are extended from the feature with same key in base flagset
12
+
13
+ ### Removed
14
+
15
+ - `Flagship.set_flagset` method. Use `Flagship.set_flagset` instead
16
+
3
17
  ## [0.2.0] - 2016-11-14
4
18
 
5
19
  ### Added
data/README.md CHANGED
@@ -112,6 +112,21 @@ Flagship.features.select{ |feature| feature.tags[:communication] && feature.enab
112
112
  # => [:comment, :trackback]
113
113
  ```
114
114
 
115
+ ### `with_tags`
116
+
117
+ Using `with_tags`, you can set same tags to multiple features at once.
118
+
119
+ ```rb
120
+ Flagship.define :blog do
121
+ enable :post
122
+
123
+ with_tags(communication: true) do
124
+ enable :comment
125
+ enable :trackback
126
+ end
127
+ end
128
+ ```
129
+
115
130
  ## Development
116
131
 
117
132
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/flagship/dsl.rb CHANGED
@@ -7,23 +7,33 @@ class Flagship::Dsl
7
7
  @base = base
8
8
  @features = {}
9
9
  @definition = block
10
+ @base_tags = {}
10
11
  end
11
12
 
12
13
  def enable(key, opts = {})
13
- opts = opts.dup
14
- condition = opts.delete(:if)
14
+ tags = opts.dup
15
+ condition = tags.delete(:if)
15
16
 
16
17
  if condition
17
- @features[key] = ::Flagship::Feature.new(key, condition, @context, opts)
18
+ @features[key] = ::Flagship::Feature.new(key, condition, @context, @base_tags.merge(tags))
18
19
  else
19
- @features[key] = ::Flagship::Feature.new(key, true, @context, opts)
20
+ @features[key] = ::Flagship::Feature.new(key, true, @context, @base_tags.merge(tags))
20
21
  end
21
22
  end
22
23
 
23
24
  def disable(key, opts = {})
24
25
  raise InvalidOptionError.new("Option :if is not available for #disable") if opts[:if]
25
26
 
26
- @features[key] = ::Flagship::Feature.new(key, false, @context, opts)
27
+ tags = opts.dup
28
+ @features[key] = ::Flagship::Feature.new(key, false, @context, @base_tags.merge(tags))
29
+ end
30
+
31
+ def with_tags(tags, &block)
32
+ orig_base_tags = @base_tags
33
+ @base_tags = @base_tags.merge(tags)
34
+ instance_eval(&block)
35
+ ensure
36
+ @base_tags = orig_base_tags
27
37
  end
28
38
 
29
39
  def flagset
@@ -26,4 +26,8 @@ class Flagship::Feature
26
26
  !!@enabled
27
27
  end
28
28
  end
29
+
30
+ def extend_feature(feature)
31
+ self.class.new(@key, @enabled, @context, feature.tags.merge(@tags))
32
+ end
29
33
  end
@@ -6,7 +6,7 @@ class Flagship::Flagset
6
6
  def initialize(key, features_hash, base = nil)
7
7
  @key = key
8
8
  @features = base ?
9
- base.features.map{ |f| [f.key, f] }.to_h.merge(features_hash) :
9
+ extend_features(features_hash, base) :
10
10
  features_hash
11
11
  end
12
12
 
@@ -20,4 +20,14 @@ class Flagship::Flagset
20
20
  def features
21
21
  @features.map { |key, feature| feature }
22
22
  end
23
+
24
+ private
25
+
26
+ def extend_features(features_hash, base)
27
+ base.features.map { |f|
28
+ [f.key, f]
29
+ }.to_h.merge(features_hash) { |key, base_f, new_f|
30
+ new_f.extend_feature(base_f)
31
+ }
32
+ end
23
33
  end
@@ -1,3 +1,3 @@
1
1
  module Flagship
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/flagship.rb CHANGED
@@ -26,12 +26,6 @@ module Flagship
26
26
  @@current_flagset = self.default_flagsets_container.get(key)
27
27
  end
28
28
 
29
- # Deprecated: Use select_flagset
30
- def self.set_flagset(key)
31
- warn "[DEPRECATION] `set_flagset` is deprecated. Please use `select_flagset` instead."
32
- self.select_flagset(key)
33
- end
34
-
35
29
  def self.features
36
30
  self.current_flagset.features
37
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flagship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuya Takeyama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-13 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler