wax_tasks 0.2.0 → 0.3.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/Gemfile +2 -0
- data/lib/{wax/tasks → tasks}/iiif.rake +3 -1
- data/lib/tasks/jspackage.rake +14 -0
- data/lib/tasks/lunr.rake +9 -0
- data/lib/{wax/tasks → tasks}/pagemaster.rake +3 -2
- data/lib/tasks/push.rake +13 -0
- data/lib/{wax/tasks → tasks}/test.rake +1 -1
- data/lib/wax_tasks/branch.rb +110 -0
- data/lib/wax_tasks/collection.rb +61 -0
- data/lib/wax_tasks/error.rb +71 -0
- data/lib/wax_tasks/iiif_collection.rb +105 -0
- data/lib/wax_tasks/lunr_collection.rb +59 -0
- data/lib/wax_tasks/lunr_index.rb +67 -0
- data/lib/wax_tasks/pagemaster_collection.rb +67 -0
- data/lib/wax_tasks/task_runner.rb +132 -0
- data/lib/wax_tasks/utils.rb +194 -0
- data/lib/wax_tasks.rb +32 -24
- data/spec/setup.rb +38 -0
- data/spec/spec_helper.rb +26 -36
- metadata +21 -51
- data/lib/wax/branch.rb +0 -70
- data/lib/wax/collection.rb +0 -49
- data/lib/wax/iiif_collection.rb +0 -63
- data/lib/wax/index.rb +0 -70
- data/lib/wax/lunr_collection.rb +0 -50
- data/lib/wax/pagemaster_collection.rb +0 -40
- data/lib/wax/tasks/jspackage.rake +0 -26
- data/lib/wax/tasks/lunr.rake +0 -9
- data/lib/wax/tasks/push.rake +0 -18
- data/lib/wax/utilities.rb +0 -99
- data/spec/iiif.rb +0 -42
- data/spec/lunr.rb +0 -24
- data/spec/pagemaster.rb +0 -41
@@ -0,0 +1,132 @@
|
|
1
|
+
module WaxTasks
|
2
|
+
# Class for running the Rake tasks in ./tasks
|
3
|
+
# TaskRunner is responsible for loading and parsing the site config
|
4
|
+
# from `_config.yml`, which can be overridden with .override(opts)
|
5
|
+
#
|
6
|
+
# @attr site [Hash] main variables from site config normalized + symbolized
|
7
|
+
class TaskRunner
|
8
|
+
attr_reader :site
|
9
|
+
|
10
|
+
# Creates a new TaskRunner with a config hash or default config file
|
11
|
+
#
|
12
|
+
# @param env [String] test/prod. only affects Branch module
|
13
|
+
# @param config [Hash] optional hash, should mirror a parsed _config.yml
|
14
|
+
# @example give a custom config
|
15
|
+
# config = {
|
16
|
+
# title: 'custom title',
|
17
|
+
# url: 'custom.url',
|
18
|
+
# collections: {...}
|
19
|
+
# }
|
20
|
+
# WaxTasks::TaskRunner.new(config)
|
21
|
+
# @example use default config from file
|
22
|
+
# WaxTasks::TaskRunner.new
|
23
|
+
def initialize(config = {}, env = 'prod')
|
24
|
+
config = YAML.load_file(DEFAULT_CONFIG).symbolize_keys if config.empty?
|
25
|
+
@site = {
|
26
|
+
env: env,
|
27
|
+
title: config.fetch(:title, ''),
|
28
|
+
url: config.fetch(:url, ''),
|
29
|
+
baseurl: config.fetch(:baseurl, ''),
|
30
|
+
repo_name: config.fetch(:repo_name, ''),
|
31
|
+
source_dir: config.fetch(:source, nil),
|
32
|
+
collections_dir: config.fetch(:collections_dir, nil),
|
33
|
+
collections: config.fetch(:collections, {}),
|
34
|
+
js: config.fetch(:js, false),
|
35
|
+
permalink: Utils.construct_permalink(config)
|
36
|
+
}
|
37
|
+
rescue StandardError => e
|
38
|
+
raise Error::InvalidSiteConfig, "Could not load _config.yml. => #{e}"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Overrides a specific part of @site
|
42
|
+
#
|
43
|
+
# @param opts [Hash] part of the site config to be overwritten
|
44
|
+
# @example override title + url
|
45
|
+
# runner = WaxTasks::TaskRunner.new
|
46
|
+
# runner.override({ title: 'my new title', url: 'my-new.url' })
|
47
|
+
def override(opts)
|
48
|
+
opts.each { |k, v| @site[k] = v }
|
49
|
+
@site[:permalink] = Utils.construct_permalink(opts)
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
# Given an array of command line arguments `args`,
|
54
|
+
# creates a PagemasterCollection for each and generates markdown
|
55
|
+
# pages from its specified data `source` file
|
56
|
+
#
|
57
|
+
# @param args [Array] the arguments/collection names from wax:pagemaster
|
58
|
+
# @return [Nil]
|
59
|
+
def pagemaster(args)
|
60
|
+
args.each do |name|
|
61
|
+
PagemasterCollection.new(name, @site).generate_pages
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Creates a LunrCollection for each collection
|
66
|
+
# that has lunr_index parameters in the site config
|
67
|
+
# and generates a lunr-index.json file from the collection data
|
68
|
+
#
|
69
|
+
# @param generate_ui [Boolean] whether/not to generate a default lunr UI
|
70
|
+
# @return [Nil]
|
71
|
+
def lunr(generate_ui = false)
|
72
|
+
lunr_collections = Utils.get_lunr_collections(@site)
|
73
|
+
lunr_collections.map! { |name| LunrCollection.new(name, @site) }
|
74
|
+
|
75
|
+
index = LunrIndex.new(lunr_collections)
|
76
|
+
index_path = Utils.make_path(@site[:source_dir], LUNR_INDEX_PATH)
|
77
|
+
|
78
|
+
FileUtils.mkdir_p(File.dirname(index_path))
|
79
|
+
File.open(index_path, 'w') { |f| f.write(index.to_s) }
|
80
|
+
|
81
|
+
ui_path = Utils.make_path(@site[:source_dir], LUNR_UI_PATH)
|
82
|
+
File.open(ui_path, 'w') { |f| f.write(index.default_ui) } if generate_ui
|
83
|
+
end
|
84
|
+
|
85
|
+
# Given an array of command line arguments `args`,
|
86
|
+
# creates a IiifCollection for each and generates iiif
|
87
|
+
# derivative images, manifests, etc. from source image files
|
88
|
+
#
|
89
|
+
# @param args [Array] the arguments/collection names from wax:pagemaster
|
90
|
+
# @return [Nil]
|
91
|
+
def iiif(args)
|
92
|
+
args.each do |name|
|
93
|
+
IiifCollection.new(name, @site).process
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Finds the JS dependencies listed in site config and
|
98
|
+
# writes them to a package.json file
|
99
|
+
# in orderto easily track / monitor / update them
|
100
|
+
#
|
101
|
+
# @return [Nil]
|
102
|
+
def js_package
|
103
|
+
names = []
|
104
|
+
package = {
|
105
|
+
'name' => site[:title],
|
106
|
+
'version' => '1.0.0',
|
107
|
+
'dependencies' => {}
|
108
|
+
}
|
109
|
+
site[:js].each do |dependency|
|
110
|
+
name = dependency[0]
|
111
|
+
names << name
|
112
|
+
version = dependency[1]['version']
|
113
|
+
package['dependencies'][name] = '^' + version
|
114
|
+
end
|
115
|
+
package
|
116
|
+
end
|
117
|
+
|
118
|
+
# Constructs a TravisBranch or LocalBranch object
|
119
|
+
# with appropriate Git credentials and pushes
|
120
|
+
# the compiled Jekyll site to the target GitHub branch
|
121
|
+
#
|
122
|
+
# @param target [String] the name of the Git branch to deploy to
|
123
|
+
# @return [Nil]
|
124
|
+
def push_branch(target)
|
125
|
+
if ENV.fetch('CI', false)
|
126
|
+
TravisBranch.new(self.site, target).push
|
127
|
+
else
|
128
|
+
LocalBranch.new(self.site, target).push
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
module WaxTasks
|
2
|
+
# Utility helper methods
|
3
|
+
module Utils
|
4
|
+
# Contructs permalink extension from site `permalink` variable
|
5
|
+
#
|
6
|
+
# @param site [Hash] the site config
|
7
|
+
# @return [String] the end of the permalink, either '/' or '.html'
|
8
|
+
def self.construct_permalink(site)
|
9
|
+
case site.fetch(:permalink, false)
|
10
|
+
when 'pretty' || '/'
|
11
|
+
'/'
|
12
|
+
else
|
13
|
+
'.html'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Checks and asserts presence of `pid` value for each item
|
18
|
+
#
|
19
|
+
# @param data [Array] array of hashes each representing a collection item
|
20
|
+
# @return [Array] same data unless a an item is missing the key `pid`
|
21
|
+
# @raise WaxTasks::Error::MissingPid
|
22
|
+
def self.assert_pids(data)
|
23
|
+
data.each_with_index { |d, i| raise Error::MissingPid, "Collection #{@name} is missing pid for item #{i}." unless d.key? 'pid' }
|
24
|
+
data
|
25
|
+
end
|
26
|
+
|
27
|
+
# Checks and asserts uniqueness of `pid` value for each item
|
28
|
+
#
|
29
|
+
# @param data [Array] array of hashes each representing a collection item
|
30
|
+
# @return [Array] same data unless an item has non-unique value for `pid`
|
31
|
+
# @raise WaxTasks::Error::NonUniquePid
|
32
|
+
def self.assert_unique(data)
|
33
|
+
pids = data.map { |d| d['pid'] }
|
34
|
+
not_unique = pids.select { |p| pids.count(p) > 1 }.uniq! || []
|
35
|
+
raise Error::NonUniquePid, "#{@name} has the following nonunique pids:\n#{not_unique}" unless not_unique.empty?
|
36
|
+
data
|
37
|
+
end
|
38
|
+
|
39
|
+
# Checks that a CSV file is valid
|
40
|
+
#
|
41
|
+
# @param source [String] path to CSV file
|
42
|
+
# @return [Array] validated CSV data as an Array of Hashes
|
43
|
+
# @raise WaxTasks::Error::InvalidCSV
|
44
|
+
def self.validate_csv(source)
|
45
|
+
CSV.read(source, headers: true).map(&:to_hash)
|
46
|
+
rescue StandardError => e
|
47
|
+
raise Error::InvalidCSV, " #{e}"
|
48
|
+
end
|
49
|
+
|
50
|
+
# Checks that a JSON file is valid
|
51
|
+
#
|
52
|
+
# @param source [String] path to JSON file
|
53
|
+
# @return [Array] validated JSON data as an Array of Hashes
|
54
|
+
# @raise WaxTasks::Error::InvalidJSON
|
55
|
+
def self.validate_json(source)
|
56
|
+
file = File.read(source)
|
57
|
+
JSON.parse(file)
|
58
|
+
rescue StandardError => e
|
59
|
+
raise Error::InvalidJSON, " #{e}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Checks that a YAML file is valid
|
63
|
+
#
|
64
|
+
# @param source [String] path to YAML file
|
65
|
+
# @return [Array] validated YAML data as an Array of Hashes
|
66
|
+
# @raise WaxTasks::Error::InvalidYAML
|
67
|
+
def self.validate_yaml(source)
|
68
|
+
YAML.load_file(source)
|
69
|
+
rescue StandardError => e
|
70
|
+
raise WaxTasks::Error::InvalidYAML, " #{e}"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Creates a file path valid file path with empty strings and
|
74
|
+
# null values dropped
|
75
|
+
#
|
76
|
+
# @param args [Array] items to concatenate in path
|
77
|
+
# @return [String] file path
|
78
|
+
def self.make_path(*args)
|
79
|
+
args.compact.reject(&:empty?).join('/')
|
80
|
+
end
|
81
|
+
|
82
|
+
# Finds collections in site config where `lunr_index` is enabled
|
83
|
+
#
|
84
|
+
# @param site [Hash] the site config
|
85
|
+
# @return [Array] a list of collection names
|
86
|
+
# @raise WaxTasks::Error::NoLunrCollections
|
87
|
+
def self.get_lunr_collections(site)
|
88
|
+
to_index = site[:collections].find_all { |c| c[1].key?('lunr_index') }
|
89
|
+
raise Error::NoLunrCollections, 'There are no lunr collections to index.' if to_index.nil?
|
90
|
+
to_index.map { |c| c[0] }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
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
|
102
|
+
|
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
|
114
|
+
|
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
|
122
|
+
|
123
|
+
# Converts string to snake case and swaps out special chars
|
124
|
+
# @return [String]
|
125
|
+
def slug
|
126
|
+
self.downcase.tr(' ', '_').gsub(/[^\w-]/, '')
|
127
|
+
end
|
128
|
+
|
129
|
+
# Normalizes string without diacritics for lunr indexing
|
130
|
+
# @return [String]
|
131
|
+
def normalize
|
132
|
+
self.remove_diacritics
|
133
|
+
end
|
134
|
+
|
135
|
+
# Colorizes console output to magenta (errors)
|
136
|
+
# @return [String]
|
137
|
+
def magenta
|
138
|
+
"\e[35m#{self}\e[0m"
|
139
|
+
end
|
140
|
+
|
141
|
+
# Colorizes console output to cyan (messages)
|
142
|
+
# @return [String]
|
143
|
+
def cyan
|
144
|
+
"\e[36m#{self}\e[0m"
|
145
|
+
end
|
146
|
+
|
147
|
+
# Colorizes console output to orange (warnings)
|
148
|
+
# @return [String]
|
149
|
+
def orange
|
150
|
+
"\e[33m#{self}\e[0m"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Monkey-patched Array class
|
155
|
+
class Array
|
156
|
+
# Normalizes an array as a string or array of hashes
|
157
|
+
# without diacritics for lunr indexing
|
158
|
+
# @return [Hash || String] description
|
159
|
+
def normalize
|
160
|
+
if self.first.is_a? Hash
|
161
|
+
self
|
162
|
+
else
|
163
|
+
self.join(', ').remove_diacritics
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# Monkey-patched Hash class
|
169
|
+
class Hash
|
170
|
+
# Normalizes hash as itself for lunr indexing
|
171
|
+
# @return [Hash]
|
172
|
+
def normalize
|
173
|
+
self
|
174
|
+
end
|
175
|
+
|
176
|
+
# Converts hash keys to symbols
|
177
|
+
# @return [Hash]
|
178
|
+
def symbolize_keys
|
179
|
+
hash = self
|
180
|
+
hash.clone.each_key do |key|
|
181
|
+
hash[key.to_sym || key] = hash.delete(key)
|
182
|
+
end
|
183
|
+
hash
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# Monkey-patched Integer class
|
188
|
+
class Integer
|
189
|
+
# Normalizes integer as a string for lunr indexing
|
190
|
+
# @return [String]
|
191
|
+
def normalize
|
192
|
+
self.to_s
|
193
|
+
end
|
194
|
+
end
|
data/lib/wax_tasks.rb
CHANGED
@@ -1,27 +1,35 @@
|
|
1
|
-
|
1
|
+
require_relative 'wax_tasks/branch'
|
2
|
+
require_relative 'wax_tasks/collection'
|
3
|
+
require_relative 'wax_tasks/error'
|
4
|
+
require_relative 'wax_tasks/iiif_collection'
|
5
|
+
require_relative 'wax_tasks/lunr_collection'
|
6
|
+
require_relative 'wax_tasks/lunr_index'
|
7
|
+
require_relative 'wax_tasks/pagemaster_collection'
|
8
|
+
require_relative 'wax_tasks/task_runner'
|
9
|
+
require_relative 'wax_tasks/utils'
|
2
10
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
#
|
11
|
+
# The WaxTasks module powers the Rake tasks in `./tasks`, including:
|
12
|
+
#
|
13
|
+
# wax:pagemaster :: generate collection md pages from csv, json, or yaml file
|
14
|
+
# wax:lunr :: build lunr search index (with default UI if UI=true)
|
15
|
+
# wax:iiif :: generate iiif derivatives from local image files
|
16
|
+
# wax:jspackage :: write a simple package.json for monitoring js dependencies
|
17
|
+
# wax:push :: push compiled Jekyll site to git branch
|
18
|
+
# wax:test :: run htmlproofer, rspec if .rspec file exists
|
19
|
+
#
|
20
|
+
# Tasks are run by a WaxTasks::TaskRunner object which is resposible
|
21
|
+
# for reading in site config from `_config.yml`
|
12
22
|
module WaxTasks
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
s_conf
|
26
|
-
end
|
23
|
+
# ----------
|
24
|
+
# CONSTANTS
|
25
|
+
# ----------
|
26
|
+
|
27
|
+
# @return [String] The path to load Jekyll site config
|
28
|
+
DEFAULT_CONFIG = '_config.yml'.freeze
|
29
|
+
# @return [String] The path to write WaxTasks::LunrIndex
|
30
|
+
LUNR_INDEX_PATH = 'js/lunr_index.json'.freeze
|
31
|
+
# @return [String] The path to write default LunrUI
|
32
|
+
LUNR_UI_PATH = 'js/lunr_ui.js'.freeze
|
33
|
+
# @return [String] The path to the compiled Jekyll site
|
34
|
+
SITE_DIR = './_site'.freeze
|
27
35
|
end
|
data/spec/setup.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
#constants
|
4
|
+
ROOT = `pwd`.strip.freeze
|
5
|
+
SAMPLE = "#{ROOT}/spec/sample_site".freeze
|
6
|
+
BUILD = "#{ROOT}/build".freeze
|
7
|
+
|
8
|
+
# helper methods
|
9
|
+
def quiet_stdout
|
10
|
+
if QUIET
|
11
|
+
begin
|
12
|
+
orig_stderr = $stderr.clone
|
13
|
+
orig_stdout = $stdout.clone
|
14
|
+
$stderr.reopen File.new('/dev/null', 'w')
|
15
|
+
$stdout.reopen File.new('/dev/null', 'w')
|
16
|
+
retval = yield
|
17
|
+
rescue StandardError => e
|
18
|
+
$stdout.reopen orig_stdout
|
19
|
+
$stderr.reopen orig_stderr
|
20
|
+
raise e
|
21
|
+
ensure
|
22
|
+
$stdout.reopen orig_stdout
|
23
|
+
$stderr.reopen orig_stderr
|
24
|
+
end
|
25
|
+
retval
|
26
|
+
else
|
27
|
+
yield
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module WaxTasks::Test
|
32
|
+
def self.reset
|
33
|
+
Dir.chdir(ROOT)
|
34
|
+
FileUtils.rm_r(BUILD) if File.directory?(BUILD)
|
35
|
+
FileUtils.copy_entry SAMPLE, BUILD
|
36
|
+
Dir.chdir(BUILD)
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,47 +1,37 @@
|
|
1
1
|
# toggle stdout/stderr verbosity
|
2
|
-
|
2
|
+
#
|
3
|
+
# run $ DEBUG=true bundle exec rspec for verbose output
|
4
|
+
# run $ bundle exec rspec for sparse output
|
5
|
+
case ENV['DEBUG']
|
6
|
+
when 'true' then QUIET = false
|
7
|
+
else QUIET = true
|
8
|
+
end
|
3
9
|
|
4
10
|
# use codecov + add requirements
|
5
11
|
require 'simplecov'
|
6
12
|
SimpleCov.start do
|
7
13
|
add_filter 'spec'
|
8
|
-
add_filter 'utilities'
|
9
14
|
add_filter 'branch'
|
10
15
|
end
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# run specs
|
25
|
-
require_relative 'pagemaster'
|
26
|
-
require_relative 'lunr'
|
27
|
-
require_relative 'iiif'
|
28
|
-
|
29
|
-
describe 'jekyll' do
|
30
|
-
it 'builds successfully' do
|
31
|
-
quiet_stdout { Bundler.with_clean_env { system('bundle exec jekyll build') } }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'wax:jspackage' do
|
36
|
-
it 'writes a package.json file' do
|
37
|
-
quiet_stdout { system('bundle exec rake wax:jspackage') }
|
38
|
-
package = File.open('package.json', 'r').read
|
39
|
-
expect(package.length > 90)
|
40
|
-
end
|
17
|
+
# load + setup
|
18
|
+
require 'wax_tasks'
|
19
|
+
require 'setup'
|
20
|
+
|
21
|
+
# provide shared context for tests
|
22
|
+
shared_context 'shared', :shared_context => :metadata do
|
23
|
+
let(:task_runner) { WaxTasks::TaskRunner.new }
|
24
|
+
let(:default_site) { task_runner.site }
|
25
|
+
let(:args) { default_site[:collections].map{ |c| c[0] } }
|
26
|
+
let(:index_path) { 'js/lunr_index.json' }
|
27
|
+
let(:ui_path) { 'js/lunr_ui.js'}
|
41
28
|
end
|
42
29
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wax_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: colorize
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.8'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.8'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: html-proofer
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +80,6 @@ dependencies:
|
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '1'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: faker
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: rspec
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +94,7 @@ dependencies:
|
|
122
94
|
- - "~>"
|
123
95
|
- !ruby/object:Gem::Version
|
124
96
|
version: '3'
|
125
|
-
description: Rake tasks for minimal
|
97
|
+
description: Rake tasks for minimal exhibition sites with Jekyll Wax.
|
126
98
|
email:
|
127
99
|
- m.nyrop@columbia.edu
|
128
100
|
executables: []
|
@@ -130,23 +102,23 @@ extensions: []
|
|
130
102
|
extra_rdoc_files: []
|
131
103
|
files:
|
132
104
|
- Gemfile
|
133
|
-
- lib/
|
134
|
-
- lib/
|
135
|
-
- lib/
|
136
|
-
- lib/
|
137
|
-
- lib/
|
138
|
-
- lib/
|
139
|
-
- lib/wax/tasks/iiif.rake
|
140
|
-
- lib/wax/tasks/jspackage.rake
|
141
|
-
- lib/wax/tasks/lunr.rake
|
142
|
-
- lib/wax/tasks/pagemaster.rake
|
143
|
-
- lib/wax/tasks/push.rake
|
144
|
-
- lib/wax/tasks/test.rake
|
145
|
-
- lib/wax/utilities.rb
|
105
|
+
- lib/tasks/iiif.rake
|
106
|
+
- lib/tasks/jspackage.rake
|
107
|
+
- lib/tasks/lunr.rake
|
108
|
+
- lib/tasks/pagemaster.rake
|
109
|
+
- lib/tasks/push.rake
|
110
|
+
- lib/tasks/test.rake
|
146
111
|
- lib/wax_tasks.rb
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
112
|
+
- lib/wax_tasks/branch.rb
|
113
|
+
- lib/wax_tasks/collection.rb
|
114
|
+
- lib/wax_tasks/error.rb
|
115
|
+
- lib/wax_tasks/iiif_collection.rb
|
116
|
+
- lib/wax_tasks/lunr_collection.rb
|
117
|
+
- lib/wax_tasks/lunr_index.rb
|
118
|
+
- lib/wax_tasks/pagemaster_collection.rb
|
119
|
+
- lib/wax_tasks/task_runner.rb
|
120
|
+
- lib/wax_tasks/utils.rb
|
121
|
+
- spec/setup.rb
|
150
122
|
- spec/spec_helper.rb
|
151
123
|
homepage: https://github.com/minicomp/wax_tasks
|
152
124
|
licenses:
|
@@ -172,9 +144,7 @@ rubyforge_project:
|
|
172
144
|
rubygems_version: 2.7.6
|
173
145
|
signing_key:
|
174
146
|
specification_version: 4
|
175
|
-
summary: Rake tasks for minimal
|
147
|
+
summary: Rake tasks for minimal exhibition sites with Jekyll Wax.
|
176
148
|
test_files:
|
149
|
+
- spec/setup.rb
|
177
150
|
- spec/spec_helper.rb
|
178
|
-
- spec/iiif.rb
|
179
|
-
- spec/pagemaster.rb
|
180
|
-
- spec/lunr.rb
|
data/lib/wax/branch.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'colorize'
|
2
|
-
require 'jekyll'
|
3
|
-
require 'tmpdir'
|
4
|
-
require 'time'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
# methods for building/pushing git branches
|
8
|
-
module Branch
|
9
|
-
def build(baseurl)
|
10
|
-
FileUtils.rm_rf('_site')
|
11
|
-
opts = {
|
12
|
-
source: '.',
|
13
|
-
destination: '_site',
|
14
|
-
config: '_config.yml',
|
15
|
-
baseurl: baseurl,
|
16
|
-
verbose: true
|
17
|
-
}
|
18
|
-
Jekyll::Site.new(Jekyll.configuration(opts)).process
|
19
|
-
end
|
20
|
-
|
21
|
-
def push
|
22
|
-
abort "Cannot find _site.".magenta unless Dir.exist? '_site'
|
23
|
-
Dir.chdir('./_site')
|
24
|
-
system 'git init && git add .'
|
25
|
-
system "git commit -m '#{@commit_msg}'"
|
26
|
-
system "git remote add origin #{@origin}"
|
27
|
-
system "git push origin master:refs/heads/#{TARGET} --force"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# configure git branches from travis info
|
32
|
-
class TravisBranch
|
33
|
-
include Branch
|
34
|
-
|
35
|
-
def initialize
|
36
|
-
@repo_slug = ENV['TRAVIS_REPO_SLUG']
|
37
|
-
@user = @repo_slug.split('/')[0]
|
38
|
-
@repo_name = '1' + @repo_slug.split('/')[1]
|
39
|
-
@token = ENV['ACCESS_TOKEN']
|
40
|
-
@commit_msg = "Site updated via #{ENV['TRAVIS_COMMIT']} at #{Time.now.utc}"
|
41
|
-
@origin = "https://#{@user}:#{@token}@github.com/#{@repo_slug}.git"
|
42
|
-
|
43
|
-
puts "Deploying to #{TARGET} branch from Travis as #{@user}.".cyan
|
44
|
-
end
|
45
|
-
|
46
|
-
def build_gh_site
|
47
|
-
abort 'You must add the gh-baseurl to config.' if @repo_name.nil?
|
48
|
-
build(@repo_name)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# configure git branches from local info
|
53
|
-
class LocalBranch
|
54
|
-
include Branch
|
55
|
-
|
56
|
-
attr_reader :origin, :commit_msg
|
57
|
-
|
58
|
-
def initialize
|
59
|
-
@origin = `git config --get remote.origin.url`
|
60
|
-
@commit_msg = "Site updated via local task at #{Time.now.utc}"
|
61
|
-
puts "Deploying to #{TARGET} branch from local task.".cyan
|
62
|
-
end
|
63
|
-
|
64
|
-
def build_gh_site
|
65
|
-
abort "Cannot load config.".magenta unless CONFIG
|
66
|
-
baseurl = CONFIG.fetch('gh-baseurl', false)
|
67
|
-
abort "You must add the gh-baseurl to config.".magenta unless baseurl
|
68
|
-
build(baseurl)
|
69
|
-
end
|
70
|
-
end
|