Sha256: 2a5ac26ef3c2461c1ad8e9f483327c4e5e62829d43f9cc868a3580c4fa73284b

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

require 'keyring_liberator'
require 'key_master'
require 'dotenv'

module Pod
  class Command
    class Keys
      class Generate < Keys
        self.summary = 'Generates the obfuscated class.'

        self.description = <<-DESC
          Generates the obfuscated Objective-C h/m files using the current key values.

          An optional operator can be done to force a project name.
        DESC

        self.arguments = [CLAide::Argument.new('project_name', false)]

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

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

        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
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cocoapods-keys-2.3.1 lib/pod/command/keys/generate.rb
cocoapods-keys-2.3.0 lib/pod/command/keys/generate.rb
cocoapods-keys-2.2.1 lib/pod/command/keys/generate.rb
cocoapods-keys-2.2.0 lib/pod/command/keys/generate.rb
cocoapods-keys-2.1.0 lib/pod/command/keys/generate.rb