front_matter_parser 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +19 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +50 -0
  6. data/.travis.yml +19 -1
  7. data/CHANGELOG.md +30 -0
  8. data/Dockerfile +5 -0
  9. data/Gemfile +0 -2
  10. data/README.md +76 -38
  11. data/Rakefile +5 -3
  12. data/bin/console +15 -0
  13. data/bin/setup +8 -0
  14. data/docker-compose.yml +12 -0
  15. data/front_matter_parser.gemspec +12 -6
  16. data/lib/front_matter_parser.rb +10 -114
  17. data/lib/front_matter_parser/loader.rb +11 -0
  18. data/lib/front_matter_parser/loader/yaml.rb +26 -0
  19. data/lib/front_matter_parser/parsed.rb +25 -14
  20. data/lib/front_matter_parser/parser.rb +82 -0
  21. data/lib/front_matter_parser/syntax_parser.rb +28 -0
  22. data/lib/front_matter_parser/syntax_parser/factorizable.rb +30 -0
  23. data/lib/front_matter_parser/syntax_parser/indentation_comment.rb +49 -0
  24. data/lib/front_matter_parser/syntax_parser/multi_line_comment.rb +50 -0
  25. data/lib/front_matter_parser/syntax_parser/single_line_comment.rb +64 -0
  26. data/lib/front_matter_parser/version.rb +3 -1
  27. data/spec/fixtures/example +6 -0
  28. data/spec/front_matter_parser/loader/yaml_spec.rb +24 -0
  29. data/spec/front_matter_parser/parsed_spec.rb +11 -21
  30. data/spec/front_matter_parser/parser_spec.rb +111 -0
  31. data/spec/front_matter_parser/syntax_parser/indentation_comment_spec.rb +166 -0
  32. data/spec/front_matter_parser/syntax_parser/multi_line_comment_spec.rb +267 -0
  33. data/spec/front_matter_parser/syntax_parser/single_line_comment_spec.rb +175 -0
  34. data/spec/front_matter_parser_spec.rb +3 -296
  35. data/spec/spec_helper.rb +9 -3
  36. data/spec/support/matcher.rb +8 -0
  37. metadata +110 -46
  38. data/spec/fixtures/example.coffee +0 -4
  39. data/spec/fixtures/example.erb +0 -6
  40. data/spec/fixtures/example.foo +0 -0
  41. data/spec/fixtures/example.haml +0 -5
  42. data/spec/fixtures/example.liquid +0 -6
  43. data/spec/fixtures/example.md +0 -4
  44. data/spec/fixtures/example.sass +0 -4
  45. data/spec/fixtures/example.scss +0 -4
  46. data/spec/fixtures/example.slim +0 -5
  47. data/spec/support/strings.rb +0 -41
  48. data/spec/support/syntaxs.rb +0 -14
  49. data/spec/support/utils.rb +0 -6
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,12 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+
5
+ SimpleCov.start
6
+
7
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
8
  require 'front_matter_parser'
3
- require 'tempfile'
4
- Dir["#{File.expand_path('../support', __FILE__)}/*.rb"].each do |file|
9
+ require 'pry-byebug'
10
+ Dir["#{File.expand_path('support', __dir__)}/*.rb"].each do |file|
5
11
  require file
6
12
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :be_parsed_result_with do |front_matter, content|
4
+ match do |result|
5
+ result.front_matter == front_matter &&
6
+ result.content == content
7
+ end
8
+ end
metadata CHANGED
@@ -1,103 +1,175 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: front_matter_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - marc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2021-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '1.5'
20
- - - "<"
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
21
46
  - !ruby/object:Gem::Version
22
- version: '1.6'
47
+ version: '3.8'
23
48
  type: :development
24
49
  prerelease: false
25
50
  version_requirements: !ruby/object:Gem::Requirement
26
51
  requirements:
27
52
  - - "~>"
28
53
  - !ruby/object:Gem::Version
29
- version: '1.5'
30
- - - "<"
54
+ version: '3.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
31
60
  - !ruby/object:Gem::Version
32
- version: '1.6'
61
+ version: '3.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.7'
33
69
  - !ruby/object:Gem::Dependency
34
- name: rake
70
+ name: rubocop
35
71
  requirement: !ruby/object:Gem::Requirement
36
72
  requirements:
