geoblacklight 0.2.0 → 0.2.1

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: 16b55f272d121ee2d812f798e81bb54c81c6cd26
4
- data.tar.gz: 50704f9e6eed51f0c8ef30d349a8985ba5a12b64
3
+ metadata.gz: 1e3dff76debb6018b35c109add225964984a5da3
4
+ data.tar.gz: f1c3cfbe2308c37e0d897ab4e88a8dbff3e62529
5
5
  SHA512:
6
- metadata.gz: 292aab24138e8c5d7ac59a8daae5075cdb8d7c4d381472093ca54153deb9847b22161206665a83e46b80c4da85ae086af490e29b413f30e986032715a370e9b1
7
- data.tar.gz: 562da646f3e4e8d7507de4007b896e0c52b7310b9551deb4f8e6d7fc318c898d13e7ae629b6d1cf7cb1c0bf20d2efa625dbf0e415efc11cd1815f49d0a46cfb9
6
+ metadata.gz: 3cb8faabed2e1d3fe1cd68a134b05c9bc668a9c668b35f32ec6fd35e88b996b222da199e036577cbba82440e2f300450eedec9db3b0431a4114abc68db8df3e3
7
+ data.tar.gz: 03c7c599e496f974b4d6d7587211dab9c67481c30ec836b1b66bf135c40545bd7e23ca39ac71cbfff5c1a02c9796a0ca7cc14fd4099871aa0202fee0268d0031
@@ -11,7 +11,7 @@ GeoBlacklight.Item = GeoBlacklight.extend({
11
11
  GeoBlacklight.prototype.initialize.call(this, element, options);
12
12
  this.dataAttributes = $(element).data();
13
13
  this.layer = new L.layerGroup().addTo(this.map);
14
- if (this.dataAttributes.available) {
14
+ if (this.dataAttributes.available && this.dataAttributes.wmsUrl !== null) {
15
15
  this.addPreviewLayer();
16
16
  this.addOpacityControl();
17
17
  } else {
@@ -4,7 +4,7 @@
4
4
 
5
5
  <div class='row'>
6
6
  <div class="col-md-8">
7
- <%= content_tag :div, id: 'map', data: { map: 'item', 'catalog-path'=> catalog_index_path , 'map-bbox' => document[:solr_bbox], 'layer-id' => document[:layer_id_s], 'wms-url' => document.references.wms.endpoint, available: document_available? } do %>
7
+ <%= content_tag :div, id: 'map', data: { map: 'item', 'catalog-path'=> catalog_index_path , 'map-bbox' => document[:solr_bbox], 'layer-id' => document[:layer_id_s], 'wms-url' => document.wms_url, available: document_available? } do %>
8
8
  <% end %>
9
9
  </div>
10
10
  <div id='table-container' class='col-md-4'><div id='attribute-table' ></div></div>
@@ -38,5 +38,25 @@ module Geoblacklight
38
38
  def itemtype
39
39
  "http://schema.org/Dataset"
40
40
  end
41
+
42
+ ##
43
+ # Provides a convenience method to access a SolrDocument's References
44
+ # endpoint url without having to check and see if it is available
45
+ # :type => a string which if its a Geoblacklight::Constants::URI key
46
+ # will return a coresponding Geoblacklight::Reference
47
+ def checked_endpoint(type)
48
+ type = references.send(type)
49
+ type.endpoint if type.present?
50
+ end
51
+
52
+ private
53
+
54
+ def method_missing(method, *args, &block)
55
+ if /.*_url$/ =~ method.to_s
56
+ checked_endpoint(method.to_s.gsub('_url', ''))
57
+ else
58
+ super
59
+ end
60
+ end
41
61
  end
42
62
  end
@@ -1,3 +1,3 @@
1
1
  module Geoblacklight
2
- VERSION = "0.2.0"
2
+ VERSION = '0.2.1'
3
3
  end
@@ -86,4 +86,26 @@ describe Geoblacklight::SolrDocument do
86
86
  expect(document.direct_download).to be_nil
87
87
  end
88
88
  end
89
+ describe 'checked_endpoint' do
90
+ let(:document_attributes) { {} }
91
+ let(:reference) { Geoblacklight::Reference.new(['http://www.opengis.net/def/serviceType/ogc/wms', 'http://www.example.com/wms']) }
92
+ it 'returns endpoint if available' do
93
+ expect_any_instance_of(Geoblacklight::References).to receive(:wms).and_return(reference)
94
+ expect(document.checked_endpoint('wms')).to eq 'http://www.example.com/wms'
95
+ end
96
+ it 'return nil if not available' do
97
+ expect_any_instance_of(Geoblacklight::References).to receive(:wms).and_return(nil)
98
+ expect(document.checked_endpoint('wms')).to be_nil
99
+ end
100
+ end
101
+ describe 'method_missing' do
102
+ let(:document_attributes) { {} }
103
+ it 'calls checked_endpoint with parsed method name if matches' do
104
+ expect(document).to receive(:checked_endpoint).with('wms').and_return(nil)
105
+ expect(document.wms_url).to be_nil
106
+ end
107
+ it 'raises no method error' do
108
+ expect { document.wms_urlz }.to raise_error NoMethodError
109
+ end
110
+ end
89
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoblacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Hardy