motion-my_env 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 +7 -0
- data/README.md +73 -0
- data/lib/motion-my_env.rb +13 -0
- data/lib/project/motion-my_env.rb +33 -0
- metadata +63 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 5aac8bd97f0b2713615b7c04c1289aa607c8c1f4
|
|
4
|
+
data.tar.gz: 6a14545688bdad92eeee84392be04b4cf9310255
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cdf780d8d2b0e8d58c70f321a35588d01208aac0b63709e79354f9def390c8a9fb181bc1d8759448fbf383059b5502942ce1f65c619b03a140933e9ef4968a93
|
|
7
|
+
data.tar.gz: 0461ff50f9022d426466da0b3a38893fd97cdf7d2ad483bea42b725c22cec7c96eaa507d229555b732b3bf580efda330ad191ef8b7588ad11b5af712fd797a74
|
data/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# motion-my_env
|
|
2
|
+
|
|
3
|
+
motion-my_env is a simple environment managing solution on RubyMotion app.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'motion-my_env'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install motion-my_env
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
in you Rakefile
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
Motion::Project::App.setup do |app|
|
|
25
|
+
...
|
|
26
|
+
app.my_env.file = './config/environment.yaml'
|
|
27
|
+
...
|
|
28
|
+
end
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
in config/environment.yaml
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
consumer_key: xxx
|
|
35
|
+
consumer_secret: XXX
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
in app code after build, motion-my_env define `MY_ENV` constant variable as Hash.
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
p MY_ENV #=> { 'consumer_key' => 'xxx', 'consumer_secret' => 'XXX' }
|
|
42
|
+
```
|
|
43
|
+
## Why don't you use `ENV`?
|
|
44
|
+
|
|
45
|
+
`ENV` constant variable has been already defined by RubyMotion runtime as a NSObject instance,
|
|
46
|
+
and, that can't be assigned Fixnum's object.
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
(main)> ENV
|
|
50
|
+
ENV
|
|
51
|
+
=> {}
|
|
52
|
+
(main)> ENV.class
|
|
53
|
+
ENV.class
|
|
54
|
+
=> NSObject
|
|
55
|
+
(main)> ENV['aaa'] = 1
|
|
56
|
+
ENV['aaa'] = 1
|
|
57
|
+
2013-08-18 11:57:00.845 shiori[74941:c07] can't convert Fixnum into String (TypeError)
|
|
58
|
+
=> #<TypeError: can't convert Fixnum into String>
|
|
59
|
+
(main)> MY_ENV
|
|
60
|
+
MY_ENV
|
|
61
|
+
2013-08-18 11:55:02.929 shiori[74941:c07] uninitialized constant MY_ENV (NameError)
|
|
62
|
+
=> #<NameError: uninitialized constant MY_ENV>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
So, I use original constant variable name.
|
|
66
|
+
|
|
67
|
+
## Contributing
|
|
68
|
+
|
|
69
|
+
1. Fork it
|
|
70
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
71
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
72
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
73
|
+
5. Create new Pull Request
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
require 'project/motion-my_env'
|
|
6
|
+
|
|
7
|
+
class Motion::Project::Config
|
|
8
|
+
variable :my_env
|
|
9
|
+
|
|
10
|
+
def my_env
|
|
11
|
+
@my_env ||= Motion::MyEnv.new(self)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'tempfile'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
module Motion
|
|
6
|
+
class MyEnv
|
|
7
|
+
attr_accessor :file
|
|
8
|
+
|
|
9
|
+
def initialize(config)
|
|
10
|
+
@config = config
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def file= path
|
|
14
|
+
add_file(generate_env_file(path))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def generate_env_file path
|
|
18
|
+
yaml = YAML.load(File.open(File.expand_path(path)).read)
|
|
19
|
+
env = Tempfile.open(['motion_env', '.rb'])
|
|
20
|
+
env.write <<-"ENV_FILE"
|
|
21
|
+
MY_ENV = #{yaml.inspect}
|
|
22
|
+
ENV_FILE
|
|
23
|
+
env.close
|
|
24
|
+
env.path
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def add_file path
|
|
28
|
+
files = @config.files.flatten
|
|
29
|
+
@config.files << path unless files.find {|x| File.expand_path(x) == File.expand_path(path) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: motion-my_env
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.1'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ainame
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-08-18 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: motion-my_env is a simple enviroment managing solution on RubyMotion
|
|
28
|
+
app. motion-my_env define MY_ENV variable on RubyMotion runtime which created by
|
|
29
|
+
defineded yaml file.
|
|
30
|
+
email:
|
|
31
|
+
- s.namai.2012@gmail.com
|
|
32
|
+
executables: []
|
|
33
|
+
extensions: []
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- README.md
|
|
37
|
+
- lib/motion-my_env.rb
|
|
38
|
+
- lib/project/motion-my_env.rb
|
|
39
|
+
homepage: ''
|
|
40
|
+
licenses:
|
|
41
|
+
- ''
|
|
42
|
+
metadata: {}
|
|
43
|
+
post_install_message:
|
|
44
|
+
rdoc_options: []
|
|
45
|
+
require_paths:
|
|
46
|
+
- lib
|
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
|
+
requirements:
|
|
49
|
+
- - '>='
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '0'
|
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - '>='
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
requirements: []
|
|
58
|
+
rubyforge_project:
|
|
59
|
+
rubygems_version: 2.0.5
|
|
60
|
+
signing_key:
|
|
61
|
+
specification_version: 4
|
|
62
|
+
summary: motion-my_env is a simple environment managing solution on RubyMotion app.
|
|
63
|
+
test_files: []
|