photish 0.3.11 → 0.4.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.pryrc +2 -0
  3. data/README.md +73 -12
  4. data/TODO.md +8 -8
  5. data/bin/console +2 -10
  6. data/bin/setup +0 -2
  7. data/lib/photish/assets/example/photos/Big Dogs/Custom Template Page.slim +5 -0
  8. data/lib/photish/assets/example/site/_plugins/footer_links.rb +2 -1
  9. data/lib/photish/assets/example/site/_plugins/tmpdir_deploy.rb +2 -2
  10. data/lib/photish/assets/example/site/_plugins/yell_loud.rb +2 -1
  11. data/lib/photish/assets/example/site/_templates/album.slim +4 -0
  12. data/lib/photish/cache/db_file.rb +40 -0
  13. data/lib/photish/cache/manifest.rb +20 -18
  14. data/lib/photish/cache/repository.rb +42 -0
  15. data/lib/photish/cli/interface.rb +4 -0
  16. data/lib/photish/command/base.rb +6 -2
  17. data/lib/photish/command/deploy.rb +4 -8
  18. data/lib/photish/command/generate.rb +10 -26
  19. data/lib/photish/command/host.rb +8 -7
  20. data/lib/photish/command/init.rb +1 -1
  21. data/lib/photish/command/worker.rb +5 -17
  22. data/lib/photish/config/default_config.rb +5 -3
  23. data/lib/photish/config/file_config.rb +19 -5
  24. data/lib/photish/config/settings.rb +59 -0
  25. data/lib/photish/gallery/album.rb +27 -14
  26. data/lib/photish/gallery/collection.rb +27 -13
  27. data/lib/photish/gallery/image.rb +5 -12
  28. data/lib/photish/gallery/page.rb +40 -0
  29. data/lib/photish/gallery/photo.rb +7 -10
  30. data/lib/photish/gallery/traits/albumable.rb +9 -3
  31. data/lib/photish/gallery/traits/fileable.rb +30 -0
  32. data/lib/photish/gallery/traits/urlable.rb +12 -7
  33. data/lib/photish/log/io.rb +20 -0
  34. data/lib/photish/log/loggable.rb +1 -1
  35. data/lib/photish/log/{log_setup.rb → setup.rb} +1 -1
  36. data/lib/photish/{gallery/traits/breadcrumbable.rb → plugin/core/breadcrumb.rb} +12 -3
  37. data/lib/photish/plugin/core/build_url.rb +26 -0
  38. data/lib/photish/plugin/core/exifable.rb +15 -0
  39. data/lib/photish/plugin/core/metadatable.rb +27 -0
  40. data/lib/photish/plugin/repository.rb +3 -7
  41. data/lib/photish/plugin/type.rb +1 -0
  42. data/lib/photish/render/{image_conversion.rb → image.rb} +34 -18
  43. data/lib/photish/render/{site_worker.rb → model.rb} +13 -12
  44. data/lib/photish/render/page.rb +13 -24
  45. data/lib/photish/render/site.rb +3 -3
  46. data/lib/photish/render/template.rb +59 -0
  47. data/lib/photish/version.rb +1 -1
  48. data/lib/photish.rb +14 -11
  49. data/photish.gemspec +1 -0
  50. metadata +32 -14
  51. data/lib/photish/cache/manifest_db_file.rb +0 -36
  52. data/lib/photish/config/app_settings.rb +0 -57
  53. data/lib/photish/config/file_config_location.rb +0 -27
  54. data/lib/photish/config/image_extension.rb +0 -8
  55. data/lib/photish/core_plugin/breadcrumb.rb +0 -35
  56. data/lib/photish/core_plugin/build_url.rb +0 -20
  57. data/lib/photish/gallery/traits/metadatable.rb +0 -30
  58. data/lib/photish/log/access_log.rb +0 -11
