flip_the_switch 1.0.0 → 1.0.1

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: 4e4c3d08117d7df04e9f0b072c46ceaa37677bae
4
- data.tar.gz: 129fd88d8381ebc2caac41d0cc28a52640043d2c
3
+ metadata.gz: 187de79fc4e08a0c688622eb4f1d32c1c2c4b342
4
+ data.tar.gz: 065bfce674a98f8e10ab1979a990aeac942366dc
5
5
  SHA512:
6
- metadata.gz: aeb03d159b4a890318eea4976566d192c15c780558ec15eb2267047fd33f23891126acd287052d58f1a308fbd4414a8a19ec99fdcfb6107b30742f73940c02f0
7
- data.tar.gz: 7120397022f1507790cd58763fc28fbb10fcc50d30ccf695eaeb21a7687474bd788c16bdb281b2d68accfc26eb01d375605955f32fb51bc8ac7eb61d42d22bb5
6
+ metadata.gz: 87eae7636b75e115dc65f4de6bf4691040a085dbfd0457451430fc8dc77cedb00e9c1163b18e66659fdbff3730b97aeee27b4cc6380eaf2ab3aa99e4f97bc9f4
7
+ data.tar.gz: 5f229faf45aa73ace7810d77ef6653f92b292ce11a0bf3de9116b392113febfa4462b98014e787b1929c255517babbb6e93790f370a947757db7096d0d041931
data/.gitignore CHANGED
@@ -14,6 +14,12 @@
14
14
  #
15
15
  #########################
16
16
 
17
+ #####
18
+ # Coverage
19
+ *.gcda
20
+ *.gcno
21
+ coverage/
22
+
17
23
  #####
18
24
  # Guard
19
25
  Guardfile
data/.travis.yml CHANGED
@@ -1,9 +1,6 @@
1
1
  language: objective-c
2
2
  osx_image: xcode7
3
3
  before_install:
4
- - brew update
5
- - brew uninstall xctool
6
- - brew install xctool
7
4
  - sudo easy_install cpp-coveralls
8
5
  - gem install bundler
9
6
  - bundle install
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.0.1 / 2015-11-02
2
+
3
+ * [ENHANCEMENT] Improve Readme/Cli usage
4
+ * [ENHANCEMENT] Remove activesupport dependency (helps with cocoapods support)
5
+
1
6
  # 1.0.0 / 2015-10-15
2
7
 
3
8
  * [ENHANCEMENT] Using JSON instead of YAML for features
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'FlipTheSwitch'
3
- s.version = '1.0.0'
3
+ s.version = '1.0.1'
4
4
  s.summary = 'A simple library to help enabling/disabling features on iOS/Mac applications.'
5
5
  s.authors = {
6
6
  'Michael England' => 'mg.england@gmail.com',
data/README.md CHANGED
@@ -158,6 +158,7 @@ The features and subfeatures, along with their default enabled/disabled state, a
158
158
  }
159
159
  },
160
160
  "beta": {
161
+ "inherits_from": "default",
161
162
  "awesome_feature": {
162
163
  "enabled": false
163
164
  }
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 "xctool test -scheme #{workspace}-Mac -workspace #{workspace}.xcworkspace -sdk macosx OBJROOT=#{build} SHARED_PRECOMPS_DIR=#{build}"
21
- sh "xctool test -scheme #{workspace}-iOS -workspace #{workspace}.xcworkspace -sdk iphonesimulator OBJROOT=#{build} SHARED_PRECOMPS_DIR=#{build}"
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
@@ -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.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'
@@ -9,25 +9,25 @@ module FlipTheSwitch
9
9
  end
10
10
 
11
11
  public
12
- class_option :input, type: :string, aliases: '-i', default: defaults[:input], desc: 'Filename or directory containing features.yml file to read'
13
- class_option :environment, type: :string, aliases: '-n', default: defaults[:environment], desc: 'Name of environment to read from in features.yml file'
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[:plist_output], desc: 'Filename or directory in which Features.plist file will be created'
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[:category_output], desc: 'Location of the directory in which FlipTheSwitch+Features.{h,m} files will be created'
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[:settings_output], desc: 'Location of the directory in which FlipTheSwitch+Features.{h,m} files will be created'
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
- File.delete(file) if File.exists?(file)
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.camelize %>Enabled;
10
- + (void)enable<%= feature.name.camelize %>;
11
- + (void)disable<%= feature.name.camelize %>;
12
- + (void)set<%= feature.name.camelize %>Enabled:(BOOL)enabled;
13
- + (void)reset<%= feature.name.camelize %>;
14
- + (NSString *)<%= feature.name.camelize(:lower) %>Key;
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.camelize %>Enabled
7
+ + (BOOL)is<%= camelize(feature.name) %>Enabled
8
8
  {
9
9
  <% if feature.has_parent? -%>
10
- return [self is<%= feature.parent_name.camelize %>Enabled] &&
11
- [[FTSFlipTheSwitch sharedInstance] isFeatureEnabled:[self <%= feature.name.camelize(:lower) %>Key]];
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.camelize(:lower) %>Key]];
13
+ return [[FTSFlipTheSwitch sharedInstance] isFeatureEnabled:[self <%= lower_camelize(feature.name) %>Key]];
14
14
  <% end -%>
