arcserver.rb 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +12 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +274 -0
- data/LICENSE +20 -20
- data/README.md +160 -0
- data/Rakefile +9 -62
- data/arcserver.rb.gemspec +35 -0
- data/lib/arcserver.rb +33 -7
- data/lib/arcserver/Identifiable.rb +10 -0
- data/lib/arcserver/Queryable.rb +10 -0
- data/lib/arcserver/feature_server.rb +19 -0
- data/lib/arcserver/geometry/geometry.rb +91 -0
- data/lib/arcserver/geometry_service.rb +18 -0
- data/lib/arcserver/gp_server.rb +20 -0
- data/lib/arcserver/graphics/feature.rb +23 -0
- data/lib/arcserver/graphics/feature_set.rb +26 -0
- data/lib/arcserver/map_server.rb +34 -40
- data/lib/arcserver/rest/feature_server.rb +30 -0
- data/lib/arcserver/rest/geometry_service.rb +54 -0
- data/lib/arcserver/rest/gp_server.rb +80 -0
- data/lib/arcserver/rest/identify.rb +66 -0
- data/lib/arcserver/rest/map_server.rb +230 -230
- data/lib/arcserver/rest/query.rb +68 -0
- data/lib/arcserver/url_helper.rb +31 -25
- data/lib/arcserver/util/legend_image.rb +0 -0
- data/lib/arcserver/version.rb +6 -6
- data/spec/custom_spec.rb +50 -0
- data/spec/factories/feature.rb +21 -0
- data/spec/feature_server_spec.rb +52 -0
- data/spec/feature_spec.rb +20 -0
- data/spec/geometry_service_spec.rb +31 -0
- data/spec/geometry_spec.rb +80 -0
- data/spec/gp_server_spec.rb +57 -0
- data/spec/identify_spec.rb +21 -0
- data/spec/query_spec.rb +38 -0
- data/spec/shared_context.rb +17 -0
- data/spec/spec_helper.rb +15 -0
- metadata +217 -158
- data/README.rdoc +0 -57
- data/lib/arcserver/soap/map_server.rb +0 -263
- data/test/functional/soap/map_server_test.rb +0 -193
- data/test/test_helper.rb +0 -25
- data/test/unit/map_server_test.rb +0 -61
- data/test/unit/url_helper_test.rb +0 -54
- data/test/unit/util/legend_image_test.rb +0 -69
data/test/test_helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'shoulda'
|
5
|
-
require 'mocha'
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
|
-
require 'arcserver'
|
10
|
-
|
11
|
-
class Test::Unit::TestCase
|
12
|
-
@@fixtures = {}
|
13
|
-
def self.fixtures list
|
14
|
-
[list].flatten.each do |fixture|
|
15
|
-
self.class_eval do
|
16
|
-
# add a method name for this fixture type
|
17
|
-
define_method(fixture) do |item|
|
18
|
-
# load and cache the YAML
|
19
|
-
@@fixtures[fixture] ||= YAML::load_file("test/fixtures/#{fixture.to_s}.yml")
|
20
|
-
@@fixtures[fixture][item.to_s]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../../test_helper", __FILE__)
|
3
|
-
|
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
|
-
|
9
|
-
context "verifying delegation of actions to the SOAP service" do
|
10
|
-
setup do
|
11
|
-
@mock_soap_service = mock
|
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
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
should "forward get_default_map_name" do
|
19
|
-
@mock_soap_service.expects(:get_default_map_name => nil)
|
20
|
-
@map_server.get_default_map_name
|
21
|
-
end
|
22
|
-
|
23
|
-
should "forward get_legend_info" do
|
24
|
-
@mock_soap_service.expects(:get_legend_info => nil)
|
25
|
-
@map_server.get_legend_info
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "verifying delegation of actions to the REST service" do
|
30
|
-
setup do
|
31
|
-
@mock_rest_service = mock
|
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
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
should "forward get_default_map_name" do
|
39
|
-
@mock_rest_service.expects(:export => nil)
|
40
|
-
@map_server.export
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "verify delegation of legend image creation to ArcServer::Util::LegendImage" do
|
45
|
-
setup do
|
46
|
-
@map_server = ArcServer::MapServer.new('http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics/ESRI_Census_USA/MapServer')
|
47
|
-
end
|
48
|
-
|
49
|
-
should "fail if optional dependency RMagick is not installed" do
|
50
|
-
Object.expects(:const_defined?).with("Magick").returns(false)
|
51
|
-
@map_server.expects(:require).with('RMagick').raises(LoadError)
|
52
|
-
assert_raise(ArcServer::ArcServerError) { @map_server.get_legend_image }
|
53
|
-
end
|
54
|
-
|
55
|
-
should "forward get_legend_image to LegendImage" do
|
56
|
-
mock_legend_image = mock { expects(:get_image) }
|
57
|
-
ArcServer::Util::LegendImage.expects(:new).with(@map_server).returns(mock_legend_image)
|
58
|
-
@map_server.get_legend_image
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../../test_helper", __FILE__)
|
3
|
-
|
4
|
-
class ArcServer::UrlHelperTest < Test::Unit::TestCase
|
5
|
-
include ArcServer::UrlHelper
|
6
|
-
|
7
|
-
context "when given a rest service url" do
|
8
|
-
setup do
|
9
|
-
@url = 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer'
|
10
|
-
end
|
11
|
-
|
12
|
-
should "be able to recognize it as a rest service" do
|
13
|
-
assert rest_service?(@url)
|
14
|
-
end
|
15
|
-
|
16
|
-
should "not be mistaken for a soap service" do
|
17
|
-
assert !soap_service?(@url)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "be able to convert to soap service url" do
|
21
|
-
soap_url = to_soap(@url)
|
22
|
-
assert soap_service?(soap_url)
|
23
|
-
assert !rest_service?(soap_url)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when given a soap service url" do
|
28
|
-
setup do
|
29
|
-
@url = 'http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics/ESRI_Census_USA/MapServer'
|
30
|
-
end
|
31
|
-
|
32
|
-
should "be able to recognize it as a soap service" do
|
33
|
-
assert soap_service?(@url)
|
34
|
-
end
|
35
|
-
|
36
|
-
should "not be mistaken for a rest service" do
|
37
|
-
assert !rest_service?(@url)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "be able to convert to rest service url" do
|
41
|
-
rest_url = to_rest(@url)
|
42
|
-
assert rest_service?(rest_url)
|
43
|
-
assert !soap_service?(rest_url)
|
44
|
-
end
|
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
|
54
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../../../test_helper", __FILE__)
|
3
|
-
require 'RMagick'
|
4
|
-
|
5
|
-
class ArcServer::Util::LegendImageTest < Test::Unit::TestCase
|
6
|
-
should "raise an error if nothing supplied to constructor" do
|
7
|
-
assert_raise(ArgumentError) { ArcServer::Util::LegendImage.new }
|
8
|
-
end
|
9
|
-
|
10
|
-
context "with third party libraries mocked out" do
|
11
|
-
setup do
|
12
|
-
legend_info = test_legend_info
|
13
|
-
map_server = mock('map_server') { stubs(:get_legend_info).returns(legend_info) }
|
14
|
-
@legend = ArcServer::Util::LegendImage.new(map_server)
|
15
|
-
|
16
|
-
mock_symbol_image = mock('symbol_image') do
|
17
|
-
expects(:first).times(3).returns(self)
|
18
|
-
expects(:destroy!).times(3)
|
19
|
-
end
|
20
|
-
Magick::Image.expects(:read_inline).with("AAA").returns(mock_symbol_image)
|
21
|
-
Magick::Image.expects(:read_inline).with("BBB").returns(mock_symbol_image)
|
22
|
-
Magick::Image.expects(:read_inline).with("CCC").returns(mock_symbol_image)
|
23
|
-
|
24
|
-
mock_image = mock('image') do
|
25
|
-
stubs(:cur_image)
|
26
|
-
expects(:composite!).with(mock_symbol_image, 20, 40, Magick::OverCompositeOp)
|
27
|
-
expects(:composite!).with(mock_symbol_image, 20, 65, Magick::OverCompositeOp)
|
28
|
-
expects(:composite!).with(mock_symbol_image, 20, 110, Magick::OverCompositeOp)
|
29
|
-
end
|
30
|
-
Magick::Image.expects(:new).returns(mock_image)
|
31
|
-
|
32
|
-
mock_draw = mock('draw') do
|
33
|
-
stubs(:draw)
|
34
|
-
stubs(:stroke_antialias)
|
35
|
-
stubs(:text_antialias=)
|
36
|
-
stubs(:density=)
|
37
|
-
expects(:text).with(10, 30, "Legend 1")
|
38
|
-
expects(:text).with(50, 54, "Symbol 1")
|
39
|
-
expects(:text).with(50, 79, "Symbol 2")
|
40
|
-
expects(:text).with(10, 100, "Legend 2")
|
41
|
-
end
|
42
|
-
Magick::Draw.expects(:new).returns(mock_draw)
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
should "be able to retrieve legend image" do
|
47
|
-
@legend.get_image
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_legend_info
|
52
|
-
[{
|
53
|
-
:name => "Legend 1",
|
54
|
-
:legend_groups => [
|
55
|
-
:legend_classes => [
|
56
|
-
{ :label => "Symbol 1", :symbol_image => { :image_data => "AAA" } },
|
57
|
-
{ :label => "Symbol 2", :symbol_image => { :image_data => "BBB" } }
|
58
|
-
]
|
59
|
-
]
|
60
|
-
}, {
|
61
|
-
:name => "Legend 2",
|
62
|
-
:legend_groups => [
|
63
|
-
:legend_classes => [
|
64
|
-
{ :symbol_image => { :image_data => "CCC" } }
|
65
|
-
]
|
66
|
-
]
|
67
|
-
}]
|
68
|
-
end
|
69
|
-
end
|