@@ -0,0 +1,15 @@
1
+ module Photish
2
+ module Plugin
3
+ module Core
4
+ module Exifable
5
+ def self.is_for?(type)
6
+ Photish::Plugin::Type::Photo == type
7
+ end
8
+
9
+ def exif
10
+ @exif ||= MiniExiftool.new(path)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module Photish
2
+ module Plugin
3
+ module Core
4
+ module Metadatable
5
+ def self.is_for?(type)
6
+ [
7
+ Photish::Plugin::Type::Collection,
8
+ Photish::Plugin::Type::Album,
9
+ Photish::Plugin::Type::Photo,
10
+ Photish::Plugin::Type::Page,
11
+ ].include?(type)
12
+ end
13
+
14
+ def metadata
15
+ return unless File.exist?(metadata_file)
16
+ @metadata ||= RecursiveOpenStruct.new(YAML.load_file(metadata_file))
17
+ end
18
+
19
+ private
20
+
21
+ def metadata_file
22
+ File.join(dirname, basename_without_extension + '.yml')
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -5,7 +5,7 @@ module Photish
5
5
  include Log::Loggable
6
6
 
7
7
  def reload(config)
8
- log.info "Loading plugins..."
8
+ log.debug "Loading plugins..."
9
9
 
10
10
  load_each_plugin_file(config.site_dir)
11
11
  require_each_explicit_plugin(config.plugins)
@@ -21,22 +21,18 @@ module Photish
21
21
  @all_plugins ||= constants + sub_constants
22
22
  end
23
23
 
24
- def loaded?
25
- @all_plugins.present?
26
- end
27
-
28
24
  private
29
25
 
30
26
  def require_each_explicit_plugin(plugins)
31
27
  plugins.each do |plugin|
32
- log.info "Requiring config explicit plugin, #{plugin}"
28
+ log.debug "Requiring config explicit plugin, #{plugin}"
33
29
  require plugin
34
30
  end
35
31
  end
36
32
 
37
33
  def load_each_plugin_constant
38
34
  all_plugins.each do |plugin|
39
- log.info "Found plugin #{plugin}"
35
+ log.debug "Found plugin #{plugin}"
40
36
  end
41
37
  end
42
38
 
@@ -6,6 +6,7 @@ module Photish
6
6
  module Photo; end
7
7
  module Image; end
8
8
  module Deploy; end
9
+ module Page; end
9
10
  end
10
11
  end
11
12
  end
@@ -1,36 +1,40 @@
1
1
  module Photish
2
2
  module Render
3
- class ImageConversion
3
+ class Image
4
4
  include Log::Loggable
5
5
 
6
- def initialize(output_dir, worker_index, version_hash, threads)
7
- @output_dir = output_dir
8
- @worker_index = worker_index
6
+ def initialize(config, version_hash)
7
+ @config = config
9
8
  @version_hash = version_hash
10
- @threads = threads
11
9
  end
12
10
 
13
11
  def render(images)
14
- log.info "Rendering #{images.count} images across #{threads} threads"
12
+ log.debug "Rendering #{images.count} images across #{threads} threads"
15
13
 
16
- cache.preload
14
+ cache_load_from_disk
17
15
  threads = spawn_thread_instances(to_queue(images))
18
16
  threads.map(&:join)
19
- flush_to_disk
17
+ cache_flush_to_disk
20
18
  end
21
19
 
22
20
  private
23
21
 
24
- attr_reader :output_dir,
25
- :worker_index,
26
- :version_hash,
27
- :threads
22
+ attr_reader :config,
23
+ :version_hash
24
+
25
+ delegate :output_dir,
26
+ :worker_index,
27
+ :threads,
28
+ :soft_failure,
29
+ :workers,
30
+ to: :config
28
31
 
29
32
  delegate :record,
30
33
  :changed?,
31
34
  :flush_to_disk,
32
- :preload,
33
- to: :cache
35
+ :load_from_disk,
36
+ to: :cache,
37
+ prefix: true
34
38
 
35
39
  def spawn_thread_instances(image_queue)
36
40
  (0...threads).map do
@@ -42,11 +46,18 @@ module Photish
42
46
 
43
47
  def process_images(image_queue)
44
48
  while !image_queue.empty?
45
- image = image_queue.pop
46
- convert(image) if changed?(image.url_path, image.path)
49
+ process_next_image(image_queue)
47
50
  end
48
51
  end
49
52
 
53
+ def process_next_image(image_queue)
54
+ image = image_queue.pop
55
+ convert(image) if cache_changed?(image.url_path, image.path)
56
+ rescue Errno::ENOENT
57
+ log.warn "Image not found #{image.path}"
58
+ raise unless soft_failure
59
+ end
60
+
50
61
  def to_queue(images)
