cocoapods-keys 1.2.1 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01550ce3823c499d612ad044e7eccb8001c95d6a
4
- data.tar.gz: 0f29cceb83d5fc37e5329f4b55dd1fd5c78e8e9a
3
+ metadata.gz: 4c88307c98c867a040758ccf5582540e2276f0e0
4
+ data.tar.gz: 55c7512d49714f0cef4f0c52b6a72023ac8a64da
5
5
  SHA512:
6
- metadata.gz: 619e1ec349b1f16bf56b1cdc4dfc88b5e12d7b2a90419e442a1b6c95ff09ec0af0e98733d48dbe1103fb1bba2abb06d8bfd12b5add0b332b215d43c369281954
7
- data.tar.gz: 7dcef234103aa256f9cb7213cdc0871f4791e9ef8da761489ba0f0ad65914285d8bce82c386e38f7ecda119b600def9bf4ad7264e0bb225b70dfe487938a7987
6
+ metadata.gz: 0b1749bcd84c5a2a9aa9062ddf5047a17fa6966b670e28e830444ff843377bba9a75e6405a7e319ea45bd6f4d27795c435040ca415704750bd598c72cc1ad2e8
7
+ data.tar.gz: 7fc660c836254817e188fc44d59f8307a221dd5756d106c164fc65f4227809cbf5793ca93792cfa3810281592f6078a3047081a87c7f48f596caf6384d21cdb0
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_from:
2
+ - .rubocop_cocoapods.yml
3
+ - .rubocop_todo.yml
4
+
5
+ #- cocoapods-keys -------------------------------------------------------------
6
+
7
+ Style/FileName:
8
+ Exclude:
9
+ - bin/*
10
+ - Rakefile
@@ -0,0 +1,116 @@
1
+ AllCops:
2
+ Include:
3
+ - ./Rakefile
4
+ - ./Gemfile
5
+ - ./*.gemspec
6
+ Exclude:
7
+ - ./spec/fixtures/**/*
8
+
9
+ # At the moment not ready to be used
10
+ # https://github.com/bbatsov/rubocop/issues/947
11
+ Documentation:
12
+ Enabled: false
13
+
14
+ #- CocoaPods -----------------------------------------------------------------#
15
+
16
+ # We adopted raise instead of fail.
17
+ SignalException:
18
+ EnforcedStyle: only_raise
19
+
20
+ # They are idiomatic
21
+ AssignmentInCondition:
22
+ Enabled: false
23
+
24
+ # Allow backticks
25
+ AsciiComments:
26
+ Enabled: false
27
+
28
+ # Indentation clarifies logic branches in implementations
29
+ IfUnlessModifier:
30
+ Enabled: false
31
+
32
+ # No enforced convention here.
33
+ SingleLineBlockParams:
34
+ Enabled: false
35
+
36
+ # We only add the comment when needed.
37
+ Encoding:
38
+ Enabled: false
39
+
40
+ # Having these make it easier to *not* forget to add one when adding a new
41
+ # value and you can simply copy the previous line.
42
+ TrailingComma:
43
+ EnforcedStyleForMultiline: comma
44
+
45
+ Style/MultilineOperationIndentation:
46
+ EnforcedStyle: indented
47
+
48
+ # Clashes with CLAide Command#validate!
49
+ GuardClause:
50
+ Enabled: false
51
+
52
+ # Not always desirable: lib/claide/command/plugins_helper.rb:12:15
53
+ Next:
54
+ Enabled: false
55
+
56
+ # Arbitrary max lengths for classes simply do not work and enabling this will
57
+ # lead to a never ending stream of annoyance and changes.
58
+ Metrics/ClassLength:
59
+ Enabled: false
60
+
61
+ # Arbitrary max lengths for methods simply do not work and enabling this will
62
+ # lead to a never ending stream of annoyance and changes.
63
+ Metrics/MethodLength:
64
+ Enabled: false
65
+
66
+ # No enforced convention here.
67
+ Metrics/BlockNesting:
68
+ Enabled: false
69
+
70
+ # It will be obvious which code is complex, Rubocop should only lint simple
71
+ # rules for us.
72
+ Metrics/AbcSize:
73
+ Enabled: false
74
+
75
+ # It will be obvious which code is complex, Rubocop should only lint simple
76
+ # rules for us.
77
+ Metrics/CyclomaticComplexity:
78
+ Enabled: false
79
+
80
+ #- CocoaPods support for Ruby 1.8.7 ------------------------------------------#
81
+
82
+ HashSyntax:
83
+ EnforcedStyle: hash_rockets
84
+
85
+ Lambda:
86
+ Enabled: false
87
+
88
+ DotPosition:
89
+ EnforcedStyle: trailing
90
+
91
+ EachWithObject:
92
+ Enabled: false
93
+
94
+ Style/SpecialGlobalVars:
95
+ Enabled: false
96
+
97
+ #- CocoaPods specs -----------------------------------------------------------#
98
+
99
+ # Allow for `should.match /regexp/`.
100
+ AmbiguousRegexpLiteral:
101
+ Exclude:
102
+ - spec/**/*
103
+
104
+ # Allow `object.should == object` syntax.
105
+ Void:
106
+ Exclude:
107
+ - spec/**/*
108
+
109
+ ClassAndModuleChildren:
110
+ Exclude:
111
+ - spec/**/*
112
+
113
+ UselessComparison:
114
+ Exclude:
115
+ - spec/**/*
116
+
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,39 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-05-15 23:41:41 -0700 using RuboCop version 0.31.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ Lint/ShadowingOuterLocalVariable:
10
+ Enabled: false
11
+
12
+ # Offense count: 1
13
+ Lint/UselessAccessModifier:
14
+ Enabled: false
15
+
16
+ # Offense count: 1
17
+ Lint/UselessSetterCall:
18
+ Enabled: false
19
+
20
+ # Offense count: 2
21
+ Lint/Void:
22
+ Enabled: false
23
+
24
+ # Offense count: 38
25
+ # Configuration parameters: AllowURI, URISchemes.
26
+ Metrics/LineLength:
27
+ Max: 173
28
+
29
+ # Offense count: 1
30
+ Metrics/PerceivedComplexity:
31
+ Max: 9
32
+
33
+ # Offense count: 4
34
+ Style/AccessorMethodName:
35
+ Enabled: false
36
+
37
+ # Offense count: 1
38
+ Style/RescueModifier:
39
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Master
2
2
 
