openseadragon 0.0.7 → 0.0.8

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: 04bc58ab79202f2c92097e5319209470ea845627
4
- data.tar.gz: 3f871fcb5a65843f8a150aa331e34d4082bc7088
3
+ metadata.gz: 49ded4f5934b0c28ce5849b7f3e63cc287180e27
4
+ data.tar.gz: 866a1293d8bb5d330c76d6616cebeb4d1e17fdb5
5
5
  SHA512:
6
- metadata.gz: 9572749a0dc443e3f083ce5b016e35343fd82e9ddd244dbe28eb8884190aca9208d5a8f66b42bcb757fdd64786baa3e5e22fa92597e2be9025faa1012b33964f
7
- data.tar.gz: 43d9e8f330bae54958218cbcef115a26c8027f1667d8bd6a64453e7ab0388bcc0bc128932948f17bc3312f7a4cd999a28bb60dde7b43e6649e83033dac52e093
6
+ metadata.gz: ead6ec905ddcd5f12020b4233f2a4be9c5d66239cf378d88cd396b650b3ce30606a94f7a97fcc2aec07a8a09cdf7c58d6c7aff334575f0bf24a1a4a969365027
7
+ data.tar.gz: cb08cc979a049b35dc0edab0c00cd7e5f445d1c87df60e502feccc1ad574e01bfeccf312b68e16762a12b1fe0322aa692433a21ea1b94e868dd528fe9649a3d8
@@ -51,7 +51,7 @@ module Openseadragon
51
51
  tile_sources = sources.map { |thing| extract_openseadragon_picture_tilesource(thing) }
52
52
 
53
53
  picture_options[:data] ||= {}
54
- picture_options[:data][:openseadragon] ||= true
54
+ picture_options[:data][:openseadragon] = osd_asset_defaults.merge(picture_options[:data][:openseadragon] || {}).to_json
55
55
 
56
56
  picture_tag [tile_sources], { media: 'openseadragon' }.merge(source_options), picture_options
57
57
  end
@@ -97,7 +97,7 @@ module Openseadragon
97
97
  html_options.merge! src_options.fetch(:html, {})
98
98
  html_options[:data] ||= {}
99
99
 
100
- osd_options = osd_asset_defaults.merge(html_options[:data][:openseadragon] || {})
100
+ osd_options = html_options[:data][:openseadragon] || {}
101
101
  osd_options.merge!(src_options.except(:html))
102
102
 
103
103
  if src.respond_to? :to_tilesource
@@ -114,7 +114,7 @@ module Openseadragon
114
114
  html_options[:data][:openseadragon] = osd_options.to_json
115
115
 
116
116
  [ html_options.fetch(:src, src) => html_options ]
117
- else
117
+ else # string
118
118
  thing
119
119
  end
120
120
  end
@@ -1,3 +1,3 @@
1
1
  module Openseadragon
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -44,63 +44,74 @@ describe Openseadragon::OpenseadragonHelper do
44
44
  end
45
45
 
46
46
  describe "#openseadragon_picture_tag" do
47
- it "should mark the <picture> as an openseadragon tag" do
48
- expect(helper.openseadragon_picture_tag).to have_selector 'picture[data-openseadragon="true"]'
47
+ before { allow(helper).to receive(:osd_asset_defaults).and_return({b: 6}) }
48
+
49
+ context "with no args" do
50
+ subject { helper.openseadragon_picture_tag }
51
+ it "should mark the <picture> as an openseadragon tag" do
52
+ expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
53
+ end
49
54
  end
50
55
 
51
- it "should pass simple strings through" do
52
- response = helper.openseadragon_picture_tag('image1.jpg', 'image2.jpg')
53
- expect(response).to have_selector 'picture source[src="image1.jpg"][media="openseadragon"]'
54
- expect(response).to have_selector 'picture source[src="image2.jpg"][media="openseadragon"]'
56
+ context "with simple strings" do
57
+ subject { helper.openseadragon_picture_tag('image1.jpg', 'image2.jpg') }
58
+
59
+ it "should pass simple strings through" do
60
+ expect(subject).to have_selector 'picture source[src="image1.jpg"][media="openseadragon"]'
61
+ expect(subject).to have_selector 'picture source[src="image2.jpg"][media="openseadragon"]'
62
+ expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
63
+ end
55
64
  end
56
65
 
57
66
  context "with tilesource objects" do
67
+ subject { helper.openseadragon_picture_tag(double(to_tilesource: { a: 1})) }
58
68
  it "should convert sources to tilesources" do
