metaheader 1.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f21e78d95638dbb7e291df77d16e6aea229473d
4
- data.tar.gz: 2e6e3dfb7238df48c160698a5ea4aae7ca18c5d1
3
+ metadata.gz: 88dca1c4f81765e7568da7a5aa48b2d272975deb
4
+ data.tar.gz: f04beb0bd69cac43a5d9c044bdc5142475afa558
5
5
  SHA512:
6
- metadata.gz: f227fd15d338c552e806f998bf14ecc2cacf23dc655c8f0068c218fa4af005b754eeff25004c3e1ad0321962426ff469cbc1e9f4fd708db87c2566c4317d5c6c
7
- data.tar.gz: 59b2bf01d3d3a2f21f6501adbccc2a637a538855fb87268de0652f4204d6ca192c32932c1e541d9143c6a7f6db6bec01d57d46fc8df9cfaa699094085b0acf98
6
+ metadata.gz: 741a2bb4f73c74bee313be60df2a82ef8fcee75bc6a848eed0917200cb8ef652a0df3b92211d638c60d8ff19b5b36e9e279d6d675d535bc89f5d25370bd1ba59
7
+ data.tar.gz: 492e930364f5af886d59a0accabd44aedf4787990da7725a2f0f579632faf0d67036bdecdf5249f4d6698cb4e1910dd213a34d06129be2420c2f9ab73050754e
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  .yardoc/
2
+ coverage/
3
+ doc/
2
4
  pkg/
3
5
  Gemfile.lock
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --hide-api private
@@ -1,4 +1,4 @@
1
1
  class MetaHeader
2
2
  # MetaHeader's version
3
- VERSION = '1.1'.freeze
3
+ VERSION = '1.1.1'.freeze
4
4
  end
data/lib/metaheader.rb CHANGED
@@ -1,18 +1,16 @@
1
- # @test Hello World
2
-
3
1
  require 'metaheader/version'
4
2
 
5
3
  class MetaHeader
6
4
  # @abstract Subclass and override {#parse} to implement a custom parser.
7
5
  class Parser
8
6
  class << self
9
- # @!visibility private
7
+ # @api private
10
8
  def inherited(k)
11
9
  @parsers ||= []
12
10
  @parsers << k
13
11
  end
14
12
 
15
- # @!visibility private
13
+ # @api private
16
14
  def each(&b)
17
15
  @parsers&.each(&b)
18
16
  end
@@ -56,6 +54,7 @@ class MetaHeader
56
54
  @last_key = nil
57
55
  @last_prefix = String.new
58
56
 