3
+ ## 1.3.0
4
+
5
+ * Support for not including keys in Podfile [ashfurrow]
6
+
3
7
  ## 1.2.0
4
8
 
5
9
  * Support for correctly scoping Keys to a target [orta]
@@ -13,4 +17,4 @@
13
17
 
14
18
  * Support both :key and "key" in user settings [alloy]
15
19
  * Use ERB templates for the .m & .h [lyricsboy]
16
- * Frameworks support [ashfurrow]
20
+ * Frameworks support [ashfurrow]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-keys (1.2.1)
4
+ cocoapods-keys (1.3.0)
5
5
  osx_keychain
6
6
 
7
7
  GEM
@@ -16,6 +16,9 @@ GEM
16
16
  minitest (~> 5.1)
17
17
  thread_safe (~> 0.3, >= 0.3.4)
18
18
  tzinfo (~> 1.1)
19
+ ast (2.0.0)
20
+ astrolabe (1.3.0)
21
+ parser (>= 2.2.0.pre.3, < 3.0)
19
22
  claide (0.8.1)
20
23
  cocoapods (0.36.3)
21
24
  activesupport (>= 3.2.15)
@@ -55,6 +58,10 @@ GEM
55
58
  open4 (1.3.4)
56
59
  osx_keychain (1.0.1)
57
60
  RubyInline (~> 3)
61
+ parser (2.2.2.2)
62
+ ast (>= 1.1, < 3.0)
63
+ powerpack (0.1.1)
64
+ rainbow (2.0.0)
58
65
  rake (10.3.2)
59
66
  rspec (3.2.0)
60
67
  rspec-core (~> 3.2.0)
@@ -69,6 +76,13 @@ GEM
69
76
  diff-lcs (>= 1.2.0, < 2.0)
70
77
  rspec-support (~> 3.2.0)
71
78
  rspec-support (3.2.2)
79
+ rubocop (0.31.0)
80
+ astrolabe (~> 1.3)
81
+ parser (>= 2.2.2.1, < 3.0)
82
+ powerpack (~> 0.1)
83
+ rainbow (>= 1.99.1, < 3.0)
84
+ ruby-progressbar (~> 1.4)
85
+ ruby-progressbar (1.7.5)
72
86
  thread_safe (0.3.5)
73
87
  tzinfo (1.2.2)
74
88
  thread_safe (~> 0.1)
@@ -85,3 +99,7 @@ DEPENDENCIES
85
99
  cocoapods-keys!
86
100
  rake
