turf 0.0.3 → 0.0.4
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/README.md +70 -18
- data/lib/turf.rb +0 -1
- data/lib/turf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 041d3a291a6ed153c3b5f82fcd2c354c1a25113d
|
4
|
+
data.tar.gz: f4db87acd04ab1142806de020c1fbadf7a816883
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da5eefaa8107fcd0112d644351a97dc9424e46282569bc94356c03af080f92b24227f13ebe9b0a580852c913e024f65e442864c3d5b1a805230aafec455689a8
|
7
|
+
data.tar.gz: c86be7230bea291951c31a1640d0c554d2999e23b0bfcc017b69dfae52cc38e1964821cac07a8046f263e482ca79ddbf74c0ee9b6772e04bfc6b2734c7104a55
|
data/README.md
CHANGED
@@ -1,41 +1,93 @@
|
|
1
1
|
# Turf
|
2
2
|
|
3
|
-
|
3
|
+
Turf lets you control the value of variables in different environments and makes it easy to override values locally. It's easy to set `speak_in_chat` to `true` when `RAILS_ENV` equals "production" and `false` otherwise. Turf is similar to the Rails `secrets.yml` file, but more powerful because it can execute Ruby code and return arrays, hashes, etc.
|
4
4
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
5
|
|
7
|
-
##
|
6
|
+
## How it works
|
8
7
|
|
9
|
-
|
8
|
+
Turf looks for methods in the following order:
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
1. The `Turf::Local` class.
|
11
|
+
2. The `Turf::Test`, `Turf::Development`, or `Turf::Production` class. Turf uses the development environment by default, but this can be overridden by setting `RAILS_ENV` to "production" or "test".
|
12
|
+
3. The `Turf::Default` class.
|
14
13
|
|
15
|
-
|
14
|
+
I recommend defining the Turf classes in the `/config/turf` directory.
|
16
15
|
|
17
|
-
$ bundle
|
18
16
|
|
19
|
-
|
17
|
+
## Examples
|
20
18
|
|
21
|
-
|
19
|
+
```ruby
|
20
|
+
ENV["RAILS_ENV"] = "production"
|
21
|
+
|
22
|
+
class Turf::Local
|
23
|
+
def something
|
24
|
+
"something in local"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Turf::Development
|
29
|
+
def blah
|
30
|
+
"blah in development"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Turf::Production
|
35
|
+
def something
|
36
|
+
"something in production"
|
37
|
+
end
|
38
|
+
|
39
|
+
def blah
|
40
|
+
"blah in production"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class Turf::Default
|
45
|
+
def four
|
46
|
+
2 + 2
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Turf::Local is the first place Turf looks for a
|
51
|
+
# matching method
|
52
|
+
Turf.find(:something) # => "something in local"
|
53
|
+
|
54
|
+
# The RAILS_ENV is set to production, so Turf looks
|
55
|
+
# in Turf::Production second if the method is not
|
56
|
+
# found in Turf::Local
|
57
|
+
# Turf::Development is ignored in production
|
58
|
+
Turf.find(:blah) # => "blah in production"
|
59
|
+
|
60
|
+
# Turf::Default is the last place to look
|
61
|
+
Turf.find(:four) # => 4
|
62
|
+
|
63
|
+
# Turf raises an exception when it can't find
|
64
|
+
# a matching method
|
65
|
+
Turf.find(:hi_there) # => raises an exception
|
66
|
+
```
|
22
67
|
|
23
|
-
##
|
68
|
+
## Setup
|
24
69
|
|
25
|
-
|
70
|
+
Add this line to your application's Gemfile:
|
26
71
|
|
27
|
-
|
72
|
+
```ruby
|
73
|
+
gem 'turf'
|
74
|
+
```
|
28
75
|
|
29
|
-
|
76
|
+
Require turf:
|
30
77
|
|
31
|
-
|
78
|
+
```ruby
|
79
|
+
require 'turf'
|
80
|
+
```
|
81
|
+
|
82
|
+
Create the `Turf::Local`, `Turf::Test`, `Turf::Development`, `Turf::Production`, and `Turf::Default` classes (you don't have to create all of them, just the ones you want).
|
83
|
+
|
84
|
+
Use `Turf.find()` in your project.
|
32
85
|
|
33
86
|
## Contributing
|
34
87
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
88
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/MrPowers/turf.
|
36
89
|
|
37
90
|
|
38
91
|
## License
|
39
92
|
|
40
93
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/lib/turf.rb
CHANGED
data/lib/turf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MrPowers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|