Class: Pod::Command::Keys::Generate

Inherits:
Pod::Command::Keys show all
Defined in:
lib/pod/command/keys/generate.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Keys

#create_keyring, #get_current_keyring

Constructor Details

#initialize(argv) ⇒ Generate



23
24
25
26
27
# File 'lib/pod/command/keys/generate.rb', line 23

def initialize(argv)
  @project_name = argv.shift_argument
  @keys = argv.option('keys', '').split(',')
  super
end

Class Method Details

.optionsObject



19
20
21
# File 'lib/pod/command/keys/generate.rb', line 19

def self.options
  [['--keys=key1,key2...', 'An array of keys to add if no keyring is found']].concat(super)
end

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pod/command/keys/generate.rb', line 29

def run
  Dotenv.load
  keyring = get_current_keyring || CocoaPodsKeys::Keyring.new(@project_name, '/', @keys)

  if keyring

    # Create the h & m files in the same folder as the podspec

    installation_root = Pod::Config.instance.installation_root
    keys_path = installation_root.+('Pods/CocoaPodsKeys/')

    key_master = CocoaPodsKeys::KeyMaster.new(keyring)
    interface_file = keys_path + (key_master.name + '.h')
    implementation_file = keys_path + (key_master.name + '.m')

    File.write(interface_file, key_master.interface)
    UI.puts "Generated #{interface_file}"

    File.write(implementation_file, key_master.implementation)
    UI.puts "Generated #{implementation_file}"

  end
end