57
+ input = input.encode universal_newline: true
59
58
  input.each_line {|line|
60
59
  if line.strip.empty?
61
60
  break
@@ -140,7 +139,7 @@ class MetaHeader
140
139
  end
141
140
 
142
141
  private
143
- # @!visibility private
142
+ # @api private
144
143
  Tag = Struct.new :name, :value
145
144
 
146
145
  REGEX = /\A(?<prefix>.*?)
data/metaheader.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'coveralls', '~> 0.8'
25
25
  spec.add_development_dependency 'minitest', '~> 5.8'
26
26
  spec.add_development_dependency 'rake', '~> 11.0'
27
+ spec.add_development_dependency 'simplecov', '~> 0.11'
27
28
  end
data/test/helper.rb CHANGED
@@ -1,9 +1,17 @@
1
- if ENV['CI']
2
- require 'coveralls'
1
+ require 'coveralls'
2
+ require 'simplecov'
3
3
 
4
- Coveralls::Output.silent = true
5
- Coveralls.wear!
6
- end
4
+ Coveralls::Output.silent = true
5
+
6
+ SimpleCov.formatters = [
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter,
9
+ ]
10
+
11
+ SimpleCov.start {
12
+ project_name 'metaheader'
13
+ add_filter '/test/'
14
+ }
7
15
 
8
16
  require 'metaheader'
9
17
  require 'minitest/autorun'
@@ -0,0 +1 @@
1
+ # @test Hello World
data/test/test_parser.rb CHANGED
@@ -153,7 +153,7 @@ class TestParser < MiniTest::Test
153
153
  end
154
154
 
155
155
  def test_read_file
156
- path = File.expand_path '../../lib/metaheader.rb', __FILE__
156
+ path = File.expand_path '../input/basic_tag', __FILE__
157
157
  mh = MetaHeader.from_file path
158
158
 
159
159
  assert_equal 'Hello World', mh[:test]
@@ -162,46 +162,50 @@ class TestParser < MiniTest::Test
162
162
 
163
163
  def test_to_hash
164
164
  mh = MetaHeader.new '@key value'
165
- expected = {:key => 'value'}
166
-
167
- assert_equal expected, mh.to_h
165
+ assert_equal Hash[key: 'value'], mh.to_h
168
166
  end
169
167
 
170
168
  def test_alternate_syntax
171
169
  mh = MetaHeader.new 'Key Test: value'
172
- expected = {:key_test => 'value'}
173
-
174
- assert_equal expected, mh.to_h
170
+ assert_equal Hash[key_test: 'value'], mh.to_h
175
171
  end
176
172
 
177
173
  def test_alternate_syntax_prefix
178
174
  mh = MetaHeader.new '-- Key Test: Value'
179
- expected = {:key_test => 'Value'}
175
+ assert_equal Hash[key_test: 'Value'], mh.to_h
176
+ end
180
177
 
181
- assert_equal expected, mh.to_h
178
+ def test_windows_newlines
179
+ mh = MetaHeader.new "key: value\r\n@run_custom"
180
+ assert_equal 'value', mh[:key]
181
+ assert_equal "key: value\n@run_custom", CustomParser.input
182
182
  end
183
183
 
184
184
  def test_alternate_syntax_trailing_space
185
185
  mh = MetaHeader.new ' Key Test : Value'
186
- expected = {:key_test => 'Value'}
187
-
188
- assert_equal expected, mh.to_h
186
+ assert_equal Hash[key_test: 'Value'], mh.to_h
189
187
  end
190
188
 
191
189
  def test_inspect
192
190
  mh = MetaHeader.new '@hello world'
193
- hash = {:hello => 'world'}
194
191
 
192
+ hash = {hello: 'world'}
195
193
  assert_equal "#<MetaHeader #{hash.inspect}>", mh.inspect
196
194
  end
197
195
 
196
+ def test_default_parser_implementation
197
+ assert_raises NotImplementedError do
198
+ MetaHeader::Parser.new.parse String.new
199
+ end
200
+ end
201
+
198
202
  def test_transform_from_text
199
203
  input = "@run_custom\nHello\n\nWorld".freeze
200
204
 
201
205
  mh = MetaHeader.new input
202
206
 
203
207
  assert CustomParser.called?
204
- assert_same input, CustomParser.input
208
+ assert_equal input, CustomParser.input
205
209
  assert_same mh, CustomParser.instance
206
210
  end
207
211
 
@@ -21,7 +21,7 @@ class TestValidator < MiniTest::Test
21
21
  end
22
22
 
23
23
  def test_strict_optional
24
- mh = MetaHeader.new "@hello\n@world"
24
+ mh = MetaHeader.new "@hello"
25
25
  mh.strict = true
26
26
 
27
27
  actual = mh.validate \
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaheader
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cfillion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-20 00:00:00.000000000 Z
11
+ date: 2016-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '11.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.11'
69
83
  description:
70
84
  email:
71
85
  - metaheader@cfillion.tk
@@ -75,6 +89,7 @@ extra_rdoc_files: []
75
89
  files:
76
90
  - ".gitignore"
77
91
  - ".travis.yml"
92
+ - ".yardopts"
78
93
  - COPYING
79
94
  - COPYING.LESSER
80
95
  - Gemfile
@@ -84,6 +99,7 @@ files:
84
99
  - lib/metaheader/version.rb
85
100
  - metaheader.gemspec
86
101
  - test/helper.rb
102
+ - test/input/basic_tag
87
103
  - test/input/custom_parser
88
104
  - test/test_parser.rb
89
105
  - test/test_validator.rb
@@ -113,6 +129,7 @@ specification_version: 4
113
129
  summary: Parser for metadata headers in plain-text files
114
130
  test_files:
115
131
  - test/helper.rb
132
+ - test/input/basic_tag
116
133
  - test/input/custom_parser
117
134
  - test/test_parser.rb
118
135
  - test/test_validator.rb