51
62
  image_queue = Queue.new
52
63
  Array(images).shuffle.each { |image| image_queue << image }
@@ -56,7 +67,7 @@ module Photish
56
67
  def convert(image)
57
68
  create_parent_directories(image)
58
69
  convert_with_imagemagick(image)
59
- record(image.url_path, image.path)
70
+ cache_record(image.url_path, image.path)
60
71
  end
61
72
 
62
73
  def convert_with_imagemagick(image)
@@ -64,8 +75,12 @@ module Photish
64
75
  convert << image.path
65
76
  convert.merge!(image.quality_params)
66
77
  convert << output_path(image)
67
- log.info "Performing image conversion #{convert.command}"
78
+ log.debug "Performing image conversion #{convert.command}"
68
79
  end
80
+ rescue MiniMagick::Error => e
81
+ log.warn "Error occured while converting"
82
+ log.warn e
83
+ raise unless soft_failure
69
84
  end
70
85
 
71
86
  def output_path(image)
@@ -78,6 +93,7 @@ module Photish
78
93
 
79
94
  def cache
80
95
  @cache ||= Cache::Manifest.new(output_dir,
96
+ workers,
81
97
  worker_index,
82
98
  version_hash)
83
99
  end
@@ -1,6 +1,6 @@
1
1
  module Photish
2
2
  module Render
3
- class SiteWorker
3
+ class Model
4
4
  def initialize(config, version_hash)
5
5
  @config = config
6
6
  @version_hash = version_hash
@@ -19,7 +19,6 @@ module Photish
19
19
  :site_dir,
20
20
  :output_dir,
21
21
  :workers,
22
- :threads,
23
22
  :worker_index,
24
23
  to: :config
25
24
 
@@ -28,6 +27,7 @@ module Photish
28
27
  ->{ album_template.render(subset(collection.all_albums)) },
29
28
  ->{ photo_template.render(subset(collection.all_photos)) },
30
29
  ->{ image_conversion.render(subset(collection.all_images)) },
30
+ ->{ page_template.render(subset(collection.all_pages)) },
31
31
  ]
32
32
  end
33
33
 
@@ -38,22 +38,23 @@ module Photish
38
38
  end
39
39
 
40
40
  def image_conversion
41
- ImageConversion.new(output_dir,
42
- worker_index,
43
- version_hash,
44
- threads)
41
+ Image.new(config, version_hash)
45
42
  end
46
43
 
47
44
  def album_template
48
- Page.new(layout_file,
49
- template_album_file,
50
- output_dir)
45
+ Template.new(layout_file,
46
+ template_album_file,
47
+ output_dir)
48
+ end
49
+
50
+ def page_template
51
+ Page.new(layout_file, output_dir)
51
52
  end
52
53
 
53
54
  def photo_template
54
- Page.new(layout_file,
55
- template_photo_file,
56
- output_dir)
55
+ Template.new(layout_file,
56
+ template_photo_file,
57
+ output_dir)
57
58
  end
58
59
 
59
60
  def layout_file
@@ -3,54 +3,43 @@ module Photish
3
3
  class Page
4
4
  include Log::Loggable
5
5
 
6
- def initialize(layout_file, template_file, output_dir)
6
+ def initialize(layout_file, output_dir)
7
7
  @layout_file = layout_file
8
- @template_file = template_file
9
8
  @output_dir = output_dir
10
9
  end
11
10
 
12
- def render(models)
13
- return template_missing unless File.exist?(template_file)
14
- render_all(models)
11
+ def render(pages)
12
+ render_all(pages)
15
13
  end
16
14
 
17
15
  private
18
16
 
19
- attr_reader :template_file,
20
- :layout_file,
17
+ attr_reader :layout_file,
21
18
  :output_dir
22
19
 
23
- def render_all(models)
24
- Array(models).each do |model|
25
- rendered_model = render_template_and_layout(model)
26
- output_model_file = relative_to_output_dir(model.url_parts)
27
- output_model_dir = relative_to_output_dir(model.base_url_parts)
20
+ def render_all(pages)
21
+ Array(pages).each do |page|
22
+ rendered_model = render_with_layout(page)
23
+ output_model_file = relative_to_output_dir(page.url_parts)
24
+ output_model_dir = relative_to_output_dir(page.base_url_parts)
28
25
 
