flip_the_switch 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/.travis.yml +0 -3
- data/CHANGELOG.md +5 -0
- data/FlipTheSwitch.podspec +1 -1
- data/README.md +1 -0
- data/Tests/Rakefile +2 -2
- data/flip_the_switch.gemspec +1 -2
- data/lib/flip_the_switch/cli.rb +5 -5
- data/lib/flip_the_switch/generator/category.rb +17 -2
- data/lib/flip_the_switch/generator/header.h.erb +6 -6
- data/lib/flip_the_switch/generator/implementation.m.erb +14 -14
- data/lib/flip_the_switch/generator/settings.rb +21 -22
- data/lib/flip_the_switch/reader/defaults.rb +16 -14
- data/spec/flip_the_switch/reader/defaults_spec.rb +15 -15
- metadata +2 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 187de79fc4e08a0c688622eb4f1d32c1c2c4b342
|
|
4
|
+
data.tar.gz: 065bfce674a98f8e10ab1979a990aeac942366dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87eae7636b75e115dc65f4de6bf4691040a085dbfd0457451430fc8dc77cedb00e9c1163b18e66659fdbff3730b97aeee27b4cc6380eaf2ab3aa99e4f97bc9f4
|
|
7
|
+
data.tar.gz: 5f229faf45aa73ace7810d77ef6653f92b292ce11a0bf3de9116b392113febfa4462b98014e787b1929c255517babbb6e93790f370a947757db7096d0d041931
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/FlipTheSwitch.podspec
CHANGED
data/README.md
CHANGED
data/Tests/Rakefile
CHANGED
|
@@ -17,6 +17,6 @@ file podfile_lock do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
task :test => podfile_lock do
|
|
20
|
-
sh "
|
|
21
|
-
sh "
|
|
20
|
+
sh "xcodebuild test -scheme #{workspace}-Mac -workspace #{workspace}.xcworkspace -sdk macosx OBJROOT=#{build} SHARED_PRECOMPS_DIR=#{build}"
|
|
21
|
+
sh "xcodebuild test -scheme #{workspace}-iOS -workspace #{workspace}.xcworkspace -sdk iphonesimulator OBJROOT=#{build} SHARED_PRECOMPS_DIR=#{build}"
|
|
22
22
|
end
|
data/flip_the_switch.gemspec
CHANGED
|
@@ -4,10 +4,9 @@ Gem::Specification.new do |s|
|
|
|
4
4
|
s.email = %w(mg.england@gmail.com rob@robsiwek.com)
|
|
5
5
|
s.summary = 'A simple library to help enabling/disabling features on iOS/Mac applications.'
|
|
6
6
|
s.homepage = 'https://github.com/michaelengland/FlipTheSwitch'
|
|
7
|
-
s.version = '1.0.
|
|
7
|
+
s.version = '1.0.1'
|
|
8
8
|
s.license = 'MIT'
|
|
9
9
|
|
|
10
|
-
s.add_dependency 'activesupport', '~> 3.2'
|
|
11
10
|
s.add_dependency 'thor', '~> 0.19'
|
|
12
11
|
s.add_dependency 'plist', '~> 3.1'
|
|
13
12
|
s.add_dependency 'json-schema', '~> 2.5'
|
data/lib/flip_the_switch/cli.rb
CHANGED
|
@@ -9,25 +9,25 @@ module FlipTheSwitch
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
public
|
|
12
|
-
class_option :input, type: :string, aliases: '-i', default: defaults[
|
|
13
|
-
class_option :environment, type: :string, aliases: '-n', default: defaults[
|
|
12
|
+
class_option :input, type: :string, aliases: '-i', default: defaults['input'], desc: 'Filename or directory containing features.json file to read'
|
|
13
|
+
class_option :environment, type: :string, aliases: '-n', default: defaults['environment'], desc: 'Name of environment to read from features.json file'
|
|
14
14
|
|
|
15
15
|
desc 'plist', 'Auto-generates a Features.plist file for enabled/disabled features'
|
|
16
|
-
method_option :output, type: :string, aliases: '-o', default: defaults[
|
|
16
|
+
method_option :output, type: :string, aliases: '-o', default: defaults['plist_output'], desc: 'Filename or directory in which Features.plist file will be created'
|
|
17
17
|
|
|
18
18
|
def plist
|
|
19
19
|
plist_generator.generate
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
desc 'category', 'Auto-generates .h & .m files for enabled/disabled features'
|
|
23
|
-
method_option :output, type: :string, aliases: '-o', default: defaults[
|
|
23
|
+
method_option :output, type: :string, aliases: '-o', default: defaults['category_output'], desc: 'Location of the directory in which FlipTheSwitch+Features.{h,m} files will be created'
|
|
24
24
|
|
|
25
25
|
def category
|
|
26
26
|
category_generator.generate
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
desc 'settings', 'Auto-generates settings.bundle files for enabling/disabling features from iOS settings menu'
|
|
30
|
-
method_option :output, type: :string, aliases: '-o', default: defaults[
|
|
30
|
+
method_option :output, type: :string, aliases: '-o', default: defaults['settings_output'], desc: 'Location of the directory in which FlipTheSwitch+Features.{h,m} files will be created'
|
|
31
31
|
|
|
32
32
|
def settings
|
|
33
33
|
settings_generator.generate
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'flip_the_switch/generator/base'
|
|
2
|
-
require 'active_support/inflector'
|
|
3
2
|
require 'erb'
|
|
4
3
|
|
|
5
4
|
module FlipTheSwitch
|
|
@@ -29,7 +28,9 @@ module FlipTheSwitch
|
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
def delete_file(file)
|
|
32
|
-
|
|
31
|
+
if File.exists?(file)
|
|
32
|
+
File.delete(file)
|
|
33
|
+
end
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
def header_file
|
|
@@ -75,6 +76,20 @@ module FlipTheSwitch
|
|
|
75
76
|
feature_and_sub_features(sub_feature)
|
|
76
77
|
}
|
|
77
78
|
end
|
|
79
|
+
|
|
80
|
+
def lower_camelize(string)
|
|
81
|
+
str = camelize(string)
|
|
82
|
+
if str.empty?
|
|
83
|
+
''
|
|
84
|
+
else
|
|
85
|
+
str[0] = str[0].downcase
|
|
86
|
+
str
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def camelize(string)
|
|
91
|
+
string.split('_').each {|s| s.capitalize! }.join('')
|
|
92
|
+
end
|
|
78
93
|
end
|
|
79
94
|
end
|
|
80
95
|
end
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
<% if feature.description -%>
|
|
7
7
|
// <%= feature.description %>
|
|
8
8
|
<% end -%>
|
|
9
|
-
+ (BOOL)is<%= feature.name
|
|
10
|
-
+ (void)enable<%= feature.name
|
|
11
|
-
+ (void)disable<%= feature.name
|
|
12
|
-
+ (void)set<%= feature.name
|
|
13
|
-
+ (void)reset<%= feature.name
|
|
14
|
-
+ (NSString *)<%= feature.name
|
|
9
|
+
+ (BOOL)is<%= camelize(feature.name) %>Enabled;
|
|
10
|
+
+ (void)enable<%= camelize(feature.name) %>;
|
|
11
|
+
+ (void)disable<%= camelize(feature.name) %>;
|
|
12
|
+
+ (void)set<%= camelize(feature.name) %>Enabled:(BOOL)enabled;
|
|
13
|
+
+ (void)reset<%= camelize(feature.name) %>;
|
|
14
|
+
+ (NSString *)<%= lower_camelize(feature.name) %>Key;
|
|
15
15
|
|
|
16
16
|
<% end -%>
|
|
17
17
|
+ (void)resetAll;
|
|
@@ -4,37 +4,37 @@
|
|
|
4
4
|
@implementation FTSFlipTheSwitch (Features)
|
|
5
5
|
|
|
6
6
|
<% all_features.each do |feature| -%>
|
|
7
|
-
+ (BOOL)is<%= feature.name
|
|
7
|
+
+ (BOOL)is<%= camelize(feature.name) %>Enabled
|
|
8
8
|
{
|
|
9
9
|
<% if feature.has_parent? -%>
|
|
10
|
-
return [self is<%= feature.parent_name
|
|
11
|
-
[[FTSFlipTheSwitch sharedInstance] isFeatureEnabled:[self <%= feature.name
|
|
10
|
+
return [self is<%= camelize(feature.parent_name) %>Enabled] &&
|
|
11
|
+
[[FTSFlipTheSwitch sharedInstance] isFeatureEnabled:[self <%= lower_camelize(feature.name) %>Key]];
|
|
12
12
|
<% else -%>
|
|
13
|
-
return [[FTSFlipTheSwitch sharedInstance] isFeatureEnabled:[self <%= feature.name
|
|
13
|
+
return [[FTSFlipTheSwitch sharedInstance] isFeatureEnabled:[self <%= lower_camelize(feature.name) %>Key]];
|
|
14
14
|
<% end -%>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
+ (void)enable<%= feature.name
|
|
17
|
+
+ (void)enable<%= camelize(feature.name) %>
|
|
18
18
|
{
|
|
19
|
-
[[FTSFlipTheSwitch sharedInstance] enableFeature:[self <%= feature.name
|
|
19
|
+
[[FTSFlipTheSwitch sharedInstance] enableFeature:[self <%= lower_camelize(feature.name) %>Key]];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
+ (void)disable<%= feature.name
|
|
22
|
+
+ (void)disable<%= camelize(feature.name) %>
|
|
23
23
|
{
|
|
24
|
-
[[FTSFlipTheSwitch sharedInstance] disableFeature:[self <%= feature.name
|
|
24
|
+
[[FTSFlipTheSwitch sharedInstance] disableFeature:[self <%= lower_camelize(feature.name) %>Key]];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
+ (void)set<%= feature.name
|
|
27
|
+
+ (void)set<%= camelize(feature.name) %>Enabled:(BOOL)enabled
|
|
28
28
|
{
|
|
29
|
-
[[FTSFlipTheSwitch sharedInstance] setFeature:[self <%= feature.name
|
|
29
|
+
[[FTSFlipTheSwitch sharedInstance] setFeature:[self <%= lower_camelize(feature.name) %>Key] enabled:enabled];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
+ (void)reset<%= feature.name
|
|
32
|
+
+ (void)reset<%= camelize(feature.name) %>
|
|
33
33
|
{
|
|
34
|
-
[[FTSFlipTheSwitch sharedInstance] resetFeature:[self <%= feature.name
|
|
34
|
+
[[FTSFlipTheSwitch sharedInstance] resetFeature:[self <%= lower_camelize(feature.name) %>Key]];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
+ (NSString *)<%= feature.name
|
|
37
|
+
+ (NSString *)<%= lower_camelize(feature.name) %>Key
|
|
38
38
|
{
|
|
39
39
|
return @"<%= feature.name %>";
|
|
40
40
|
}
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
+ (void)resetAll
|
|
44
44
|
{
|
|
45
45
|
<% all_features.each do |feature| -%>
|
|
46
|
-
[self reset<%= feature.name
|
|
46
|
+
[self reset<%= camelize(feature.name) %>];
|
|
47
47
|
<% end -%>
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'flip_the_switch/generator/base'
|
|
2
|
-
require 'active_support/core_ext/hash/indifferent_access'
|
|
3
2
|
require 'plist'
|
|
4
3
|
|
|
5
4
|
module FlipTheSwitch
|
|
@@ -55,54 +54,54 @@ module FlipTheSwitch
|
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
def root
|
|
58
|
-
current_plist.
|
|
57
|
+
current_plist.merge('PreferenceSpecifiers' => root_preferences)
|
|
59
58
|
end
|
|
60
59
|
|
|
61
60
|
def root_preferences
|
|
62
61
|
existing_root_preferences.delete_if { |root_preference|
|
|
63
|
-
root_preference[
|
|
62
|
+
root_preference['Title'] == 'Features'
|
|
64
63
|
} + feature_root_preferences
|
|
65
64
|
end
|
|
66
65
|
|
|
67
66
|
def existing_root_preferences
|
|
68
|
-
current_plist
|
|
67
|
+
current_plist['PreferenceSpecifiers'] || []
|
|
69
68
|
end
|
|
70
69
|
|
|
71
70
|
def feature_root_preferences
|
|
72
71
|
[
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
{
|
|
73
|
+
'Title' => 'Features',
|
|
74
|
+
'Type' => 'PSGroupSpecifier'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
'File' => 'Features',
|
|
78
|
+
'Title' => 'Features',
|
|
79
|
+
'Type' => 'PSChildPaneSpecifier'
|
|
80
|
+
}
|
|
82
81
|
]
|
|
83
82
|
end
|
|
84
83
|
|
|
85
84
|
def feature_properties
|
|
86
|
-
{PreferenceSpecifiers
|
|
85
|
+
{'PreferenceSpecifiers' => feature_toggles}
|
|
87
86
|
end
|
|
88
87
|
|
|
89
88
|
def feature_toggles
|
|
90
89
|
features.map { |feature|
|
|
91
90
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
'Type' => 'PSToggleSwitchSpecifier',
|
|
92
|
+
'Title' => feature.name,
|
|
93
|
+
'Key' => "FTS_FEATURE_#{feature.name}",
|
|
94
|
+
'DefaultValue' => feature.enabled
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
end
|
|
99
98
|
|
|
100
99
|
def current_plist
|
|
101
100
|
@current_plist ||= if File.exists?(root_plist)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
::Plist::parse_xml(root_plist)
|
|
102
|
+
else
|
|
103
|
+
{}
|
|
104
|
+
end
|
|
106
105
|
end
|
|
107
106
|
|
|
108
107
|
def root_plist
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'yaml'
|
|
2
2
|
|
|
3
3
|
module FlipTheSwitch
|
|
4
4
|
module Reader
|
|
@@ -7,7 +7,7 @@ module FlipTheSwitch
|
|
|
7
7
|
if valid_file?
|
|
8
8
|
base_defaults.merge(file_defaults)
|
|
9
9
|
else
|
|
10
|
-
raise Error::InvalidFile.new(
|
|
10
|
+
raise Error::InvalidFile.new(defaults_file_name)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -19,23 +19,25 @@ module FlipTheSwitch
|
|
|
19
19
|
|
|
20
20
|
def base_defaults
|
|
21
21
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
22
|
+
'input' => Dir.pwd,
|
|
23
|
+
'environment' => 'default',
|
|
24
|
+
'enabled' => '',
|
|
25
|
+
'disabled' => '',
|
|
26
|
+
'category_output' => Dir.pwd,
|
|
27
|
+
'plist_output' => Dir.pwd,
|
|
28
|
+
'settings_output' => Dir.pwd
|
|
29
|
+
}
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def file_defaults
|
|
33
|
-
@file_defaults ||=
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
@file_defaults ||= if File.exists?(defaults_file_name)
|
|
34
|
+
YAML.load(File.read(defaults_file_name))
|
|
35
|
+
else
|
|
36
|
+
{}
|
|
37
|
+
end
|
|
36
38
|
end
|
|
37
39
|
|
|
38
|
-
def
|
|
40
|
+
def defaults_file_name
|
|
39
41
|
'.flip.yml'
|
|
40
42
|
end
|
|
41
43
|
end
|
|
@@ -12,32 +12,32 @@ describe FlipTheSwitch::Reader::Defaults do
|
|
|
12
12
|
context 'when valid' do
|
|
13
13
|
before do
|
|
14
14
|
File.write(defaults_file, YAML.dump({
|
|
15
|
-
input
|
|
16
|
-
environment
|
|
17
|
-
category_output
|
|
18
|
-
plist_output
|
|
19
|
-
settings_output
|
|
15
|
+
'input' => 'input',
|
|
16
|
+
'environment' => 'environment',
|
|
17
|
+
'category_output' => 'category_output',
|
|
18
|
+
'plist_output' => 'plist_output',
|
|
19
|
+
'settings_output' => 'settings_output'
|
|
20
20
|
}))
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'returns file input default' do
|
|
24
|
-
expect(subject.defaults[
|
|
24
|
+
expect(subject.defaults['input']).to eql('input')
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it 'returns file environment default' do
|
|
28
|
-
expect(subject.defaults[
|
|
28
|
+
expect(subject.defaults['environment']).to eql('environment')
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it 'returns file category output default' do
|
|
32
|
-
expect(subject.defaults[
|
|
32
|
+
expect(subject.defaults['category_output']).to eql('category_output')
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it 'returns file plist output default' do
|
|
36
|
-
expect(subject.defaults[
|
|
36
|
+
expect(subject.defaults['plist_output']).to eql('plist_output')
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it 'returns file settings output default' do
|
|
40
|
-
expect(subject.defaults[
|
|
40
|
+
expect(subject.defaults['settings_output']).to eql('settings_output')
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -56,23 +56,23 @@ describe FlipTheSwitch::Reader::Defaults do
|
|
|
56
56
|
|
|
57
57
|
context 'when defaults file does NOT exist' do
|
|
58
58
|
it 'returns base input default' do
|
|
59
|
-
expect(subject.defaults[
|
|
59
|
+
expect(subject.defaults['input']).to eql(Dir.pwd)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it 'returns base environment default' do
|
|
63
|
-
expect(subject.defaults[
|
|
63
|
+
expect(subject.defaults['environment']).to eql('default')
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it 'returns base category output default' do
|
|
67
|
-
expect(subject.defaults[
|
|
67
|
+
expect(subject.defaults['category_output']).to eql(Dir.pwd)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it 'returns base plist output default' do
|
|
71
|
-
expect(subject.defaults[
|
|
71
|
+
expect(subject.defaults['plist_output']).to eql(Dir.pwd)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it 'returns base settings output default' do
|
|
75
|
-
expect(subject.defaults[
|
|
75
|
+
expect(subject.defaults['settings_output']).to eql(Dir.pwd)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flip_the_switch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael England
|
|
@@ -9,22 +9,8 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2015-
|
|
12
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
-
- !ruby/object:Gem::Dependency
|
|
15
|
-
name: activesupport
|
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
requirements:
|
|
18
|
-
- - ~>
|
|
19
|
-
- !ruby/object:Gem::Version
|
|
20
|
-
version: '3.2'
|
|
21
|
-
type: :runtime
|
|
22
|
-
prerelease: false
|
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
-
requirements:
|
|
25
|
-
- - ~>
|
|
26
|
-
- !ruby/object:Gem::Version
|
|
27
|
-
version: '3.2'
|
|
28
14
|
- !ruby/object:Gem::Dependency
|
|
29
15
|
name: thor
|
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|