wax_tasks 0.3.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: a05cb7d5dd4a2218f7c20546a7bb40762ff50c1382457ab5dc8573f5a8131eb9
4
- data.tar.gz: d80600e1d481d7aa91c78fc38fb214aa234f86859ff1ae8660310f17586b5ed0
3
+ metadata.gz: 6a9f379405599184347f73da048e52435aacd769de71046e617bcd9b44b0f760
4
+ data.tar.gz: 3e9e07cda10a6063cb82a3b6af02ce2453ee561fa085baf9118f6c6ef4183a52
5
5
  SHA512:
6
- metadata.gz: 36879c674be8917117b4219e485c987386370c8d8c89d6d8fdc8bc0149a6d05265ede31b4f4720a1aa48d9cca5db1d2e10a8511663f0aaab9ee34a48bbb96edd
7
- data.tar.gz: 8b9ba90bd8a415fcacc969bd787862d8d37e1b7f222341bd23a9c9b08c33cd5eb9fd641f31d5a02b0df99707009ffb57969d945d462698df10c45bde58d0e758
6
+ metadata.gz: 939570ab776be0b04c78665439e36254f0c1a2a6fb071383f439844be039167a84986ac2fa430c6865cb61be3f35d8e1fa539a90d0054719f538a4d15d1c5dd5
7
+ data.tar.gz: b27e94c4c56e17b9298cfb5c612497c049890a3e91ec05ea8ba44d2401c9f7a5873e315fbb78d571bd0b708f0ade59db6b799b779d3b75ebc1923b5d37b23bdd
data/lib/tasks/push.rake CHANGED
@@ -6,8 +6,7 @@ namespace :wax do
6
6
  ARGS = ARGV.drop(1).each { |a| task a.to_sym }
7
7
  raise 'You must specify a branch after \'wax:push:branch\'' if ARGS.empty?
8
8
 
9
- target = WaxTasks::Utils.slug(ARGS.first)
10
9
  task_runner = WaxTasks::TaskRunner.new
11
- task_runner.push_branch(target)
10
+ task_runner.push_branch(ARGS.first)
12
11
  end
13
12
  end
@@ -1,6 +1,5 @@
1
1
  require 'jekyll'
2
2
  require 'logger'
3
- require 'time'
4
3
  require 'tmpdir'
5
4
 
6
5
  module WaxTasks
@@ -37,10 +36,11 @@ module WaxTasks
37
36
  msg = 'Building the gh-pages _site without a baseurl is not recommended'
38
37
  Logger.new($stdout).warn(msg.orange)
39
38
  end
40
- FileUtils.rm_r(SITE_DIR) if File.directory?(SITE_DIR)
39
+ FileUtils.rm_r(SITE_DIR) if File.directory?(WaxTasks::SITE_DIR)
41
40
  opts = {
42
- source: '.',
43
- destination: SITE_DIR,
41
+ source: @site[:source_dir] || '.',
42
+ destination: WaxTasks::SITE_DIR,
43
+ config: WaxTasks::DEFAULT_CONFIG,
44
44
  baseurl: @baseurl,
45
45
  verbose: true
46
46
  }
@@ -52,7 +52,7 @@ module WaxTasks
52
52
  def push
53
53
  if @site[:env] == 'prod'
54
54
  rebuild if @target == 'gh-pages'
55
- raise Error::MissingSite, "Cannot find #{SITE_DIR}" unless Dir.exist? SITE_DIR
55
+ raise Error::MissingSite, "Cannot find #{WaxTasks::SITE_DIR}" unless Dir.exist? WaxTasks::SITE_DIR
56
56
  Dir.chdir(SITE_DIR)
57
57
  system 'git init && git add .'
58
58
  system "git commit -m '#{@commit_msg}'"
@@ -64,47 +64,4 @@ module WaxTasks
64
64
  end
65
65
  end
66
66
  end
