motion-config 1.0.0 → 1.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a63a545c8cccc3cb482786702e9611b0c1b505f7
4
+ data.tar.gz: c234e45775dfd8598ca69dc963b296e03df37a76
5
+ SHA512:
6
+ metadata.gz: 9445b27870d4795b1484528a6b4ce832a7250f8f22b04bb56ba663968530845c19e4b3655fa0d7fb7480e25a55749d2d92063581e94271cc807d026778b454eb
7
+ data.tar.gz: 48820d4b217ba5e075f75adba96e86cbb8ef3267458543b5698eb48a3b1741645b2ad13ecfd168d08ac39ce6aff69a6caa9eb73e8aed1d1c5c2a5ec23a18cb78
data/app/app_delegate.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class AppDelegate
2
2
  def application(application, didFinishLaunchingWithOptions:launchOptions)
3
- p ENV['FacebookAPPID']
4
- p ENV['api_endpoint']
3
+ ENV['FacebookAPPID']
4
+ ENV['api_endpoint']
5
5
  true
6
6
  end
7
7
  end
data/lib/motion_config.rb CHANGED
@@ -5,44 +5,63 @@ end
5
5
  require 'yaml'
6
6
 
7
7
  module MotionConfig
8
- GLOBAL_CONFIG = File.expand_path("~/.motion_config.yml")
9
- APP_CONFIG = File.expand_path(".motion_config.yml")
8
+ class Configuration
10
9
 
11
- module_function
10
+ def self.setup
11
+ instance = allocate
12
+ instance.custom_initializer
13
+ instance
14
+ end
12
15
 
13
- def start
14
- check_files
15
- environmentize parse(GLOBAL_CONFIG)
16
- environmentize parse(APP_CONFIG)
17
- end
16
+ def custom_initializer
17
+ check_files
18
+ environmentize parse(user_config)
19
+ environmentize parse(app_config)
20
+ end
18
21
 
19
- def check_files
20
- system("touch #{GLOBAL_CONFIG.shellescape}") unless File.exist?(GLOBAL_CONFIG)
21
- system("touch #{APP_CONFIG.shellescape}") unless File.exist?(APP_CONFIG)
22
- end
22
+ def user_config
23
+ @user_config ||= File.expand_path("~/.motion_config.yml")
24
+ end
23
25
 
24
- def environmentize(settings)
25
- settings.each do |key, value|
26
- log_override(key) unless ENV[key].nil?
27
- ENV[key] = value
26
+ def app_config
27
+ @app_config ||= File.expand_path(".motion_config.yml")
28
28
  end
29
- end
30
29
 
31
- def parse(file)
32
- # catch exception for a bug in ruby-1.9.3p194
33
- # https://bugs.ruby-lang.org/issues/6487
34
- begin
35
- YAML.load_file(file) || {}
36
- rescue TypeError
37
- {}
30
+ private
31
+
32
+ def check_files
33
+ create_config_file(user_config) unless File.exist?(user_config)
34
+ create_config_file(app_config) unless File.exist?(app_config)
38
35
  end
39
- end
40
36
 
41
- def log_override(key)
42
- App.log "motion-config", "#{key} previously set has been overridden"
37
+ def environmentize(settings)
38
+ settings.each do |key, value|
39
+ warn_override(key) unless ENV[key].nil?
40
+ ENV[key] = value
41
+ end
42
+ end
43
+
44
+ def parse(file)
45
+ # catch exception for a bug in ruby-1.9.3p194
46
+ # https://bugs.ruby-lang.org/issues/6487
47
+ begin
48
+ YAML.load_file(file) || {}
49
+ rescue TypeError
50
+ {}
51
+ end
52
+ end
53
+
54
+ def warn_override(key)
55
+ App.log "motion-config", "#{key} previously set has been overridden"
56
+ end
57
+
58
+ def create_config_file(file)
59
+ system("touch #{file.shellescape}")
60
+ App.log "motion-config", "#{file} has been created"
61
+ end
43
62
  end
44
63
  end
45
64
 
46
65
  Motion::Project::App.setup do |app|
47
- MotionConfig.start
66
+ MotionConfig::Configuration.setup
48
67
  end
@@ -1,3 +1,3 @@
1
1
  module MotionConfig
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/spec/main_spec.rb ADDED
@@ -0,0 +1,6 @@
1
+ describe "Application 'MotionConfig'" do
2
+ it "sets ENV variables" do
3
+ ENV['FacebookAPPID'].should == '13123123'
4
+ ENV['api_endpoint'].should == 'https://www.google.fr'
5
+ end
6
+ end
metadata CHANGED
@@ -1,33 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: motion-config
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 0
9
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Joffrey Jaffeux
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2013-03-23 00:00:00 +01:00
18
- default_executable:
11
+ date: 2013-03-24 00:00:00.000000000 Z
19
12
  dependencies: []
20
-
21
13
  description: RubyMotion config out of your Rakefile !
22
- email:
14
+ email:
23
15
  - j.jaffeux@gmail.com
24
16
  executables: []
25
-
26
17
  extensions: []
27
-
28
18
  extra_rdoc_files: []
29
-
30
- files:
19
+ files:
31
20
  - .gitignore
32
21
  - .motion_config.yml
33
22
  - Gemfile
@@ -37,35 +26,28 @@ files:
37
26
  - app/app_delegate.rb
38
27
  - lib/motion_config.rb
39
28
  - lib/motion_config/version.rb
40
- has_rdoc: true
29
+ - spec/main_spec.rb
41
30
  homepage: https://github.com/jjaffeux/motion-config
42
31
  licenses: []
43
-
32
+ metadata: {}
44
33
  post_install_message:
45
34
  rdoc_options: []
46
-
47
- require_paths:
35
+ require_paths:
48
36
  - lib
49
- required_ruby_version: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- segments:
61
- - 0
62
- version: "0"
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
63
47
  requirements: []
64
-
65
48
  rubyforge_project:
66
- rubygems_version: 1.3.6
49
+ rubygems_version: 2.0.0
67
50
  signing_key:
68
- specification_version: 3
51
+ specification_version: 4
69
52
  summary: RubyMotion config out of your Rakefile !
70
53
  test_files: []
71
-