motion_settings 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.motion-settings.yml +2 -0
- data/Gemfile +3 -0
- data/MotionSettings.gemspec +16 -0
- data/README.md +40 -0
- data/Rakefile +11 -0
- data/app/app_delegate.rb +7 -0
- data/lib/motion_settings.rb +48 -0
- data/lib/motion_settings/version.rb +3 -0
- metadata +54 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/motion_settings/version.rb', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'motion_settings'
|
6
|
+
gem.version = MotionSettings::VERSION
|
7
|
+
|
8
|
+
gem.authors = ['Joffrey Jaffeux']
|
9
|
+
gem.email = ['j.jaffeux@gmail.com']
|
10
|
+
gem.summary = "RubyMotion settings out of your Rakefile !"
|
11
|
+
gem.description = "RubyMotion settings out of your Rakefile !"
|
12
|
+
gem.homepage = 'https://github.com/jjaffeux/motion-settings'
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# MotionSettings
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
MotionSettings 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_settings.yml # this is the user level config file
|
10
|
+
|
11
|
+
* /path/to/your_rm_project/.motion_settings.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-settings'
|
18
|
+
|
19
|
+
require 'motion-settings' in the Rakefile
|
20
|
+
|
21
|
+
or
|
22
|
+
|
23
|
+
gem 'motion-settings' in your Gemfile
|
24
|
+
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
1) Run rake to create files
|
29
|
+
|
30
|
+
2) Edit files ~/.motion_settings.yml or /path/to/your_rm_project/.motion_settings.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-settings gem must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module MotionSettings
|
8
|
+
GLOBAL_CONFIG = File.expand_path("~/.motion-settings.yml")
|
9
|
+
APP_CONFIG = File.expand_path(".motion-settings.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-settings", "#{key} previously set has been overridden"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Motion::Project::App.setup do |app|
|
47
|
+
MotionSettings.start
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion_settings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joffrey Jaffeux
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: RubyMotion settings out of your Rakefile !
|
15
|
+
email:
|
16
|
+
- j.jaffeux@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .motion-settings.yml
|
23
|
+
- Gemfile
|
24
|
+
- MotionSettings.gemspec
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- app/app_delegate.rb
|
28
|
+
- lib/motion_settings.rb
|
29
|
+
- lib/motion_settings/version.rb
|
30
|
+
homepage: https://github.com/jjaffeux/motion-settings
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.8.24
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: RubyMotion settings out of your Rakefile !
|
54
|
+
test_files: []
|