sixarm_ruby_range_parse 1.0.2 → 1.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: 4f27dd3d6b237f7733d69db29215a8893d96ebed
4
- data.tar.gz: 79a6cc793574f7ce62a3e3695e3d513a381315c3
3
+ metadata.gz: 8761a98c05b548f424d18e6b460a870c074a63aa
4
+ data.tar.gz: f115ac7410363bd5d5f8d5068d3b1150ffd9dca5
5
5
  SHA512:
6
- metadata.gz: 8a0d3128e35d9b78a19cd8a04fa7e59997566b7fe76c439e5937c1f86510e1c2ea0c631db3ec82721333b7727d4f896c25df0f0fac11e82ec0f309cd8f65c2c9
7
- data.tar.gz: 18ce45d36766845792b0b1989606f774b996b6e3fd229c3b62bf07872b72cd0c24a5b6e1ab18e74e98b3b71e8af48a3cfe9aff8b4ed3f4e4dd3bf54f58f6fcb3
6
+ metadata.gz: 695473053389798dab0c32de926e0e40e57f0e7ecc7b5657c37293a41889f8ad6ddfc738d38b3dfe141188ebc1efcd75a6ad2936927a2b97994384f7a3b2f8f8
7
+ data.tar.gz: 50eb099f48d82f4f41cd83d90faff9d965a72f005ffb51de51fe8d9d205f66e8ab018de7cebf57ed8617d1fb9e05a86f6ae495fda13b0d20c0785046fac23780
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -3,8 +3,9 @@ require "rake"
3
3
  require "rake/testtask"
4
4
 
5
5
  Rake::TestTask.new(:test) do |t|
6
- t.libs << 'lib' << 'test'
7
- t.pattern = 'test/*.rb'
6
+ t.libs.push("lib", "test")
7
+ t.pattern = "test/**/*.rb"
8
8
  end
9
9
  task :default => [:test]
10
10
  task :default => [:test]
11
+ task :default => [:test]
@@ -3,38 +3,4 @@
3
3
  Please see README
4
4
  =end
5
5
 
6
- class Range
7
-
8
- # Parse the text to a pair of tokens and return these as a new range object.
9
- #
10
- # The separator may be two dots or three dots:
11
- #
12
- # * Two dots ".." includes the stop item.
13
- # * Three dots "..." excludes the stop item.
14
- #
15
- # This method delegates parsing of each tokens to Range.parse_helper
16
- #
17
- def self.parse(text)
18
- begin
19
- text=text.to_s
20
- if text=~/(\.\.\.?)/
21
- start_token = $`
22
- stop_token = $'
23
- separator = $1
24
- exclude_end = (separator == "...")
25
- return self.new(self.parse_helper(start_token), self.parse_helper(stop_token), exclude_end)
26
- end
27
- rescue
28
- end
29
- raise ArgumentError.new("#parse text must have a start token, two or three dots, and a stop token; this text does not parse: \"#{text}\"")
30
- end
31
-
32
- # Parse one item of the pair of items.
33
- # Subclasses will likely want to override this.
34
- #
35
- def self.parse_helper(text)
36
- text
37
- end
38
-
39
- end
40
-
6
+ require_relative "sixarm_ruby_range_parse/range"
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Range extensions to parse text.
4
+ =end
5
+
6
+ class Range
7
+
8
+ # Parse the text to a pair of tokens and return these as a new range object.
9
+ #
10
+ # The separator may be two dots or three dots:
11
+ #
12
+ # * Two dots ".." includes the stop item.
13
+ # * Three dots "..." excludes the stop item.
14
+ #
15
+ # This method delegates parsing of each tokens to Range.parse_helper
16
+ #
17
+ def self.parse(text)
18
+ begin
19
+ text=text.to_s
20
+ if text=~/(\.\.\.?)/
21
+ start_token = $`
22
+ stop_token = $'
23
+ separator = $1
24
+ exclude_end = (separator == "...")
25
+ return self.new(self.parse_helper(start_token), self.parse_helper(stop_token), exclude_end)
26
+ end
27
+ rescue
28
+ end
29
+ raise ArgumentError.new("#parse text must have a start token, two or three dots, and a stop token; this text does not parse: \"#{text}\"")
30
+ end
31
+
32
+ # Parse one item of the pair of items.
33
+ # Subclasses will likely want to override this.
34
+ #
35
+ def self.parse_helper(text)
36
+ text
37
+ end
38
+
39
+ end
40
+
@@ -1,40 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require "minitest/autorun"
3
+ require "coveralls"
3
4
  require "simplecov"
