gemmyrb 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74c01cebf13722a15f5802d2d3264020e3dec979
4
- data.tar.gz: 86990ea4e3d8bf73a8c0b8bbe99eb1923ca9e2be
3
+ metadata.gz: 1b30fe2939e2251a99af369b5ddd6c8b0ac67a17
4
+ data.tar.gz: a8bd3b128d659c5cc1db588106ec302f357ddd0a
5
5
  SHA512:
6
- metadata.gz: b81ed9ba77a689af77d892a1ef609c99d98a6c5a130e898f8fbb684d60908377046ee196ab1101b0227dfb8af5c39b4b90a2ab0cd0b7340cffbc21adf160c689
7
- data.tar.gz: 95fcd4ba24e28536747f092f1711137414db55c9756fceacea866fa9b4369aafd24793ea79d7707fd0e98daa8e179d179b1046c548ba5c516323031730fb3144
6
+ metadata.gz: 586500544147c163596317533ec51a26a1be5c537ae71084acc2c39d7ba4fa52f1bc32855bf7d470c9993213028bba42e093ba0475d1258cfb70e750e244744b
7
+ data.tar.gz: 02c9d99ba878a1e7f15892daea36ec72fb2dd53d067e6f0df5fbb9bd2a3f7e13b69e00301e46e0e55133bad71281fb79a57ace33e88db60725cc60c9781ecc5f
@@ -3,7 +3,6 @@ module Gemmy::Tests
3
3
  module PatchTests
4
4
 
5
5
  def self.run
