seteable 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +48 -0
- data/lib/seteable.rb +23 -0
- data/seteable.gemspec +12 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec4904f269918a1df2b7f383c89039666d1741d7
|
4
|
+
data.tar.gz: f719d5fa0a2714e2adabadb7a432c5e1bf2bb077
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f5236d5fe2713b83c8d337aa1d2c5a2df8115cbb23154f4a8e3d225b9e74f44ec9525eb5ecfccf38817a791f9b2657f81ef8e2c2006336274fa38efcaa39c81d
|
7
|
+
data.tar.gz: 76e43dda54e6d43b228b1f6c2c992935b7b4f42cef958f7669097f76bfe01f392e8e3ed91a418b64b44acd5b6ed64c20ee51986046757cf8ac431a63cc4488f6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Francesco Rodríguez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
seteable
|
2
|
+
--------
|
3
|
+
|
4
|
+
Define settings for your library.
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
|
9
|
+
Use the `settings` method to set and get values:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
class Base
|
13
|
+
include Seteable
|
14
|
+
end
|
15
|
+
|
16
|
+
Base.settings[:foo] = "foo"
|
17
|
+
|
18
|
+
Base.settings[:foo] # => "foo"
|
19
|
+
Base.new.settings[:foo] # => "foo"
|
20
|
+
```
|
21
|
+
|
22
|
+
Settings are inherited:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
class Parent
|
26
|
+
include Seteable
|
27
|
+
|
28
|
+
settings[:foo] = "foo"
|
29
|
+
end
|
30
|
+
|
31
|
+
class Child < Parent
|
32
|
+
settings[:bar] = "bar"
|
33
|
+
end
|
34
|
+
|
35
|
+
Child.settings[:foo] # => "foo"
|
36
|
+
Child.settings[:bar] # => "bar"
|
37
|
+
```
|
38
|
+
|
39
|
+
Check the [posten][posten] gem for a real example.
|
40
|
+
|
41
|
+
Installation
|
42
|
+
------------
|
43
|
+
|
44
|
+
```
|
45
|
+
$ gem install seteable
|
46
|
+
```
|
47
|
+
|
48
|
+
[posten]: https://github.com/harmoni/posten
|
data/lib/seteable.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Seteable
|
2
|
+
def self.included(base)
|
3
|
+
base.extend(ClassMethods)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.deepclone(obj)
|
7
|
+
return Marshal.load(Marshal.dump(obj))
|
8
|
+
end
|
9
|
+
|
10
|
+
def settings
|
11
|
+
return self.class.settings
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def inherited(subclass)
|
16
|
+
subclass.settings.replace(Seteable.deepclone(settings))
|
17
|
+
end
|
18
|
+
|
19
|
+
def settings
|
20
|
+
return @settings ||= {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/seteable.gemspec
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "seteable"
|
3
|
+
s.version = "1.0.0"
|
4
|
+
s.summary = "Define settings for your library"
|
5
|
+
s.description = s.summary
|
6
|
+
s.authors = ["Francesco Rodríguez"]
|
7
|
+
s.email = ["frodsan@protonmail.ch"]
|
8
|
+
s.homepage = "https://github.com/harmoni/seteable"
|
9
|
+
s.license = "MIT"
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seteable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Francesco Rodríguez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Define settings for your library
|
14
|
+
email:
|
15
|
+
- frodsan@protonmail.ch
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- LICENSE
|
21
|
+
- README.md
|
22
|
+
- lib/seteable.rb
|
23
|
+
- seteable.gemspec
|
24
|
+
homepage: https://github.com/harmoni/seteable
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.4.8
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Define settings for your library
|
48
|
+
test_files: []
|