nanoc-conref-fs 0.6.10 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af97546774d5b23e33b691e8d3aab9e115061fcd
4
- data.tar.gz: 97ce0cf24a1b572201b2f2322d216774ae2039ca
3
+ metadata.gz: 62064e24b4596e3eff0b6ef03a865da1840efdc5
4
+ data.tar.gz: f097cb00de1ad5f31e33701bcbb4c394241e5b4b
5
5
  SHA512:
6
- metadata.gz: 8fa4d77ccfaf3cbdfdc68e930c98f860b30288b24519e1cfc1f11b8546843572ec71831104058759c0fe598c5b64d3bec919f1ae889da533ed795f5e3a65a065
7
- data.tar.gz: b67e5b5ff20ea6754c65a81421d21f02608397c664bc953a061ede33de5eedb9a4c4ae145de0d8983094b9bbb800f38a68164b688e475859b1a12e5007174887
6
+ metadata.gz: ed8578d2747086afd9e6cf48d80bc7e17880ec584aeaca948a81f1b3d443cf1af3bc6bbbb006c0b94381ef171c94b39828fd533ee8c47bf755ce70fceab63c54
7
+ data.tar.gz: 244555f171ef8570d934be049ecb5ba80770effafcd04c560419af2ce489f29cdae53b4eeed1ebe62b782b90f4472d9726868d5fa30bcdfffa8ef767e8901544
@@ -0,0 +1,10 @@
1
+ inherit_gem:
2
+ rubocop-github:
3
+ - config/default.yml
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: single_quotes
8
+
9
+ RequireParentheses:
10
+ Enabled: true
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3
3
+ - 2.3.6
4
+ - 2.4.3
5
+ - 2.5.0
4
6
  env:
5
7
  global:
6
8
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
@@ -10,3 +12,8 @@ cache: bundler
10
12
 
11
13
  git:
12
14
  depth: 10
15
+
16
+ matrix:
17
+ include:
18
+ - script: bundle exec rake rubocop
19
+ rvm: 2.5.0
data/Rakefile CHANGED
@@ -9,3 +9,7 @@ Rake::TestTask.new do |t|
9
9
  end
10
10
 
11
11
  task default: [:test]
12
+
13
+ require 'rubocop/rake_task'
14
+
15
+ RuboCop::RakeTask.new(:rubocop)
@@ -1,5 +1,6 @@
1
1
  begin
2
2
  require 'awesome_print'
3
+ require 'pry'
3
4
  rescue LoadError
4
5
  end
5
6
 
@@ -2,8 +2,21 @@ require_relative 'conrefifier'
2
2
  require 'active_support/core_ext/hash'
3
3
  require 'active_support/core_ext/string'
4
4
 
