wax_iiif 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b13d4ff2abd3af952990aacf338ff5d9842fa9947699e5fc1844bbc09e43f625
4
- data.tar.gz: 531615c4d2380c96916370b798cf22ed945ea53e79906bc6f757da3c6101ce64
3
+ metadata.gz: 9c8960705254abe3b74d5e75c7972d07f4152f840c2de845f6555905bc1abb42
4
+ data.tar.gz: ae4d3e69e8b3ebccedc19d09005209e8b97232adcce67c1a9a78a9fbc05d80dc
5
5
  SHA512:
6
- metadata.gz: 9b1f984f67dae9f129339d2b62f9fd7dbe7382e2be43b8111e3733ac286bd6d063239bb75b59b0bb5484ea88f43c5baa3429eafc78390a593f0f3668ff913d35
7
- data.tar.gz: 3b2350315e8945edf5bc2ae9102d806c2df2de9a60f130b818bd937a67e3aa818e325a29bea8df00bfed11289e7a68959917ce0d9c4d391be263c1dabc189d20
6
+ metadata.gz: 0d7161eccce1b681d6bdb543ac5dcbdf1bd3506a51e755a16a39a4c2091e8d3e874c9e6122004cb799ff2eab1fac95d8224572870771a0696c7904d90a040be3
7
+ data.tar.gz: 15f1b8cbd87bfeadbea25e781f4ecd8d5301a1ed036fce8a94bada86bb4dac0b376b655b18c77f00eaeec1c47499f05d7726e0a1caff0002135aca100e16e43b
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ Welcome to the Changelog! Below is the first attempt at a log for this project.
4
+
5
+
6
+ ## v0.2.0
7
+ #### Date: 09/10/2019
8
+
9
+ #### Breaking Changes:
10
+ - N/A
11
+
12
+ #### Non-breaking Changes:
13
+ - :white_check_mark: `wax_iiif` can now run its `build` process in parallel. (Credit: [@KitaitiMakoto](https://github.com/KitaitiMakoto))
14
+ - :white_check_mark: `progress_bar` on `builder.process_data` shows up faster.
15
+
16
+ #### Dependency Changes:
17
+ - \+ `gem 'parallel'`
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem 'rubocop', '0.59.0', require: false
4
+ gem 'rubocop', require: false
5
5
  gem 'yard', require: false
data/README.md CHANGED
@@ -1,8 +1,52 @@
1
1
  # wax_iiif
2
- [![Gem Version](https://badge.fury.io/rb/wax_iiif.svg)](https://badge.fury.io/rb/wax_iiif) [![Build Status](https://travis-ci.org/minicomp/wax_iiif.svg?branch=master)](https://travis-ci.org/minicomp/wax_iiif) [![Maintainability](https://api.codeclimate.com/v1/badges/a7d79a1b819cef81eb11/maintainability)](https://codeclimate.com/github/minicomp/wax_iiif/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/a7d79a1b819cef81eb11/test_coverage)](https://codeclimate.com/github/minicomp/wax_iiif/test_coverage)
2
+ [![Gem Version](https://badge.fury.io/rb/wax_iiif.svg)](https://badge.fury.io/rb/wax_iiif) [![Build Status](https://travis-ci.org/minicomp/wax_iiif.svg?branch=master)](https://travis-ci.org/minicomp/wax_iiif) [![Maintainability](https://api.codeclimate.com/v1/badges/a7d79a1b819cef81eb11/maintainability)](https://codeclimate.com/github/minicomp/wax_iiif/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/a7d79a1b819cef81eb11/test_coverage)](https://codeclimate.com/github/minicomp/wax_iiif/test_coverage) [![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/minicomp/wax_iiif)](https://libraries.io/github/minicomp/wax_iiif)
3
3
 
4
4
  ![License](https://img.shields.io/badge/license-MIT-green.svg) [![docs](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](https://www.rubydoc.info/github/minicomp/wax_iiif/)
5
5
 
6
6
  This fork is *mostly* a copy of the [iiif_s3 gem](https://github.com/cmoa/iiif_s3) with all the s3 dependencies and functionality removed. It creates level 0 IIIF derivatives for static exhibition sites with [Minicomp/Wax](https://github.com/minicomp/wax/) via [Wax_Tasks](https://github.com/minicomp/wax_tasks/).
7
7
 
8
+ ## Installation
9
+
10
+ This library assumes that you have ImageMagick installed. If you need to install it, follow the instructions:
11
+
12
+ on OSX, `brew install imagemagick ` should be sufficient.
13
+
14
+ If you have issues with TIFF files, try
15
+
16
+ ```shell
17
+
18
+ brew update
19
+ brew reinstall --with-libtiff --ignore-dependencies imagemagick
20
+
21
+ ```
22
+
23
+ If you plan to work with PDFs, you should also have a copy of GhostScript installed.
24
+
25
+ on OSX, `brew install gs`
26
+
27
+
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ gem 'wax_iiif'
32
+
33
+ And then execute:
34
+
35
+ $ bundle
36
+
37
+ Or install it yourself as:
38
+
39
+ $ gem install wax_iiif
40
+
41
+ ## Usage
42
+
8
43
  Documentation for using `wax_iiif` without `wax_tasks` is forthcoming. In the meantime, check out [rubydoc](https://www.rubydoc.info/gems/wax_iiif).
44
+
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/minicomp/wax_iiif/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
@@ -1,5 +1,6 @@
1
1
  require 'csv'
2
2
  require 'json'
3
+ require 'rainbow'
3
4
 
4
5
  require_relative 'wax_iiif/errors'
5
6
  require_relative 'wax_iiif/base_properties'
@@ -2,6 +2,7 @@ require_relative 'utilities'
2
2
 
3
3
  require 'pathname'
4
4
  require 'progress_bar'
5
+ require 'parallel'
5
6
 
6
7
  module WaxIiif
7
8
  # Builder class
@@ -60,20 +61,26 @@ module WaxIiif
60
61
  #
61
62
  # Take the loaded data and generate all the files.
62
63
  #
64
+ # @param [Integer] thread_count Thread count to use for processing images concurrently. Defaults to number of processors.
65
+ #
63
66
  # @return [Void]
64
67
  #
65
- def process_data
68
+ def process_data(thread_count: Parallel.processor_count)
69
+ puts Rainbow("Running on #{thread_count} threads.").blue
70
+
66
71
  return nil if @data.nil? # do nothing without data.
67
72
 
68
73
  @manifests = []
69
74
 
70
75
  data = @data.group_by(&:manifest_id)
71
76
  bar = ProgressBar.new(data.length)
77
+ bar.write
72
78
 
73
79
  data.each do |key, value|
74
80
  manifest_id = key
75
81
  image_records = value
76
- resources = process_image_records(image_records)
82
+ resources = process_image_records(image_records,
83
+ thread_count: thread_count)
77
84
 
78
85
  # Generate the manifest
79
86
  if manifest_id.to_s.empty?
@@ -128,13 +135,7 @@ module WaxIiif
128
135
  # remove optional header
129
136
  vals.shift if vals[0][0] == HEADER_VAL
130
137
 
131
- @data = vals.collect do |data|
132
- {
133
- 'image_path' => data[0],
134
- 'id' => data[1],
135
- 'label' => data[2]
136
- }
137
- end
138
+ @data = vals.collect { |d| { 'image_path' => d[0], 'id' => d[1], 'label' => d[2] } }
138
139
  end
139
140
 
140
141
  protected
@@ -239,11 +240,12 @@ module WaxIiif
239
240
  obj
240
241
  end
241
242
 
242
- def process_image_records(image_records)
243
+ def process_image_records(image_records,
244
+ thread_count: Parallel.processor_count)
243
245
  resources = {}
244
246
 
245
247
  # genrate the images
246
- image_records.each do |image_record|
248
+ Parallel.each(image_records, in_threads: thread_count) do |image_record|
247
249
  # It attempts to load the info files and skip generation - not currently working.
248
250
  info_file = image_info_file_name(image_record)
249
251
  if File.exist?(info_file)
@@ -36,7 +36,7 @@ module WaxIiif
36
36
  #
37
37
  # @return [String] The JSON representation as a string
38
38
  #
39
- def to_json
39
+ def to_json(*_args)
40
40
  obj = base_properties
41
41
  obj['collections'] = collect_object(collections) unless collections.empty?
42
42
  obj['manifests'] = collect_object(manifests) unless manifests.empty?
@@ -48,7 +48,7 @@ module WaxIiif
48
48
  #
49
49
  # @return [String] the JSON representation of this image
50
50
  #
51
- def to_json
51
+ def to_json(*_args)
52
52
  obj = {
53
53
  '@context' => context,
54
54
  '@id' => id,
@@ -48,7 +48,7 @@ module WaxIiif
48
48
  #
49
49
  # @return [String] the JSON-LD representation of the manifest as a string.
50
50
  #
51
- def to_json
51
+ def to_json(*_args)
52
52
  obj = base_properties
53
53
 
54
54
  obj['thumbnail'] = @primary.variants['thumbnail'].uri
@@ -106,10 +106,9 @@ module WaxIiif
106
106
  #--------------------------------------------------------------------------
107
107
  def build_canvas(data)
108
108
  canvas_id = generate_id "canvas/#{data.id}"
109
-
110
109
  obj = {
111
110
  '@type' => CANVAS_TYPE,
112
- '@id' => canvas_id,
111
+ '@id' => canvas_id,
113
112
  'label' => data.section_label,
114
113
  'width' => data.variants['full'].width.floor,
115
114
  'height' => data.variants['full'].height.floor,
@@ -130,7 +129,7 @@ module WaxIiif
130
129
  annotation_id = generate_id "annotation/#{data.id}"
131
130
  {
132
131
  '@type' => ANNOTATION_TYPE,
133
- '@id' => annotation_id,
132
+ '@id' => annotation_id,
134
133
  'motivation' => MOTIVATION,
135
134
  'resource' => {
136
135
  '@id' => data.variants['full'].uri,
@@ -45,7 +45,7 @@ describe WaxIiif::Builder do
45
45
  include_context('fake data')
46
46
 
47
47
  before(:example) do
48
- @iiif = WaxIiif::Builder.new({base_url: 'http://0.0.0.0', verbose: true, thumbnail_size: 120})
48
+ @iiif = WaxIiif::Builder.new({base_url: 'http://0.0.0.0', verbose: false, thumbnail_size: 120})
49
49
  @iiif.load(@fake_data)
50
50
  allow(@iiif).to receive(:generate_tiles) {nil}
51
51
  allow(@iiif).to receive(:generate_variants) {@fake_variants}
@@ -73,7 +73,7 @@ describe WaxIiif::Builder do
73
73
 
74
74
  before(:example) do
75
75
  @dir = Dir.mktmpdir
76
- @iiif = WaxIiif::Builder.new({output_dir: @dir, base_url: 'http://0.0.0.0', verbose: true, thumbnail_size: 120})
76
+ @iiif = WaxIiif::Builder.new({output_dir: @dir, base_url: 'http://0.0.0.0', verbose: false, thumbnail_size: 120})
77
77
  @iiif.load(@fake_data)
78
78
  @info_json = "#{@dir}/images/1/info.json"
79
79
  allow(@iiif).to receive(:generate_tiles) {nil}
@@ -34,18 +34,18 @@ describe WaxIiif::ImageVariant do
34
34
  @img = WaxIiif::ImageVariant.new(data, config, 100)
35
35
  end
36
36
 
37
- # it 'has a uri' do
38
- # expect(@img.uri).to eq("#{@img.generate_image_id(1)}/full/100,/0/default.jpg")
39
- # end
40
- # it 'has an id' do
41
- # expect(@img.id).to eq(@img.generate_image_id(1))
42
- # end
43
- # it 'has a width' do
44
- # expect(@img.width).to eq(100)
45
- # end
46
- # it 'has a mime type' do
47
- # expect(@img.mime_type).to eq('image/jpeg')
48
- # end
37
+ it 'has a uri' do
38
+ expect(@img.uri).to eq("#{@img.generate_image_id(1)}/full/100,/0/default.jpg")
39
+ end
40
+ it 'has an id' do
41
+ expect(@img.id).to eq(@img.generate_image_id(1))
42
+ end
43
+ it 'has a width' do
44
+ expect(@img.width).to eq(100)
45
+ end
46
+ it 'has a mime type' do
47
+ expect(@img.mime_type).to eq('image/jpeg')
48
+ end
49
49
  end
50
50
 
51
51
  context 'Full Image' do
@@ -58,9 +58,9 @@ describe WaxIiif::ImageVariant do
58
58
  config = WaxIiif::Config.new
59
59
  @img = WaxIiif::FullImage.new(data, config)
60
60
  end
61
- # it 'has the default filestring' do
62
- # expect(@img.uri).to include 'full/full'
63
- # end
61
+ it 'has the default filestring' do
62
+ expect(@img.uri).to include 'full/full'
63
+ end
64
64
 
65
65
  end
66
66
  end
@@ -3,25 +3,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'wax_iiif'
6
- spec.version = '0.1.2'
6
+ spec.version = '0.2.0'
7
7
  spec.authors = ['Marii Nyrop', 'David Newbury']
8
- spec.email = ['m.nyrop@columbia.edu']
8
+ spec.email = ['marii@nyu.edu']
9
9
  spec.summary = 'Minimal IIIF level 0 generator'
10
10
  spec.description = 'Minimal IIIF level 0 generator for use with minicomp/wax'
11
11
  spec.homepage = 'https://github.com/minicomp/wax_iiif'
12
12
  spec.license = 'MIT'
13
13
 
14
- spec.files = `git ls-files -z`.split("\x0")
15
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
- spec.require_paths = ['lib']
14
+ spec.required_ruby_version = '>= 2.4'
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
18
19
 
19
- spec.metadata['yard.run'] = 'yri'
20
-
21
- spec.add_development_dependency 'dotenv', '~> 2.5'
20
+ spec.add_development_dependency 'dotenv', '~> 2.7'
22
21
  spec.add_development_dependency 'rspec', '~> 3.8'
23
22
  spec.add_development_dependency 'simplecov', '~> 0.16'
24
23
 
25
- spec.add_runtime_dependency 'mini_magick', '~> 4.8'
24
+ spec.add_runtime_dependency 'mini_magick', '~> 4.9'
25
+ spec.add_runtime_dependency 'parallel', '~> 1.17'
26
26
  spec.add_runtime_dependency 'progress_bar', '~> 1.3'
27
+ spec.add_runtime_dependency 'rainbow', '~> 3.0'
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wax_iiif
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marii Nyrop
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-05 00:00:00.000000000 Z
12
+ date: 2019-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dotenv
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '2.5'
20
+ version: '2.7'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '2.5'
27
+ version: '2.7'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -59,14 +59,28 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '4.8'
62
+ version: '4.9'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '4.8'
69
+ version: '4.9'
70
+ - !ruby/object:Gem::Dependency
71
+ name: parallel
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.17'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.17'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: progress_bar
72
86
  requirement: !ruby/object:Gem::Requirement
@@ -81,9 +95,23 @@ dependencies:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
97
  version: '1.3'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rainbow
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '3.0'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '3.0'
84
112
  description: Minimal IIIF level 0 generator for use with minicomp/wax
85
113
  email:
86
- - m.nyrop@columbia.edu
114
+ - marii@nyu.edu
87
115
  executables: []
88
116
  extensions: []
89
117
  extra_rdoc_files: []
@@ -92,6 +120,7 @@ files:
92
120
  - ".rspec"
93
121
  - ".rubocop.yml"
94
122
  - ".travis.yml"
123
+ - CHANGELOG.md
95
124
  - Gemfile
96
125
  - LICENSE.md
97
126
  - README.md
@@ -132,8 +161,7 @@ files:
132
161
  homepage: https://github.com/minicomp/wax_iiif
133
162
  licenses:
134
163
  - MIT
135
- metadata:
136
- yard.run: yri
164
+ metadata: {}
137
165
  post_install_message:
138
166
  rdoc_options: []
139
167
  require_paths:
@@ -142,15 +170,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
170
  requirements:
143
171
  - - ">="
144
172
  - !ruby/object:Gem::Version
145
- version: '0'
173
+ version: '2.4'
146
174
  required_rubygems_version: !ruby/object:Gem::Requirement
147
175
  requirements:
148
176
  - - ">="
149
177
  - !ruby/object:Gem::Version
150
178
  version: '0'
151
179
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.7.6
180
+ rubygems_version: 3.0.4
154
181
  signing_key:
155
182
  specification_version: 4
156
183
  summary: Minimal IIIF level 0 generator