front_matter_parser 0.2.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +43 -1
- data/.travis.yml +9 -9
- data/CHANGELOG.md +13 -0
- data/Dockerfile +5 -8
- data/README.md +13 -21
- data/docker-compose.yml +7 -2
- data/front_matter_parser.gemspec +3 -1
- data/lib/front_matter_parser/loader/yaml.rb +5 -5
- data/lib/front_matter_parser/version.rb +1 -1
- data/spec/front_matter_parser/loader/yaml_spec.rb +3 -3
- metadata +34 -9
- data/.overcommit.yml +0 -54
- data/.overcommit_gems.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a904dbf5bade2127e0bb2b9abb7106f179ce22876ca6e57aa9dc7c89730d2898
|
4
|
+
data.tar.gz: b43330122a6496888be51b937fc06749dd0b256394227425736b88a0e9e9f781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf46ac330a47187dc37041b4c25ec6dd8500761ec18feaa2102659e19cda516f03be66b3ac32a9a530406b9d4fe598a86666916418ddf54f5380d9c164787095
|
7
|
+
data.tar.gz: 1d359953cd78bac9bf7186eb5b16e22f95a4d01ddaaf3d9e643580c7d407332f6730573733aa55423fd06c147e7816873b8deb62b1f1fa59ac7429e0f1490489
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,50 @@
|
|
1
1
|
require: rubocop-rspec
|
2
2
|
AllCops:
|
3
|
-
TargetRubyVersion:
|
3
|
+
TargetRubyVersion: 3.0
|
4
|
+
Exclude:
|
5
|
+
- Gemfile
|
6
|
+
- front_matter_parser.gemspec
|
7
|
+
- vendor/**/*
|
4
8
|
RSpec/NestedGroups:
|
5
9
|
Max: 3
|
10
|
+
RSpec/MessageExpectation:
|
11
|
+
EnforcedStyle: 'expect'
|
6
12
|
Metrics/BlockLength:
|
7
13
|
Exclude:
|
8
14
|
- "spec/**/*.rb"
|
15
|
+
Style/SafeNavigation:
|
16
|
+
Enabled: false
|
17
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
18
|
+
Enabled: true
|
19
|
+
Layout/SpaceAroundMethodCallOperator:
|
20
|
+
Enabled: true
|
21
|
+
Lint/DeprecatedOpenSSLConstant:
|
22
|
+
Enabled: true
|
23
|
+
Lint/MixedRegexpCaptureTypes:
|
24
|
+
Enabled: true
|
25
|
+
Lint/RaiseException:
|
26
|
+
Enabled: true
|
27
|
+
Lint/StructNewOverride:
|
28
|
+
Enabled: true
|
29
|
+
Style/AccessorGrouping:
|
30
|
+
Enabled: true
|
31
|
+
Style/BisectedAttrAccessor:
|
32
|
+
Enabled: true
|
33
|
+
Style/ExponentialNotation:
|
34
|
+
Enabled: true
|
35
|
+
Style/HashEachMethods:
|
36
|
+
Enabled: true
|
37
|
+
Style/HashTransformKeys:
|
38
|
+
Enabled: true
|
39
|
+
Style/HashTransformValues:
|
40
|
+
Enabled: true
|
41
|
+
Style/RedundantAssignment:
|
42
|
+
Enabled: true
|
43
|
+
Style/RedundantFetchBlock:
|
44
|
+
Enabled: true
|
45
|
+
Style/RedundantRegexpCharacterClass:
|
46
|
+
Enabled: true
|
47
|
+
Style/RedundantRegexpEscape:
|
48
|
+
Enabled: true
|
49
|
+
Style/SlicingWithRange:
|
50
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
2
|
+
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.4
|
5
|
-
- 2.5
|
6
4
|
- 2.6
|
5
|
+
- 2.7
|
6
|
+
- 3.0
|
7
|
+
- ruby-head
|
7
8
|
before_install:
|
8
9
|
- gem update --system --no-doc
|
9
|
-
-
|
10
|
-
before_script:
|
11
|
-
- git config --global user.email 'travis@travis.ci'
|
12
|
-
- git config --global user.name 'Travis CI'
|
10
|
+
- gem install bundler
|
13
11
|
script:
|
14
12
|
- bundle exec rspec
|
13
|
+
- bundle exec rubocop
|
15
14
|
- bundle exec codeclimate-test-reporter
|
16
|
-
|
17
|
-
|
15
|
+
jobs:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
18
18
|
addons:
|
19
19
|
code_climate:
|
20
20
|
repo_token:
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [1.0.0] - 2020-08-31
|
8
|
+
- Depreciate "whitelist" in favor of "allowlist" by renaming the `whitelist_classes` param to `allowlist_classes`.
|
9
|
+
|
10
|
+
If your project uses the `whitelist_classes` param, you will need to upgrade your code as follows:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
## before
|
14
|
+
loader = FrontMatterParser::Loader::Yaml.new(whitelist_classes: [Time])
|
15
|
+
|
16
|
+
## after
|
17
|
+
loader = FrontMatterParser::Loader::Yaml.new(allowlist_classes: [Time])
|
18
|
+
```
|
19
|
+
|
7
20
|
## [0.2.1] - 2019-06-06
|
8
21
|
### Fixed
|
9
22
|
- Do not add `bin` development executables to generated gem.
|
data/Dockerfile
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
FROM ruby:
|
2
|
-
ENV
|
3
|
-
|
4
|
-
|
5
|
-
WORKDIR
|
6
|
-
COPY Gemfile *gemspec $APP_HOME
|
7
|
-
COPY $LIB_DIR/version.rb $APP_HOME/$LIB_DIR
|
8
|
-
RUN bundle install
|
1
|
+
FROM ruby:3.0.0
|
2
|
+
ENV APP_USER front_matter_parser_user
|
3
|
+
RUN useradd -ms /bin/bash $APP_USER
|
4
|
+
USER $APP_USER
|
5
|
+
WORKDIR /home/$APP_USER/app
|
data/README.md
CHANGED
@@ -75,17 +75,17 @@ title = FrontMatterParser::Parser.parse_file('example.haml')['title'] #=> 'Hello
|
|
75
75
|
|
76
76
|
Following there is a relation of known syntaxes and their known comment delimiters:
|
77
77
|
|
78
|
-
| Syntax | Single line comment | Start multiline comment | End multiline comment
|
79
|
-
| ------ | ------------------- | ----------------------- |
|
80
|
-
| haml | | -# | (indentation)
|
81
|
-
| slim | | / | (indentation)
|
82
|
-
| liquid | | {% comment %} | {% endcomment %}
|
83
|
-
| md | | |
|
84
|
-
| html | | <!-- | -->
|
85
|
-
| erb | | <%# | %>
|
86
|
-
| coffee | # | |
|
87
|
-
| sass | // | |
|
88
|
-
| scss | // | |
|
78
|
+
| Syntax | Single line comment | Start multiline comment | End multiline comment |
|
79
|
+
| ------ | ------------------- | ----------------------- | --------------------- |
|
80
|
+
| haml | | -# | (indentation) |
|
81
|
+
| slim | | / | (indentation) |
|
82
|
+
| liquid | | {% comment %} | {% endcomment %} |
|
83
|
+
| md | | | |
|
84
|
+
| html | | <!-- | --> |
|
85
|
+
| erb | | <%# | %> |
|
86
|
+
| coffee | # | | |
|
87
|
+
| sass | // | | |
|
88
|
+
| scss | // | | |
|
89
89
|
|
90
90
|
### Parsing a string
|
91
91
|
|
@@ -134,10 +134,10 @@ FrontMatterParser::Parser.parse_file('example.md', loader: json_loader)
|
|
134
134
|
FrontMatterParser::Parser.new(:md, loader: json_loader).call(string)
|
135
135
|
```
|
136
136
|
|
137
|
-
If you need to
|
137
|
+
If you need to allow one or more classes for the built-in YAML loader, you can just create a custom loader based on it and provide needed classes in a `allowlist_classes:` param:
|
138
138
|
|
139
139
|
```ruby
|
140
|
-
loader = FrontMatterParser::Loader::Yaml.new(
|
140
|
+
loader = FrontMatterParser::Loader::Yaml.new(allowlist_classes: [Time])
|
141
141
|
parsed = FrontMatterParser::Parser.parse_file('example.md', loader: loader)
|
142
142
|
puts parsed['timestamp']
|
143
143
|
```
|
@@ -152,14 +152,6 @@ An then, for example:
|
|
152
152
|
|
153
153
|
`docker-compose exec app rspec`
|
154
154
|
|
155
|
-
This gem uses [overcommit](https://github.com/brigade/overcommit) to execute some code review engines. If you submit a pull request, it will be executed in the CI process. In order to set it up, you need to do:
|
156
|
-
|
157
|
-
```ruby
|
158
|
-
bundle install --gemfile=.overcommit_gems.rb
|
159
|
-
overcommit --sign
|
160
|
-
overcommit --run # To test if it works
|
161
|
-
```
|
162
|
-
|
163
155
|
## Contributing
|
164
156
|
|
165
157
|
1. Fork it
|
data/docker-compose.yml
CHANGED
@@ -2,6 +2,11 @@ version: '2'
|
|
2
2
|
services:
|
3
3
|
app:
|
4
4
|
build: .
|
5
|
-
|
5
|
+
image: front_matter_parser_user
|
6
|
+
command: bash -c "bundle && tail -f Gemfile"
|
6
7
|
volumes:
|
7
|
-
- .:/app
|
8
|
+
- .:/home/front_matter_parser_user/app
|
9
|
+
tty: true
|
10
|
+
stdin_open: true
|
11
|
+
tmpfs:
|
12
|
+
- /tmp
|
data/front_matter_parser.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.8"
|
24
24
|
spec.add_development_dependency "pry-byebug", "~> 3.7"
|
25
25
|
# Test reporting
|
26
|
-
spec.add_development_dependency '
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 1.9'
|
27
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
|
28
|
+
spec.add_development_dependency 'simplecov', '0.17'
|
27
29
|
spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
|
28
30
|
end
|
@@ -6,12 +6,12 @@ module FrontMatterParser
|
|
6
6
|
module Loader
|
7
7
|
# {Loader} that uses YAML library
|
8
8
|
class Yaml
|
9
|
-
# @!attribute [r]
|
9
|
+
# @!attribute [r] allowlist_classes
|
10
10
|
# Classes that may be parsed by #call.
|
11
|
-
attr_reader :
|
11
|
+
attr_reader :allowlist_classes
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
13
|
+
def initialize(allowlist_classes: [])
|
14
|
+
@allowlist_classes = allowlist_classes
|
15
15
|
end
|
16
16
|
|
17
17
|
# Loads a hash front matter from a string
|
@@ -19,7 +19,7 @@ module FrontMatterParser
|
|
19
19
|
# @param string [String] front matter string representation
|
20
20
|
# @return [Hash] front matter hash representation
|
21
21
|
def call(string)
|
22
|
-
YAML.safe_load(string,
|
22
|
+
YAML.safe_load(string, allowlist_classes)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -12,11 +12,11 @@ describe FrontMatterParser::Loader::Yaml do
|
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'loads with
|
15
|
+
it 'loads with classes in allowlist' do
|
16
16
|
string = 'timestamp: 2017-10-17 00:00:00Z'
|
17
|
-
params = {
|
17
|
+
params = { allowlist_classes: [Time] }
|
18
18
|
|
19
|
-
expect(described_class.new(params).call(string)).to eq(
|
19
|
+
expect(described_class.new(**params).call(string)).to eq(
|
20
20
|
'timestamp' => Time.parse('2017-10-17 00:00:00Z')
|
21
21
|
)
|
22
22
|
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.
|
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:
|
11
|
+
date: 2021-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,19 +67,47 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.7'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '2.2'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
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'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: codeclimate-test-reporter
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,8 +131,6 @@ extra_rdoc_files: []
|
|
103
131
|
files:
|
104
132
|
- ".codeclimate.yml"
|
105
133
|
- ".gitignore"
|
106
|
-
- ".overcommit.yml"
|
107
|
-
- ".overcommit_gems.rb"
|
108
134
|
- ".rspec"
|
109
135
|
- ".rubocop.yml"
|
110
136
|
- ".ruby-version"
|
@@ -163,8 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
189
|
- !ruby/object:Gem::Version
|
164
190
|
version: '0'
|
165
191
|
requirements: []
|
166
|
-
|
167
|
-
rubygems_version: 2.7.8
|
192
|
+
rubygems_version: 3.2.3
|
168
193
|
signing_key:
|
169
194
|
specification_version: 4
|
170
195
|
summary: Library to parse a front matter from strings or files. It allows writing
|
data/.overcommit.yml
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Select version of overcommit and the other tools from Gemfile
|
3
|
-
#
|
4
|
-
gemfile: .overcommit_gems.rb
|
5
|
-
|
6
|
-
#
|
7
|
-
# Hooks that are run against every commit message after a user has written it.
|
8
|
-
#
|
9
|
-
CommitMsg:
|
10
|
-
ALL:
|
11
|
-
required: true
|
12
|
-
exclude: &default_excludes
|
13
|
-
- Gemfile
|
14
|
-
- CHANGELOG.md
|
15
|
-
- front_matter_parser.gemspec
|
16
|
-
- README.md
|
17
|
-
|
18
|
-
HardTabs:
|
19
|
-
enabled: true
|
20
|
-
|
21
|
-
SingleLineSubject:
|
22
|
-
enabled: true
|
23
|
-
|
24
|
-
#
|
25
|
-
# Hooks that are run after `git commit` is executed, before the commit message
|
26
|
-
# editor is displayed.
|
27
|
-
#
|
28
|
-
PreCommit:
|
29
|
-
ALL:
|
30
|
-
required: true
|
31
|
-
exclude: *default_excludes
|
32
|
-
|
33
|
-
BundleAudit:
|
34
|
-
enabled: true
|
35
|
-
|
36
|
-
BundleCheck:
|
37
|
-
enabled: true
|
38
|
-
|
39
|
-
LocalPathsInGemfile:
|
40
|
-
enabled: true
|
41
|
-
|
42
|
-
ExecutePermissions:
|
43
|
-
enabled: true
|
44
|
-
exclude:
|
45
|
-
- bin/*
|
46
|
-
|
47
|
-
Reek:
|
48
|
-
enabled: true
|
49
|
-
|
50
|
-
RuboCop:
|
51
|
-
enabled: true
|
52
|
-
|
53
|
-
TrailingWhitespace:
|
54
|
-
enabled: true
|
data/.overcommit_gems.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gem 'overcommit', '~> 0.36'
|
6
|
-
|
7
|
-
# Patch-level verification for Bundled apps
|
8
|
-
gem 'bundler-audit', '~> 0.5'
|
9
|
-
|
10
|
-
# Ruby code smell reporter
|
11
|
-
gem 'reek', '~> 4.5'
|
12
|
-
|
13
|
-
# Ruby code style checking
|
14
|
-
gem 'rubocop', '~> 0.43'
|
15
|
-
gem 'rubocop-rspec', '~> 1.7'
|