29
- log.info "Rendering #{model.url} with template #{template_file} to #{output_model_file}"
26
+ log.debug "Rendering #{page.url} to #{output_model_file}"
30
27
 
31
28
  FileUtils.mkdir_p(output_model_dir)
32
29
  File.write(output_model_file, rendered_model)
33
30
  end
34
31
  end
35
32
 
36
- def template_missing
37
- log.info "Template not found #{template_file}, skipping rendering"
38
- end
39
-
40
33
  def relative_to_output_dir(url_parts)
41
34
  File.join(output_dir, url_parts)
42
35
  end
43
36
 
44
- def render_template_and_layout(model)
45
- layout.render(model) do
46
- template.render(model)
37
+ def render_with_layout(page)
38
+ layout.render(page) do
39
+ Tilt.new(page.path).render(page)
47
40
  end
48
41
  end
49
42
 
50
- def template
51
- @template ||= Tilt.new(template_file)
52
- end
53
-
54
43
  def layout
55
44
  @layout ||= Tilt.new(layout_file)
56
45
  end
@@ -51,9 +51,9 @@ module Photish
51
51
  end
52
52
 
53
53
  def collection_template
54
- Page.new(layout_file,
55
- template_collection_file,
56
- output_dir)
54
+ Template.new(layout_file,
55
+ template_collection_file,
56
+ output_dir)
57
57
  end
58
58
 
59
59
  def non_ignored_site_contents
@@ -0,0 +1,59 @@
1
+ module Photish
2
+ module Render
3
+ class Template
4
+ include Log::Loggable
5
+
6
+ def initialize(layout_file, template_file, output_dir)
7
+ @layout_file = layout_file
8
+ @template_file = template_file
9
+ @output_dir = output_dir
10
+ end
11
+
12
+ def render(models)
13
+ return template_missing unless File.exist?(template_file)
14
+ render_all(models)
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :template_file,
20
+ :layout_file,
21
+ :output_dir
22
+
23
+ def render_all(models)
24
+ Array(models).each do |model|
25
+ rendered_model = render_template_and_layout(model)
26
+ output_model_file = relative_to_output_dir(model.url_parts)
27
+ output_model_dir = relative_to_output_dir(model.base_url_parts)
28
+
29
+ log.debug "Rendering #{model.url} with template #{template_file} to #{output_model_file}"
30
+
31
+ FileUtils.mkdir_p(output_model_dir)
32
+ File.write(output_model_file, rendered_model)
33
+ end
34
+ end
35
+
36
+ def template_missing
37
+ log.debug "Template not found #{template_file}, skipping rendering"
38
+ end
39
+
40
+ def relative_to_output_dir(url_parts)
41
+ File.join(output_dir, url_parts)
42
+ end
43
+
44
+ def render_template_and_layout(model)
45
+ layout.render(model) do
46
+ template.render(model)
47
+ end
48
+ end
49
+
50
+ def template
51
+ @template ||= Tilt.new(template_file)
52
+ end
53
+
54
+ def layout
55
+ @layout ||= Tilt.new(layout_file)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Photish
2
- VERSION = "0.3.11"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/photish.rb CHANGED
@@ -21,8 +21,8 @@ require 'open3'
21
21
  # Photish
22
22
  require 'photish/log/loggable'
23
23
  require 'photish/log/formatter'
24
- require 'photish/log/log_setup'
25
- require 'photish/log/access_log'
24
+ require 'photish/log/setup'
25
+ require 'photish/log/io'
26
26
  require 'photish/log/safe_block'
27
27
  require 'photish/plugin/type'
28
28
  require 'photish/plugin/pluginable'
@@ -34,26 +34,29 @@ require 'photish/command/host'
34
34
  require 'photish/command/init'
35
35
  require 'photish/command/deploy'
36
36
  require 'photish/cli/interface'
37
- require 'photish/config/image_extension'
38
37
  require 'photish/config/default_config'
39
38
  require 'photish/config/file_config'
40
- require 'photish/config/file_config_location'
41
- require 'photish/config/app_settings'
42
- require 'photish/core_plugin/build_url'
43
- require 'photish/core_plugin/breadcrumb'
39
+ require 'photish/config/settings'
40
+ require 'photish/plugin/core/build_url'
41
+ require 'photish/plugin/core/breadcrumb'
42
+ require 'photish/plugin/core/metadatable'
43
+ require 'photish/plugin/core/exifable'
44
44
  require 'photish/gallery/traits/urlable'
