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 +4 -4
- data/.gitignore +2 -0
- data/.yardopts +1 -0
- data/lib/metaheader/version.rb +1 -1
- data/lib/metaheader.rb +4 -5
- data/metaheader.gemspec +1 -0
- data/test/helper.rb +13 -5
- data/test/input/basic_tag +1 -0
- data/test/test_parser.rb +18 -14
- data/test/test_validator.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88dca1c4f81765e7568da7a5aa48b2d272975deb
|
4
|
+
data.tar.gz: f04beb0bd69cac43a5d9c044bdc5142475afa558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 741a2bb4f73c74bee313be60df2a82ef8fcee75bc6a848eed0917200cb8ef652a0df3b92211d638c60d8ff19b5b36e9e279d6d675d535bc89f5d25370bd1ba59
|
7
|
+
data.tar.gz: 492e930364f5af886d59a0accabd44aedf4787990da7725a2f0f579632faf0d67036bdecdf5249f4d6698cb4e1910dd213a34d06129be2420c2f9ab73050754e
|
data/.gitignore
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--hide-api private
|
data/lib/metaheader/version.rb
CHANGED
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
|
-
#
|
7
|
+
# @api private
|
10
8
|
def inherited(k)
|
11
9
|
@parsers ||= []
|
12
10
|
@parsers << k
|
13
11
|
end
|
14
12
|
|
15
|
-
#
|
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
|
-
#
|
142
|
+
# @api private
|
144
143
|
Tag = Struct.new :name, :value
|
145
144
|
|
146
145
|
REGEX = /\A(?<prefix>.*?)
|
data/metaheader.gemspec
CHANGED
data/test/helper.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'coveralls'
|
2
|
+
require 'simplecov'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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 '
|
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
|
-
|
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
|
-
|
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
|
-
|
175
|
+
assert_equal Hash[key_test: 'Value'], mh.to_h
|
176
|
+
end
|
180
177
|
|
181
|
-
|
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
|
-
|
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
|
-
|
208
|
+
assert_equal input, CustomParser.input
|
205
209
|
assert_same mh, CustomParser.instance
|
206
210
|
end
|
207
211
|
|
data/test/test_validator.rb
CHANGED
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:
|
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-
|
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
|