67
-
68
- # Branch object for `$ wax:push` task when run on Travis-CI VM
69
- # using encrypted Travis environment vars
70
- #
71
- # @attr repo_slug [String] the 'user/repo_name'
72
- # @attr user [String] the GitHub user making the commit/push
73
- # @attr token [String] secret git access token
74
- # @attr commit_msg [String] the commit message to use on push
75
- # @attr origin [String] the current repository remote
76
- # @attr baseurl [String] the site baseurl to build with (if on gh-pages)
77
- # @attr success_msg [String] informative message to be output to console
78
- class TravisBranch < Branch
79
- def initialize(site, target)
80
- super(site, target)
81
-
82
- @repo_slug = ENV['TRAVIS_REPO_SLUG']
83
- @user = @repo_slug.split('/').first
84
- @token = ENV['ACCESS_TOKEN']
85
-
86
- @commit_msg = "Updated via #{ENV['TRAVIS_COMMIT']} @#{Time.now.utc}"
87
- @origin = "https://#{@user}:#{@token}@github.com/#{@repo_slug}.git"
88
- @baseurl = @repo_slug.split('/').last
89
- @success_msg = "Deploying to #{@target} branch from Travis as #{@user}."
90
- end
91
- end
92
-
93
- # Branch object for `$ wax:push` task when run on local machine
94
- # using local credentials
95
- #
96
- # @attr origin [String] the current repository remote
97
- # @attr commit_msg [String] the commit message to use on push
98
- # @attr baseurl [String] the site baseurl to build with (if on gh-pages)
99
- # @attr success_msg [String] informative message to be output to console
100
- class LocalBranch < Branch
101
- def initialize(site, target)
102
- super(site, target)
103
-
104
- @origin = `git config --get remote.origin.url`.strip
105
- @commit_msg = "Updated via local task at #{Time.now.utc}"
106
- @baseurl = @origin.split('/').last.gsub('.git', '')
107
- @success_msg = "Deploying to #{@target} branch from local task."
108
- end
109
- end
110
67
  end
@@ -47,12 +47,16 @@ module WaxTasks
47
47
  def ingest_file(source)
48
48
  raise Error::MissingSource, "Cannot find #{source}" unless File.exist? source
49
49
 
50
- case File.extname(source)
51
- when '.csv' then data = WaxTasks::Utils.validate_csv(source)
52
- when '.json' then data = WaxTasks::Utils.validate_json(source)
53
- when /\.ya?ml/ then data = WaxTasks::Utils.validate_yaml(source)
54
- else raise Error::InvalidSource, "Cannot load #{File.extname(source)} files. Culprit: #{source}"
55
- end
50
+ data = case File.extname(source)
51
+ when '.csv'
52
+ WaxTasks::Utils.validate_csv(source)
53
+ when '.json'
54
+ WaxTasks::Utils.validate_json(source)
55
+ when /\.ya?ml/
56
+ WaxTasks::Utils.validate_yaml(source)
57
+ else
58
+ raise Error::InvalidSource, "Can't load #{File.extname(source)} files. Culprit: #{source}"
59
+ end
56
60
 
57
61
  WaxTasks::Utils.assert_pids(data)
58
62
  WaxTasks::Utils.assert_unique(data)
@@ -0,0 +1,21 @@
1
+ require 'time'
2
+
3
+ module WaxTasks
4
+ # Branch object for `$ wax:push` task when run on local machine
5
+ # using local credentials
6
+ #
7
+ # @attr origin [String] the current repository remote
8
+ # @attr commit_msg [String] the commit message to use on push
9
+ # @attr baseurl [String] the site baseurl to build with (if on gh-pages)
10
+ # @attr success_msg [String] informative message to be output to console
11
+ class LocalBranch < Branch
12
+ def initialize(site, target)
13
+ super(site, target)
14
+
15
+ @origin = `git config --get remote.origin.url`.strip
16
+ @commit_msg = "Updated via local task at #{Time.now.utc}"
17
+ @baseurl = "/#{@origin.split('/').last.gsub('.git', '')}"
18
+ @success_msg = "Deploying to #{@target} branch from local task."
19
+ end
20
+ end
21
+ end
@@ -50,9 +50,12 @@ module WaxTasks
50
50
  'link' => "{{'#{yaml.fetch('permalink')}' | relative_url }}",
51
51
  'collection' => @name
52
52
  }
53
- hash['content'] = File.read(page).html_strip.remove_diacritics if @content
53
+ if @content
54
+ content = WaxTasks::Utils.html_strip(File.read(page))
55
+ hash['content'] = WaxTasks::Utils.remove_diacritics(content)
56
+ end
54
57
  fields = @fields.push('pid').uniq
55
- fields.each { |f| hash[f] = yaml[f].normalize }
58
+ fields.each { |f| hash[f] = yaml[f].lunr_normalize }
56
59
  hash
57
60
  end
58
61
  end
@@ -43,7 +43,7 @@ module WaxTasks
43
43
  FileUtils.mkdir_p(@page_dir)
44
44
  pages = []
45
45
  @data.each_with_index do |item, idx|
46
- page_slug = item.fetch('pid').to_s.slug
46
+ page_slug = Utils.slug(item.fetch('pid'))
47
47
  path = "#{@page_dir}/#{page_slug}.md"
48
48
  item['permalink'] = "/#{@name}/#{page_slug}#{@site[:permalink]}"
