framecurve 2.1.0 → 2.2.0

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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ 2.2.0
2
+
3
+ * Let Parser add the filename to the curve when parsing
4
+
1
5
  2.1.0
2
6
 
3
7
  * Adds Validator#ok?
data/framecurve.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "framecurve"
8
- s.version = "2.1.0"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Julik"]
@@ -11,9 +11,7 @@ class Framecurve::Parser
11
11
  # If the first argument is a path parse from the opened file,
12
12
  # and record the filename in the curve as well
13
13
  unless path_or_io.respond_to?(:read)
14
- curve = File.open(path_or_io, "r", &method(:parse))
15
- curve.filename = File.basename(path_or_io)
16
- return curve
14
+ return File.open(path_or_io, "r", &method(:parse))
17
15
  end
18
16
 
19
17
  @line_counter = 0 # IO#lineno is not exactly super-reliable
@@ -32,8 +30,12 @@ class Framecurve::Parser
32
30
  end
33
31
  elements.push(item)
34
32
  end
33
+ curve = Framecurve::Curve.new(elements)
35
34
 
36
- return Framecurve::Curve.new(elements)
35
+ # Pick the actual filename if it's available
36
+ curve.filename = File.basename(path_or_io.path) if path_or_io.respond_to?(:path)
37
+
38
+ return curve
37
39
  end
38
40
 
39
41
  private
data/lib/framecurve.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Framecurve
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
 
4
4
  # Is raised when a malformed framecurve bit has occurred in the system
5
5
  class Malformed < RuntimeError
@@ -47,6 +47,15 @@ class TestFramecurveParser < Test::Unit::TestCase
47
47
  end
48
48
  end
49
49
 
50
+ def test_should_pick_file_path_from_passed_file_object
51
+ v = Framecurve::Parser.new
52
+ path = File.dirname(__FILE__) + "/fixtures/framecurves/sample_framecurve1.framecurve.txt"
53
+ File.open(path) do | f |
54
+ curve = v.parse(f)
55
+ assert_equal "sample_framecurve1.framecurve.txt", curve.filename
56
+ end
57
+ end
58
+
50
59
  def test_parser_fails_on_malformed_lines
51
60
  data = "Sachlich gesehen\nbambam"
52
61
  assert_raise(Framecurve::Malformed) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: framecurve
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &12017030 !ruby/object:Gem::Requirement
16
+ requirement: &11888320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12017030
24
+ version_requirements: *11888320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jeweler
27
- requirement: &12016790 !ruby/object:Gem::Requirement
27
+ requirement: &11888080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.4
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *12016790
35
+ version_requirements: *11888080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &12016550 !ruby/object:Gem::Requirement
38
+ requirement: &11887840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *12016550
46
+ version_requirements: *11887840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cli_test
49
- requirement: &12016310 !ruby/object:Gem::Requirement
49
+ requirement: &11887600 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *12016310
57
+ version_requirements: *11887600
58
58
  description: ! ' Parser, validation and interpolation'
59
59
  email: me@julik.nl
60
60
  executables: