front_matter_parser 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +19 -0
  3. data/.gitignore +1 -0
  4. data/.overcommit.yml +54 -0
  5. data/.overcommit_gems.rb +15 -0
  6. data/.rspec +1 -0
  7. data/.rubocop.yml +8 -0
  8. data/.travis.yml +18 -1
  9. data/Dockerfile +8 -0
  10. data/Gemfile +0 -2
  11. data/README.md +64 -24
  12. data/Rakefile +5 -3
  13. data/bin/console +15 -0
  14. data/bin/setup +8 -0
  15. data/docker-compose.yml +7 -0
  16. data/front_matter_parser.gemspec +9 -5
  17. data/lib/front_matter_parser.rb +10 -114
  18. data/lib/front_matter_parser/loader.rb +11 -0
  19. data/lib/front_matter_parser/loader/yaml.rb +18 -0
  20. data/lib/front_matter_parser/parsed.rb +25 -14
  21. data/lib/front_matter_parser/parser.rb +80 -0
  22. data/lib/front_matter_parser/syntax_parser.rb +28 -0
  23. data/lib/front_matter_parser/syntax_parser/factorizable.rb +30 -0
  24. data/lib/front_matter_parser/syntax_parser/indentation_comment.rb +48 -0
  25. data/lib/front_matter_parser/syntax_parser/multi_line_comment.rb +49 -0
  26. data/lib/front_matter_parser/syntax_parser/single_line_comment.rb +63 -0
  27. data/lib/front_matter_parser/version.rb +3 -1
  28. data/spec/fixtures/example +6 -0
  29. data/spec/front_matter_parser/loader/yaml_spec.rb +15 -0
  30. data/spec/front_matter_parser/parsed_spec.rb +11 -21
  31. data/spec/front_matter_parser/parser_spec.rb +111 -0
  32. data/spec/front_matter_parser/syntax_parser/indentation_comment_spec.rb +146 -0
  33. data/spec/front_matter_parser/syntax_parser/multi_line_comment_spec.rb +249 -0
  34. data/spec/front_matter_parser/syntax_parser/single_line_comment_spec.rb +156 -0
  35. data/spec/front_matter_parser_spec.rb +3 -296
  36. data/spec/spec_helper.rb +7 -1
  37. data/spec/support/matcher.rb +8 -0
  38. metadata +86 -46
  39. data/spec/fixtures/example.coffee +0 -4
  40. data/spec/fixtures/example.erb +0 -6
  41. data/spec/fixtures/example.foo +0 -0
  42. data/spec/fixtures/example.haml +0 -5
  43. data/spec/fixtures/example.liquid +0 -6
  44. data/spec/fixtures/example.md +0 -4
  45. data/spec/fixtures/example.sass +0 -4
  46. data/spec/fixtures/example.scss +0 -4
  47. data/spec/fixtures/example.slim +0 -5
  48. data/spec/support/strings.rb +0 -41
  49. data/spec/support/syntaxs.rb +0 -14
  50. data/spec/support/utils.rb +0 -6
@@ -1,6 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+
5
+ SimpleCov.start
6
+
1
7
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
8
  require 'front_matter_parser'