45
45
  require 'photish/gallery/traits/albumable'
46
- require 'photish/gallery/traits/metadatable'
46
+ require 'photish/gallery/traits/fileable'
47
47
  require 'photish/gallery/photo'
48
+ require 'photish/gallery/page'
48
49
  require 'photish/gallery/album'
49
50
  require 'photish/gallery/image'
50
51
  require 'photish/gallery/collection'
52
+ require 'photish/render/template'
51
53
  require 'photish/render/page'
52
54
  require 'photish/render/site'
53
- require 'photish/render/site_worker'
54
- require 'photish/render/image_conversion'
55
+ require 'photish/render/model'
56
+ require 'photish/render/image'
57
+ require 'photish/cache/db_file'
55
58
  require 'photish/cache/manifest'
56
- require 'photish/cache/manifest_db_file'
59
+ require 'photish/cache/repository'
57
60
  require 'photish/rake/task'
58
61
  require 'photish/version'
59
62
 
data/photish.gemspec CHANGED
@@ -44,4 +44,5 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency "rspec-html-matchers"
45
45
  spec.add_development_dependency "metric_fu"
46
46
  spec.add_development_dependency "photish-plugin-sshdeploy"
47
+ spec.add_development_dependency "awesome_print"
47
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Lawson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-27 00:00:00.000000000 Z
11
+ date: 2016-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -304,6 +304,20 @@ dependencies:
304
304
  - - ">="
305
305
  - !ruby/object:Gem::Version
306
306
  version: '0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: awesome_print
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ type: :development
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - ">="
319
+ - !ruby/object:Gem::Version
320
+ version: '0'
307
321
  description: |-
308
322
  Photish is a simple, convention based (but
309
323
  configurable) static photo site generator.
@@ -317,6 +331,7 @@ files:
317
331
  - ".codeclimate.yml"
318
332
  - ".csslintrc"
319
333
  - ".gitignore"
334
+ - ".pryrc"
320
335
  - ".rspec"
321
336
  - ".rubocop.yml"
322
337
  - ".simplecov"
@@ -336,6 +351,7 @@ files:
336
351
  - lib/photish/assets/barebones/site/_templates/layout.slim
337
352
  - lib/photish/assets/barebones/site/styles/basic.css
338
353
  - lib/photish/assets/config.yml
354
+ - lib/photish/assets/example/photos/Big Dogs/Custom Template Page.slim
339
355
  - lib/photish/assets/example/photos/Big Dogs/Tired Dogs.jpg
340
356
  - lib/photish/assets/example/photos/Big Dogs/Winking Dog.jpg
341
357
  - lib/photish/assets/example/photos/Small Dogs/Fluffy Dogs/Exhausted Dogs.jpg
@@ -356,8 +372,9 @@ files:
356
372
  - lib/photish/assets/example/site/images/crumbs.gif
357
373
  - lib/photish/assets/example/site/styles/basic.css
358
374
  - lib/photish/assets/gitignore
375
+ - lib/photish/cache/db_file.rb
359
376
  - lib/photish/cache/manifest.rb
360
- - lib/photish/cache/manifest_db_file.rb
377
+ - lib/photish/cache/repository.rb
361
378
  - lib/photish/cli/interface.rb
362
379
  - lib/photish/command/base.rb
363
380
  - lib/photish/command/deploy.rb
@@ -365,34 +382,35 @@ files:
365
382
  - lib/photish/command/host.rb
366
383
  - lib/photish/command/init.rb
367
384
  - lib/photish/command/worker.rb
368
- - lib/photish/config/app_settings.rb
369
385
  - lib/photish/config/default_config.rb
370
386
  - lib/photish/config/file_config.rb
371
- - lib/photish/config/file_config_location.rb
372
- - lib/photish/config/image_extension.rb
373
- - lib/photish/core_plugin/breadcrumb.rb
374
- - lib/photish/core_plugin/build_url.rb
387
+ - lib/photish/config/settings.rb
375
388
  - lib/photish/gallery/album.rb
376
389
  - lib/photish/gallery/collection.rb
377
390
  - lib/photish/gallery/image.rb
