motion-config 1.0.1 → 1.1.0
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 +4 -4
- data/lib/motion-config.rb +11 -0
- data/lib/motion-config/configuration.rb +52 -0
- data/lib/motion-config/version.rb +3 -0
- metadata +4 -11
- data/.gitignore +0 -6
- data/.motion_config.yml +0 -2
- data/Gemfile +0 -3
- data/MotionConfig.gemspec +0 -16
- data/README.md +0 -40
- data/Rakefile +0 -11
- data/app/app_delegate.rb +0 -7
- data/lib/motion_config.rb +0 -67
- data/lib/motion_config/version.rb +0 -3
- data/spec/main_spec.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3968235922cded9e3612dee8ce7a442c1312b210
|
4
|
+
data.tar.gz: 0ec81d38374568fe0e6aac610f770d10c11e3639
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
-
- .
|
21
|
-
- .
|
22
|
-
-
|
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
data/.motion_config.yml
DELETED
data/Gemfile
DELETED
data/MotionConfig.gemspec
DELETED
@@ -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
data/app/app_delegate.rb
DELETED
data/lib/motion_config.rb
DELETED
@@ -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
|