qiita_matome 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.rubocop.yml +0 -0
- data/.travis.yml +8 -0
- data/CONTRIBUTING.md +44 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +210 -0
- data/Rakefile +8 -0
- data/bin/qiitam +34 -0
- data/lib/display.rb +10 -0
- data/lib/display/display_consts.rb +35 -0
- data/lib/display/displayer.rb +81 -0
- data/lib/file_writer.rb +19 -0
- data/lib/models/article.rb +38 -0
- data/lib/models/articles.rb +40 -0
- data/lib/qiita_json_loader.rb +43 -0
- data/lib/qiita_matome/version.rb +4 -0
- data/lib/qiita_matome_core.rb +121 -0
- data/lib/qiita_matome_dsl.rb +31 -0
- data/lib/qiita_matome_dsl_model.rb +37 -0
- data/lib/sort.rb +10 -0
- data/lib/sort/sort_consts.rb +28 -0
- data/lib/sort/sorter.rb +51 -0
- data/lib/validators.rb +13 -0
- data/lib/validators/article_validator.rb +19 -0
- data/lib/validators/articles_validator.rb +16 -0
- data/lib/validators/display_columns_validator.rb +41 -0
- data/lib/validators/sort_type_validator.rb +19 -0
- data/manual_test_docs/.gitkeep +0 -0
- data/qiita_matome.gemspec +28 -0
- data/samples/matome_title_asc.md +25 -0
- data/spec/display/displayer_spec.rb +341 -0
- data/spec/file_writer_spec.rb +92 -0
- data/spec/models/article_spec.rb +131 -0
- data/spec/models/articles_spec.rb +305 -0
- data/spec/qiita_matome_core_spec.rb +46 -0
- data/spec/sort/sorter_spec.rb +392 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/validators/article_validator_spec.rb +53 -0
- data/spec/validators/articles_validator_spec.rb +54 -0
- data/spec/validators/display_columns_validator_spec.rb +58 -0
- data/spec/validators/sort_type_validator_spec.rb +54 -0
- metadata +202 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'models/article'
|
4
|
+
require 'validators/article_validator'
|
5
|
+
|
6
|
+
# rubocop:disable LineLength, UnusedMethodArgument
|
7
|
+
describe QiitaMatome::Validators::ArticleValidator do
|
8
|
+
context :validate do
|
9
|
+
cases = [
|
10
|
+
{
|
11
|
+
case_no: 1,
|
12
|
+
case_title: 'valid args',
|
13
|
+
articles: [QiitaMatome::Article.new, QiitaMatome::Article.new],
|
14
|
+
expect_error: false
|
15
|
+
},
|
16
|
+
{
|
17
|
+
case_no: 2,
|
18
|
+
case_title: 'invalid article class "String"',
|
19
|
+
articles: [QiitaMatome::Article.new, 'String'],
|
20
|
+
expect_error: true
|
21
|
+
}
|
22
|
+
]
|
23
|
+
|
24
|
+
cases.each do |c|
|
25
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
26
|
+
begin
|
27
|
+
case_before c
|
28
|
+
|
29
|
+
# -- given --
|
30
|
+
# nothing
|
31
|
+
|
32
|
+
# -- when/then --
|
33
|
+
if c[:expect_error]
|
34
|
+
-> { QiitaMatome::Validators::ArticleValidator.validate(c[:articles]) }.should raise_error(ArgumentError)
|
35
|
+
else
|
36
|
+
-> { QiitaMatome::Validators::ArticleValidator.validate(c[:articles]) }.should_not raise_error
|
37
|
+
end
|
38
|
+
ensure
|
39
|
+
case_after c
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def case_before(c)
|
44
|
+
# implement each case before
|
45
|
+
end
|
46
|
+
|
47
|
+
def case_after(c)
|
48
|
+
# implement each case after
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
# rubocop:enable LineLength, UnusedMethodArgument
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'models/article'
|
4
|
+
require 'models/articles'
|
5
|
+
require 'validators/articles_validator'
|
6
|
+
|
7
|
+
# rubocop:disable LineLength, UnusedMethodArgument
|
8
|
+
describe QiitaMatome::Validators::ArticlesValidator do
|
9
|
+
context :validate do
|
10
|
+
cases = [
|
11
|
+
{
|
12
|
+
case_no: 1,
|
13
|
+
case_title: 'valid args',
|
14
|
+
articles: [QiitaMatome::Article.new, QiitaMatome::Article.new],
|
15
|
+
expect_error: false
|
16
|
+
},
|
17
|
+
{
|
18
|
+
case_no: 2,
|
19
|
+
case_title: 'invalid articles class "String"',
|
20
|
+
articles: 'String',
|
21
|
+
expect_error: true
|
22
|
+
}
|
23
|
+
]
|
24
|
+
|
25
|
+
cases.each do |c|
|
26
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
27
|
+
begin
|
28
|
+
case_before c
|
29
|
+
|
30
|
+
# -- given --
|
31
|
+
# nothing
|
32
|
+
|
33
|
+
# -- when/then --
|
34
|
+
if c[:expect_error]
|
35
|
+
-> { QiitaMatome::Validators::ArticlesValidator.validate(c[:articles]) }.should raise_error(ArgumentError)
|
36
|
+
else
|
37
|
+
-> { QiitaMatome::Validators::ArticlesValidator.validate(c[:articles]) }.should_not raise_error
|
38
|
+
end
|
39
|
+
ensure
|
40
|
+
case_after c
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def case_before(c)
|
45
|
+
# implement each case before
|
46
|
+
end
|
47
|
+
|
48
|
+
def case_after(c)
|
49
|
+
# implement each case after
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# rubocop:enable LineLength, UnusedMethodArgument
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'models/article'
|
4
|
+
require 'display/display_consts'
|
5
|
+
require 'display/displayer'
|
6
|
+
require 'validators/display_columns_validator'
|
7
|
+
|
8
|
+
# rubocop:disable LineLength, UnusedMethodArgument
|
9
|
+
describe QiitaMatome::Validators::DisplayColumnsValidator do
|
10
|
+
context :validate do
|
11
|
+
cases = [
|
12
|
+
{
|
13
|
+
case_no: 1,
|
14
|
+
case_title: 'valid display_columns',
|
15
|
+
articles: [QiitaMatome::Article.new, QiitaMatome::Article.new],
|
16
|
+
display_columns: [:no, :title],
|
17
|
+
expect_error: false
|
18
|
+
},
|
19
|
+
{
|
20
|
+
case_no: 2,
|
21
|
+
case_title: 'invalid display_columns "invalid"',
|
22
|
+
articles: [QiitaMatome::Article.new, QiitaMatome::Article.new],
|
23
|
+
display_columns: 'invalid',
|
24
|
+
expect_error: true
|
25
|
+
}
|
26
|
+
]
|
27
|
+
|
28
|
+
cases.each do |c|
|
29
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
30
|
+
begin
|
31
|
+
case_before c
|
32
|
+
|
33
|
+
# -- given --
|
34
|
+
# nothing
|
35
|
+
display_columns_list = Array(c[:display_columns])
|
36
|
+
|
37
|
+
# -- when/then --
|
38
|
+
if c[:expect_error]
|
39
|
+
-> { QiitaMatome::Validators::DisplayColumnsValidator.validate(display_columns_list) }.should raise_error(ArgumentError)
|
40
|
+
else
|
41
|
+
-> { QiitaMatome::Validators::DisplayColumnsValidator.validate(display_columns_list) }.should_not raise_error
|
42
|
+
end
|
43
|
+
ensure
|
44
|
+
case_after c
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def case_before(c)
|
49
|
+
# implement each case before
|
50
|
+
end
|
51
|
+
|
52
|
+
def case_after(c)
|
53
|
+
# implement each case after
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
# rubocop:enable LineLength, UnusedMethodArgument
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'models/article'
|
4
|
+
require 'sort/sort_consts'
|
5
|
+
require 'validators/sort_type_validator'
|
6
|
+
|
7
|
+
# rubocop:disable LineLength, UnusedMethodArgument
|
8
|
+
describe QiitaMatome::Validators::SortTypeValidator do
|
9
|
+
context :validate do
|
10
|
+
cases = [
|
11
|
+
{
|
12
|
+
case_no: 1,
|
13
|
+
case_title: 'valid args',
|
14
|
+
sort_type: QiitaMatome::Sort::Consts::CREATED_AT_ASC,
|
15
|
+
expect_error: false
|
16
|
+
},
|
17
|
+
{
|
18
|
+
case_no: 4,
|
19
|
+
case_title: 'invalid sort_type "invalid"',
|
20
|
+
sort_type: 'invalid',
|
21
|
+
expect_error: true
|
22
|
+
}
|
23
|
+
]
|
24
|
+
|
25
|
+
cases.each do |c|
|
26
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
27
|
+
begin
|
28
|
+
case_before c
|
29
|
+
|
30
|
+
# -- given --
|
31
|
+
# nothing
|
32
|
+
|
33
|
+
# -- when/then --
|
34
|
+
if c[:expect_error]
|
35
|
+
-> { QiitaMatome::Validators::SortTypeValidator.validate(c[:sort_type]) }.should raise_error(ArgumentError)
|
36
|
+
else
|
37
|
+
-> { QiitaMatome::Validators::SortTypeValidator.validate(c[:sort_type]) }.should_not raise_error
|
38
|
+
end
|
39
|
+
ensure
|
40
|
+
case_after c
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def case_before(c)
|
45
|
+
# implement each case before
|
46
|
+
end
|
47
|
+
|
48
|
+
def case_after(c)
|
49
|
+
# implement each case after
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# rubocop:enable LineLength, UnusedMethodArgument
|
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qiita_matome
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tbpgr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.0.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.0.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: thor
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.18.1
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.18.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.14'
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.14.1
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.14'
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.14.1
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: simplecov
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0.8'
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.8.2
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.8'
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.8.2
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: bundler
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.6'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ~>
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '1.6'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: rake
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ~>
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ~>
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
description: Qiita article matome generator
|
116
|
+
email:
|
117
|
+
- tbpgr@tbpgr.jp
|
118
|
+
executables:
|
119
|
+
- qiitam
|
120
|
+
extensions: []
|
121
|
+
extra_rdoc_files: []
|
122
|
+
files:
|
123
|
+
- .coveralls.yml
|
124
|
+
- .gitignore
|
125
|
+
- .rspec
|
126
|
+
- .rubocop.yml
|
127
|
+
- .travis.yml
|
128
|
+
- CONTRIBUTING.md
|
129
|
+
- Gemfile
|
130
|
+
- LICENSE.txt
|
131
|
+
- README.md
|
132
|
+
- Rakefile
|
133
|
+
- bin/qiitam
|
134
|
+
- lib/display.rb
|
135
|
+
- lib/display/display_consts.rb
|
136
|
+
- lib/display/displayer.rb
|
137
|
+
- lib/file_writer.rb
|
138
|
+
- lib/models/article.rb
|
139
|
+
- lib/models/articles.rb
|
140
|
+
- lib/qiita_json_loader.rb
|
141
|
+
- lib/qiita_matome/version.rb
|
142
|
+
- lib/qiita_matome_core.rb
|
143
|
+
- lib/qiita_matome_dsl.rb
|
144
|
+
- lib/qiita_matome_dsl_model.rb
|
145
|
+
- lib/sort.rb
|
146
|
+
- lib/sort/sort_consts.rb
|
147
|
+
- lib/sort/sorter.rb
|
148
|
+
- lib/validators.rb
|
149
|
+
- lib/validators/article_validator.rb
|
150
|
+
- lib/validators/articles_validator.rb
|
151
|
+
- lib/validators/display_columns_validator.rb
|
152
|
+
- lib/validators/sort_type_validator.rb
|
153
|
+
- manual_test_docs/.gitkeep
|
154
|
+
- qiita_matome.gemspec
|
155
|
+
- samples/matome_title_asc.md
|
156
|
+
- spec/display/displayer_spec.rb
|
157
|
+
- spec/file_writer_spec.rb
|
158
|
+
- spec/models/article_spec.rb
|
159
|
+
- spec/models/articles_spec.rb
|
160
|
+
- spec/qiita_matome_core_spec.rb
|
161
|
+
- spec/sort/sorter_spec.rb
|
162
|
+
- spec/spec_helper.rb
|
163
|
+
- spec/validators/article_validator_spec.rb
|
164
|
+
- spec/validators/articles_validator_spec.rb
|
165
|
+
- spec/validators/display_columns_validator_spec.rb
|
166
|
+
- spec/validators/sort_type_validator_spec.rb
|
167
|
+
homepage: https://github.com/tbpgr/qiita_matome
|
168
|
+
licenses:
|
169
|
+
- MIT
|
170
|
+
metadata: {}
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - '>='
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - '>='
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
requirements: []
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 2.3.0
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: Qiita article matome generator
|
191
|
+
test_files:
|
192
|
+
- spec/display/displayer_spec.rb
|
193
|
+
- spec/file_writer_spec.rb
|
194
|
+
- spec/models/article_spec.rb
|
195
|
+
- spec/models/articles_spec.rb
|
196
|
+
- spec/qiita_matome_core_spec.rb
|
197
|
+
- spec/sort/sorter_spec.rb
|
198
|
+
- spec/spec_helper.rb
|
199
|
+
- spec/validators/article_validator_spec.rb
|
200
|
+
- spec/validators/articles_validator_spec.rb
|
201
|
+
- spec/validators/display_columns_validator_spec.rb
|
202
|
+
- spec/validators/sort_type_validator_spec.rb
|