motion-config 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.motion_config.yml +2 -0
- data/Gemfile +3 -0
- data/MotionConfig.gemspec +16 -0
- data/README.md +40 -0
- data/Rakefile +11 -0
- data/app/app_delegate.rb +7 -0
- data/lib/motion_config.rb +48 -0
- data/lib/motion_config/version.rb +3 -0
- metadata +71 -0
data/.gitignore
ADDED
data/.motion_config.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
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
ADDED
@@ -0,0 +1,40 @@
|
|
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
ADDED
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,48 @@
|
|
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
|
+
GLOBAL_CONFIG = File.expand_path("~/.motion_config.yml")
|
9
|
+
APP_CONFIG = File.expand_path(".motion_config.yml")
|
10
|
+
|
11
|
+
module_function
|
12
|
+
|
13
|
+
def start
|
14
|
+
check_files
|
15
|
+
environmentize parse(GLOBAL_CONFIG)
|
16
|
+
environmentize parse(APP_CONFIG)
|
17
|
+
end
|
18
|
+
|
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
|
23
|
+
|
24
|
+
def environmentize(settings)
|
25
|
+
settings.each do |key, value|
|
26
|
+
log_override(key) unless ENV[key].nil?
|
27
|
+
ENV[key] = value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
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
|
+
{}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def log_override(key)
|
42
|
+
App.log "motion-config", "#{key} previously set has been overridden"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Motion::Project::App.setup do |app|
|
47
|
+
MotionConfig.start
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
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
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Joffrey Jaffeux
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-03-23 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: RubyMotion config out of your Rakefile !
|
22
|
+
email:
|
23
|
+
- j.jaffeux@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- .motion_config.yml
|
33
|
+
- Gemfile
|
34
|
+
- MotionConfig.gemspec
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- app/app_delegate.rb
|
38
|
+
- lib/motion_config.rb
|
39
|
+
- lib/motion_config/version.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: https://github.com/jjaffeux/motion-config
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- 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"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.6
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: RubyMotion config out of your Rakefile !
|
70
|
+
test_files: []
|
71
|
+
|