snail_parser 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/snail_parser +1 -1
- data/lib/snail_parser/formatter/default.rb +5 -0
- data/lib/snail_parser/formatter/json.rb +7 -0
- data/lib/snail_parser/{reporter.rb → formatter.rb} +3 -2
- data/lib/snail_parser/option_parser.rb +3 -3
- data/lib/snail_parser/version.rb +1 -1
- data/lib/snail_parser.rb +11 -3
- data/spec/lib/snail_parser/{reporter → formatter}/json_spec.rb +4 -3
- data/spec/lib/snail_parser/option_parser_spec.rb +2 -2
- data/spec/lib/snail_parser_spec.rb +19 -2
- metadata +6 -5
- data/lib/snail_parser/reporter/json.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0ac283bb474f376a1777787bff35b8623a419ea
|
4
|
+
data.tar.gz: a71eca840272647c1c9d2dc62365866397baeaa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e840d5f7ae9885c25b84513036253fa86c9ea46e943d8845c9d679b62366de9f85ef76c36140ebe699bedb9514ad577934bbdbc7b868f61c9bb2d1199dd454fe
|
7
|
+
data.tar.gz: 2940a1652a413a43d53598b6ddcc788398ebe476a68a18fc7481a14622951db9d074bbbc9fb780bbac17e39692375ce07869cdf7522910e4d2325c763e5b7fff
|
data/bin/snail_parser
CHANGED
@@ -19,9 +19,9 @@ module SnailParser
|
|
19
19
|
SnailParser.configuration[:path] = path
|
20
20
|
end
|
21
21
|
|
22
|
-
parser.on('--
|
23
|
-
# SnailParser.configuration[:
|
24
|
-
SnailParser.configuration[:
|
22
|
+
parser.on('--formatter FORMATTER') do |klass|
|
23
|
+
# SnailParser.configuration[:formatter] = Formatter.const_get(klass)
|
24
|
+
SnailParser.configuration[:formatter] = Formatter::Json
|
25
25
|
end
|
26
26
|
|
27
27
|
parser.on_tail('-h', '--help', 'Show this usage message and quit.') do |setting|
|
data/lib/snail_parser/version.rb
CHANGED
data/lib/snail_parser.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
require 'snail_parser/option_parser'
|
2
2
|
require 'snail_parser/parser'
|
3
|
-
require 'snail_parser/
|
3
|
+
require 'snail_parser/formatter'
|
4
4
|
require 'snail_parser/version'
|
5
5
|
|
6
6
|
module SnailParser
|
7
7
|
def self.invoke!
|
8
8
|
OptionParser.new(ARGV).parse!
|
9
|
+
run
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.run
|
9
13
|
result = Parser.parse(configuration[:path])
|
10
|
-
configuration[:
|
14
|
+
configuration[:formatter].new(result).report
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
yield(configuration)
|
11
19
|
end
|
12
20
|
|
13
21
|
def self.configuration
|
@@ -18,7 +26,7 @@ module SnailParser
|
|
18
26
|
|
19
27
|
def self.default_configuration
|
20
28
|
{
|
21
|
-
|
29
|
+
formatter: Formatter::Default
|
22
30
|
}
|
23
31
|
end
|
24
32
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
RSpec.describe SnailParser::
|
2
|
-
let(:
|
1
|
+
RSpec.describe SnailParser::Formatter::Json do
|
2
|
+
let(:formatter) { described_class.new(result) }
|
3
3
|
let(:result) do
|
4
4
|
[
|
5
5
|
{
|
@@ -13,8 +13,9 @@ RSpec.describe SnailParser::Reporter::Json do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#report' do
|
16
|
+
subject { formatter.report }
|
16
17
|
it 'report as json' do
|
17
|
-
|
18
|
+
is_expected.to eq result.to_json
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -18,8 +18,8 @@ RSpec.describe SnailParser::OptionParser do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
it_should_behave_like 'parsing option', :
|
22
|
-
let(:argv) { %w(--
|
21
|
+
it_should_behave_like 'parsing option', :formatter, SnailParser::Formatter::Json do
|
22
|
+
let(:argv) { %w(--formatter Json) }
|
23
23
|
end
|
24
24
|
|
25
25
|
it_should_behave_like 'parsing option', :path, 'path' do
|
@@ -1,8 +1,25 @@
|
|
1
1
|
RSpec.describe SnailParser do
|
2
|
+
before do
|
3
|
+
SnailParser.instance_variable_set(:@configuration, nil)
|
4
|
+
end
|
5
|
+
|
2
6
|
describe '.configuration' do
|
3
7
|
subject { described_class.configuration }
|
4
|
-
it '
|
5
|
-
is_expected.to eq(
|
8
|
+
it 'returns configuration' do
|
9
|
+
is_expected.to eq(formatter: SnailParser::Formatter::Default)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.configure' do
|
14
|
+
before do
|
15
|
+
described_class.configure do |config|
|
16
|
+
config[:path] = path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
let(:path) { 'path' }
|
20
|
+
|
21
|
+
it 'set path to configuration' do
|
22
|
+
expect(described_class.configuration[:path]).to eq(path)
|
6
23
|
end
|
7
24
|
end
|
8
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snail_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alpaca-tc
|
@@ -63,15 +63,16 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- bin/snail_parser
|
65
65
|
- lib/snail_parser.rb
|
66
|
+
- lib/snail_parser/formatter.rb
|
67
|
+
- lib/snail_parser/formatter/default.rb
|
68
|
+
- lib/snail_parser/formatter/json.rb
|
66
69
|
- lib/snail_parser/option_parser.rb
|
67
70
|
- lib/snail_parser/parser.rb
|
68
|
-
- lib/snail_parser/reporter.rb
|
69
|
-
- lib/snail_parser/reporter/json.rb
|
70
71
|
- lib/snail_parser/version.rb
|
71
72
|
- spec/fixtures/test.csv
|
73
|
+
- spec/lib/snail_parser/formatter/json_spec.rb
|
72
74
|
- spec/lib/snail_parser/option_parser_spec.rb
|
73
75
|
- spec/lib/snail_parser/parser_spec.rb
|
74
|
-
- spec/lib/snail_parser/reporter/json_spec.rb
|
75
76
|
- spec/lib/snail_parser/version_spec.rb
|
76
77
|
- spec/lib/snail_parser_spec.rb
|
77
78
|
- spec/spec_helper.rb
|
@@ -101,9 +102,9 @@ specification_version: 4
|
|
101
102
|
summary: ''
|
102
103
|
test_files:
|
103
104
|
- spec/fixtures/test.csv
|
105
|
+
- spec/lib/snail_parser/formatter/json_spec.rb
|
104
106
|
- spec/lib/snail_parser/option_parser_spec.rb
|
105
107
|
- spec/lib/snail_parser/parser_spec.rb
|
106
|
-
- spec/lib/snail_parser/reporter/json_spec.rb
|
107
108
|
- spec/lib/snail_parser/version_spec.rb
|
108
109
|
- spec/lib/snail_parser_spec.rb
|
109
110
|
- spec/spec_helper.rb
|