37
73
  - - "~>"
38
74
  - !ruby/object:Gem::Version
39
- version: '10.1'
75
+ version: '1.9'
40
76
  type: :development
41
77
  prerelease: false
42
78
  version_requirements: !ruby/object:Gem::Requirement
43
79
  requirements:
44
80
  - - "~>"
45
81
  - !ruby/object:Gem::Version
46
- version: '10.1'
82
+ version: '1.9'
47
83
  - !ruby/object:Gem::Dependency
48
- name: rspec
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: '0.17'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: '0.17'
111
+ - !ruby/object:Gem::Dependency
112
+ name: codeclimate-test-reporter
49
113
  requirement: !ruby/object:Gem::Requirement
50
114
  requirements:
51
115
  - - "~>"
52
116
  - !ruby/object:Gem::Version
53
- version: '2.14'
117
+ version: '1.0'
54
118
  type: :development
55
119
  prerelease: false
56
120
  version_requirements: !ruby/object:Gem::Requirement
57
121
  requirements:
58
122
  - - "~>"
59
123
  - !ruby/object:Gem::Version
60
- version: '2.14'
61
- description: Library to parse files or strings with YAML front matters with syntax
62
- autodetection.
124
+ version: '1.0'
125
+ description: Parse a front matter from syntactically correct strings or files
63
126
  email:
64
127
  - marc@lamarciana.com
65
128
  executables: []
66
129
  extensions: []
67
130
  extra_rdoc_files: []
68
131
  files:
132
+ - ".codeclimate.yml"
69
133
  - ".gitignore"
70
134
  - ".rspec"
135
+ - ".rubocop.yml"
71
136
  - ".ruby-version"
72
137
  - ".travis.yml"
73
138
  - ".yardopts"
139
+ - CHANGELOG.md
74
140
  - COPYING.LESSER
75
141
  - COPYING.txt
142
+ - Dockerfile
76
143
  - Gemfile
77
144
  - LICENSE.txt
78
145
  - README.md
79
146
  - Rakefile
147
+ - bin/console
148
+ - bin/setup
149
+ - docker-compose.yml
80
150
  - front_matter_parser.gemspec
81
151
  - lib/front_matter_parser.rb
152
+ - lib/front_matter_parser/loader.rb
153
+ - lib/front_matter_parser/loader/yaml.rb
82
154
  - lib/front_matter_parser/parsed.rb
155
+ - lib/front_matter_parser/parser.rb
156
+ - lib/front_matter_parser/syntax_parser.rb
157
+ - lib/front_matter_parser/syntax_parser/factorizable.rb
158
+ - lib/front_matter_parser/syntax_parser/indentation_comment.rb
159
+ - lib/front_matter_parser/syntax_parser/multi_line_comment.rb
160
+ - lib/front_matter_parser/syntax_parser/single_line_comment.rb
83
161
  - lib/front_matter_parser/version.rb
84
162
  - spec/fixtures/example
85
- - spec/fixtures/example.coffee
86
- - spec/fixtures/example.erb
87
- - spec/fixtures/example.foo
88
- - spec/fixtures/example.haml
89
163
  - spec/fixtures/example.html
90
- - spec/fixtures/example.liquid
91
- - spec/fixtures/example.md
92
- - spec/fixtures/example.sass
93
- - spec/fixtures/example.scss
94
- - spec/fixtures/example.slim
164
+ - spec/front_matter_parser/loader/yaml_spec.rb
95
165
  - spec/front_matter_parser/parsed_spec.rb
166
+ - spec/front_matter_parser/parser_spec.rb
167
+ - spec/front_matter_parser/syntax_parser/indentation_comment_spec.rb
168
+ - spec/front_matter_parser/syntax_parser/multi_line_comment_spec.rb
169
+ - spec/front_matter_parser/syntax_parser/single_line_comment_spec.rb
96
170
  - spec/front_matter_parser_spec.rb
97
171
  - spec/spec_helper.rb
98
- - spec/support/strings.rb
99
- - spec/support/syntaxs.rb
100
- - spec/support/utils.rb
172
+ - spec/support/matcher.rb
101
173
  homepage: https://github.com/waiting-for-dev/front_matter_parser
102
174
  licenses:
103
175
  - LGPL3
