skywalker 2.0.0 → 2.1.0
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/CHANGELOG.md +24 -0
- data/examples/Gemfile.lock +1 -1
- data/lib/skywalker/acceptable.rb +4 -1
- data/lib/skywalker/version.rb +1 -1
- data/spec/lib/skywalker/acceptable_spec.rb +5 -0
- 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: f34e5d3df438e1dded141d4b9e093785bb392cdd
|
4
|
+
data.tar.gz: e108b0e461eddb8f298ca5c771a0baf988e6c86f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f0fe7a5edd3bc67f0478dc91369e10001ce9fb037a464cde6016241f202f1afc724d2b879e95e8198d1eda1663448984d9ec81e278df20687e65399f5f97f92
|
7
|
+
data.tar.gz: 53d3eff371345c36dbe9ea155a29fbbad8806743ddac162abfda4e8c3c9557b6a9df224f56c6cfe63d72b8ac83f807eb9f01075d3149242c6da024c6b8b7c99d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
All commits by Rob Yurkowski unless otherwise noted.
|
2
2
|
|
3
|
+
## 2.1.0 (2015-05-14)
|
4
|
+
|
5
|
+
- Yields self to any block given to any object implementing `Skywalker::Acceptable`.
|
6
|
+
|
7
|
+
This has a few ramifications; first, it allows some easy extension simply by
|
8
|
+
passing a block to the constructor, as such:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
a = MyObject.new(an_argument: :foo) { |instance| instance.an_argument = :bar }
|
12
|
+
a.an_argument # => :bar
|
13
|
+
```
|
14
|
+
|
15
|
+
More importantly, it allows for simpler subclassing:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
class MyCommand < Skywalker::Command
|
19
|
+
def initialize(*args)
|
20
|
+
super do
|
21
|
+
a_symbol = :new_symbol
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
3
27
|
## 2.0.0 (2015-05-02)
|
4
28
|
|
5
29
|
- Refactors guts of commands to extract kwarg instantiation pattern into `Acceptable` module.
|
data/examples/Gemfile.lock
CHANGED
data/lib/skywalker/acceptable.rb
CHANGED
@@ -12,7 +12,8 @@ module Skywalker
|
|
12
12
|
|
13
13
|
|
14
14
|
#
|
15
|
-
# Instantiates an object, setting all kwargs as accessors
|
15
|
+
# Instantiates an object, setting all kwargs as accessors, and yields self
|
16
|
+
# to any block given.
|
16
17
|
#
|
17
18
|
# @since 2.0.0
|
18
19
|
#
|
@@ -22,6 +23,8 @@ module Skywalker
|
|
22
23
|
|
23
24
|
validate_arguments!
|
24
25
|
parse_arguments
|
26
|
+
|
27
|
+
yield self if block_given?
|
25
28
|
end
|
26
29
|
|
27
30
|
|
data/lib/skywalker/version.rb
CHANGED
@@ -39,6 +39,11 @@ module Skywalker
|
|
39
39
|
allow_any_instance_of(klass).to receive(:required_args).and_return([:required_arg])
|
40
40
|
expect { klass.new(required_arg: :blah) }.not_to raise_error
|
41
41
|
end
|
42
|
+
|
43
|
+
it "yields self if given a block" do
|
44
|
+
instance = klass.new(a_symbol: :my_symbol) { |_self| _self.a_symbol = :new_symbol }
|
45
|
+
expect(instance.a_symbol).to eq :new_symbol
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
44
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skywalker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Yurkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|