iiif_url 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 3c81c70f9aca9c036e51b8f469c768fe7ee07a43
4
- data.tar.gz: 048cf777800fed40f0ef8e78152b40ecae7b89c0
3
+ metadata.gz: cdc59d4c9f29f74fd43a2f582c1ed495637278c6
4
+ data.tar.gz: 29453c9dbd90f47db47236a651d878957198284c
5
5
  SHA512:
6
- metadata.gz: fb3d08bef126d3203ce9a94431d3cc9f1dbdcd5497dde4d744e1c4840751787784d5a7469d6a5e654a8ade37ff33bc1fb4e2327ff252e443c03b601d79a34ea0
7
- data.tar.gz: efc6eb6c4dec79f1514aed432841ca3349a9e20b65ea1dd4067fbe054d5641c283916531c4f52a3e0f9df85aff4a928642917f8f4fdf2eb0c2228f8c56289e0c
6
+ metadata.gz: 62f2420a77aee79a19eb338fc19859bae398b73d7a66bda8cc551578b2ade779c12e24aa656fa7adc342054dc89dbea0e958b1a19eed785e48a672590d4c6f67
7
+ data.tar.gz: 1bb3fdafe0095008ce4483754dccc3153523823e2123f49c4ddcdc38a9643bd9fad5e804d80d60150105a2942793a4fb37f630d379c8bf592fa78220202507f8
@@ -102,15 +102,26 @@ class IiifUrl
102
102
  quality, format = quality_format.split('.')
103
103
 
104
104
  rotation_string = url_parts.pop
105
- rotation = if rotation_string.include?('!')
106
- degrees = rotation_string.sub('!', '')
107
- {degrees: degrees.to_i, mirror: true}
105
+ rotation = {}
106
+ rotation[:mirror] = if rotation_string.include?('!')
107
+ rotation_string.sub!('!', '')
108
+ true
108
109
  else
109
- {degrees: rotation_string.to_i, mirror: false}
110
+ false
111
+ end
112
+ rotation[:degrees] = if is_number?(rotation_string)
113
+ rotation_string.to_i
114
+ else
115
+ rotation_string
110
116
  end
111
117
 
112
118
  size_string = url_parts.pop
113
- size = if size_string.include?(',')
119
+ size = {}
120
+ if size_string =~ /^!\d+,\d+/
121
+ size[:confined] = true
122
+ size_string.gsub!('!', '')
123
+ end
124
+ if size_string.include?(',')
114
125
  w, h = size_string.split(',')
115
126
  w = if w.empty?
116
127
  nil
@@ -118,12 +129,13 @@ class IiifUrl
118
129
  w.to_i
119
130
  end
120
131
  h = h.to_i if !h.nil?
121
- {w: w, h: h}
132
+ size[:w] = w
133
+ size[:h] = h
122
134
  elsif size_string.include?('pct')
123
- pct, size = size_string.split(':')
124
- {pct: size.to_f}
135
+ pct, pct_size = size_string.split(':')
136
+ size[:pct] = pct_size.to_f
125
137
  else
126
- size_string
138
+ size = size_string
127
139
  end
128
140
 
129
141
  region_string = url_parts.pop
@@ -152,4 +164,10 @@ class IiifUrl
152
164
  format: format
153
165
  }
154
166
  end
167
+
168
+ private
169
+
170
+ def self.is_number?(string)
171
+ true if Float(string) rescue false
172
+ end
155
173
  end
@@ -1,3 +1,3 @@
1
1
  class IiifUrl
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iiif_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Ronallo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-20 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler