parsable 0.0.1 → 0.0.3
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/lib/parsable/parser.rb +2 -2
- data/lib/parsable/version.rb +1 -1
- data/spec/parsable_spec.rb +13 -0
- data/spec/parser_spec.rb +7 -0
- metadata +1 -2
- data/lib/parsable/combiner.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c740f58f539581f7589ed578a9ed87ea584a4c97
|
4
|
+
data.tar.gz: a3be8dcade555f1e0feeb3ccf4a47a989bd70485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9c47f798a3e30eb128084b973a9d2723581f761112c5085506ea1ea1374a5cd142f7e0d15ffe9f02bf9facf2fd3ae3d3610e365c0e11a4f117cc6fb5bfb0e6
|
7
|
+
data.tar.gz: a5af0ba0090e4f737897dfce4b2f4da65bd7ea1d17898c3fa61e3a48c2856e14790fd0dc5cec56469fea97219aafc5261f2d288022944f394ff3c0852da69337
|
data/lib/parsable/parser.rb
CHANGED
@@ -5,7 +5,7 @@ module Parsable
|
|
5
5
|
:original_string, :strings, :context
|
6
6
|
|
7
7
|
def initialize args={}
|
8
|
-
@original_string = args.fetch(:string)
|
8
|
+
@original_string = args.fetch(:string).to_s
|
9
9
|
@context = args[:context]
|
10
10
|
@strings = all_captures(@original_string)
|
11
11
|
end
|
@@ -42,7 +42,7 @@ module Parsable
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def all_captures string
|
45
|
-
string.scan(/\{\{(\w*\(?\w*\.?\w*\)?)\}\}/).flatten
|
45
|
+
string.to_s.scan(/\{\{(\w*\(?\w*\.?\w*\)?)\}\}/).flatten
|
46
46
|
end
|
47
47
|
|
48
48
|
def capture_function_method string
|
data/lib/parsable/version.rb
CHANGED
data/spec/parsable_spec.rb
CHANGED
@@ -14,6 +14,19 @@ describe Parsable do
|
|
14
14
|
expect(output).to eql(%(my+Here@email.com))
|
15
15
|
end
|
16
16
|
|
17
|
+
context "nil string" do
|
18
|
+
it "does nothing" do
|
19
|
+
location = OpenStruct.new(:name => "Here")
|
20
|
+
|
21
|
+
output = Parsable.crunch(\
|
22
|
+
:string => nil,
|
23
|
+
:context => {:location => location}
|
24
|
+
)
|
25
|
+
|
26
|
+
expect(output).to eql("")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
17
30
|
context "no replacements" do
|
18
31
|
it "returns the original" do
|
19
32
|
string = %(my@email.com)
|
data/spec/parser_spec.rb
CHANGED
@@ -11,6 +11,13 @@ describe Parsable::Parser do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
context "nil string" do
|
15
|
+
it "returns empty" do
|
16
|
+
parsed = Parsable::Parser.new(:string => nil).parse
|
17
|
+
expect(parsed).to be_empty
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
14
21
|
context 'when one variable' do
|
15
22
|
|
16
23
|
context 'no function method' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hubert Liu
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
81
|
- lib/parsable.rb
|
82
|
-
- lib/parsable/combiner.rb
|
83
82
|
- lib/parsable/parser.rb
|
84
83
|
- lib/parsable/version.rb
|
85
84
|
- parsable.gemspec
|