@@ -117,29 +189,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
189
  - !ruby/object:Gem::Version
118
190
  version: '0'
119
191
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.2.2
192
+ rubygems_version: 3.2.3
122
193
  signing_key:
123
194
  specification_version: 4
124
- summary: FrontMatterParser is a library to parse files or strings with YAML front
125
- matters. When working with files, it can automatically detect the syntax of a file
126
- from its extension and it supposes that the front matter is marked as that syntax
127
- comments.
195
+ summary: Library to parse a front matter from strings or files. It allows writing
196
+ syntactically correct source files, marking front matters as comments in the source
197
+ file language.
128
198
  test_files:
129
199
  - spec/fixtures/example
130
- - spec/fixtures/example.coffee
131
- - spec/fixtures/example.erb
132
- - spec/fixtures/example.foo
133
- - spec/fixtures/example.haml
134
200
  - spec/fixtures/example.html
135
- - spec/fixtures/example.liquid
136
- - spec/fixtures/example.md
137
- - spec/fixtures/example.sass
138
- - spec/fixtures/example.scss
139
- - spec/fixtures/example.slim
201
+ - spec/front_matter_parser/loader/yaml_spec.rb
140
202
  - spec/front_matter_parser/parsed_spec.rb
203
+ - spec/front_matter_parser/parser_spec.rb
204
+ - spec/front_matter_parser/syntax_parser/indentation_comment_spec.rb
205
+ - spec/front_matter_parser/syntax_parser/multi_line_comment_spec.rb
206
+ - spec/front_matter_parser/syntax_parser/single_line_comment_spec.rb
141
207
  - spec/front_matter_parser_spec.rb
142
208
  - spec/spec_helper.rb
143
- - spec/support/strings.rb
144
- - spec/support/syntaxs.rb
145
- - spec/support/utils.rb
209
+ - spec/support/matcher.rb
@@ -1,4 +0,0 @@
1
- # ---
2
- # title: hello
3
- # ---
4
- Content
@@ -1,6 +0,0 @@
1
- <%#
2
- ---
3
- title: hello
4
- ---
5
- %>
6
- Content
File without changes
@@ -1,5 +0,0 @@
1
- -#
2
- ---
3
- title: hello
4
- ---
5
- Content
@@ -1,6 +0,0 @@
1
- {% comment %}
2
- ---
3
- title: hello
4
- ---
5
- {% endcomment %}
6
- Content
@@ -1,4 +0,0 @@
1
- ---
2
- title: hello
3
- ---
4
- Content
@@ -1,4 +0,0 @@
1
- // ---
2
- // title: hello
3
- // ---
4
- Content
@@ -1,4 +0,0 @@
1
- // ---
2
- // title: hello
3
- // ---
4
- Content
@@ -1,5 +0,0 @@
1
- /
2
- ---
3
- title: hello
4
- ---
5
- Content
@@ -1,41 +0,0 @@
1
- def string
2
- "---
3
- title: hello
4
- ---
5
- Content"
6
- end
7
-
8
- def string_no_front_matter
9
- "Content"
10
- end
11
-
12
- def string_no_content
13
- "---
14
- title: hello
15
- ---
16
- "
17
- end
18
-
19
- def string_comment(comment)
20
- "#{comment} ---
21
- #{comment} title: hello
22
- #{comment} ---
23
- Content"
24
- end
25
-
26
- def string_start_comment(start_comment)
27
- "#{start_comment}
28
- ---
29
- title: hello
30
- ---
31
- Content"
32
- end
33
-
34
- def string_start_end_comment(start_comment, end_comment)
35
- "#{start_comment}
36
- ---
37
- title: hello
38
- ---
39
- #{end_comment}
40
- Content"
41
- end
@@ -1,14 +0,0 @@
1
- # key is a human name, value is :syntax value or file extension
2
- def syntaxs
3
- {
4
- slim: :slim,
5
- 'coffee script' => :coffee,
6
- html: :html,
7
- haml: :haml,
8
- liquid: :liquid,
9
- sass: :sass,
10
- scss: :scss,
11
- md: :md,
12
- erb: :erb,
13
- }
14
- end
@@ -1,6 +0,0 @@
1
- def file_fixture(string)
2
- file = Tempfile.new('foo')
3
- file.write(string)
4
- file.rewind
5
- file.path
6
- end