sqed 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sqed.rb +14 -12
  3. data/lib/sqed/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bed449b7e6c2dc2d480aa35b2ae8e5d13621d49a
4
- data.tar.gz: a811f9fa39ee7d15b13a42e44a93dead7a4ca4ca
3
+ metadata.gz: a06556fe8ccfebadb944693c4c8675f2ae95e019
4
+ data.tar.gz: 72aa2b8778bfb884b9cb524db4287c18d3641ccb
5
5
  SHA512:
6
- metadata.gz: 50c2a9d2fc71ad0f925855f0dc9fd40b1e00de9b467466373183c43b382daef6f1305c6a55a74b846941ed84122266cebb1f7b5b623096a8e5aebc0d6e8273b2
7
- data.tar.gz: 1064acbb372a2549508031cb882834ab6085a15d2873061c68ffbe5fdac65e362054e0081a0a4b90fc043df183d3f56f4e2298964fedb2293c94f0f27f530a71
6
+ metadata.gz: b6df4ecaa35e16585fcc03c2fe05bfcd610b25ae92c5dfb3715d4f9cc4f9d930af3fe4f0f18d61318a683d30629a70f459cc233c4860b3c5e91d3b59825c871b
7
+ data.tar.gz: ad2d4dd2f09a43994ae6add3f5c45d72004ac8d141b820d32909cf1a72b13fbedc8628aa178311516c39bb099c3c690bd3c248c06e8697294f4136e40496dd3d
@@ -23,9 +23,12 @@ class Sqed
23
23
  # initial image which is an instance of ImageMagick::Image, containing background and stage, or just stage
24
24
  attr_accessor :image
25
25
 
26
- # the particular arrangement of the content, a symbol taken from SqedConfig::EXTRACTION_PATTERNS
26
+ # pointer to a combined boundary_finder, layout, and metadata_map pattern, a symbol taken from SqedConfig::EXTRACTION_PATTERNS
27
27
  attr_accessor :pattern
28
28
 
29
+ # Provide a specific layout, overrides layout metadata taken from pattern
30
+ attr_accessor :layout
31
+
29
32
  # the image that is the cropped content for parsing
30
33
  attr_accessor :stage_image
31
34
 
@@ -44,16 +47,13 @@ class Sqed
44
47
  # Boolean, whether to do the boundary detection (not stage detection at present) against a thumbnail version of the passed image (faster, less accurate, true be default)
45
48
  attr_accessor :use_thumbnail
46
49
 
47
- # Provide a specific layout, overrides metadata taken from pattern
48
- attr_accessor :layout
49
-
50
50
  # Provide a metadata map, overrides metadata taken from pattern
51
51
  attr_accessor :metadata_map
52
52
 
53
53
  # Provide a boundary_finder, overrides metadata taken from pattern
54
54
  attr_accessor :boundary_finder
55
55
 
56
- def initialize(target_image: image, target_pattern: pattern, has_border: true, boundary_color: :green, use_thumbnail: true, boundary_finder: nil, target_layout: nil, metadata_map: nil)
56
+ def initialize(target_image: nil, target_pattern: :cross, target_layout: nil, has_border: true, boundary_color: :green, use_thumbnail: true, boundary_finder: nil, metadata_map: nil)
57
57
  raise 'extraction pattern not defined' if target_pattern && !SqedConfig::EXTRACTION_PATTERNS.keys.include?(target_pattern)
58
58
 
59
59
  # data, and stubs for results
@@ -63,9 +63,10 @@ class Sqed
63
63
 
64
64
  # extraction metadata
65
65
  @pattern = (target_pattern || :cross)
66
+
66
67
  @has_border = has_border
67
68
  @boundary_finder = boundary_finder.constantize if boundary_finder
68
- @layout = target_layout
69
+ @layout = target_layout || SqedConfig::EXTRACTION_PATTERNS[pattern][:layout]
69
70
  @metadata_map = metadata_map
70
71
  @boundary_color = boundary_color
71
72
  @use_thumbnail = use_thumbnail
@@ -78,12 +79,12 @@ class Sqed
78
79
  def extraction_metadata
79
80
  data = SqedConfig::EXTRACTION_PATTERNS[pattern]
80
81
 
81
- data.merge!(boundary_color: boundary_color)
82
- data.merge!(boundary_finder: @boundary_finder) if boundary_finder
83
- data.merge!(has_border: has_border)
84
- data.merge!(target_layout: layout) if layout
85
- data.merge!(target_metadata_map: metadata_map) if metadata_map
86
- data.merge!(use_thumbnail: use_thumbnail)
82
+ data[:boundary_color] = boundary_color
83
+ data[:boundary_finder] = @boundary_finder if boundary_finder
84
+ data[:has_border] = has_border
85
+ data[:target_layout] = layout if layout
86
+ data[:target_metadata_map] = metadata_map if metadata_map
87
+ data[:use_thumbnail] = use_thumbnail
87
88
  data
88
89
  end
89
90
 
@@ -135,6 +136,7 @@ class Sqed
135
136
  def result
136
137
  # pattern.nil? is no longer true -> must have values for all extraction_metadata keys
137
138
  return false if image.nil? || pattern.nil?
139
+
138
140
  extractor = Sqed::Extractor.new(
139
141
  target_boundaries: boundaries,
140
142
  target_metadata_map: extraction_metadata[:metadata_map],
@@ -1,3 +1,3 @@
1
1
  class Sqed
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Yoder