wax_tasks 0.0.3 → 0.0.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tasks/config.rake +1 -2
- data/lib/tasks/ghbranch.rake +1 -4
- data/lib/tasks/iiif.rake +12 -10
- data/lib/tasks/lunr.rake +2 -2
- data/lib/tasks/pagemaster.rake +3 -5
- data/lib/tasks/s3branch.rake +2 -20
- data/lib/tasks/test.rake +1 -1
- data/lib/{wax_collection.rb → wax_tasks/collection.rb} +5 -12
- data/lib/{helpers.rb → wax_tasks/helpers.rb} +4 -7
- data/lib/{lunr_index.rb → wax_tasks/index.rb} +6 -8
- data/lib/wax_tasks.rb +7 -0
- data/spec/spec_helper.rb +7 -7
- metadata +41 -54
- data/spec/fake_data.rb +0 -43
- data/spec/fake_helpers.rb +0 -22
- data/spec/fake_site.rb +0 -27
- data/spec/test_config.rb +0 -28
- data/spec/test_iiif.rb +0 -20
- data/spec/test_lunr.rb +0 -24
- data/spec/test_pagemaster.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e575498bcfd76bd5bd11705d9d6cac510a422eb
|
4
|
+
data.tar.gz: 725bae639d3bbb4ed57bdb0d79e9fb8147c85324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c120c938aaf9778d1061749c2f9f38e0899ba4b56dd20ae97c08a34b3a15a77766f481b91efa43b6612295210368260613f9b79be2d863a7d90f35bc9accb16
|
7
|
+
data.tar.gz: 3f71b6b7e531c01f2d8d22aa2ef03d0c053f96a8e5dd9938e352226c0325e75a8c5e2b7fbf58cdf7d4ec3c76d588cd0ac5ad122d90de4e1d766f938d2adbcd35
|
data/lib/tasks/config.rake
CHANGED
data/lib/tasks/ghbranch.rake
CHANGED
data/lib/tasks/iiif.rake
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
-
require '
|
1
|
+
require 'wax_tasks'
|
2
2
|
require 'iiif_s3'
|
3
3
|
|
4
4
|
namespace :wax do
|
5
5
|
task :iiif => :config do
|
6
6
|
abort "You must specify a collections after 'bundle exec rake wax:iiif'.".magenta if $argv.empty?
|
7
|
-
|
7
|
+
outputdir = './iiif'
|
8
|
+
FileUtils.mkdir outputdir
|
8
9
|
all_records = []
|
9
10
|
id_counter = 0
|
10
11
|
build_opts = {
|
11
|
-
:base_url => $config['baseurl'] + '/
|
12
|
-
:output_dir =>
|
12
|
+
:base_url => $config['baseurl'] + '/iiif',
|
13
|
+
:output_dir => outputdir,
|
13
14
|
:tile_scale_factors => [1, 2],
|
14
15
|
:verbose => true
|
15
16
|
}
|
16
17
|
$argv.each do |a|
|
17
18
|
id_counter += 1
|
18
|
-
|
19
|
-
|
19
|
+
inpath = './_iiif_source/' + a
|
20
|
+
abort "Source path '#{inpath}' does not exist. Exiting.".magenta unless Dir.exist?(inpath)
|
21
|
+
paged = $config['collections'][a]['iiif_paged'] == true
|
22
|
+
collection_records = make_records(a, inpath, paged)
|
20
23
|
all_records.concat collection_records
|
21
|
-
abort "Source path '#{dirpath}' does not exist. Exiting.".magenta unless Dir.exist?(dirpath)
|
22
24
|
end
|
23
25
|
builder = IiifS3::Builder.new(build_opts)
|
24
26
|
builder.load(all_records)
|
@@ -26,15 +28,15 @@ namespace :wax do
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
def make_records(collection_name)
|
31
|
+
def make_records(collection_name, inpath, paged)
|
30
32
|
counter = 1
|
31
33
|
collection_records = []
|
32
|
-
imagefiles = Dir[
|
34
|
+
imagefiles = Dir[inpath + '/*'].sort!
|
33
35
|
imagefiles.each do |imagefile|
|
34
36
|
basename = File.basename(imagefile, '.*').to_s
|
35
37
|
record_opts = {
|
36
38
|
:id => collection_name + '-' + basename,
|
37
|
-
:is_document =>
|
39
|
+
:is_document => paged,
|
38
40
|
:path => imagefile,
|
39
41
|
:label => $config['title'] + ' - ' + collection_name + ' - ' + basename
|
40
42
|
}
|
data/lib/tasks/lunr.rake
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'wax_tasks'
|
2
2
|
|
3
3
|
namespace :wax do
|
4
4
|
desc 'build lunr search index'
|
5
5
|
task :lunr => :config do
|
6
6
|
collections = $config['collections']
|
7
7
|
lunr_language = $config['lunr_language']
|
8
|
-
index =
|
8
|
+
index = Index.new(collections, lunr_language)
|
9
9
|
|
10
10
|
Dir.mkdir('js') unless File.exist?('js')
|
11
11
|
File.open('js/lunr-index.js', 'w') { |file| file.write(index.output) }
|
data/lib/tasks/pagemaster.rake
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'wax_collection'
|
3
|
-
require 'helpers'
|
1
|
+
require 'wax_tasks'
|
4
2
|
|
5
3
|
namespace :wax do
|
6
4
|
desc 'generate collection md pages from yaml or csv data source'
|
@@ -11,8 +9,8 @@ namespace :wax do
|
|
11
9
|
else
|
12
10
|
$argv.each do |collection_name|
|
13
11
|
collection_config = valid_pagemaster(collection_name)
|
14
|
-
collections_dir = $config['collections_dir'].nil? ? '' : $config
|
15
|
-
collection =
|
12
|
+
collections_dir = $config['collections_dir'].nil? ? '' : $config.fetch('collections_dir').to_s + '/'
|
13
|
+
collection = Collection.new(collection_name, collection_config, collections_dir)
|
16
14
|
collection.pagemaster
|
17
15
|
end
|
18
16
|
end
|
data/lib/tasks/s3branch.rake
CHANGED
@@ -1,30 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require 'tmpdir'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'time'
|
1
|
+
require 'wax_tasks'
|
5
2
|
|
6
3
|
namespace :wax do
|
7
4
|
desc 'build site with baseurl and publish to s3 branch'
|
8
|
-
task :s3branch
|
9
|
-
FileUtils.rm_rf('_site')
|
10
|
-
|
11
|
-
opts = {
|
12
|
-
'source' => '.',
|
13
|
-
'destination' => '_site',
|
14
|
-
'config' => '_config.yml',
|
15
|
-
'incremental' => true,
|
16
|
-
'verbose' => true,
|
17
|
-
'baseurl' => $config['baseurl']
|
18
|
-
}
|
19
|
-
|
20
|
-
Jekyll::Site.new(Jekyll.configuration(opts)).process
|
21
|
-
|
5
|
+
task :s3branch do
|
22
6
|
origin = `git config --get remote.origin.url`
|
23
|
-
|
24
7
|
Dir.mktmpdir do |tmp|
|
25
8
|
cp_r '_site/.', tmp
|
26
9
|
Dir.chdir tmp
|
27
|
-
|
28
10
|
system 'git init' # Init the repo.
|
29
11
|
system "git add . && git commit -m 'Site updated at #{Time.now.utc}'"
|
30
12
|
system 'git remote add origin ' + origin
|
data/lib/tasks/test.rake
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'csv'
|
3
|
-
require 'json'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'colorized_string'
|
6
|
-
require 'helpers'
|
7
|
-
|
8
1
|
include FileUtils
|
9
2
|
|
10
|
-
#
|
11
|
-
class
|
3
|
+
# initializes a wax collection for use with pagemaster,lunr,and iiif tasks
|
4
|
+
class Collection
|
12
5
|
attr_reader :name, :config, :src, :layout, :dir, :data
|
13
6
|
|
14
7
|
def initialize(collection_name, collection_config, collections_dir)
|
15
8
|
@name = collection_name
|
16
9
|
@config = collection_config
|
17
10
|
@cdir = collections_dir
|
18
|
-
@src = '_data/' + @config
|
19
|
-
@layout = File.basename(@config
|
11
|
+
@src = '_data/' + @config.fetch('source')
|
12
|
+
@layout = File.basename(@config.fetch('layout'), '.*')
|
20
13
|
@dir = @cdir + '_' + @name
|
21
14
|
@data = []
|
22
15
|
@lunr = {}
|
@@ -49,7 +42,7 @@ class WaxCollection
|
|
49
42
|
completed = 0
|
50
43
|
skipped = 0
|
51
44
|
data.each do |item|
|
52
|
-
pagename = slug(item
|
45
|
+
pagename = slug(item.fetch('pid'))
|
53
46
|
pagepath = @dir + '/' + pagename + '.md'
|
54
47
|
permalink = '/' + @name + '/' + pagename + perma_ext
|
55
48
|
if File.exist?(pagepath)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'colorized_string'
|
2
|
-
|
3
1
|
def clean(str)
|
4
2
|
str.gsub!(/\A---(.|\n)*?---/, '') # remove yaml front matter
|
5
3
|
str.gsub!(/{%(.*)%}/, '') # remove functional liquid
|
@@ -11,11 +9,10 @@ def clean(str)
|
|
11
9
|
end
|
12
10
|
|
13
11
|
def valid_pagemaster(collection_name)
|
14
|
-
c = $config
|
15
|
-
abort "Cannot find the collection '#{collection_name}' in _config.yml. Exiting.".magenta if c.nil?
|
16
|
-
abort "Cannot find '
|
17
|
-
abort "Cannot find
|
18
|
-
abort "Cannot find the file '#{'_data/' + c['source']}'. Exiting.".magenta unless File.file?('_data/' + c['source'])
|
12
|
+
c = $config.fetch('collections').fetch(collection_name)
|
13
|
+
abort "Cannot find 'source' for the collection '#{collection_name}' in _config.yml. Exiting.".magenta if c.fetch('source').nil?
|
14
|
+
abort "Cannot find 'layout' for the collection '#{collection_name}' in _config.yml. Exiting.".magenta if c.fetch('layout').nil?
|
15
|
+
abort "Cannot find the file '#{'_data/' + c['source']}'. Exiting.".magenta unless File.file?('_data/' + c.fetch('source'))
|
19
16
|
c
|
20
17
|
end
|
21
18
|
|
@@ -1,15 +1,13 @@
|
|
1
|
-
|
2
|
-
require 'colorized_string'
|
3
|
-
require 'helpers'
|
1
|
+
include FileUtils
|
4
2
|
|
5
|
-
#
|
6
|
-
class
|
3
|
+
# initializes a lunr index to be output to js/lunr-index.js
|
4
|
+
class Index
|
7
5
|
attr_reader :output
|
8
6
|
|
9
7
|
def initialize(collections, lunr_language)
|
10
8
|
@collections = collections
|
11
9
|
@lunr_language = lunr_language
|
12
|
-
@cdir = $config['collections_dir'].nil? ? '' : $config
|
10
|
+
@cdir = $config['collections_dir'].nil? ? '' : $config.fetch('collections_dir') + '/'
|
13
11
|
@lunr_collections = []
|
14
12
|
@total_fields = []
|
15
13
|
@output = ''
|
@@ -52,9 +50,9 @@ class LunrIndex
|
|
52
50
|
yaml = YAML.load_file(page)
|
53
51
|
hash = {
|
54
52
|
'lunr_id' => count,
|
55
|
-
'link' => "{{'" + yaml
|
53
|
+
'link' => "{{'" + yaml.fetch('permalink') + "' | relative_url }}"
|
56
54
|
}
|
57
|
-
fields.each { |f| hash[f] = rm_diacritics(yaml[f]) }
|
55
|
+
fields.each { |f| hash[f] = rm_diacritics(yaml[f].to_s) }
|
58
56
|
hash['content'] = rm_diacritics(clean(File.read(page))) if c[1]['lunr_index']['content']
|
59
57
|
@output += "\nindex.addDoc(" + hash.to_json + "); "
|
60
58
|
store_string += "\n" + hash.to_json + ", "
|
data/lib/wax_tasks.rb
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
1
|
+
require 'fake/helpers'
|
2
|
+
require 'fake/site'
|
3
|
+
require 'fake/data'
|
4
|
+
require 'test/config'
|
5
|
+
require 'test/pagemaster'
|
6
|
+
require 'test/lunr'
|
7
|
+
require 'test/iiif'
|
metadata
CHANGED
@@ -1,141 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wax_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.40
|
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-02-
|
11
|
+
date: 2018-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: colorize
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '0.8'
|
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: '
|
26
|
+
version: '0.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: html-proofer
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
33
|
+
version: '3.0'
|
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: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: iiif_s3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
47
|
+
version: '0.1'
|
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: '
|
54
|
+
version: '0.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: jekyll
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
type: :
|
61
|
+
version: '3.7'
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.7'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
75
|
+
version: '12.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
82
|
+
version: '12.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
-
type: :
|
89
|
+
version: '1.16'
|
90
|
+
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.16'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: faker
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
104
|
-
type: :
|
103
|
+
version: '1.8'
|
104
|
+
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1.8'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
118
|
-
type: :
|
117
|
+
version: '3.5'
|
118
|
+
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
124
|
+
version: '3.5'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: rubocop
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
132
|
-
type: :
|
131
|
+
version: '0.52'
|
132
|
+
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '0.52'
|
139
139
|
description: Rake tasks for minimal iiif exhibition sites with Jekyll.
|
140
140
|
email:
|
141
141
|
- m.nyrop@columbia.edu
|
@@ -144,8 +144,6 @@ extensions: []
|
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
146
|
- Gemfile
|
147
|
-
- lib/helpers.rb
|
148
|
-
- lib/lunr_index.rb
|
149
147
|
- lib/tasks/config.rake
|
150
148
|
- lib/tasks/ghbranch.rake
|
151
149
|
- lib/tasks/iiif.rake
|
@@ -153,15 +151,11 @@ files:
|
|
153
151
|
- lib/tasks/pagemaster.rake
|
154
152
|
- lib/tasks/s3branch.rake
|
155
153
|
- lib/tasks/test.rake
|
156
|
-
- lib/
|
157
|
-
-
|
158
|
-
-
|
159
|
-
-
|
154
|
+
- lib/wax_tasks.rb
|
155
|
+
- lib/wax_tasks/collection.rb
|
156
|
+
- lib/wax_tasks/helpers.rb
|
157
|
+
- lib/wax_tasks/index.rb
|
160
158
|
- spec/spec_helper.rb
|
161
|
-
- spec/test_config.rb
|
162
|
-
- spec/test_iiif.rb
|
163
|
-
- spec/test_lunr.rb
|
164
|
-
- spec/test_pagemaster.rb
|
165
159
|
homepage: https://github.com/mnyrop/wax_tasks
|
166
160
|
licenses:
|
167
161
|
- MIT
|
@@ -188,10 +182,3 @@ specification_version: 4
|
|
188
182
|
summary: Rake tasks for minimal exhibitions.
|
189
183
|
test_files:
|
190
184
|
- spec/spec_helper.rb
|
191
|
-
- spec/test_iiif.rb
|
192
|
-
- spec/test_config.rb
|
193
|
-
- spec/test_lunr.rb
|
194
|
-
- spec/fake_helpers.rb
|
195
|
-
- spec/fake_data.rb
|
196
|
-
- spec/fake_site.rb
|
197
|
-
- spec/test_pagemaster.rb
|
data/spec/fake_data.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'csv'
|
2
|
-
require 'faker'
|
3
|
-
require 'json'
|
4
|
-
require 'rake'
|
5
|
-
|
6
|
-
# make csvs
|
7
|
-
I18n.enforce_available_locales = false
|
8
|
-
Faker::Config.locale = 'zh-CN'
|
9
|
-
Dir.mkdir('_data') unless File.exist?('_data')
|
10
|
-
|
11
|
-
def fake_data(name, type)
|
12
|
-
data = []
|
13
|
-
keys = ['pid']
|
14
|
-
5.times { keys << slug(Faker::Lovecraft.unique.word) } # keys = pid + 5
|
15
|
-
5.times do # with 5 records
|
16
|
-
record = {
|
17
|
-
keys[0] => slug(Faker::Dune.unique.character),
|
18
|
-
keys[1] => Faker::Lorem.sentence,
|
19
|
-
keys[2] => Faker::TwinPeaks.quote,
|
20
|
-
keys[3] => Faker::Name.name,
|
21
|
-
keys[4] => Faker::Space.star,
|
22
|
-
keys[5] => Faker::Lovecraft.sentence
|
23
|
-
}
|
24
|
-
data << record
|
25
|
-
$collection_data[name] = { 'keys' => keys, 'type' => type }
|
26
|
-
end
|
27
|
-
data
|
28
|
-
end
|
29
|
-
|
30
|
-
5.times do |i|
|
31
|
-
name = slug(Faker::RuPaul.unique.queen)
|
32
|
-
if i.even?
|
33
|
-
data = fake_data(name, '.csv')
|
34
|
-
path = '_data/' + name + '.csv'
|
35
|
-
write_csv(path, data)
|
36
|
-
else
|
37
|
-
data = fake_data(name, '.json')
|
38
|
-
path = '_data/' + name + '.json'
|
39
|
-
File.open(path, 'w') { |f| f.write(data.to_json) }
|
40
|
-
end
|
41
|
-
Faker::Dune.unique.clear
|
42
|
-
Faker::Lovecraft.unique.clear
|
43
|
-
end
|
data/spec/fake_helpers.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'csv'
|
2
|
-
require 'colorized_string'
|
3
|
-
|
4
|
-
# global
|
5
|
-
$collection_data = {}
|
6
|
-
|
7
|
-
# helper methods
|
8
|
-
def slug(str)
|
9
|
-
str.downcase.tr(' ', '_').gsub(/[^\w-]/, '')
|
10
|
-
end
|
11
|
-
|
12
|
-
def write_csv(path, hashes)
|
13
|
-
CSV.open(path, 'wb:UTF-8') do |csv|
|
14
|
-
csv << hashes.first.keys
|
15
|
-
hashes.each do |hash|
|
16
|
-
csv << hash.values
|
17
|
-
end
|
18
|
-
end
|
19
|
-
puts "Writing csv data to #{path}."
|
20
|
-
rescue StandardError
|
21
|
-
abort "Cannot write csv data to #{path} for some reason.".magenta
|
22
|
-
end
|
data/spec/fake_site.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'jekyll'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
include FileUtils
|
6
|
-
|
7
|
-
site_dir = 'faker_site'
|
8
|
-
mkdir_p(site_dir)
|
9
|
-
image_dir = Dir.glob('spec/data/_iiif')
|
10
|
-
cp_r(image_dir, site_dir)
|
11
|
-
cd(site_dir)
|
12
|
-
|
13
|
-
config_file = {
|
14
|
-
'title' => 'faker',
|
15
|
-
'url' => '',
|
16
|
-
'baseurl' => '',
|
17
|
-
'exclude' => ['Rakefile']
|
18
|
-
}
|
19
|
-
config_opts = {
|
20
|
-
'source' => '.',
|
21
|
-
'destination' => '_site',
|
22
|
-
'config' => '_config.yml'
|
23
|
-
}
|
24
|
-
|
25
|
-
File.open('_config.yml', 'w') { |f| f.puts(config_file.to_yaml) }
|
26
|
-
File.open('Rakefile', 'w') { |f| f.puts('Dir.glob("../lib/tasks/*.rake").each { |r| load r }') }
|
27
|
-
Jekyll::Site.new(Jekyll.configuration(config_opts)).process
|
data/spec/test_config.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
# run + test wax:config
|
5
|
-
describe 'wax:config' do
|
6
|
-
it 'accesses _config.yml and argvs' do
|
7
|
-
load File.expand_path("../../lib/tasks/config.rake", __FILE__)
|
8
|
-
Rake::Task['wax:config'].invoke
|
9
|
-
|
10
|
-
$collection_data.each { |col| $argv << col[0] }
|
11
|
-
expect($config.length)
|
12
|
-
expect($argv.length)
|
13
|
-
|
14
|
-
# add collection data to config file
|
15
|
-
collection_hash = {}
|
16
|
-
$argv.each do |coll_name|
|
17
|
-
ext = $collection_data[coll_name]['type']
|
18
|
-
collection_hash[coll_name] = {
|
19
|
-
'source' => coll_name + ext,
|
20
|
-
'layout' => 'default'
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
$config['collections'] = collection_hash
|
25
|
-
output = YAML.dump $config
|
26
|
-
File.write('_config.yml', output)
|
27
|
-
end
|
28
|
-
end
|
data/spec/test_iiif.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'csv'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'rake'
|
4
|
-
|
5
|
-
include FileUtils
|
6
|
-
|
7
|
-
describe 'wax:iiif' do
|
8
|
-
it 'generates iiif tiles and data' do
|
9
|
-
images = Dir.glob('./_iiif/source_images/*.jpg')
|
10
|
-
$collection_data.each do |coll|
|
11
|
-
new_dir = './_iiif/source_images/' + coll[0]
|
12
|
-
mkdir_p(new_dir)
|
13
|
-
images.each { |f| cp(File.expand_path(f), new_dir) }
|
14
|
-
end
|
15
|
-
rm_r(images)
|
16
|
-
$argv = [$argv.first] # make tests faster by only running on 1/3 collections
|
17
|
-
load File.expand_path("../../lib/tasks/iiif.rake", __FILE__)
|
18
|
-
Rake::Task['wax:iiif'].invoke
|
19
|
-
end
|
20
|
-
end
|
data/spec/test_lunr.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
|
3
|
-
describe 'wax:lunr' do
|
4
|
-
it 'generates a lunr index' do
|
5
|
-
$config['collections'].each do |collection|
|
6
|
-
name = collection[0]
|
7
|
-
# get info on what to index
|
8
|
-
lunr_hash = {
|
9
|
-
'content' => false,
|
10
|
-
'fields' => $collection_data[name]['keys']
|
11
|
-
}
|
12
|
-
# add it to config
|
13
|
-
$config['collections'][name]['lunr_index'] = lunr_hash
|
14
|
-
output = YAML.dump $config
|
15
|
-
File.write('_config.yml', output)
|
16
|
-
end
|
17
|
-
# invoke lunr task
|
18
|
-
load File.expand_path("../../lib/tasks/lunr.rake", __FILE__)
|
19
|
-
Rake::Task['wax:lunr'].invoke
|
20
|
-
# expect a populated index
|
21
|
-
index = File.open('js/lunr-index.js', 'r').read
|
22
|
-
expect(index.length > 1000)
|
23
|
-
end
|
24
|
-
end
|