49
49
  item['layout'] = @layout
@@ -0,0 +1,28 @@
1
+ require 'time'
2
+
3
+ module WaxTasks
4
+ # Branch object for `$ wax:push` task when run on Travis-CI VM
5
+ # using encrypted Travis environment vars
6
+ #
7
+ # @attr repo_slug [String] the 'user/repo_name'
8
+ # @attr user [String] the GitHub user making the commit/push
9
+ # @attr token [String] secret git access token
10
+ # @attr commit_msg [String] the commit message to use on push
11
+ # @attr origin [String] the current repository remote
12
+ # @attr baseurl [String] the site baseurl to build with (if on gh-pages)
13
+ # @attr success_msg [String] informative message to be output to console
14
+ class TravisBranch < Branch
15
+ def initialize(site, target)
16
+ super(site, target)
17
+
18
+ @repo_slug = ENV['TRAVIS_REPO_SLUG']
19
+ @user = @repo_slug.split('/').first
20
+ @token = ENV['ACCESS_TOKEN']
21
+
22
+ @commit_msg = "Updated via #{ENV['TRAVIS_COMMIT']} @#{Time.now.utc}"
23
+ @origin = "https://#{@user}:#{@token}@github.com/#{@repo_slug}.git"
24
+ @baseurl = "/#{@repo_slug.split('/').last}"
25
+ @success_msg = "Deploying to #{@target} branch from Travis as #{@user}."
26
+ end
27
+ end
28
+ end
@@ -89,47 +89,47 @@ module WaxTasks
89
89
  raise Error::NoLunrCollections, 'There are no lunr collections to index.' if to_index.nil?
90
90
  to_index.map { |c| c[0] }
91
91
  end
92
- end
93
- end
94
92
 
95
- # Monkey-patched String class
96
- class String
97
- # Removes YAML front matter from a string
98
- # @return [String]
99
- def remove_yaml
100
- self.gsub!(/\A---(.|\n)*?---/, '')
101
- end
93
+ # Removes YAML front matter from a string
94
+ # @return [String]
95
+ def self.remove_yaml(str)
96
+ str.to_s.gsub!(/\A---(.|\n)*?---/, '')
97
+ end
102
98
 
103
- # Cleans YAML front matter + markdown pages for lunr indexing
104
- # @return [String]
105
- def html_strip
106
- self.gsub!(/\A---(.|\n)*?---/, '') # remove yaml front matter
107
- self.gsub!(/{%(.*)%}/, '') # remove functional liquid
108
- self.gsub!(%r{<\/?[^>]*>}, '') # remove html
109
- self.gsub!('\\n', '') # remove newlines
110
- self.gsub!(/\s+/, ' ') # remove extra space
111
- self.tr!('"', "'") # replace double quotes with single
112
- self
113
- end
99
+ # Cleans YAML front matter + markdown pages for lunr indexing
100
+ # @return [String]
101
+ def self.html_strip(str)
102
+ str.gsub!(/\A---(.|\n)*?---/, '') # remove yaml front matter
103
+ str.gsub!(/{%(.*)%}/, '') # remove functional liquid
104
+ str.gsub!(%r{<\/?[^>]*>}, '') # remove html
105
+ str.gsub!('\\n', '') # remove newlines
106
+ str.gsub!(/\s+/, ' ') # remove extra space
107
+ str.tr!('"', "'") # replace double quotes with single
108
+ str
109
+ end
114
110
 
115
- # Normalizes accent marks/diacritics for Lunr indexing
116
- # @return [String]
117
- def remove_diacritics
118
- to_replace = 'ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž'
119
- replaced_by = 'AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz'
120
- self.tr(to_replace, replaced_by)
121
- end
111
+ # Normalizes accent marks/diacritics for Lunr indexing
112
+ # @return [String]
113
+ def self.remove_diacritics(str)
114
+ to_replace = 'ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž'
115
+ replaced_by = 'AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz'
116
+ str.to_s.tr(to_replace, replaced_by)
117
+ end
122
118
 
123
- # Converts string to snake case and swaps out special chars
124
- # @return [String]
125
- def slug
126
- self.downcase.tr(' ', '_').gsub(/[^\w-]/, '')
119
+ # Converts string to snake case and swaps out special chars
120
+ # @return [String]
121
+ def self.slug(str)
122
+ str.to_s.downcase.tr(' ', '_').gsub(/[^\w-]/, '')
123
+ end
127
124
  end
125
+ end
128
126
 
127
+ # Monkey-patched String class
128
+ class String
129
129
  # Normalizes string without diacritics for lunr indexing