87
101
  rspec
102
+ rubocop
103
+
104
+ BUNDLED WITH
105
+ 1.10.0
data/README.md CHANGED
@@ -20,6 +20,26 @@ The generated Objective-C classes are stored in the `Pods/Keys` directory, so if
20
20
 
21
21
  ## Usage
22
22
 
23
+ Using the new Plugin API in CocoaPods we can automate a lot of the fiddly bits away. You define what keys you want inside your [Podfile](https://github.com/artsy/eidolon/blob/0a9f5947914eb637fd4abf364fa3532b56da3c52/Podfile#L6-L21) and Keys will detect what keys are not yet set. If you need to specify a different project name from the target name, use the key `:target` to specify it.
24
+
25
+ ```
26
+ plugin 'cocoapods-keys', {
27
+ :project => "Eidolon",
28
+ :keys => [
29
+ "ArtsyAPIClientSecret",
30
+ "ArtsyAPIClientKey",
31
+ "HockeyProductionSecret",
32
+ "HockeyBetaSecret",
33
+ "MixpanelProductionAPIClientKey",
34
+ ...
35
+ ]}
36
+ ```
37
+
38
+ Then running `pod install` will prompt for the keys not yet set and you can ensure everyone has the same setup.
39
+
40
+
41
+ ## Alternative Usage
42
+
23
43
  You can save keys on a per-project basis by running the command:
24
44
 
25
45
  $ pod keys set KEY VALUE
@@ -47,7 +67,7 @@ For example:
47
67
  └ redditAPIToken & mixpanelAPIToken
48
68
  ```
49
69
 
50
- After the next `pod install` or `pod update` keys will add a new `Keys` pod to your Pods project, supporting both static libraries and frameworks. This provides an API to your keys from Cocoa code. For example the application code above would look like:
70
+ After the next `pod install` or `pod update` keys will add a new `Keys` pod to your Pods project, supporting both static libraries and frameworks. *Note* you have to include `plugin 'cocoapods-keys'` in the Podfile for Keys to register that it should work. This provides an API to your keys from Cocoa code. For example the application code above would look like:
51
71
 
52
72
  ``` objc
53
73
 
@@ -69,24 +89,7 @@ After the next `pod install` or `pod update` keys will add a new `Keys` pod to y
69
89
 
70
90
  ```
71
91
 
72
- ## Usage via CocoaPods 0.36
73
-
74
- Using the new Plugin API in CocoaPods we can automate a lot of the fiddly bits away. You define what keys you want inside your [Podfile](https://github.com/artsy/eidolon/blob/0a9f5947914eb637fd4abf364fa3532b56da3c52/Podfile#L6-L21) and Keys will detect what keys are not yet set. If you need to specify a different project name from the target name, use the key `:target` to specify it.
75
-
76
- ```
77
- plugin 'cocoapods-keys', {
78
- :project => "Eidolon",
79
- :keys => [
80
- "ArtsyAPIClientSecret",
81
- "ArtsyAPIClientKey",
82
- "HockeyProductionSecret",
83
- "HockeyBetaSecret",
84
- "MixpanelProductionAPIClientKey",
85
- ...
86
- ]}
87
- ```
88
-
89
- Then running `pod install` will prompt for the keys not yet set and you can ensure everyone has the same setup.
92
+ Some documentation is also available to [use cocoapods-keys in Swift projects](SWIFT_PROJECTS.md).
90
93
 
91
94
  #### Other commands
92
95
 
data/Rakefile CHANGED
@@ -6,9 +6,10 @@ file dump_keys_tool => dump_keys_source_file do
6
6
  sh "xcrun clang -framework Foundation #{dump_keys_source_file} -o #{dump_keys_tool}"
7
7
  end
8
8
 
9
- desc "Run tests"
9
+ desc 'Run tests'
10
10
  task :spec => dump_keys_tool do
11
- sh "bundle exec rspec spec/*_spec.rb"
11
+ sh 'bundle exec rspec spec/*_spec.rb'
12
+ sh 'bundle exec rubocop lib spec Rakefile'
12
13
  end
13
14
 
14
15
  task :default => :spec
data/SWIFT_PROJECTS.md ADDED
@@ -0,0 +1,31 @@
1
+ # Using Cocoapods-Keys in Swift projects
2
+
3
+ Once you've followed the setup instructions described in the [Usage](/orta/cocoapods-keys#usage)
4
+ section of the README, you have two choices.
5
+
6
+ ## Using the bridge header
7
+
8
+ If you want to make your keys available to your whole project:
9
+
10
+ 1. Make sure you have a [bridging header](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) already setup.
11
+ 2. In the bridging header, import the generated key file:
12
+ ```objectivec
13
+ #import <Keys/MyApplicationKeys.h>
14
+ ```
15
+
16
+ ## Importing the framework
17
+
18
+ If you've added the `use_frameworks!` and only want your Keys to be available in
19
+ specific files, simply use Swift's `import` statement. The name of the generated
20
+ module is `Keys`.
21
+
22
+ ```swift
23
+ import Keys
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```swift
29
+ let keys = MyApplicationKeys()
30
+ ARAnalytics.setupWithAnalytics(keys.analyticsToken)
31
+ ```
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "rubocop"
25
26
  end
@@ -1,3 +1,3 @@
1
1
  module CocoaPodsKeys
2
- VERSION = "1.2.1"
2
+ VERSION = '1.3.0'
3
3
  end
@@ -1,3 +1,3 @@
1
- require "keyring"
1
+ require 'keyring'
2
2
  require 'pod/command/keys'
3
3
  require 'plugin'
data/lib/key_master.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  require 'set'
2
2
  require 'erb'
3
3
  require 'digest'
4
+ require 'securerandom'
4
5
 
5
6
  module CocoaPodsKeys
6
7
  class KeyMaster
7
-
8
8
  attr_accessor :name, :interface, :implementation
9
9
 
10
- def initialize(keyring, time=Time.now)
10
+ def initialize(keyring, time = Time.now)
11
11
  @time = time
12
12
  @keys = Hash[keyring.keychain_data.map { |(key, value)| [key[0].downcase + key[1..-1], value] }]
13
13
  @name = keyring.code_name + 'Keys'
@@ -19,13 +19,15 @@ module CocoaPodsKeys
19
19
  end
20
20
 
21
21
  def generate_data
22
+ # guard method; raises error if something in application keychain
23
+ # is nil. provides for better error message.
24
+ verify_keychain_integrity
22
25
 
23
- return nil if @keys.empty?
24
26
  # Generate a base64 hash string that is ~25 times the length of all keys
25
27
 
26
28
  @data_length = @keys.values.map(&:length).reduce(:+) * (20 + rand(10))
27
- data = `head -c #{@data_length} /dev/random | base64 | head -c #{@data_length}`
28
- data = data + '\\"'
29
+ data = SecureRandom.base64(@data_length)
30
+ data += '\\"'
29
31
  @data_length = data.length
30
32
 
31
33
  # Swap the characters within the hashed string with the characters from
@@ -36,13 +38,12 @@ module CocoaPodsKeys
36
38
 
37
39
  value.chars.each_with_index do |char, char_index|
38
40
  loop do
39
-
40
41
  if char == '"'
41
42
  index = data.delete('\\').length - 1
42
43
  @indexed_keys[key][char_index] = index
43
44
  break
44
45
  else
45
- index = rand data.length
46
+ index = SecureRandom.random_number data.length
46
47
  unless @used_indexes.include?(index)
47
48
  data[index] = char
48
49
 
@@ -59,23 +60,28 @@ module CocoaPodsKeys
59
60
  end
60
61
 
61
62
  def generate_interface
62
- render_erb("Keys.h.erb")
63
+ render_erb('Keys.h.erb')
63
64
  end
64
65
 
65
66
  def generate_implementation
66
- render_erb("Keys.m.erb")
67
+ render_erb('Keys.m.erb')
67
68
  end
68
69
 
69
- :private
70
-
70
+ def verify_keychain_integrity
71
+ if @keys.values.any?.nil? || @keys.any?.nil?
72
+ raise 'A key/value pair in the application keychain is nil.'
73
+ end
74
+ end
75
+
76
+ private
77
+
71
78
  def render_erb(erb_template)
72
- erb = IO.read(File.join(__dir__, "../templates", erb_template))
79
+ erb = (Pathname(__dir__).parent + 'templates' + erb_template).read
73
80
  ERB.new(erb, nil, '-').result(binding)
74
81
  end
75
82
 
76
83
  def key_data_arrays
77
- Hash[@indexed_keys.map {|key, value| [key, value.map { |i| name + "Data[#{i}]" }.join(', ')]}]
84
+ Hash[@indexed_keys.map { |key, value| [key, value.map { |i| name + "Data[#{i}]" }.join(', ')] }]
78
85
  end
79
-
80
86
  end
81
87
  end