Skip to content

Instantly share code, notes, and snippets.

@tibastral
Forked from dblandin/.env
Last active March 17, 2016 15:11
Show Gist options
  • Select an option

  • Save tibastral/1f67e61ed40e9b1db4f4 to your computer and use it in GitHub Desktop.

Select an option

Save tibastral/1f67e61ed40e9b1db4f4 to your computer and use it in GitHub Desktop.

Revisions

  1. tibastral revised this gist Mar 17, 2016. 3 changed files with 4 additions and 28 deletions.
    14 changes: 2 additions & 12 deletions Rakefile
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,8 @@
    # -*- coding: utf-8 -*-
    $:.unshift('/Library/RubyMotion/lib')

    ...
    environment_variables = Dotenv.load


    Motion::Project::App.setup do |app|
    ...

    app.info_plist[:ENV] = Dotenv.load
    app.testflight do |config|
    config.api_token = ENV['TESTFLIGHT_API_TOKEN']
    config.team_token = ENV['TESTFLIGHT_TEAM_TOKEN']
    @@ -17,10 +13,4 @@ Motion::Project::App.setup do |app|
    config.api_key = ENV['BUGSENSE_API_KEY']
    config.token = ENV['BUGSENSE_API_TOKEN']
    end

    ...

    environment_variables.each { |key, value| app.info_plist["ENV_#{key}"] = value }

    ...
    end
    16 changes: 1 addition & 15 deletions env.rb
    Original file line number Diff line number Diff line change
    @@ -1,15 +1 @@
    module App; module ENV
    class << self
    def [](key)
    vars["ENV_#{key}"]
    end

    def vars
    @vars ||= info_dictionary.select { |key, value| key.start_with? 'ENV_' }
    end

    def info_dictionary
    NSBundle.mainBundle.infoDictionary
    end
    end
    end; end
    Env = NSBundle.mainBundle.infoDictionary[:ENV]
    2 changes: 1 addition & 1 deletion some_file.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    class SomeClass
    def activate_bugsense!
    ...
    BugSenseController.sharedControllerWithBugSenseAPIKey(App::ENV['BUGSENSE_API_KEY'])
    BugSenseController.sharedControllerWithBugSenseAPIKey(Env['BUGSENSE_API_KEY'])
    ...
    end
    end
  2. @dblandin dblandin created this gist Jan 19, 2014.
    15 changes: 15 additions & 0 deletions .env
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    TESTFLIGHT_APP_TOKEN=90210
    TESTFLIGHT_TEAM_TOKEN=90210
    TESTFLIGHT_API_TOKEN=90210

    BUGSENSE_API_KEY=90210
    BUGSENSE_API_TOKEN=90210

    DEVELOPMENT_CERTIFICATE_NAME="iPhone Developer: yourName"
    DEVELOPMENT_PROVISIONING_PROFILE_PATH="/path/to/development.mobileprovision"

    ADHOC_CERTIFICATE_NAME="iPhone Distribution: yourCompany, Inc."
    ADHOC_PROVISIONING_PROFILE_PATH="/path/to/adhoc_distribution.mobileprovision"

    RELEASE_CERTIFICATE_NAME="iPhone Distribution: yourCompany, Inc."
    RELEASE_PROVISIONING_PROFILE_PATH="/path/to/store_distribution.mobileprovision"
    5 changes: 5 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    source 'https://rubygems.org'

    ...
    gem 'dotenv', '~> 0.9.0'
    ...
    26 changes: 26 additions & 0 deletions Rakefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    # -*- coding: utf-8 -*-
    $:.unshift('/Library/RubyMotion/lib')

    ...
    environment_variables = Dotenv.load

    Motion::Project::App.setup do |app|
    ...

    app.testflight do |config|
    config.api_token = ENV['TESTFLIGHT_API_TOKEN']
    config.team_token = ENV['TESTFLIGHT_TEAM_TOKEN']
    config.app_token = ENV['TESTFLIGHT_APP_TOKEN']
    end

    app.bugsense do |config|
    config.api_key = ENV['BUGSENSE_API_KEY']
    config.token = ENV['BUGSENSE_API_TOKEN']
    end

    ...

    environment_variables.each { |key, value| app.info_plist["ENV_#{key}"] = value }

    ...
    end
    15 changes: 15 additions & 0 deletions env.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    module App; module ENV
    class << self
    def [](key)
    vars["ENV_#{key}"]
    end

    def vars
    @vars ||= info_dictionary.select { |key, value| key.start_with? 'ENV_' }
    end

    def info_dictionary
    NSBundle.mainBundle.infoDictionary
    end
    end
    end; end
    7 changes: 7 additions & 0 deletions some_file.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    class SomeClass
    def activate_bugsense!
    ...
    BugSenseController.sharedControllerWithBugSenseAPIKey(App::ENV['BUGSENSE_API_KEY'])
    ...
    end
    end