15
15
  }
16
16
 
17
- + (void)enable<%= feature.name.camelize %>
17
+ + (void)enable<%= camelize(feature.name) %>
18
18
  {
19
- [[FTSFlipTheSwitch sharedInstance] enableFeature:[self <%= feature.name.camelize(:lower) %>Key]];
19
+ [[FTSFlipTheSwitch sharedInstance] enableFeature:[self <%= lower_camelize(feature.name) %>Key]];
20
20
  }
21
21
 
22
- + (void)disable<%= feature.name.camelize %>
22
+ + (void)disable<%= camelize(feature.name) %>
23
23
  {
24
- [[FTSFlipTheSwitch sharedInstance] disableFeature:[self <%= feature.name.camelize(:lower) %>Key]];
24
+ [[FTSFlipTheSwitch sharedInstance] disableFeature:[self <%= lower_camelize(feature.name) %>Key]];
25
25
  }
26
26
 
27
- + (void)set<%= feature.name.camelize %>Enabled:(BOOL)enabled
27
+ + (void)set<%= camelize(feature.name) %>Enabled:(BOOL)enabled
28
28
  {
29
- [[FTSFlipTheSwitch sharedInstance] setFeature:[self <%= feature.name.camelize(:lower) %>Key] enabled:enabled];
29
+ [[FTSFlipTheSwitch sharedInstance] setFeature:[self <%= lower_camelize(feature.name) %>Key] enabled:enabled];
30
30
  }
31
31
 
32
- + (void)reset<%= feature.name.camelize %>
32
+ + (void)reset<%= camelize(feature.name) %>
33
33
  {
34
- [[FTSFlipTheSwitch sharedInstance] resetFeature:[self <%= feature.name.camelize(:lower) %>Key]];
34
+ [[FTSFlipTheSwitch sharedInstance] resetFeature:[self <%= lower_camelize(feature.name) %>Key]];
35
35
  }
36
36
 
37
- + (NSString *)<%= feature.name.camelize(:lower) %>Key
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.camelize %>];
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.with_indifferent_access.merge(PreferenceSpecifiers: root_preferences)
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[:Title] == 'Features'
62
+ root_preference['Title'] == 'Features'
64
63
  } + feature_root_preferences
65
64
  end
66
65
 
67
66
  def existing_root_preferences
68
- current_plist.with_indifferent_access[:PreferenceSpecifiers] || []
67
+ current_plist['PreferenceSpecifiers'] || []
69
68
  end
70
69
 
71
70
  def feature_root_preferences
72
71
  [
73
- {
74
- Title: 'Features',
75
- Type: 'PSGroupSpecifier'
76
- },
77
- {
78
- File: 'Features',
79
- Title: 'Features',
80
- Type: 'PSChildPaneSpecifier'
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: feature_toggles}
85
+ {'PreferenceSpecifiers' => feature_toggles}
87
86
  end
88
87
 
89
88
  def feature_toggles
90
89
  features.map { |feature|
91
90
  {
92
- Type: 'PSToggleSwitchSpecifier',
93
- Title: feature.name,
94
- Key: "FTS_FEATURE_#{feature.name}",
95
- DefaultValue: feature.enabled
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
- ::Plist::parse_xml(root_plist)
103
- else
104
- {}
105
- end
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 'active_support/core_ext/hash/indifferent_access'
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(defaults_file)
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
- 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
- }.with_indifferent_access
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 ||= YAML.load_file(defaults_file)
34
- rescue SystemCallError
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 defaults_file
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: 'input',
16
- environment: 'environment',
17
- category_output: 'category_output',
18
- plist_output: 'plist_output',
19
- settings_output: '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[:input]).to eql('input')
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[:environment]).to eql('environment')
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[:category_output]).to eql('category_output')
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[:plist_output]).to eql('plist_output')
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[:settings_output]).to eql('settings_output')
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[:input]).to eql(Dir.pwd)
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[:environment]).to eql('default')
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[:category_output]).to eql(Dir.pwd)
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[:plist_output]).to eql(Dir.pwd)
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[:settings_output]).to eql(Dir.pwd)
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.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-10-23 00:00:00.000000000 Z
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