hexpress 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/lib/hexpress.rb +97 -0
  3. data/lib/hexpress/character.rb +26 -0
  4. data/lib/hexpress/main.rb +5 -0
  5. data/lib/hexpress/modifier.rb +26 -0
  6. data/lib/hexpress/modifier/many.rb +25 -0
  7. data/lib/hexpress/modifier/one.rb +19 -0
  8. data/lib/hexpress/nested.rb +38 -0
  9. data/lib/hexpress/nested/find.rb +17 -0
  10. data/lib/hexpress/nested/matching.rb +31 -0
  11. data/lib/hexpress/value.rb +28 -0
  12. data/lib/hexpress/value/ending.rb +22 -0
  13. data/lib/hexpress/value/except.rb +22 -0
  14. data/lib/hexpress/value/starting.rb +22 -0
  15. data/lib/hexpress/value/with.rb +21 -0
  16. data/lib/hexpress/values.rb +20 -0
  17. data/lib/hexpress/values/either.rb +24 -0
  18. data/lib/hexpress/values/range.rb +28 -0
  19. data/lib/hexpress/verbal_expressions.rb +47 -0
  20. data/lib/hexpress/version.rb +3 -0
  21. data/lib/hexpress/web.rb +45 -0
  22. data/lib/hexpress/wrapped.rb +9 -0
  23. data/spec/lib/hexpress/main_spec.rb +14 -0
  24. data/spec/lib/hexpress/modifier/many_spec.rb +19 -0
  25. data/spec/lib/hexpress/modifier/one_spec.rb +21 -0
  26. data/spec/lib/hexpress/modifier_spec.rb +49 -0
  27. data/spec/lib/hexpress/nested/find_spec.rb +13 -0
  28. data/spec/lib/hexpress/nested/matching_spec.rb +15 -0
  29. data/spec/lib/hexpress/nested_spec.rb +42 -0
  30. data/spec/lib/hexpress/value/ending_spec.rb +13 -0
  31. data/spec/lib/hexpress/value/except_spec.rb +9 -0
  32. data/spec/lib/hexpress/value/starting_spec.rb +13 -0
  33. data/spec/lib/hexpress/value/with_spec.rb +9 -0
  34. data/spec/lib/hexpress/value_spec.rb +25 -0
  35. data/spec/lib/hexpress/values/either_spec.rb +9 -0
  36. data/spec/lib/hexpress/values/range_spec.rb +33 -0
  37. data/spec/lib/hexpress/values_spec.rb +22 -0
  38. data/spec/lib/hexpress/verbal_expressions_standard.rb +112 -0
  39. data/spec/lib/hexpress/version_spec.rb +7 -0
  40. data/spec/lib/hexpress_spec.rb +73 -0
  41. data/spec/spec_helper.rb +9 -0
  42. metadata +216 -0
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe Hexpress::Values do
4
+ describe "#values" do
5
+ class ExampleValues
6
+ include Hexpress::Values
7
+
8
+ def initialize(*values)
9
+ @delimiter = "."
10
+ @values = values
11
+ end
12
+ end
13
+
14
+ it "returns the values list" do
15
+ expect(ExampleValues.new("foo", "bar").values).to eq(["foo", "bar"])
16
+ end
17
+
18
+ it "escapes the regex characters" do
19
+ expect(ExampleValues.new("fo.o", "bar").values).to eq(["fo\\.o", "bar"])
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,112 @@
1
+ require "spec_helper"
2
+ require "hexpress/verbal_hexpressions"
3
+
4
+ describe "VerbalHexpressions" do
5
+ def hexpressed(method, *arguments)
6
+ Hexpress.new.send(method, *arguments).to_s
7
+ end
8
+
9
+ describe "#startOfLine" do
10
+ it 'returns `^`' do
11
+ expect(hexpressed(:startOfLine)).to eq('^')
12
+ end
13
+ end
14
+
15
+ describe "#endOfLine" do
16
+ it 'returns `$`' do
17
+ expect(hexpressed(:endOfLine)).to eq('$')
18
+ end
19
+ end
20
+
21
+ describe "#find" do
22
+ it 'returns `(?:foo)`' do
23
+ expect(hexpressed(:find, "foo")).to eq('(?:foo)')
24
+ end
25
+ end
26
+
27
+ describe "#maybe" do
28
+ it 'returns `(?:foo)?`' do
29
+ expect(hexpressed(:maybe, "foo")).to eq('(?:foo)?')
30
+ end
31
+ end
32
+
33
+ describe "#anything" do
34
+ it 'returns `(?:.*)`' do
35
+ expect(hexpressed(:anything)).to eq('(?:.*)')
36
+ end
37
+ end
38
+
39
+ describe "#anythingBut" do
40
+ it 'returns `(?:[^f]*)`' do
41
+ expect(hexpressed(:anythingBut, "f")).to eq('(?:[^f]*)')
42
+ end
43
+ end
44
+
45
+ describe "#something" do
46
+ it 'returns `(?:.+)`' do
47
+ expect(hexpressed(:something)).to eq('(?:.+)')
48
+ end
49
+ end
50
+
51
+ describe "#somethingBut" do
52
+ it 'returns `(?:[^f]+)`' do
53
+ expect(hexpressed(:somethingBut)).to eq('(?:[^f]+)')
54
+ end
55
+ end
56
+
57
+ describe "#lineBreak" do
58
+ it 'returns `(?:(?:\n)|(?:\r\n))`' do
59
+ expect(hexpressed(:lineBreak)).to eq('(?:(?:\n)|(?:\r\n))')
60
+ end
61
+ end
62
+
63
+ describe "#br" do
64
+ it 'returns `(?:(?:\n)|(?:\r\n))`' do
65
+ expect(hexpressed(:br)).to eq('(?:(?:\n)|(?:\r\n))')
66
+ end
67
+ end
68
+
69
+ describe "#tab" do
70
+ it 'returns `\t`' do
71
+ expect(hexpressed(:tab)).to eq('\t')
72
+ end
73
+ end
74
+
75
+ describe "#anyOf" do
76
+ it 'returns `(?:[f])`' do
77
+ expect(hexpressed(:anyOf, "f")).to eq('(?:[f])')
78
+ end
79
+ end
80
+
81
+ describe "#range" do
82
+ it 'to be decided by spec'
83
+ end
84
+
85
+ describe "#withAnyCase" do
86
+ it 'case insensitive search'
87
+ end
88
+
89
+ describe "#stopAtFirst" do
90
+ it 'match first hexpression'
91
+ end
92
+
93
+ describe "#searchOneLine" do
94
+ it 'only look at one line'
95
+ end
96
+
97
+ describe "#multiple" do
98
+ it 'match multiple lines'
99
+ end
100
+
101
+ describe "#or" do
102
+ it 'uses `|` as delimiter for or statements'
103
+ end
104
+
105
+ describe "#begindCapture" do
106
+ it 'begins a capture'
107
+ end
108
+
109
+ describe "#endCapture" do
110
+ it 'ends a capture'
111
+ end
112
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Hexpress::VERSION do
4
+ it "should be a string" do
5
+ expect(Hexpress::VERSION).to be_kind_of(String)
6
+ end
7
+ end
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+
3
+ describe Hexpress do
4
+ it "takes a block and turns into a regex" do
5
+ pattern = Hexpress.new { find("foo") }
6
+ expect(pattern.to_r).to eq(/(foo)/)
7
+ end
8
+
9
+ it "takes a chain and turns into a regex" do
10
+ pattern = Hexpress.new.find("foo")
11
+ expect(pattern.to_r).to eq(/(foo)/)
12
+ end
13
+
14
+ describe "#word" do
15
+ it "returns the word matcher" do
16
+ expect(Hexpress.new.word.to_s).to eq('\w')
17
+ end
18
+ end
19
+
20
+ describe "#digit" do
21
+ it "returns the digit matcher" do
22
+ expect(Hexpress.new.digit.to_s).to eq('\d')
23
+ end
24
+ end
25
+
26
+ describe "#space" do
27
+ it "returns the whitespace matcher" do
28
+ expect(Hexpress.new.space.to_s).to eq('\s')
29
+ end
30
+ end
31
+
32
+ describe "#words" do
33
+ it "returns the word and multiple matchers" do
34
+ expect(Hexpress.new.words.to_s).to eq('(?:\w)+')
35
+ end
36
+ end
37
+
38
+ describe "#digits" do
39
+ it "returns the digit and multiple matchers" do
40
+ expect(Hexpress.new.digits.to_s).to eq('(?:\d)+')
41
+ end
42
+ end
43
+
44
+ describe "#spaces" do
45
+ it "returns the whitespace and multiple matchers" do
46
+ expect(Hexpress.new.spaces.to_s).to eq('(?:\s)+')
47
+ end
48
+ end
49
+
50
+ describe "#nonword" do
51
+ it "returns the nonword matcher" do
52
+ expect(Hexpress.new.nonword.to_s).to eq('\W')
53
+ end
54
+ end
55
+
56
+ describe "#nondigit" do
57
+ it "returns the nondigit matcher" do
58
+ expect(Hexpress.new.nondigit.to_s).to eq('\D')
59
+ end
60
+ end
61
+
62
+ describe "#nonspace" do
63
+ it "returns the nonwhitespace matcher" do
64
+ expect(Hexpress.new.nonspace.to_s).to eq('\S')
65
+ end
66
+ end
67
+
68
+ describe "#anything" do
69
+ it "returns any with zero or more pattern wrapped in noncapute" do
70
+ expect(Hexpress.new.anything.to_s).to eq('(?:.)*')
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,9 @@
1
+ require "coveralls"
2
+ Coveralls.wear! do
3
+ add_filter "/spec/"
4
+ end
5
+
6
+ require "pry"
7
+ require "rspec"
8
+ require "mocha/api"
9
+ require "hexpress"
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hexpress
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kurtis Rainbolt-Greene
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mocha
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: kramdown
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Hexpress is for Human Expressions, similar to Verbal Expressions
126
+ email:
127
+ - me@kurtisrainboltgreene.name
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - lib/hexpress/character.rb
133
+ - lib/hexpress/main.rb
134
+ - lib/hexpress/modifier/many.rb
135
+ - lib/hexpress/modifier/one.rb
136
+ - lib/hexpress/modifier.rb
137
+ - lib/hexpress/nested/find.rb
138
+ - lib/hexpress/nested/matching.rb
139
+ - lib/hexpress/nested.rb
140
+ - lib/hexpress/value/ending.rb
141
+ - lib/hexpress/value/except.rb
142
+ - lib/hexpress/value/starting.rb
143
+ - lib/hexpress/value/with.rb
144
+ - lib/hexpress/value.rb
145
+ - lib/hexpress/values/either.rb
146
+ - lib/hexpress/values/range.rb
147
+ - lib/hexpress/values.rb
148
+ - lib/hexpress/verbal_expressions.rb
149
+ - lib/hexpress/version.rb
150
+ - lib/hexpress/web.rb
151
+ - lib/hexpress/wrapped.rb
152
+ - lib/hexpress.rb
153
+ - spec/lib/hexpress/main_spec.rb
154
+ - spec/lib/hexpress/modifier/many_spec.rb
155
+ - spec/lib/hexpress/modifier/one_spec.rb
156
+ - spec/lib/hexpress/modifier_spec.rb
157
+ - spec/lib/hexpress/nested/find_spec.rb
158
+ - spec/lib/hexpress/nested/matching_spec.rb
159
+ - spec/lib/hexpress/nested_spec.rb
160
+ - spec/lib/hexpress/value/ending_spec.rb
161
+ - spec/lib/hexpress/value/except_spec.rb
162
+ - spec/lib/hexpress/value/starting_spec.rb
163
+ - spec/lib/hexpress/value/with_spec.rb
164
+ - spec/lib/hexpress/value_spec.rb
165
+ - spec/lib/hexpress/values/either_spec.rb
166
+ - spec/lib/hexpress/values/range_spec.rb
167
+ - spec/lib/hexpress/values_spec.rb
168
+ - spec/lib/hexpress/verbal_expressions_standard.rb
169
+ - spec/lib/hexpress/version_spec.rb
170
+ - spec/lib/hexpress_spec.rb
171
+ - spec/spec_helper.rb
172
+ homepage: http://krainboltgreene.github.com/hexpress
173
+ licenses:
174
+ - MIT
175
+ metadata: {}
176
+ post_install_message:
177
+ rdoc_options: []
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - '>='
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ requirements: []
191
+ rubyforge_project:
192
+ rubygems_version: 2.0.5
193
+ signing_key:
194
+ specification_version: 4
195
+ summary: Hexpress is for Human Expressions, similar to Verbal Expressions
196
+ test_files:
197
+ - spec/lib/hexpress/main_spec.rb
198
+ - spec/lib/hexpress/modifier/many_spec.rb
199
+ - spec/lib/hexpress/modifier/one_spec.rb
200
+ - spec/lib/hexpress/modifier_spec.rb
201
+ - spec/lib/hexpress/nested/find_spec.rb
202
+ - spec/lib/hexpress/nested/matching_spec.rb
203
+ - spec/lib/hexpress/nested_spec.rb
204
+ - spec/lib/hexpress/value/ending_spec.rb
205
+ - spec/lib/hexpress/value/except_spec.rb
206
+ - spec/lib/hexpress/value/starting_spec.rb
207
+ - spec/lib/hexpress/value/with_spec.rb
208
+ - spec/lib/hexpress/value_spec.rb
209
+ - spec/lib/hexpress/values/either_spec.rb
210
+ - spec/lib/hexpress/values/range_spec.rb
211
+ - spec/lib/hexpress/values_spec.rb
212
+ - spec/lib/hexpress/verbal_expressions_standard.rb
213
+ - spec/lib/hexpress/version_spec.rb
214
+ - spec/lib/hexpress_spec.rb
215
+ - spec/spec_helper.rb
216
+ has_rdoc: