better_struct 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/better_struct.gemspec +1 -1
- data/lib/better_struct.rb +7 -1
- data/lib/better_struct/version.rb +1 -1
- data/test/better_struct_test.rb +13 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60dc46874b353a8194a935de7f3dbd539be5dce8
|
4
|
+
data.tar.gz: 4b07a4ac506666b9f63688606571ec0fddf31c4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e256d283c41f2715e7760aeafadd05c0c371d2d90c7cbfb83ba826207bbe1bea102c6a164004a07f6c6a976c9988fa5afb5417c400efaeb584083daf7b7d1798
|
7
|
+
data.tar.gz: 54c4cf5172f9d89bc1a282fa0e7bf9a1e035e68e670c13f09fcc7023da5aedcf3c2d92ed493728491bcd4731a3688cfddcb46b6f1848955fc9fd617a640c3933
|
data/better_struct.gemspec
CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "minitest", "~> 5.5"
|
24
|
-
spec.add_development_dependency "pry", "~> 0
|
24
|
+
spec.add_development_dependency "pry-byebug", "~> 2.0"
|
25
25
|
end
|
data/lib/better_struct.rb
CHANGED
@@ -54,9 +54,15 @@ private
|
|
54
54
|
method_name = args.first.to_s
|
55
55
|
|
56
56
|
if value.respond_to?(method_name)
|
57
|
-
wrap(value.public_send(*args, &wrap_block_arguments(*args, &block)))
|
57
|
+
result = wrap(value.public_send(*args, &wrap_block_arguments(*args, &block)))
|
58
|
+
|
59
|
+
method_name == "map" ? unwrap_items(result) : result
|
58
60
|
else
|
59
61
|
wrap(@defined_methods[method_name])
|
60
62
|
end
|
61
63
|
end
|
64
|
+
|
65
|
+
def unwrap_items(wrapped_array)
|
66
|
+
wrap(wrapped_array.value.map(&:value))
|
67
|
+
end
|
62
68
|
end
|
data/test/better_struct_test.rb
CHANGED
@@ -41,4 +41,17 @@ class BetterStructTest < Minitest::Test
|
|
41
41
|
|
42
42
|
assert_equal better_struct.foo_bar1.foo_bar2, BetterStruct.new("Hello World!")
|
43
43
|
end
|
44
|
+
|
45
|
+
def test_map_result
|
46
|
+
better_struct = BetterStruct.new([1, 2, 3])
|
47
|
+
|
48
|
+
mapped = better_struct.map do |i|
|
49
|
+
assert i.is_a?(BetterStruct)
|
50
|
+
i
|
51
|
+
end
|
52
|
+
|
53
|
+
mapped.value.each do |i|
|
54
|
+
assert !i.is_a?(BetterStruct)
|
55
|
+
end
|
56
|
+
end
|
44
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_struct
|
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
|
- Evgeny Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
56
|
+
name: pry-byebug
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '2.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '2.0'
|
69
69
|
description: Use your data without pain
|
70
70
|
email:
|
71
71
|
- exaspark@gmail.com
|