motion-config 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a63a545c8cccc3cb482786702e9611b0c1b505f7
4
- data.tar.gz: c234e45775dfd8598ca69dc963b296e03df37a76
3
+ metadata.gz: 3968235922cded9e3612dee8ce7a442c1312b210
4
+ data.tar.gz: 0ec81d38374568fe0e6aac610f770d10c11e3639
5
5
  SHA512:
6
- metadata.gz: 9445b27870d4795b1484528a6b4ce832a7250f8f22b04bb56ba663968530845c19e4b3655fa0d7fb7480e25a55749d2d92063581e94271cc807d026778b454eb
7
- data.tar.gz: 48820d4b217ba5e075f75adba96e86cbb8ef3267458543b5698eb48a3b1741645b2ad13ecfd168d08ac39ce6aff69a6caa9eb73e8aed1d1c5c2a5ec23a18cb78
6
+ metadata.gz: fa33314e6400f135772fc8f93a074feb4abfe342afc06e32ca04335407dda5746f7cb539e47e317dab68ad37bb8c5946e9f73209844582a2ce24a75c4b55b431
7
+ data.tar.gz: 76dbe89b8cedc804e43f2ee98de8eda6a24b4aaeee2206b7ef418d04f02099a8fe231344ac83986fa82e826153f47a9d421df5705302048f251952dbdbfa18a4
@@ -0,0 +1,11 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "The motion-config gem must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ require 'yaml'
6
+ require 'motion-config/configuration'
7
+ require 'motion-config/version'
8
+
9
+ Motion::Project::App.setup do |app|
10
+ MotionConfig::Configuration.setup
11
+ end
@@ -0,0 +1,52 @@
1
+ module MotionConfig
2
+ class Configuration
3
+ def self.setup
4
+ instance = allocate
5
+ instance.custom_initializer
6
+ instance
7
+ end
8
+
9
+ def custom_initializer
10
+ [app_config, user_config].each do |config|
11
+ create_config_file(config) unless File.exist?(config)
12
+ environmentize parse(config)
13
+ end
14
+ end
15
+
16
+ def user_config
17
+ @user_config ||= File.expand_path("~/.motion-config.yml")
18
+ end
19
+
20
+ def app_config
21
+ @app_config ||= File.expand_path(".motion-config.yml")
22
+ end
23
+
24
+ private
25
+
26
+ def environmentize(settings)
27
+ settings.each do |key, value|
28
+ log "#{key} has been overridden" unless ENV[key].nil?
29
+ ENV[key] = value
30
+ end
31
+ end
32
+
33
+ def parse(file)
34
+ # catch exception for a bug in ruby-1.9.3p194
35
+ # https://bugs.ruby-lang.org/issues/6487
36
+ begin
37
+ YAML.load_file(file) || {}
38
+ rescue TypeError
39
+ {}
40
+ end
41
+ end
42
+
43
+ def create_config_file(file)
44
+ system("touch #{file.shellescape}")
45
+ log "#{file} has been created"
46
+ end
47
+
48
+ def log(message)
49
+ App.log "motion-config", message
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module MotionConfig
2
+ VERSION = "1.1.0"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joffrey Jaffeux
@@ -17,16 +17,9 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .gitignore
21
- - .motion_config.yml
22
- - Gemfile
23
- - MotionConfig.gemspec
24
- - README.md
25
- - Rakefile
26
- - app/app_delegate.rb
27
- - lib/motion_config.rb
28
- - lib/motion_config/version.rb
29
- - spec/main_spec.rb
20
+ - lib/motion-config.rb
21
+ - lib/motion-config/configuration.rb
22
+ - lib/motion-config/version.rb
30
23
  homepage: https://github.com/jjaffeux/motion-config
31
24
  licenses: []
32
25
  metadata: {}
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- .repl_history
2
- build
3
- .DS_STORE
4
- Gemfile.lock
5
- .ruby-version
6
- *.gem
@@ -1,2 +0,0 @@
1
- FacebookAPPID: "13123123"
2
- api_endpoint: "https://www.google.fr"
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
@@ -1,16 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/motion_config/version.rb', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.name = 'motion-config'
6
- gem.version = MotionConfig::VERSION
7
-
8
- gem.authors = ['Joffrey Jaffeux']
9
- gem.email = ['j.jaffeux@gmail.com']
10
- gem.summary = "RubyMotion config out of your Rakefile !"
11
- gem.description = "RubyMotion config out of your Rakefile !"
12
- gem.homepage = 'https://github.com/jjaffeux/motion-config'
13
-
14
- gem.files = `git ls-files`.split($\)
15
- gem.require_paths = ['lib']
16
- end
data/README.md DELETED
@@ -1,40 +0,0 @@
1
- # MotionConfig
2
-
3
- ## Description
4
-
5
- MotionConfig allows you to define string settings for you RubyMotion project without putting them in the Rakefile. You can set user level settings and app level settings.
6
-
7
- After installation, the first rake will create two files
8
-
9
- * ~/.motion_config.yml # this is the user level config file
10
-
11
- * /path/to/your_rm_project/.motion_config.yml # this is the app level config file
12
-
13
- App level config file take precedence over user level config file.
14
-
15
- ## Installation
16
-
17
- gem install 'motion-config'
18
-
19
- require 'motion-config' in the Rakefile
20
-
21
- or
22
-
23
- gem 'motion-config' in your Gemfile
24
-
25
-
26
- ## Usage
27
-
28
- 1) Run rake to create files
29
-
30
- 2) Edit files ~/.motion_config.yml or /path/to/your_rm_project/.motion_config.yml
31
-
32
- This is YAML and you can only set strings or this will fail, example yaml config :
33
-
34
- ```yaml
35
- api_endpoint: "https://www.google.fr"
36
- FacebookAPPID: "323232DQSDQDDS"
37
- ```
38
-
39
- 3) You now have access to ENV['api_endpoint'] in your app or your Rakefile
40
-
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- $:.unshift('/Library/RubyMotion/lib')
2
- require 'motion/project'
3
- require "bundler/gem_tasks"
4
- require "bundler/setup"
5
-
6
- $:.unshift("./lib/")
7
- require './lib/motion_config'
8
-
9
- Motion::Project::App.setup do |app|
10
- app.name = 'MotionConfig'
11
- end
@@ -1,7 +0,0 @@
1
- class AppDelegate
2
- def application(application, didFinishLaunchingWithOptions:launchOptions)
3
- ENV['FacebookAPPID']
4
- ENV['api_endpoint']
5
- true
6
- end
7
- end
@@ -1,67 +0,0 @@
1
- unless defined?(Motion::Project::Config)
2
- raise "The motion-config gem must be required within a RubyMotion project Rakefile."
3
- end
4
-
5
- require 'yaml'
6
-
7
- module MotionConfig
8
- class Configuration
9
-
10
- def self.setup
11
- instance = allocate
12
- instance.custom_initializer
13
- instance
14
- end
15
-
16
- def custom_initializer
17
- check_files
18
- environmentize parse(user_config)
19
- environmentize parse(app_config)
20
- end
21
-
22
- def user_config
23
- @user_config ||= File.expand_path("~/.motion_config.yml")
24
- end
25
-
26
- def app_config
27
- @app_config ||= File.expand_path(".motion_config.yml")
28
- end
29
-
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)
35
- end
36
-
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
62
- end
63
- end
64
-
65
- Motion::Project::App.setup do |app|
66
- MotionConfig::Configuration.setup
67
- end
@@ -1,3 +0,0 @@
1
- module MotionConfig
2
- VERSION = "1.0.1"
3
- end
@@ -1,6 +0,0 @@
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