6
- # call each of the patch_class methods
7
6
  %i{
8
7
  array_test symbol_test method_test thread_test
9
8
  global_test string_test hash_test
@@ -11,116 +10,111 @@ module Gemmy::Tests
11
10
  end
12
11
 
13
12
  module Error
14
- # Allow using raise with one argument only
15
- # raises RuntimeError
16
- #
17
- # this is included in the global patches,
18
- # but the test suite doesn't depend on it.
19
- #
20
- # @param msg [String]
21
- #
22
13
  def error(msg='')
23
14
  raise(RuntimeError, msg)
24
15
  end
25
16
  end
26
17
 
27
- class PatchedClass
18
+ BuildPatchedClass = Proc.new {
19
+ class PatchedClass
28
20
 
29
- Gemmy::Patches.class_refinements.each { |r| using r }
21
+ Gemmy::Patches.class_refinements.each { |r| using r }
30
22
 
31
- extend Gemmy::Tests::PatchTests::Error
23
+ extend Gemmy::Tests::PatchTests::Error
32
24
 
33
- def self.thread_test
34
- # Threads abort on exception
35
- Thread.new { fail }
36
- sleep 0.25
37
- error "thread didn't bubble up error"
38
- rescue
39
- puts " Threads abort on exception".blue
40
- end
25
+ def self.thread_test
26
+ # Threads abort on exception
27
+ Thread.new { fail }
28
+ sleep 0.25
29
+ error "thread didn't bubble up error"
30
+ rescue
31
+ puts " Threads abort on exception".blue
32
+ end
41
33
 
42
- def self.hash_test
43
- # Hash#autovivified
44
- hash = {}.autovivified
45
- hash[:a][:b] = 0
46
- error unless hash[:a][:b] == 0
47
- puts " Hash#autovivified".blue
48
-
49
- # Hash#bury
50
- hash = { a: { b: { } } }
51
- hash.bury(:a, :b, :c, 0)
52
- error unless hash[:a][:b][:c] == 0
53
- puts " Hash#bury".blue
54
-
55
- # Hash#persisted
56
- db = "test_db.yaml"
57
- hash = {}.persisted db
58
- hash.set(:a, :b, 0)
59
- error unless hash.get(:a, :b) == 0
60
- error unless hash.get(:a, :b, disk: true) == 0
61
- error unless YAML.load(File.read db)[:data][:a][:b] == 0
62
- File.delete(db)
63
- puts " Hash#persisted".blue
64
- end
34
+ def self.hash_test
35
+ # Hash#autovivified
36
+ hash = {}.autovivified
37
+ hash[:a][:b] = 0
38
+ error unless hash[:a][:b] == 0
39
+ puts " Hash#autovivified".blue
40
+
41
+ # Hash#bury
42
+ hash = { a: { b: { } } }
43
+ hash.bury(:a, :b, :c, 0)
44
+ error unless hash[:a][:b][:c] == 0
45
+ puts " Hash#bury".blue
46
+
47
+ # Hash#persisted
48
+ db = "test_db.yaml"
49
+ hash = {}.persisted db
50
+ hash.set(:a, :b, 0)
51
+ error unless hash.get(:a, :b) == 0
52
+ error unless hash.get(:a, :b, disk: true) == 0
53
+ error unless YAML.load(File.read db)[:data][:a][:b] == 0
54
+ File.delete(db)
55
+ puts " Hash#persisted".blue
56
+ end
65
57
 
66
- def self.array_test
67
- # Array#any_not?
68
- false_case = [[]].any_not? &:empty?
69
- true_case = [[1]].any_not? &:empty?
70
- error unless true_case && !false_case
71
- puts " Array#any_not?".blue
72
- end
58
+ def self.array_test
59
+ # Array#any_not?
60
+ false_case = [[]].any_not? &:empty?
61
+ true_case = [[1]].any_not? &:empty?
62
+ error unless true_case && !false_case
63
+ puts " Array#any_not?".blue
64
+ end
73
65
 
74
- def self.symbol_test
75
- # Symbol#with
76
- result = [[]].map &:concat.with([1])
77
- error unless result == [[1]]
78
- puts " Symbol#with".blue
79
- end
66
+ def self.symbol_test
67
+ # Symbol#with
68
+ result = [[]].map &:concat.with([1])
69
+ error unless result == [[1]]
70
+ puts " Symbol#with".blue
71
+ end
80
72
 
81
- def self.method_test
82
- # Method#bind
83
- def self.add(a,b)
84
- a + b
73
+ def self.method_test
74
+ # Method#bind
75
+ def self.add(a,b)
76
+ a + b
77
+ end
78
+ result = [0].map &method(:add).bind(1)
79
+ error unless result == [1]
80
+ puts " Method#bind".blue
85
81
  end
86
- result = [0].map &method(:add).bind(1)
87
- error unless result == [1]
88
- puts " Method#bind".blue
89
- end
90
82
 
91
- def self.global_test
92
- # m is an alias for method
93
- def self.sample_method(x)
94
- x
83
+ def self.global_test
84
+ # m is an alias for method
85
+ def self.sample_method(x)
86
+ x
87
+ end
88
+ result = [0].map &m(:sample_method)
89
+ error unless result == [0]
90
+ puts " Object#m".blue
91
+
92
+ # error_if_blank
93
+ # error an error if an object is blank
94
+ blank = nil
95
+ not_blank = 0
96
+ error_if_blank not_blank
97
+ begin
98
+ error_if_blank blank
99
+ error("this won't be raised")
100
+ rescue RuntimeError => e
101
+ error if e.message == "this won't be raised"
102
+ puts " Object#error_if_blank".blue
103
+ end
95
104
  end
96
- result = [0].map &m(:sample_method)
97
- error unless result == [0]
98
- puts " Object#m".blue
99
-
100
- # error_if_blank
101
- # error an error if an object is blank
102
- blank = nil
103
- not_blank = 0
104
- error_if_blank not_blank
105
- begin
106
- error_if_blank blank
107
- error("this won't be raised")
108
- rescue RuntimeError => e
109
- error if e.message == "this won't be raised"
110
- puts " Object#error_if_blank".blue
105
+
106
+ def self.string_test
107
+ # String#unindent
108
+ result = " 0".unindent
109
+ error unless result == "0"
110
+ puts " String#unindent".blue
111
111
  end
112
- end
113
112
 
114
- def self.string_test
115
- # String#unindent
116
- result = " 0".unindent
117
- error unless result == "0"
118
- puts " String#unindent".blue
119
- end
113
+ end # PatchedClass
120
114
 
121
- end
115
+ } # BuildPatchedClass
122
116
 
123
- end
117
+ end # PatchedTests
124
118
 
125
119
  TestSets << PatchTests
126
120
 
data/lib/gemmy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Gemmy
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/gemmy.rb CHANGED
@@ -102,3 +102,5 @@ unless ENV["NO_G_MODE"]
102
102
  class G < Gemmy
103
103
  end
104
104
  end
105
+
106
+ Gemmy::Tests::PatchTests::BuildPatchedClass.call
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemmyrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - max pleaner