59
- source = double(to_tilesource: { a: 1})
60
- response = helper.openseadragon_picture_tag(source)
61
- expect(response).to have_selector 'picture source[src="openseadragon-tilesource"]'
62
- expect(response).to match /data-openseadragon="#{helper.escape_once({a: 1}.to_json)}"/
69
+ expect(subject).to have_selector 'picture source[src="openseadragon-tilesource"]'
70
+ expect(subject).to match /data-openseadragon="#{helper.escape_once({a: 1}.to_json)}"/
71
+ expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
63
72
  end
64
73
  end
65
74
 
66
75
  context "with a source given as a hash" do
67
- before { allow(helper).to receive(:osd_asset_defaults).and_return({b: 6}) }
68
-
76
+ subject { helper.openseadragon_picture_tag(['image1.jpg' => { html: { id: 'xyz' }}]) }
69
77
  it "should extract html options" do
70
- response = helper.openseadragon_picture_tag(['image1.jpg' => { html: { id: 'xyz' }}])
71
- expect(response).to have_selector 'picture source[src="image1.jpg"][id="xyz"]'
78
+ expect(subject).to have_selector 'picture source[src="image1.jpg"][id="xyz"]'
79
+ expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
72
80
  end
73
81
 
74
- it "should pass the remaining options as encoded openseadragon options" do
75
- response = helper.openseadragon_picture_tag(['image1.jpg' => { a: 1}])
76
- expect(response).to have_selector 'picture source[src="image1.jpg"]'
77
- expect(response).to have_selector 'picture source[src="image1.jpg"][data-openseadragon]'
78
- expect(response).to match /data-openseadragon="#{helper.escape_once({b: 6, a: 1}.to_json)}"/
82
+ context "and extra options" do
83
+ subject { helper.openseadragon_picture_tag(['image1.jpg' => { a: 1}]) }
84
+ it "should pass the remaining options as encoded openseadragon options" do
85
+ expect(subject).to have_selector 'picture source[src="image1.jpg"]'
86
+ expect(subject).to have_selector 'picture source[src="image1.jpg"][data-openseadragon]'
87
+ expect(subject).to match /data-openseadragon="#{helper.escape_once({a: 1}.to_json)}"/
88
+ end
79
89
  end
80
90
 
81
- it "should merge a tilesource key with the options provided" do
82
- source = double(to_tilesource: { a: 1, b: 1})
83
- response = helper.openseadragon_picture_tag([source => { html: { id: 'xyz' }, b: 2, c: 3}])
84
- expect(response).to have_selector 'picture source[src="openseadragon-tilesource"]'
85
- expect(response).to have_selector 'picture source[src="openseadragon-tilesource"][id="xyz"]'
86
- expect(response).to match /data-openseadragon="#{helper.escape_once({b: 2, c: 3, a: 1}.to_json)}"/
91
+ context "tielsource key and options" do
92
+ let(:source) { double(to_tilesource: { a: 1, b: 1}) }
93
+ subject { helper.openseadragon_picture_tag([source => { html: { id: 'xyz' }, b: 2, c: 3}]) }
94
+ it "should merge a tilesource key with the options provided" do
95
+ expect(subject).to have_selector 'picture source[src="openseadragon-tilesource"]'
96
+ expect(subject).to have_selector 'picture source[src="openseadragon-tilesource"][id="xyz"]'
97
+ expect(subject).to match /data-openseadragon="#{helper.escape_once({b: 2, c: 3, a: 1}.to_json)}"/
98
+ end
87
99
  end
88
100
  end
101
+ end
89
102
 
