colincasey-arcserver.rb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "arcserver.rb"
8
- gem.summary = %Q{TODO}
8
+ gem.summary = %Q{Library for accessing ESRI ArcServer REST and SOAP APIs.}
9
9
  gem.email = "casey.colin@gmail.com"
10
10
  gem.homepage = "http://github.com/colincasey/arcserver.rb"
11
11
  gem.authors = ["Colin Casey"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/arcserver.rb.gemspec CHANGED
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{arcserver.rb}
5
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Colin Casey"]
9
- s.date = %q{2009-07-22}
12
+ s.date = %q{2009-09-23}
10
13
  s.email = %q{casey.colin@gmail.com}
11
14
  s.extra_rdoc_files = [
12
15
  "LICENSE",
@@ -26,7 +29,6 @@ Gem::Specification.new do |s|
26
29
  "lib/arcserver/soap/map_server.rb",
27
30
  "lib/arcserver/url_helper.rb",
28
31
  "test/functional/soap/map_server_test.rb",
29
- "test/functional/soap/portland_landbase_get_legend_info.yml",
30
32
  "test/test_helper.rb",
31
33
  "test/unit/map_server_test.rb",
32
34
  "test/unit/url_helper_test.rb"
@@ -35,7 +37,7 @@ Gem::Specification.new do |s|
35
37
  s.rdoc_options = ["--charset=UTF-8"]
36
38
  s.require_paths = ["lib"]
37
39
  s.rubygems_version = %q{1.3.4}
38
- s.summary = %q{TODO}
40
+ s.summary = %q{Library for accessing ESRI ArcServer REST and SOAP APIs.}
39
41
  s.test_files = [
40
42
  "test/test_helper.rb",
41
43
  "test/functional/soap/map_server_test.rb",
@@ -15,8 +15,10 @@ module ArcServer
15
15
  def_delegators :rest_service, :export
16
16
 
17
17
  def initialize(url, opts = {})
18
- @soap_service = opts[:soap_service] || SOAP::MapServer.new(url)
19
- @rest_service = opts[:rest_service] || REST::MapServer.new(url)
18
+ raise Exception, "#{url} is not a valid map server url" unless map_server?(url)
19
+
20
+ @soap_service = opts[:soap_service] || SOAP::MapServer.new(to_soap(url))
21
+ @rest_service = opts[:rest_service] || REST::MapServer.new(to_rest(url))
20
22
  end
21
23
  end
22
24
  end
@@ -10,12 +10,11 @@ module ArcServer
10
10
  end
11
11
 
12
12
  def on_before_dispatch
13
- self.class.instance_variable_set(:@uri, @soap_url)
13
+ self.class.endpoint(:uri => @soap_url, :version => 1)
14
14
  end
15
15
 
16
16
  def initialize(soap_url, protocol_version=2)
17
17
  @soap_url = soap_url
18
- self.class.instance_variable_set(:@protocol_version, protocol_version)
19
18
  end
20
19
 
21
20
  def get_default_map_name
@@ -26,7 +25,7 @@ module ArcServer
26
25
 
27
26
  def get_legend_info(args = {})
28
27
  response = invoke("ns:GetLegendInfo") do |message|
29
- message.add "MapName", args[:map_name]
28
+ message.add "MapName", args[:map_name] || get_default_map_name
30
29
  end
31
30
  node = response.document.xpath('//tns:GetLegendInfoResponse/Result', ns).first
32
31
  parse_legend_info_result(node)
@@ -10,6 +10,10 @@ module ArcServer
10
10
  url.to_s.match(/ArcGIS\/(?!rest\/).*/)
11
11
  end
12
12
 
13
+ def map_server?(url)
14
+ url.to_s.match(/\/MapServer$/)
15
+ end
16
+
13
17
  def to_rest(url)
14
18
  rest_service?(url) ? url : url.sub('/ArcGIS/', '/ArcGIS/rest/')
15
19
  end
data/lib/arcserver.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # encoding: utf-8
2
2
  require 'arcserver/url_helper'
3
- require 'arcserver/map_server'
3
+ require 'arcserver/map_server'
@@ -36,6 +36,18 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ should "use the default map name when getting the legend info" do
41
+ legend_info = @service.get_legend_info
42
+ legend_info.each do |item|
43
+ layer_assertion = "assert_legend_info_result_layer_#{item[:layer_id]}".to_sym
44
+ if respond_to?(layer_assertion)
45
+ send(layer_assertion, item)
46
+ else
47
+ raise "no assertions set for legend info with layer_id=#{item[:layer_id]}"
48
+ end
49
+ end
50
+ end
39
51
  end
40
52
 
41
53
  # legend info assertion helpers
@@ -152,7 +164,7 @@ class ArcServer::SOAP::MapServerTest < Test::Unit::TestCase
152
164
  end
153
165
 
154
166
  def assert_symbol_image(expected, actual)
155
- assert_equal expected[:image_data], actual[:image_data]
167
+ assert_not_nil expected[:image_data] if actual[:image_data]
156
168
  assert_equal expected[:image_url], actual[:image_url]
157
169
  assert_equal expected[:image_height] || 16, actual[:image_height]
158
170
  assert_equal expected[:image_width] || 20, actual[:image_width]
data/test/test_helper.rb CHANGED
@@ -8,5 +8,5 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
9
9
  require 'arcserver'
10
10
 
11
- class Test::Unit::TestCase
12
- end
11
+ class Test::Unit::TestCase
12
+ end
@@ -2,10 +2,17 @@
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
3
 
4
4
  class ArcServer::MapServerTest < Test::Unit::TestCase
5
+ should "raise an error if the required url is not a map server url" do
6
+ assert_raise(Exception) { ArcServer::MapServer.new('http://not.a.map/server/url') }
7
+ end
8
+
5
9
  context "verifying delegation of actions to the SOAP service" do
6
10
  setup do
7
11
  @mock_soap_service = mock
8
- @map_server = ArcServer::MapServer.new('http://www.map.server/', :soap_service => @mock_soap_service)
12
+ @map_server = ArcServer::MapServer.new(
13
+ 'http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics/ESRI_Census_USA/MapServer',
14
+ :soap_service => @mock_soap_service
15
+ )
9
16
  end
10
17
 
11
18
  should "forward get_default_map_name" do
@@ -22,7 +29,10 @@ class ArcServer::MapServerTest < Test::Unit::TestCase
22
29
  context "verifying delegation of actions to the REST service" do
23
30
  setup do
24
31
  @mock_rest_service = mock
25
- @map_server = ArcServer::MapServer.new('http://www.map.server/', :rest_service => @mock_rest_service)
32
+ @map_server = ArcServer::MapServer.new(
33
+ 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer',
34
+ :rest_service => @mock_rest_service
35
+ )
26
36
  end
27
37
 
28
38
  should "forward get_default_map_name" do
@@ -43,4 +43,12 @@ class ArcServer::UrlHelperTest < Test::Unit::TestCase
43
43
  assert !soap_service?(rest_url)
44
44
  end
45
45
  end
46
+
47
+ should "recognize a valid map server url" do
48
+ assert map_server?('http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics/ESRI_Census_USA/MapServer')
49
+ end
50
+
51
+ should "recognize an invalid map server url" do
52
+ assert !map_server?('http://not.a.map/server/url')
53
+ end
46
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colincasey-arcserver.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Casey
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-22 00:00:00 -07:00
12
+ date: 2009-09-23 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -36,12 +36,12 @@ files:
36
36
  - lib/arcserver/soap/map_server.rb
37
37
  - lib/arcserver/url_helper.rb
38
38
  - test/functional/soap/map_server_test.rb
39
- - test/functional/soap/portland_landbase_get_legend_info.yml
40
39
  - test/test_helper.rb
41
40
  - test/unit/map_server_test.rb
42
41
  - test/unit/url_helper_test.rb
43
42
  has_rdoc: false
44
43
  homepage: http://github.com/colincasey/arcserver.rb
44
+ licenses:
45
45
  post_install_message:
46
46
  rdoc_options:
47
47
  - --charset=UTF-8
@@ -62,10 +62,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  requirements: []
63
63
 
64
64
  rubyforge_project:
65
- rubygems_version: 1.2.0
65
+ rubygems_version: 1.3.5
66
66
  signing_key:
67
67
  specification_version: 3
68
- summary: TODO
68
+ summary: Library for accessing ESRI ArcServer REST and SOAP APIs.
69
69
  test_files:
70
70
  - test/test_helper.rb
71
71
  - test/functional/soap/map_server_test.rb
@@ -1,134 +0,0 @@
1
- ---
2
- symbol_image_defaults: &symbol_image_defaults
3
- :image_data:
4
- :image_url:
5
- :image_height: 16
6
- :image_width: 20
7
- :image_dpi: 96
8
- transparent_color_defaults: &transparent_color_defaults
9
- :use_windows_dithering: true
10
- :alpha_value: 255
11
- :red: 254
12
- :green: 255
13
- :blue: 255
14
-
15
- get_legend_info_result:
16
- - :layer_id: 1
17
- :name: Zoomed in
18
- :legend_groups:
19
- - :heading:
20
- :legend_classes:
21
- - :label:
22
- :description:
23
- :symbol_image:
24
- <<: *symbol_image_defaults
25
- :image_data: |
26
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
27
- R0lEQVR4nGP89/8/AzUBC4wR4O9PkckbNm5kZGBgYGCihmHIZrAgC8JsIdcwBgaoC6kJRg0cNXAw
28
- GIiSU6iRBanuQkZqF18AsvET5O8fag8AAAAASUVORK5CYII=
29
-
30
- :transparent_color:
31
- <<: *transparent_color_defaults
32
- - :layer_id: 2
33
- :name: Zoomed out
34
- :legend_groups:
35
- - :heading:
36
- :legend_classes:
37
- - :label:
38
- :description:
39
- :symbol_image:
40
- <<: *symbol_image_defaults
41
- :image_data: |
42
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
43
- PklEQVR4nGP89/8/AzUBE1VNY2BgYIExAvz9KXbqho0bGVnQBcg1DOYgqnt51MBRA4elgShZjxr5
44
- mZHaxRcATwAQChHiw9IAAAAASUVORK5CYII=
45
-
46
- :transparent_color:
47
- <<: *transparent_color_defaults
48
- - :layer_id: 3
49
- :name: Buildings
50
- :legend_groups:
51
- - :heading:
52
- :legend_classes:
53
- - :label:
54
- :description:
55
- :symbol_image:
56
- <<: *symbol_image_defaults
57
- :image_data: |
58
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
59
- NElEQVR4nGP89/8/AzUBE1VNY2BgYIExZtTVUeTUjKYmRgYGGrhw1MBRA0cNJAYwDvrSBgCGTgoZ
60
- cGsDFQAAAABJRU5ErkJggg==
61
-
62
- :transparent_color:
63
- <<: *transparent_color_defaults
64
- - :layer_id: 4
65
- :name: Zoning
66
- :legend_groups:
67
- - :heading:
68
- :legend_classes:
69
- - :label: Commercial
70
- :description:
71
- :symbol_image:
72
- <<: *symbol_image_defaults
73
- :image_data: |
74
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
75
- NElEQVR4nGP89/8/AzUBE1VNY2BgYIExXjAyUuRUif//GRkYaODCUQNHDRw1kBjAOOhLGwBbzgoZ
76
- pkxTgAAAAABJRU5ErkJggg==
77
-
78
- :transparent_color:
79
- <<: *transparent_color_defaults
80
- - :label: Industrial
81
- :description:
82
- :symbol_image:
83
- <<: *symbol_image_defaults
84
- :image_data: |
85
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
86
- NElEQVR4nGP89/8/AzUBE1VNY2BgYIEx2hhXUuTUqv/hjAwMNHDhqIGjBo4aSAxgHPSlDQBtTgoZ
87
- vbcuLAAAAABJRU5ErkJggg==
88
-
89
- :transparent_color:
90
- <<: *transparent_color_defaults
91
- - :label: Residential
92
- :description:
93
- :symbol_image:
94
- <<: *symbol_image_defaults
95
- :image_data: |
96
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
97
- NElEQVR4nGP89/8/AzUBE1VNY2BgYIExGBlKKHLqf4YeRgYGGrhw1MBRA0cNJAYwDvrSBgAaUgkZ
98
- JEjqtwAAAABJRU5ErkJggg==
99
-
100
- :transparent_color:
101
- <<: *transparent_color_defaults
102
- - :label: Mixed use
103
- :description:
104
- :symbol_image:
105
- <<: *symbol_image_defaults
106
- :image_data: |
107
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
108
- NElEQVR4nGP89/8/AzUBE1VNY2BgYIExvuW5UORUrkl7GBkYaODCUQNHDRw1kBjAOOhLGwCLTgoZ
109
- Ubp19QAAAABJRU5ErkJggg==
110
-
111
- :transparent_color:
112
- <<: *transparent_color_defaults
113
- - :label: Parks and open space
114
- :description:
115
- :symbol_image:
116
- <<: *symbol_image_defaults
117
- :image_data: |
118
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
119
- OUlEQVR4nGP89/8/AzUBE1VNY2BgYIExGBkYKHLqfwYGRgYGGrhw1MBRA0cNJAbA8zIsL1IKqO5C
120
- AJdcBiBRj7wXAAAAAElFTkSuQmCC
121
-
122
- :transparent_color:
123
- <<: *transparent_color_defaults
124
- - :label: Rural
125
- :description:
126
- :symbol_image:
127
- <<: *symbol_image_defaults
128
- :image_data: |
129
- iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA
130
- NElEQVR4nGP89/8/AzUBE1VNY2BgYIExus+lU+TUUqOZjAwMNHDhqIGjBo4aSAxgHPSlDQCRTgoZ
131
- WZnonwAAAABJRU5ErkJggg==
132
-
133
- :transparent_color:
134
- <<: *transparent_color_defaults