bergamasco 0.1.1 → 0.1.2
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/Gemfile.lock +1 -1
- data/README.md +0 -2
- data/lib/bergamasco/markdown.rb +9 -0
- data/lib/bergamasco/version.rb +1 -1
- data/spec/fixtures/cool-dois.yml +1 -0
- data/spec/markdown_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62901afff36fd4f178b9cf83af26ca098b624bfc
|
4
|
+
data.tar.gz: 259429f324394efe47680033ff33068427171b4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e230e0cd85143096d69b4fce20b7fbbf87b37fc48dd69c455113eb6e1d6207ddcf87884ffc3ee17774b0cd442bec61bbb4b7011e2d037df445ba902b6fa05eee
|
7
|
+
data.tar.gz: 88d56f662c43c51f48617729f7542b93dd3e3f60d80b7388748cd30809ed0ddc09ceebbb3b82b126375e616a36e4680e0091e1f7c6ca2e45a85017aea2e5e792
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/bergamasco)
|
4
4
|
[](https://travis-ci.org/datacite/bergamasco)
|
5
|
-
[](https://codeclimate.com/github/datacite/bergamasco/coverage)
|
6
|
-
[](https://codeclimate.com/github/datacite/bergamasco)
|
7
5
|
|
8
6
|
Text utilities for common cleanup and reformatting tasks when working with scholarly metadata.
|
9
7
|
|
data/lib/bergamasco/markdown.rb
CHANGED
@@ -23,6 +23,15 @@ module Bergamasco
|
|
23
23
|
join_yaml_frontmatter(metadata, content)
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.read_yaml(filepath)
|
27
|
+
file = IO.read(filepath)
|
28
|
+
SafeYAML.load(file)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.write_yaml(filepath, content)
|
32
|
+
IO.write(filepath, content.to_yaml)
|
33
|
+
end
|
34
|
+
|
26
35
|
def self.render_html(text, options={})
|
27
36
|
text = split_yaml_frontmatter(text).last if options[:skip_yaml_header]
|
28
37
|
|
data/lib/bergamasco/version.rb
CHANGED
data/spec/fixtures/cool-dois.yml
CHANGED
data/spec/markdown_spec.rb
CHANGED
@@ -37,6 +37,20 @@ describe Bergamasco::Markdown do
|
|
37
37
|
expect(updated_file).to eq(file)
|
38
38
|
end
|
39
39
|
|
40
|
+
it 'should read yaml' do
|
41
|
+
filepath = fixture_path + 'cool-dois.yml'
|
42
|
+
metadata = subject.read_yaml(filepath)
|
43
|
+
expect(metadata["title"]).to eq("Cool DOI's")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should write yaml' do
|
47
|
+
filepath = fixture_path + 'cool-dois.yml'
|
48
|
+
text = IO.read(filepath)
|
49
|
+
metadata = subject.read_yaml(filepath)
|
50
|
+
length = subject.write_yaml(filepath, metadata)
|
51
|
+
expect(length).to eq(text.length)
|
52
|
+
end
|
53
|
+
|
40
54
|
it 'should update file' do
|
41
55
|
filepath = fixture_path + 'cool-dois.html.md'
|
42
56
|
file = IO.read(filepath)
|