391
+ - lib/photish/gallery/page.rb
378
392
  - lib/photish/gallery/photo.rb
379
393
  - lib/photish/gallery/traits/albumable.rb
380
- - lib/photish/gallery/traits/breadcrumbable.rb
381
- - lib/photish/gallery/traits/metadatable.rb
394
+ - lib/photish/gallery/traits/fileable.rb
382
395
  - lib/photish/gallery/traits/urlable.rb
383
- - lib/photish/log/access_log.rb
384
396
  - lib/photish/log/formatter.rb
385
- - lib/photish/log/log_setup.rb
397
+ - lib/photish/log/io.rb
386
398
  - lib/photish/log/loggable.rb
387
399
  - lib/photish/log/safe_block.rb
400
+ - lib/photish/log/setup.rb
401
+ - lib/photish/plugin/core/breadcrumb.rb
402
+ - lib/photish/plugin/core/build_url.rb
403
+ - lib/photish/plugin/core/exifable.rb
404
+ - lib/photish/plugin/core/metadatable.rb
388
405
  - lib/photish/plugin/pluginable.rb
389
406
  - lib/photish/plugin/repository.rb
390
407
  - lib/photish/plugin/type.rb
391
408
  - lib/photish/rake/task.rb
392
- - lib/photish/render/image_conversion.rb
409
+ - lib/photish/render/image.rb
410
+ - lib/photish/render/model.rb
393
411
  - lib/photish/render/page.rb
394
412
  - lib/photish/render/site.rb
395
- - lib/photish/render/site_worker.rb
413
+ - lib/photish/render/template.rb
396
414
  - lib/photish/version.rb
397
415
  - photish.gemspec
398
416
  homepage: https://github.com/henrylawson/photish
@@ -1,36 +0,0 @@
1
- module Photish
2
- module Cache
3
- class ManifestDbFile
4
- def initialize(output_dir)
5
- @output_dir = output_dir
6
- end
7
-
8
- def concat_db_files(workers)
9
- changes = (1..workers).inject({}) do |accumulator, worker_index|
10
- file = worker_db_file(worker_index)
11
- accumulator.merge!(YAML.load_file(file)) if File.exist?(file)
12
- accumulator
13
- end
14
- File.open(db_file, 'w') { |f| f.write(changes.to_yaml) }
15
- end
16
-
17
- def clear
18
- FileUtils.rm_rf(db_file)
19
- end
20
-
21
- def db_file
22
- FileUtils.mkdir_p(output_dir)
23
- File.join(output_dir, '.changes.yml')
24
- end
25
-
26
- def worker_db_file(index)
27
- FileUtils.mkdir_p(output_dir)
28
- File.join(output_dir, ".changes.#{index}.yml")
29
- end
30
-
31
- private
32
-
33
- attr_reader :output_dir
34
- end
35
- end
36
- end
@@ -1,57 +0,0 @@
1
- module Photish
2
- module Config
3
- class AppSettings
4
- def initialize(runtime_config)
5
- @runtime_config = symbolize(runtime_config)
6
- end
7
-
8
- def config
9
- @config ||= RecursiveOpenStruct.new(prioritized_config)
10
- end
11
-
12
- def version_hash
13
- @version_hash ||= Digest::MD5.hexdigest(sensitive_config.to_json)
14
- end
15
-
16
- private
17
-
18
- attr_reader :runtime_config
19
-
20
- def prioritized_config
21
- {}.deep_merge(default_config)
22
- .deep_merge(file_config)
23
- .deep_merge(runtime_config)
24
- .deep_merge(derived_config)
25
- end
26
-
27
- def sensitive_config
28
- prioritized_config.slice('qualities')
29
- end
30
-
31
- def derived_config
32
- {
33
- config_file_location: config_file_location
34
- }
35
- end
36
-
37
- def file_config
38
- symbolize(FileConfig.new(config_file_location)
39
- .hash)
40
- end
41
-
42
- def default_config
43
- symbolize(DefaultConfig.new.hash)
44
- end
45
-
46
- def config_file_location
47
- FileConfigLocation.new(runtime_config[:config_dir])
48
- .path
49
- end
50
-
51
- def symbolize(hash)
52
- (hash || {})
53
- .deep_symbolize_keys
54
- end
55
- end
56
- end
57
- end