5
+ class Nanoc::DataSources::Filesystem::Parser
6
+ alias_method :old_parse_metadata, :parse_metadata
7
+ # There are a lot of problems when trying to parse liquid
8
+ # out of the frontmatter—all of them dealing with collision between
9
+ # the { character in Liquid and its signfigance in YAML. We'll overload
10
+ # the parse method here to resolve those issues ahead of time.
11
+ def parse_metadata(data, filename)
12
+ wrapped_data = data.gsub(/^([^:]+): (\{\{.+)/, '\1: \'\2\'')
13
+
14
+ old_parse_metadata(wrapped_data, filename)
15
+ end
16
+ end
17
+
5
18
  class ConrefFS < Nanoc::DataSources::Filesystem
6
- DEFAULT_DATA_DIR = "data".freeze
19
+ DEFAULT_DATA_DIR = 'data'.freeze
7
20
 
8
21
  include NanocConrefFS::Variables
9
22
  include NanocConrefFS::Ancestry
@@ -29,7 +42,7 @@ class ConrefFS < Nanoc::DataSources::Filesystem
29
42
 
30
43
  def self.apply_attributes(config, item, rep)
31
44
  page_vars = NanocConrefFS::Conrefifier.file_variables(config[:page_variables], item[:filename], rep)
32
- frontmatter_vars = { :page => page_vars }.merge(NanocConrefFS::Variables.variables[rep])
45
+ frontmatter_vars = { page: page_vars }.merge(NanocConrefFS::Variables.variables[rep])
33
46
 
34
47
  unless page_vars[:data_association].nil?
35
48
  association = page_vars[:data_association]
@@ -64,44 +77,7 @@ class ConrefFS < Nanoc::DataSources::Filesystem
64
77
  end
65
78
  end
66
79
 
67
- # There are a lot of problems when trying to parse liquid
68
- # out of the frontmatter—all of them dealing with collision between
69
- # the { character in Liquid and its signfigance in YAML. We'll overload
70
- # the parse method here to resolve those issues ahead of time.
71
- def parse_with_frontmatter(content_filename)
72
- # Read data
73
- data = read(content_filename)
74
-
75
- # Check presence of metadata section
76
- if data !~ /\A-{3,5}\s*$/
77
- return ParseResult.new(content: data, attributes: {}, attributes_data: '')
78
- end
79
-
80
- # Split data
81
- pieces = data.split(/^(-{5}|-{3})[ \t]*\r?\n?/, 3)
82
- if pieces.size < 4
83
- raise RuntimeError.new(
84
- "The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format.",
85
- )
86
- end
87
-
88
- # N.B. the only change to the original function
89
- pieces[2].gsub!(/^([^:]+): (\{\{.+)/, '\1: \'\2\'')
90
-
91
- # Parse
92
- begin
93
- meta = YAML.load(pieces[2]) || {}
94
- rescue Exception => e
95
- raise "Could not parse YAML for #{content_filename}: #{e.message}"
96
- end
97
- verify_meta(meta, content_filename)
98
- content = pieces[4]
99
-
100
- # Done
101
- ParseResult.new(content: content, attributes: meta, attributes_data: pieces[2])
102
- end
103
-
104
- # Some of the static class methods below (and elsewhere in the Gem) require
80
+ # Some of the static class methods below (and elsewhere in the Gem) require
105
81
  # access to the `data_dir` value from the config. This need comes about
106
82
  # *before* Nanoc has a chance to properly load up the configuration file,
107
83
  # so we're doing a bare-bones load here to gain access to that configuration
@@ -114,21 +90,21 @@ class ConrefFS < Nanoc::DataSources::Filesystem
114
90
  # Returns:
115
91
  # - Custom `data_dir` attribute from the 'conref-fs' data_source
116
92
  # - Default `data_dir` of 'data' if none is configured in `nanoc.yaml`
117
- def self.data_dir_name(config=nil)
93
+ def self.data_dir_name(config = nil)
118
94
  config ||= YAML.load_file('nanoc.yaml')
119
- config = config.to_h.with_indifferent_access()
95
+ config = config.to_h.with_indifferent_access
120
96
 
121
97
  # In certain parts of the nanoc pipeline the config is rooted at the
122
98
  # data-source already.
123
- data_dir = config.fetch("data_dir") { nil }
99
+ data_dir = config.fetch('data_dir') { nil }
124
100
  return data_dir if data_dir
125
101
 
126
- data_sources = config.fetch("data_sources") { nil }
102
+ data_sources = config.fetch('data_sources') { nil }
127
103
  return DEFAULT_DATA_DIR unless data_sources
128
104
 
129
- data_source = data_sources.find { |ds| ds["type"] == "conref-fs" }
105
+ data_source = data_sources.find { |ds| ds['type'] == 'conref-fs' }
130
106
 
131
- data_dir = data_source.fetch("data_dir") { nil }
107
+ data_dir = data_source.fetch('data_dir') { nil }
132
108
  return DEFAULT_DATA_DIR unless data_dir
133
109
  return data_dir
134
110
  end
@@ -32,7 +32,7 @@ module NanocConrefFS
32
32
 
33
33
  def self.liquify(config, path:, content:, rep:)
34
34
  page_vars = NanocConrefFS::Conrefifier.file_variables(config[:page_variables], path, rep)
35
- page_vars = { :page => page_vars }.merge(NanocConrefFS::Variables.variables[rep])
35
+ page_vars = { page: page_vars }.merge(NanocConrefFS::Variables.variables[rep])
36
36
 
37
37
  # we must obfuscate essential ExtendedMarkdownFilter content
38
38
  content = content.gsub(/\{\{\s*#(\S+)\s*\}\}/, '[[#\1]]')
@@ -62,7 +62,7 @@ module NanocConrefFS
62
62
 
63
63
  def self.apply_liquid(content, data_vars)
64
64
  data_vars['page'] = data_vars[:page].stringify_keys
65
- result = Liquid::Template.parse(content, :error_mode => :warn).render(data_vars)
65
+ result = Liquid::Template.parse(content, error_mode: :warn).render(data_vars)
66
66
  # This second pass renders any previously inserted
67
67
  # data conditionals within the body. If a Liquid parse
68
68
  # returns a blank string, we'll return the original
@@ -9,7 +9,7 @@ module NanocConrefFS
9
9
 
10
10
  def self.apply_conditionals(config, path:, content:, rep:)
11
11
  vars = Conrefifier.file_variables(config[:data_variables], path, rep)
12
- data_vars = { :page => vars, :site => { :config => config } }
12
+ data_vars = { page: vars, site: { config: config } }
13
13
 
14
14
  content = obfuscate_and_liquify(content, data_vars)
15
15
  begin
@@ -24,7 +24,7 @@ module NanocConrefFS
24
24
  while key = reference.shift
25
25
  begin
26
26
  data = data[key]
27
- rescue Exception => ex
27
+ rescue StandardError => ex
28
28
  raise "Unable to locate #{key} in #{@variables[rep]['site'].inspect}"
29
29
  end
30
30
  end
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'nanoc-conref-fs'
6
- spec.version = '0.6.10'
6
+ spec.version = '0.7.0'
7
7
  spec.authors = ['Garen Torikian']
8
8
  spec.email = ['gjtorikian@gmail.com']
9
9
  spec.summary = 'A Nanoc filesystem to permit using conrefs/reusables in your content.'
@@ -15,11 +15,15 @@ Gem::Specification.new do |spec|
15
15
  spec.test_files = spec.files.grep(%r{^(test)/})
16
16
  spec.require_paths = ['lib']
17
17
 
18
- spec.add_runtime_dependency 'nanoc', '~> 4.3'
19
18
  spec.add_runtime_dependency 'activesupport', '~> 4.2'
20
- spec.add_runtime_dependency 'liquid', '3.0.6'
19
+ spec.add_runtime_dependency 'liquid', '~> 4.0'
20
+ spec.add_runtime_dependency 'nanoc', '~> 4.9'
21
21
 
22
- spec.add_development_dependency 'rake'
23
- spec.add_development_dependency 'minitest', '~> 5.8'
24
22
  spec.add_development_dependency 'awesome_print'
23
+ spec.add_development_dependency 'minitest', '~> 5.8'
24
+ spec.add_development_dependency 'minitest-focus', '~> 1.1'
25
+ spec.add_development_dependency 'pry', '~> 0.10.0'
26
+ spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'rubocop-github'
25
29
  end
@@ -42,16 +42,6 @@ class DatafilesTest < MiniTest::Test
42
42
  end
43
43
  end
44
44
 
45
- def test_it_renders_nested_conrefs
46
- with_site do |site|
47
- site.compile
48
-
49
- output_file = read_output_file('datafiles', 'deep')
50
- test_file = read_test_file('datafiles', 'deep')
51
- assert_equal output_file, test_file
52
- end
53
- end
54
-
55
45
  def test_it_applies_any_attribute
56
46
  with_site do |site|
57
47
  site.compile
@@ -21,7 +21,7 @@ compile '/**/*.md' do
21
21
  end
22
22
  end
23
23
 
24
- compile '/multiple/single_var.md', :rep => :X do
24
+ compile '/multiple/single_var.md', rep: :X do
25
25
  filter :'conref-fs-filter'
26
26
  filter :erb
27
27
  layout '/default.*'
@@ -31,7 +31,7 @@ route '/**/*.md' do
31
31
  item.identifier.without_ext + '/index.html'
32
32
  end
33
33
 
34
- route '/multiple/single_var.md', :rep => :X do
34
+ route '/multiple/single_var.md', rep: :X do
35
35
  item.identifier.without_ext + '_x/index.html'
36
36
  end
37
37
 
@@ -9,7 +9,7 @@
9
9
  <body>
10
10
 
11
11
 
12
- Here they are!
12
+ Here they are!
13
13
 
14
14
 
15
15
  ["About branches", "Setting the default branch", "Viewing branches in your repository", "Creating and deleting branches within your repository"]
@@ -8,8 +8,8 @@
8
8
 
9
9
  <body>
10
10
 
11
-
12
- Below should be an empty array.
11
+
12
+ Below should be an empty array.
13
13
 
14
14
 
15
15
  []
@@ -11,7 +11,7 @@
11
11
  We use SVNHub
12
12
 
13
13
 
14
- Inception
14
+ Inception
15
15
 
16
16
 
17
17
  </body>
@@ -9,8 +9,7 @@
9
9
  <body>
10
10
 
11
11
  GitHub Enterprise
12
-
13
- Fetchy
12
+ Fetchy
14
13
 
15
14
  </body>
16
15
  </html>
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
 
14
- Some other page.
14
+ Some other page.
15
15
 
16
16
 
17
17
  </body>
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
 
14
- Some other page.
14
+ Some other page.
15
15
 
16
16
 
17
17
  </body>
@@ -11,7 +11,7 @@
11
11
  Here I am, in the front.
12
12
 
13
13
 
14
- Some words.
14
+ Some words.
15
15
 
16
16
 
17
17
  </body>
@@ -8,7 +8,7 @@
8
8
 
9
9
  <body>
10
10
 
11
- For example, to list a project's name, you might write something like `The project is called {{ site.github.project_title }}` or to list an organization's open source repositories, you might use the following:
11
+ For example, to list a project's name, you might write something like `The project is called {{ site.github.project_title }}` or to list an organization's open source repositories, you might use the following:
12
12
 
13
13
  ``` liquid
14
14
  {% for repository in site.github.public_repositories %}
@@ -9,7 +9,7 @@
9
9
  <body>
10
10
  **Two-factor authentication**, or 2FA, is a way of logging into websites that requires more than just a password. Using a password to log into a website is susceptible to security threats, because it represents a _single_ piece of information a malicious person needs to acquire. The added security that 2FA provides is requiring _additional information_ to sign in.
11
11
 
12
- *Ta-da!*
12
+ *Ta-da!*
13
13
 
14
14
  </body>
15
15
  </html>
@@ -9,7 +9,7 @@
9
9
  <body>
10
10
  *Two-factor authentication*, or 2FA, is a way of logging into websites that requires more than just a password. Using a password to log into a website is susceptible to security threats, because it represents a _single_ piece of information a malicious person needs to acquire. The added security that 2FA provides is requiring _additional information_ to sign in.
11
11
 
12
- *Ta-da!*
12
+ *Ta-da!*
13
13
 
14
14
  </body>
15
15
  </html>
@@ -8,7 +8,7 @@
8
8
 
9
9
  <body>
10
10
 
11
- You may also wish to add the `{% feed_meta %}` tag to your layout's `<head>` section to allow browsers to more easily discover your site's feed.
11
+ You may also wish to add the `{% feed_meta %}` tag to your layout's `<head>` section to allow browsers to more easily discover your site's feed.
12
12
 
13
13
  </body>
14
14
  </html>
@@ -9,8 +9,7 @@
9
9
  <body>
10
10
 
11
11
  Creating a new organization account
12
-
13
- Array parent.
12
+ Array parent.
14
13
 
15
14
  </body>
16
15
  </html>
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
 
14
- Little Orphan Annie.
14
+ Little Orphan Annie.
15
15
 
16
16
 
17
17
  </body>
@@ -10,8 +10,7 @@
10
10
 
11
11
 
12
12
  Keyboard Shortcuts
13
-
14
- Something something
13
+ Something something
15
14
 
16
15
 
17
16
  </body>
@@ -10,8 +10,7 @@
10
10
 
11
11
 
12
12
  Collaborating
13
-
14
- Two parents!
13
+ Two parents!
15
14
 
16
15
 
17
16
  </body>
@@ -6,6 +6,7 @@ require 'nanoc'
6
6
  require_relative '../lib/nanoc-conref-fs'
7
7
  require 'minitest/autorun'
8
8
  require 'minitest/pride'
9
+ require 'minitest/focus'
9
10
  require 'active_support'
10
11
 
11
12
  FIXTURES_DIR = File.join(Dir.pwd, 'test', 'fixtures')
metadata CHANGED
@@ -1,59 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-conref-fs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-05 00:00:00.000000000 Z
11
+ date: 2018-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nanoc
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.3'
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.3'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: liquid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.2'
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.2'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: liquid
42
+ name: nanoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.6
47
+ version: '4.9'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.0.6
54
+ version: '4.9'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: awesome_print
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -81,7 +81,63 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.8'
83
83
  - !ruby/object:Gem::Dependency
84
- name: awesome_print
84
+ name: minitest-focus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.10.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.10.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-github
85
141
  requirement: !ruby/object:Gem::Requirement
86
142
  requirements:
87
143
  - - ">="
@@ -102,6 +158,7 @@ extensions: []
102
158
  extra_rdoc_files: []
103
159
  files:
104
160
  - ".gitignore"
161
+ - ".rubocop.yml"
105
162
  - ".travis.yml"
106
163
  - Gemfile
107
164
  - LICENSE.txt