seteable 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +48 -7
- data/lib/seteable.rb +7 -4
- data/test/seteable_test.rb +57 -0
- metadata +65 -12
- data/.gems +0 -1
- data/makefile +0 -9
- data/seteable.gemspec +0 -12
- data/test/all.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ac096bdc6f350ee21c5bba47296e7a064208989
|
4
|
+
data.tar.gz: 7ebd741877347d8827586c5df9a21a37d138d9d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dabe3da46f9e7741abc4ad895fc6d6f05f034bc510a513da6e8c5f1164e084d03c69c0054040e5611ee2f7ebb75a3e1ff6a7a0aff9ce0d13ebb28938ecd3a1a2
|
7
|
+
data.tar.gz: 4f1ad0999d7701bbd52e28beac06192fb8668ee23eb21fc45898a4123df5584b0fecdf9c5dd4741f50278c2b019ba5e2be4f9713006949d3c38b325f91dfd820
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2015 Francesco Rodríguez
|
3
|
+
Copyright (c) 2015-2016 Francesco Rodríguez
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,8 +1,29 @@
|
|
1
|
-
seteable
|
2
|
-
|
1
|
+
Seteable [![Build Status](https://gitlab.com/frodsan/seteable/badges/master/build.svg)](https://gitlab.com/frodsan/seteable/builds)
|
2
|
+
========
|
3
3
|
|
4
4
|
Define settings for your library.
|
5
5
|
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "seteable"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ gem install seteable
|
25
|
+
```
|
26
|
+
|
6
27
|
Usage
|
7
28
|
-----
|
8
29
|
|
@@ -36,13 +57,33 @@ Child.settings[:foo] # => "foo"
|
|
36
57
|
Child.settings[:bar] # => "bar"
|
37
58
|
```
|
38
59
|
|
39
|
-
|
40
|
-
|
41
|
-
Installation
|
60
|
+
Contributing
|
42
61
|
------------
|
43
62
|
|
63
|
+
Fork the project with:
|
64
|
+
|
44
65
|
```
|
45
|
-
$
|
66
|
+
$ git clone git@gitlab.com:frodsan/seteable.git
|
67
|
+
```
|
68
|
+
|
69
|
+
To install dependencies, use:
|
70
|
+
|
71
|
+
```
|
72
|
+
$ bundle install
|
46
73
|
```
|
47
74
|
|
48
|
-
|
75
|
+
To run the test suite, do:
|
76
|
+
|
77
|
+
```
|
78
|
+
$ rake test
|
79
|
+
```
|
80
|
+
|
81
|
+
For bug reports and pull requests use [GitLab][issues].
|
82
|
+
|
83
|
+
License
|
84
|
+
-------
|
85
|
+
|
86
|
+
Seteable is released under the [MIT License][mit].
|
87
|
+
|
88
|
+
[mit]: http://www.opensource.org/licenses/MIT
|
89
|
+
[issues]: https://gitlab.com/frodsan/seteable/issues
|
data/lib/seteable.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Seteable
|
2
4
|
def self.included(base)
|
3
5
|
base.include(InstanceMethods)
|
@@ -5,16 +7,17 @@ module Seteable
|
|
5
7
|
end
|
6
8
|
|
7
9
|
def self.deepclone(hash)
|
8
|
-
default_proc
|
10
|
+
default_proc = hash.default_proc
|
11
|
+
hash.default_proc = nil
|
9
12
|
|
10
|
-
|
13
|
+
Marshal.load(Marshal.dump(hash))
|
11
14
|
ensure
|
12
15
|
hash.default_proc = default_proc
|
13
16
|
end
|
14
17
|
|
15
18
|
module InstanceMethods
|
16
19
|
def settings
|
17
|
-
|
20
|
+
self.class.settings
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
@@ -25,7 +28,7 @@ module Seteable
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def settings
|
28
|
-
|
31
|
+
@settings ||= {}
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "minitest/autorun"
|
5
|
+
require "minitest/pride"
|
6
|
+
require "minitest/sugar"
|
7
|
+
require_relative "../lib/seteable"
|
8
|
+
|
9
|
+
class SeteableTest < Minitest::Test
|
10
|
+
test "settings" do
|
11
|
+
class Base
|
12
|
+
include Seteable
|
13
|
+
end
|
14
|
+
|
15
|
+
Base.settings[:foo] = "foo"
|
16
|
+
|
17
|
+
assert_equal "foo", Base.settings[:foo]
|
18
|
+
assert_equal "foo", Base.new.settings[:foo]
|
19
|
+
end
|
20
|
+
|
21
|
+
test "inheritance" do
|
22
|
+
class Parent
|
23
|
+
include Seteable
|
24
|
+
end
|
25
|
+
|
26
|
+
Parent.settings[:foo] = "foo"
|
27
|
+
|
28
|
+
class Child < Parent
|
29
|
+
end
|
30
|
+
|
31
|
+
assert_equal "foo", Child.settings[:foo]
|
32
|
+
end
|
33
|
+
|
34
|
+
test "look up parent if setting not exists" do
|
35
|
+
class Foo
|
36
|
+
include Seteable
|
37
|
+
end
|
38
|
+
|
39
|
+
class Bar < Foo
|
40
|
+
end
|
41
|
+
|
42
|
+
class Baz < Bar
|
43
|
+
end
|
44
|
+
|
45
|
+
Foo.settings[:foo] = "foo"
|
46
|
+
Bar.settings[:bar] = "bar"
|
47
|
+
|
48
|
+
assert_equal "foo", Bar.settings[:foo]
|
49
|
+
assert_equal "foo", Baz.settings[:foo]
|
50
|
+
assert_equal "bar", Baz.settings[:bar]
|
51
|
+
|
52
|
+
Bar.settings[:foo] = "bar"
|
53
|
+
|
54
|
+
assert_equal "bar", Bar.settings[:foo]
|
55
|
+
assert_equal "foo", Baz.settings[:foo]
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,30 +1,82 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seteable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodríguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest-sugar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
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: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.39'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.39'
|
13
69
|
description: Define settings for your library
|
14
|
-
email:
|
15
|
-
- frodsan@protonmail.ch
|
70
|
+
email: hello@frodsan.com
|
16
71
|
executables: []
|
17
72
|
extensions: []
|
18
73
|
extra_rdoc_files: []
|
19
74
|
files:
|
20
|
-
- ".gems"
|
21
75
|
- LICENSE
|
22
76
|
- README.md
|
23
77
|
- lib/seteable.rb
|
24
|
-
-
|
25
|
-
|
26
|
-
- test/all.rb
|
27
|
-
homepage: https://github.com/harmoni/seteable
|
78
|
+
- test/seteable_test.rb
|
79
|
+
homepage: https://gitlab.com/frodsan/seteable
|
28
80
|
licenses:
|
29
81
|
- MIT
|
30
82
|
metadata: {}
|
@@ -44,8 +96,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
96
|
version: '0'
|
45
97
|
requirements: []
|
46
98
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.5.1
|
48
100
|
signing_key:
|
49
101
|
specification_version: 4
|
50
102
|
summary: Define settings for your library
|
51
|
-
test_files:
|
103
|
+
test_files:
|
104
|
+
- test/seteable_test.rb
|
data/.gems
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
cutest:1.2.2
|
data/makefile
DELETED
data/seteable.gemspec
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = "seteable"
|
3
|
-
s.version = "1.2.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
|
data/test/all.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require_relative "../lib/seteable"
|
2
|
-
|
3
|
-
test "settings" do
|
4
|
-
class Base
|
5
|
-
include Seteable
|
6
|
-
end
|
7
|
-
|
8
|
-
Base.settings[:foo] = "foo"
|
9
|
-
|
10
|
-
assert_equal "foo", Base.settings[:foo]
|
11
|
-
assert_equal "foo", Base.new.settings[:foo]
|
12
|
-
end
|
13
|
-
|
14
|
-
test "inheritance" do
|
15
|
-
class Parent
|
16
|
-
include Seteable
|
17
|
-
end
|
18
|
-
|
19
|
-
Parent.settings[:foo] = "foo"
|
20
|
-
|
21
|
-
class Child < Parent
|
22
|
-
end
|
23
|
-
|
24
|
-
assert_equal "foo", Child.settings[:foo]
|
25
|
-
end
|
26
|
-
|
27
|
-
test "look up parent if setting not exists" do
|
28
|
-
class Foo
|
29
|
-
include Seteable
|
30
|
-
end
|
31
|
-
|
32
|
-
class Bar < Foo
|
33
|
-
end
|
34
|
-
|
35
|
-
class Baz < Bar
|
36
|
-
end
|
37
|
-
|
38
|
-
Foo.settings[:foo] = "foo"
|
39
|
-
Bar.settings[:bar] = "bar"
|
40
|
-
|
41
|
-
assert_equal "foo", Bar.settings[:foo]
|
42
|
-
assert_equal "foo", Baz.settings[:foo]
|
43
|
-
assert_equal "bar", Baz.settings[:bar]
|
44
|
-
|
45
|
-
Bar.settings[:foo] = "bar"
|
46
|
-
|
47
|
-
assert_equal "bar", Bar.settings[:foo]
|
48
|
-
assert_equal "foo", Baz.settings[:foo]
|
49
|
-
end
|