3
- require 'tempfile'
9
+ require 'pry-byebug'
4
10
  Dir["#{File.expand_path('../support', __FILE__)}/*.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,14 +1,14 @@
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: 0.1.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: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,88 +16,135 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '1.6'
19
+ version: '1.14'
23
20
  type: :development
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '1.5'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '1.6'
26
+ version: '1.14'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: '10.1'
33
+ version: '12.0'
40
34
  type: :development
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: '10.1'
40
+ version: '12.0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rspec
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '2.14'
47
+ version: '3.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
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.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
54
90
  type: :development
55
91
  prerelease: false
56
92
  version_requirements: !ruby/object:Gem::Requirement
57
93
  requirements:
58
94
  - - "~>"
59
95
  - !ruby/object:Gem::Version
60
- version: '2.14'
61
- description: Library to parse files or strings with YAML front matters with syntax
62
- autodetection.
96
+ version: '1.0'
97
+ description: Parse a front matter from syntactically correct strings or files
63
98
  email:
64
99
  - marc@lamarciana.com
65
- executables: []
100
+ executables:
101
+ - console
102
+ - setup
66
103
  extensions: []
67
104
  extra_rdoc_files: []
68
105
  files:
106
+ - ".codeclimate.yml"
69
107
  - ".gitignore"
108
+ - ".overcommit.yml"
109
+ - ".overcommit_gems.rb"
70
110
  - ".rspec"
111
+ - ".rubocop.yml"
71
112
  - ".ruby-version"
72
113
  - ".travis.yml"
73
114
  - ".yardopts"
74
115
  - COPYING.LESSER
75
116
  - COPYING.txt
117
+ - Dockerfile
76
118
  - Gemfile
77
119
  - LICENSE.txt
78
120
  - README.md
79
121
  - Rakefile
122
+ - bin/console
123
+ - bin/setup
124
+ - docker-compose.yml
80
125
  - front_matter_parser.gemspec
81
126
  - lib/front_matter_parser.rb
127
+ - lib/front_matter_parser/loader.rb
128
+ - lib/front_matter_parser/loader/yaml.rb
82
129
  - lib/front_matter_parser/parsed.rb
130
+ - lib/front_matter_parser/parser.rb
131
+ - lib/front_matter_parser/syntax_parser.rb
132
+ - lib/front_matter_parser/syntax_parser/factorizable.rb
133
+ - lib/front_matter_parser/syntax_parser/indentation_comment.rb
134
+ - lib/front_matter_parser/syntax_parser/multi_line_comment.rb
135
+ - lib/front_matter_parser/syntax_parser/single_line_comment.rb
83
136
  - lib/front_matter_parser/version.rb
84
137
  - spec/fixtures/example
85
- - spec/fixtures/example.coffee
86
- - spec/fixtures/example.erb
87
- - spec/fixtures/example.foo
88
- - spec/fixtures/example.haml
89
138
  - 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
139
+ - spec/front_matter_parser/loader/yaml_spec.rb
95
140
  - spec/front_matter_parser/parsed_spec.rb
141
+ - spec/front_matter_parser/parser_spec.rb
142
+ - spec/front_matter_parser/syntax_parser/indentation_comment_spec.rb
143
+ - spec/front_matter_parser/syntax_parser/multi_line_comment_spec.rb
144
+ - spec/front_matter_parser/syntax_parser/single_line_comment_spec.rb
96
145
  - spec/front_matter_parser_spec.rb
97
146
  - spec/spec_helper.rb
98
- - spec/support/strings.rb
99
- - spec/support/syntaxs.rb
100
- - spec/support/utils.rb
147
+ - spec/support/matcher.rb
101
148
  homepage: https://github.com/waiting-for-dev/front_matter_parser
102
149
  licenses:
103
150
  - LGPL3
@@ -118,28 +165,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
165
  version: '0'
119
166
  requirements: []
120
167
  rubyforge_project:
121
- rubygems_version: 2.2.2
168
+ rubygems_version: 2.6.10
122
169
  signing_key:
123
170
  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.
171
+ summary: Library to parse a front matter from strings or files. It allows writing
172
+ syntactically correct source files, marking front matters as comments in the source
173
+ file language.
128
174
  test_files:
129
175
  - spec/fixtures/example
130
- - spec/fixtures/example.coffee
131
- - spec/fixtures/example.erb
132
- - spec/fixtures/example.foo
133
- - spec/fixtures/example.haml
134
176
  - 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
177
+ - spec/front_matter_parser/loader/yaml_spec.rb
140
178
  - spec/front_matter_parser/parsed_spec.rb
179
+ - spec/front_matter_parser/parser_spec.rb
180
+ - spec/front_matter_parser/syntax_parser/indentation_comment_spec.rb
181
+ - spec/front_matter_parser/syntax_parser/multi_line_comment_spec.rb
182
+ - spec/front_matter_parser/syntax_parser/single_line_comment_spec.rb
141
183
  - spec/front_matter_parser_spec.rb
142
184
  - spec/spec_helper.rb
143
- - spec/support/strings.rb
144
- - spec/support/syntaxs.rb
145
- - spec/support/utils.rb
185
+ - 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