130
130
  # @return [String]
131
- def normalize
132
- self.remove_diacritics
131
+ def lunr_normalize
132
+ WaxTasks::Utils.remove_diacritics(self)
133
133
  end
134
134
 
135
135
  # Colorizes console output to magenta (errors)
@@ -156,11 +156,11 @@ class Array
156
156
  # Normalizes an array as a string or array of hashes
157
157
  # without diacritics for lunr indexing
158
158
  # @return [Hash || String] description
159
- def normalize
159
+ def lunr_normalize
160
160
  if self.first.is_a? Hash
161
161
  self
162
162
  else
163
- self.join(', ').remove_diacritics
163
+ WaxTasks::Utils.remove_diacritics(self.join(', '))
164
164
  end
165
165
  end
166
166
  end
@@ -169,7 +169,7 @@ end
169
169
  class Hash
170
170
  # Normalizes hash as itself for lunr indexing
171
171
  # @return [Hash]
172
- def normalize
172
+ def lunr_normalize
173
173
  self
174
174
  end
175
175
 
@@ -188,7 +188,16 @@ end
188
188
  class Integer
189
189
  # Normalizes integer as a string for lunr indexing
190
190
  # @return [String]
191
- def normalize
191
+ def lunr_normalize
192
+ self.to_s
193
+ end
194
+ end
195
+
196
+ # Monkey-patched Nil class
197
+ class NilClass
198
+ # Normalizes integer as a string for lunr indexing
199
+ # @return [String]
200
+ def lunr_normalize
192
201
  self.to_s
193
202
  end
194
203
  end
data/lib/wax_tasks.rb CHANGED
@@ -2,10 +2,12 @@ require_relative 'wax_tasks/branch'
2
2
  require_relative 'wax_tasks/collection'
3
3
  require_relative 'wax_tasks/error'
4
4
  require_relative 'wax_tasks/iiif_collection'
5
+ require_relative 'wax_tasks/local_branch'
5
6
  require_relative 'wax_tasks/lunr_collection'
6
7
  require_relative 'wax_tasks/lunr_index'
7
8
  require_relative 'wax_tasks/pagemaster_collection'
8
9
  require_relative 'wax_tasks/task_runner'
10
+ require_relative 'wax_tasks/travis_branch'
9
11
  require_relative 'wax_tasks/utils'
10
12
 
11
13
  # The WaxTasks module powers the Rake tasks in `./tasks`, including:
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,6 @@
1
- # toggle stdout/stderr verbosity
2
- #
3
1
  # run $ DEBUG=true bundle exec rspec for verbose output
4
2
  # run $ bundle exec rspec for sparse output
5
- case ENV['DEBUG']
6
- when 'true' then QUIET = false
7
- else QUIET = true
8
- end
3
+ QUIET = !ENV['DEBUG']
9
4
 
10
5
  # use codecov + add requirements
11
6
  require 'simplecov'
@@ -26,12 +21,3 @@ shared_context 'shared', :shared_context => :metadata do
26
21
  let(:index_path) { 'js/lunr_index.json' }
27
22
  let(:ui_path) { 'js/lunr_ui.js'}
28
23
  end
29
-
30
- # run tests in a more intuitive order
31
- require 'tests/tasks_spec'
32
- require 'tests/task_runner_spec'
33
- require 'tests/utils_spec'
34
- require 'tests/pagemaster_collection_spec'
35
- require 'tests/lunr_collection_spec'
36
- require 'tests/iiif_collection_spec'
37
- require 'tests/branch_spec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wax_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marii Nyrop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-26 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-proofer
@@ -113,10 +113,12 @@ files:
113
113
  - lib/wax_tasks/collection.rb
114
114
  - lib/wax_tasks/error.rb
115
115
  - lib/wax_tasks/iiif_collection.rb
116
+ - lib/wax_tasks/local_branch.rb
116
117
  - lib/wax_tasks/lunr_collection.rb
117
118
  - lib/wax_tasks/lunr_index.rb
118
119
  - lib/wax_tasks/pagemaster_collection.rb
119
120
  - lib/wax_tasks/task_runner.rb
121
+ - lib/wax_tasks/travis_branch.rb
120
122
  - lib/wax_tasks/utils.rb
121
123
  - spec/setup.rb
122
124
  - spec/spec_helper.rb
@@ -146,5 +148,5 @@ signing_key:
146
148
  specification_version: 4
147
149
  summary: Rake tasks for minimal exhibition sites with Jekyll Wax.
148
150
  test_files:
149
- - spec/setup.rb
150
151
  - spec/spec_helper.rb
152
+ - spec/setup.rb