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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +14 -0
- data/README.md +15 -0
- data/lib/flagship/dsl.rb +15 -5
- data/lib/flagship/feature.rb +4 -0
- data/lib/flagship/flagset.rb +11 -1
- data/lib/flagship/version.rb +1 -1
- data/lib/flagship.rb +0 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cc791479b0f25f7d381e01b9dd1a34b214f4d7e
|
4
|
+
data.tar.gz: f485f304352532299eb3757ca01bcb1d9978cfc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42632f27ed80b517a0662dc2ac8df22566aa3ae41a1ec80bcf7630ca46abdd19d52b0ce3f9ed83112d7ccf7120b580e3cbeb49d7abc299ad94819d1b1d1d7e94
|
7
|
+
data.tar.gz: 2a28a9460e250b90d43837c56d56e0ec9189cc3dc0df5a6e3dfc6e20c0982d0c34a10af5bac4b7b61000736e8ce8cc9b74ce0a65d95b8e27cf4d054e079c37f0
|
data/.travis.yml
CHANGED
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
|
-
|
14
|
-
condition =
|
14
|
+
tags = opts.dup
|
15
|
+
condition = tags.delete(:if)
|
15
16
|
|
16
17
|
if condition
|
17
|
-
@features[key] = ::Flagship::Feature.new(key, condition, @context,
|
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,
|
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
|
-
|
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
|
data/lib/flagship/feature.rb
CHANGED
data/lib/flagship/flagset.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/flagship/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|