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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f593cfaed243bd455a5b54d6fbc209eedd367de8
4
- data.tar.gz: 35cb090332db65e58ec19d83f16b95ff68a848c7
3
+ metadata.gz: c740f58f539581f7589ed578a9ed87ea584a4c97
4
+ data.tar.gz: a3be8dcade555f1e0feeb3ccf4a47a989bd70485
5
5
  SHA512:
6
- metadata.gz: be718003528ade2a45f7ad33678197608ce8cb7d768f031cdbbc35c5cdcc1e4d7ac27fdb336d033e82a581aacf200f58e7a8bb39d2ad39ef3e9dbc629474f15f
7
- data.tar.gz: a106062667fde8970b5897b14fedcb7bcbcdba1cb1ad617df680d20f7c512927f95023f97aa1f971bf8f1d555de4d0031e7050a7545ae21adba5c4aa36bd8af9
6
+ metadata.gz: dc9c47f798a3e30eb128084b973a9d2723581f761112c5085506ea1ea1374a5cd142f7e0d15ffe9f02bf9facf2fd3ae3d3610e365c0e11a4f117cc6fb5bfb0e6
7
+ data.tar.gz: a5af0ba0090e4f737897dfce4b2f4da65bd7ea1d17898c3fa61e3a48c2856e14790fd0dc5cec56469fea97219aafc5261f2d288022944f394ff3c0852da69337
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Parsable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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.1
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
@@ -1,7 +0,0 @@
1
- module Parsable
2
- class Combiner
3
-
4
-
5
-
6
- end
7
- end