5
+ Coveralls.wear!
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
4
10
  SimpleCov.start
5
11
  require "sixarm_ruby_range_parse"
6
-
7
- describe Range do
8
-
9
- describe "#parse" do
10
-
11
- it "parses two dots as a range including the end" do
12
- Range.parse("a..z").must_equal "a".."z"
13
- end
14
-
15
- it "parses three dots as a range including the end" do
16
- Range.parse("a...z").must_equal "a"..."z"
17
- end
18
-
19
- it "calls to_s on the input" do
20
- x = Object.new
21
- def x.to_s; "a..z"; end
22
- Range.parse(x).must_equal "a".."z"
23
- end
24
-
25
- it "round trips" do
26
- range = "a".."z"
27
- Range.parse(range).must_equal range
28
- end
29
-
30
- end
31
-
32
- describe "#parse_helper" do
33
-
34
- it "is pass through (subclasses will override this method)" do
35
- Range.parse_helper("a").must_equal ("a")
36
- end
37
-
38
- end
39
-
40
- end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "sixarm_ruby_range_parse_test"
3
+
4
+ describe Range do
5
+
6
+ describe "#parse" do
7
+
8
+ it "parses two dots as a range including the end" do
9
+ Range.parse("a..z").must_equal "a".."z"
10
+ end
11
+
12
+ it "parses three dots as a range including the end" do
13
+ Range.parse("a...z").must_equal "a"..."z"
14
+ end
15
+
16
+ it "calls to_s on the input" do
17
+ x = Object.new
18
+ def x.to_s; "a..z"; end
19
+ Range.parse(x).must_equal "a".."z"
20
+ end
21
+
22
+ it "round trips" do
23
+ range = "a".."z"
24
+ Range.parse(range).must_equal range
25
+ end
26
+
27
+ end
28
+
29
+ describe "#parse_helper" do
30
+
31
+ it "is pass through (subclasses will override this method)" do
32
+ Range.parse_helper("a").must_equal ("a")
33
+ end
34
+
35
+ end
36
+
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_range_parse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SixArm
@@ -44,7 +44,7 @@ cert_chain:
44
44
  2AC9FOGkybW6DJEFSFFMlNk0IILsa/gNp8ufGuTVLWF9FUUdMNK+TMbghnifT8/1
45
45
  n+ES/gQPOnvmVkLDGw==
46
46
  -----END CERTIFICATE-----
47
- date: 2015-07-10 00:00:00.000000000 Z
47
+ date: 2015-07-19 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: minitest
@@ -134,7 +134,9 @@ extra_rdoc_files: []
134
134
  files:
135
135
  - Rakefile
136
136
  - lib/sixarm_ruby_range_parse.rb
137
+ - lib/sixarm_ruby_range_parse/range.rb
137
138
  - test/sixarm_ruby_range_parse_test.rb
139
+ - test/sixarm_ruby_range_parse_test/range_test.rb
138
140
  homepage: http://sixarm.com/
139
141
  licenses:
140
142
  - BSD
@@ -165,4 +167,5 @@ specification_version: 4
165
167
  summary: SixArm.com » Ruby » Range.parse method
166
168
  test_files:
167
169
  - test/sixarm_ruby_range_parse_test.rb
170
+ - test/sixarm_ruby_range_parse_test/range_test.rb
168
171
  has_rdoc: true
metadata.gz.sig CHANGED
Binary file