90
- describe "#osd_asset_defaults" do
91
- subject { helper.send(:osd_asset_defaults) }
92
- its(['prefixUrl']) { should eq ''}
93
- its(['navImages']) { should eq(
94
- "zoomIn"=>{"REST"=>"/assets/openseadragon/zoomin_rest.png", "GROUP"=>"/assets/openseadragon/zoomin_grouphover.png", "HOVER"=>"/assets/openseadragon/zoomin_hover.png", "DOWN"=>"/assets/openseadragon/zoomin_pressed.png"},
95
- "zoomOut"=>{"REST"=>"/assets/openseadragon/zoomout_rest.png", "GROUP"=>"/assets/openseadragon/zoomout_grouphover.png", "HOVER"=>"/assets/openseadragon/zoomout_hover.png", "DOWN"=>"/assets/openseadragon/zoomout_pressed.png"},
96
- "home"=>{"REST"=>"/assets/openseadragon/home_rest.png", "GROUP"=>"/assets/openseadragon/home_grouphover.png", "HOVER"=>"/assets/openseadragon/home_hover.png", "DOWN"=>"/assets/openseadragon/home_pressed.png"},
97
- "fullpage"=>{"REST"=>"/assets/openseadragon/fullpage_rest.png", "GROUP"=>"/assets/openseadragon/fullpage_grouphover.png", "HOVER"=>"/assets/openseadragon/fullpage_hover.png", "DOWN"=>"/assets/openseadragon/fullpage_pressed.png"},
98
- "rotateleft"=>{"REST"=>"/assets/openseadragon/rotateleft_rest.png", "GROUP"=>"/assets/openseadragon/rotateleft_grouphover.png", "HOVER"=>"/assets/openseadragon/rotateleft_hover.png", "DOWN"=>"/assets/openseadragon/rotateleft_pressed.png"},
99
- "rotateright"=>{"REST"=>"/assets/openseadragon/rotateright_rest.png", "GROUP"=>"/assets/openseadragon/rotateright_grouphover.png", "HOVER"=>"/assets/openseadragon/rotateright_hover.png", "DOWN"=>"/assets/openseadragon/rotateright_pressed.png"},
100
- "previous"=>{"REST"=>"/assets/openseadragon/previous_rest.png", "GROUP"=>"/assets/openseadragon/previous_grouphover.png", "HOVER"=>"/assets/openseadragon/previous_hover.png", "DOWN"=>"/assets/openseadragon/previous_pressed.png"},
101
- "next"=>{"REST"=>"/assets/openseadragon/next_rest.png", "GROUP"=>"/assets/openseadragon/next_grouphover.png", "HOVER"=>"/assets/openseadragon/next_hover.png", "DOWN"=>"/assets/openseadragon/next_pressed.png"}
102
- )}
103
-
104
- end
103
+ describe "#osd_asset_defaults" do
104
+ subject { helper.send(:osd_asset_defaults) }
105
+ its(['prefixUrl']) { should eq ''}
106
+ its(['navImages']) { should eq(
107
+ "zoomIn"=>{"REST"=>"/assets/openseadragon/zoomin_rest.png", "GROUP"=>"/assets/openseadragon/zoomin_grouphover.png", "HOVER"=>"/assets/openseadragon/zoomin_hover.png", "DOWN"=>"/assets/openseadragon/zoomin_pressed.png"},
108
+ "zoomOut"=>{"REST"=>"/assets/openseadragon/zoomout_rest.png", "GROUP"=>"/assets/openseadragon/zoomout_grouphover.png", "HOVER"=>"/assets/openseadragon/zoomout_hover.png", "DOWN"=>"/assets/openseadragon/zoomout_pressed.png"},
109
+ "home"=>{"REST"=>"/assets/openseadragon/home_rest.png", "GROUP"=>"/assets/openseadragon/home_grouphover.png", "HOVER"=>"/assets/openseadragon/home_hover.png", "DOWN"=>"/assets/openseadragon/home_pressed.png"},
110
+ "fullpage"=>{"REST"=>"/assets/openseadragon/fullpage_rest.png", "GROUP"=>"/assets/openseadragon/fullpage_grouphover.png", "HOVER"=>"/assets/openseadragon/fullpage_hover.png", "DOWN"=>"/assets/openseadragon/fullpage_pressed.png"},
111
+ "rotateleft"=>{"REST"=>"/assets/openseadragon/rotateleft_rest.png", "GROUP"=>"/assets/openseadragon/rotateleft_grouphover.png", "HOVER"=>"/assets/openseadragon/rotateleft_hover.png", "DOWN"=>"/assets/openseadragon/rotateleft_pressed.png"},
112
+ "rotateright"=>{"REST"=>"/assets/openseadragon/rotateright_rest.png", "GROUP"=>"/assets/openseadragon/rotateright_grouphover.png", "HOVER"=>"/assets/openseadragon/rotateright_hover.png", "DOWN"=>"/assets/openseadragon/rotateright_pressed.png"},
113
+ "previous"=>{"REST"=>"/assets/openseadragon/previous_rest.png", "GROUP"=>"/assets/openseadragon/previous_grouphover.png", "HOVER"=>"/assets/openseadragon/previous_hover.png", "DOWN"=>"/assets/openseadragon/previous_pressed.png"},
114
+ "next"=>{"REST"=>"/assets/openseadragon/next_rest.png", "GROUP"=>"/assets/openseadragon/next_grouphover.png", "HOVER"=>"/assets/openseadragon/next_hover.png", "DOWN"=>"/assets/openseadragon/next_pressed.png"}
115
+ )}
105
116
  end
106
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openseadragon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne