global-configuration-writable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +2 -0
- data/global-configuration-writable.gemspec +26 -0
- data/lib/global-configuration-writable.rb +1 -0
- data/lib/global/configuration/writable.rb +11 -0
- data/lib/global/configuration/writable/version.rb +5 -0
- data/spec/files/rspec_config.yml +8 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/version_spec.rb +5 -0
- data/spec/writable_spec.rb +27 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9a7bfd75e990b0caafd7241c07aa3cdcc3cb1b48
|
4
|
+
data.tar.gz: c4ce825eb02d330ea60fdd38401064792b1d6bd8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df707b93615408cf653805f2c1e88a0a40ead09ecedebbcdc3f04c6351e6dfa262f2bb5c86e2a257bcae1a8091eece510aeba908649e80379c45c1e66eeefd2b
|
7
|
+
data.tar.gz: 3c236a92983049abc08cc4aad4de8ace003379feeb0edc11a5db177d88eb784332ff846206f80b2e5b9654632917514323ca124e8b96631dc7488182625b6a6f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Keiichiro Nagano
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Global::Configuration::Writable
|
2
|
+
|
3
|
+
Make global's configuration writable
|
4
|
+
|
5
|
+
global: https://rubygems.org/gems/global
|
6
|
+
|
7
|
+
## CAUTION
|
8
|
+
|
9
|
+
This gem is unholy. You break global's referential transparency
|
10
|
+
that's so cute, pretty, precious and trustworthy. You'll shoot your
|
11
|
+
foot. I just warned. Think twice.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'global-configuration-writable'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install global-configuration-writable
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
pry> Global.some_config.some_entry
|
32
|
+
=> "some value"
|
33
|
+
pry> Global.some_config.some_entry = "new value"
|
34
|
+
NoMethodError: undefined method `some_entry=' for Global::Configuration
|
35
|
+
|
36
|
+
pry> require 'global-configuration-writable'
|
37
|
+
=> true
|
38
|
+
|
39
|
+
pry> Global.some_config.some_entry = "new value"
|
40
|
+
=> "new value" # causes no error
|
41
|
+
pry> Global.some_config.some_entry
|
42
|
+
=> "new value"
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it ( https://github.com/knagano/global-configuration-writable/fork )
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'global/configuration/writable/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "global-configuration-writable"
|
8
|
+
spec.version = Global::Configuration::Writable::VERSION
|
9
|
+
spec.authors = ["Keiichiro Nagano"]
|
10
|
+
spec.email = ["knagano@CPAN.org"]
|
11
|
+
spec.summary = %q{Make global's configuration writable}
|
12
|
+
spec.description = %q{Make global's configuration writable.}
|
13
|
+
spec.homepage = "https://github.com/knagano/global-configuration-writable"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'global', '~> 0.1'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency 'rspec', '~> 2.13'
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'global/configuration/writable'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'global/configuration/writable/version'
|
2
|
+
|
3
|
+
module Global::Configuration::Writable
|
4
|
+
def method_missing(method, *args, &block)
|
5
|
+
return super unless method.to_s[-1] == '='
|
6
|
+
raise ArgumentError.new("wrong number of arguments (1 for 2)") if args.length < 1
|
7
|
+
hash[method.to_s[0..-2]] = args[0]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Global::Configuration.__send__(:prepend, Global::Configuration::Writable)
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
describe Global::Configuration::Writable do
|
2
|
+
before(:each) do
|
3
|
+
Global.configure do |config|
|
4
|
+
config.environment = 'test'
|
5
|
+
config.config_directory = File.join(Dir.pwd, 'spec/files')
|
6
|
+
end
|
7
|
+
Global.reload!
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns the value of the file before overwrite' do
|
11
|
+
expect(Global.rspec_config.test_value).to eq 'test value'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'can be overwritten and changes it\'s value' do
|
15
|
+
expect(Global.rspec_config.test_value).to eq 'test value'
|
16
|
+
Global.rspec_config.test_value = 'test value overwrittten'
|
17
|
+
expect(Global.rspec_config.test_value).to eq 'test value overwrittten'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'revives the value of the file after reload!' do
|
21
|
+
expect(Global.rspec_config.test_value).to eq 'test value'
|
22
|
+
Global.rspec_config.test_value = 'test value overwrittten'
|
23
|
+
expect(Global.rspec_config.test_value).to eq 'test value overwrittten'
|
24
|
+
Global.reload!
|
25
|
+
expect(Global.rspec_config.test_value).to eq 'test value'
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: global-configuration-writable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keiichiro Nagano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: global
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.13'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.13'
|
69
|
+
description: Make global's configuration writable.
|
70
|
+
email:
|
71
|
+
- knagano@CPAN.org
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- global-configuration-writable.gemspec
|
83
|
+
- lib/global-configuration-writable.rb
|
84
|
+
- lib/global/configuration/writable.rb
|
85
|
+
- lib/global/configuration/writable/version.rb
|
86
|
+
- spec/files/rspec_config.yml
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/version_spec.rb
|
89
|
+
- spec/writable_spec.rb
|
90
|
+
homepage: https://github.com/knagano/global-configuration-writable
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.2.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Make global's configuration writable
|
114
|
+
test_files:
|
115
|
+
- spec/files/rspec_config.yml
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/version_spec.rb
|
118
|
+
- spec/writable_spec.rb
|