rgeoserver 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/rgeoserver/catalog.rb +4 -3
- data/lib/rgeoserver/coveragestore.rb +2 -4
- data/lib/rgeoserver/datastore.rb +2 -4
- data/lib/rgeoserver/resource.rb +21 -2
- data/lib/rgeoserver/workspace.rb +6 -12
- data/spec/lib/integration_test_spec.rb +2 -2
- metadata +3 -5
- data/lib/rgeoserver/coverages.rb +0 -114
- data/lib/rgeoserver/datastores.rb +0 -83
data/README.rdoc
CHANGED
@@ -50,7 +50,7 @@ To enter into an irb console with all classess loaded:
|
|
50
50
|
|
51
51
|
== Release History
|
52
52
|
|
53
|
-
- <b>v0.5
|
53
|
+
- <b>v0.5</b> - Initial alpha release
|
54
54
|
|
55
55
|
== TODO
|
56
56
|
- Complete stores and coverages functionality, handle Layers, styles and data upload.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
data/lib/rgeoserver/catalog.rb
CHANGED
@@ -32,12 +32,13 @@ module RGeoServer
|
|
32
32
|
{:accept => sym, :content_type=> sym}
|
33
33
|
end
|
34
34
|
|
35
|
-
# List of workspaces
|
35
|
+
# List of available workspaces
|
36
36
|
# @return [Array<RGeoServer::Workspace>]
|
37
|
-
def get_workspaces
|
37
|
+
def get_workspaces &block
|
38
38
|
response = self.search :workspaces => nil
|
39
39
|
doc = Nokogiri::XML(response)
|
40
|
-
doc.xpath(Workspace.root_xpath).collect
|
40
|
+
workspaces = doc.xpath(Workspace.root_xpath).collect{|w| w.text.to_s }
|
41
|
+
ResourceInfo.list Workspace, self, workspaces, {}, &block
|
41
42
|
end
|
42
43
|
|
43
44
|
# @param [String] workspace
|
@@ -78,10 +78,8 @@ module RGeoServer
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def coverages
|
82
|
-
profile[
|
83
|
-
Coverage.new @catalog, :workspace => @workspace, :coverage_store => self, :name => name
|
84
|
-
}
|
81
|
+
def coverages &block
|
82
|
+
self.class.list Coverage, @catalog, profile['coverages'], {:workspace => @workspace}, check_remote = true, &block
|
85
83
|
end
|
86
84
|
|
87
85
|
def profile_xml_to_hash profile_xml
|
data/lib/rgeoserver/datastore.rb
CHANGED
@@ -86,10 +86,8 @@ module RGeoServer
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
def featuretypes
|
90
|
-
profile[
|
91
|
-
FeatureType.new @catalog, :workspace => @workspace, :data_store => self, :name => name
|
92
|
-
}
|
89
|
+
def featuretypes &block
|
90
|
+
self.class.list FeatureType, @catalog, profile['featureTypes'], {:workspace => @workspace}, check_remote = true, &block
|
93
91
|
end
|
94
92
|
|
95
93
|
def profile_xml_to_hash profile_xml
|
data/lib/rgeoserver/resource.rb
CHANGED
@@ -30,6 +30,24 @@ module RGeoServer
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
# Generic object construction iterator
|
34
|
+
# @param [RGeoServer::ResourceInfo.class] klass
|
35
|
+
# @param [RGeoServer::Catalog] catalog
|
36
|
+
# @param [Array<String>] names
|
37
|
+
# @param [Hash] options
|
38
|
+
# @param [bool] check_remote if already exists in catalog and cache it
|
39
|
+
# @yield [RGeoServer::ResourceInfo]
|
40
|
+
def self.list klass, catalog, names, options, check_remote = false, &block
|
41
|
+
return to_enum(:list, klass, catalog, names, options).to_a unless block_given?
|
42
|
+
|
43
|
+
(names.is_a?(Array)? names : [names]).each { |name|
|
44
|
+
obj = klass.new catalog, options.merge(:name => name)
|
45
|
+
obj.new? if check_remote
|
46
|
+
block.call(obj)
|
47
|
+
}
|
48
|
+
|
49
|
+
end
|
50
|
+
|
33
51
|
def initialize options
|
34
52
|
@new = true
|
35
53
|
end
|
@@ -46,8 +64,9 @@ module RGeoServer
|
|
46
64
|
self.class.update_method
|
47
65
|
end
|
48
66
|
|
67
|
+
|
49
68
|
# Modify or save the resource
|
50
|
-
# @param
|
69
|
+
# @param [Hash] options
|
51
70
|
# @return [RGeoServer::ResourceInfo]
|
52
71
|
def save options = {}
|
53
72
|
@previously_changed = changes
|
@@ -65,7 +84,7 @@ module RGeoServer
|
|
65
84
|
end
|
66
85
|
|
67
86
|
# Purge resource from Geoserver Catalog
|
68
|
-
# @param
|
87
|
+
# @param [Hash] options
|
69
88
|
# @return [RGeoServer::ResourceInfo] `self`
|
70
89
|
def delete options = {}
|
71
90
|
run_callbacks :destroy do
|
data/lib/rgeoserver/workspace.rb
CHANGED
@@ -56,22 +56,16 @@ module RGeoServer
|
|
56
56
|
@route = route
|
57
57
|
end
|
58
58
|
|
59
|
-
def data_stores
|
60
|
-
profile['dataStores']
|
61
|
-
DataStore.new @catalog, :workspace => self, :name => name
|
62
|
-
}
|
59
|
+
def data_stores &block
|
60
|
+
self.class.list DataStore, @catalog, profile['dataStores'], {:workspace => self}, check_remote = true, &block
|
63
61
|
end
|
64
62
|
|
65
|
-
def coverage_stores
|
66
|
-
profile['coverageStores']
|
67
|
-
CoverageStore.new @catalog, :workspace => self, :name => name
|
68
|
-
}
|
63
|
+
def coverage_stores &block
|
64
|
+
self.class.list CoverageStore, @catalog, profile['coverageStores'], {:workspace => self}, check_remote = true, &block
|
69
65
|
end
|
70
66
|
|
71
|
-
def wms_stores
|
72
|
-
profile['wmsStores']
|
73
|
-
WmsStore.new @catalog, :workspace => self, :name => name
|
74
|
-
}
|
67
|
+
def wms_stores &block
|
68
|
+
self.class.list WmsStore, @catalog, profile['wmsStores'], {:workspace => self}, check_remote = true, &block
|
75
69
|
end
|
76
70
|
|
77
71
|
end
|
@@ -64,10 +64,10 @@ describe "Integration test against a GeoServer instance", :integration => true d
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should list datastore objects that belong to it" do
|
67
|
-
@ws.data_stores
|
67
|
+
@ws.data_stores do |ds|
|
68
68
|
ds.should be_kind_of(RGeoServer::DataStore)
|
69
69
|
["s1", "s2", "s3"].should include ds.name
|
70
|
-
|
70
|
+
end
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgeoserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 3
|
10
|
+
version: 0.5.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Renzo Sanchez-Silva
|
@@ -207,10 +207,8 @@ files:
|
|
207
207
|
- lib/rgeoserver/catalog.rb
|
208
208
|
- lib/rgeoserver/config.rb
|
209
209
|
- lib/rgeoserver/coverage.rb
|
210
|
-
- lib/rgeoserver/coverages.rb
|
211
210
|
- lib/rgeoserver/coveragestore.rb
|
212
211
|
- lib/rgeoserver/datastore.rb
|
213
|
-
- lib/rgeoserver/datastores.rb
|
214
212
|
- lib/rgeoserver/featuretype.rb
|
215
213
|
- lib/rgeoserver/geoserver_url_helpers.rb
|
216
214
|
- lib/rgeoserver/resource.rb
|
data/lib/rgeoserver/coverages.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
|
2
|
-
module RGeoServer
|
3
|
-
|
4
|
-
class CoverageStore < ResourceInfo
|
5
|
-
|
6
|
-
OBJ_ATTRIBUTES = {:catalog => 'catalog', :workspace => 'workspace', :url => 'url', :data_type => 'type', :name => 'name', :enabled => 'enabled', :description => 'description'}
|
7
|
-
OBJ_DEFAULT_ATTRIBUTES = {:catalog => nil, :workspace => nil, :url => '', :data_type => 'GeoTIFF', :name => nil, :enabled => true, :description=>nil}
|
8
|
-
define_attribute_methods OBJ_ATTRIBUTES.keys
|
9
|
-
update_attribute_accessors OBJ_ATTRIBUTES
|
10
|
-
|
11
|
-
@@r = Confstruct::Configuration.new(
|
12
|
-
#:route => "workspaces/%s/coveragestores",
|
13
|
-
:route => "workspaces/%s/coveragestores/%s",
|
14
|
-
#:root => "coverageStores",
|
15
|
-
:root => "coverageStore",
|
16
|
-
:resource_name => "coverageStore"
|
17
|
-
)
|
18
|
-
|
19
|
-
def self.root
|
20
|
-
@@r.root
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.method
|
24
|
-
:put
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.resource_name
|
28
|
-
@@r.resource_name
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.root_xpath
|
32
|
-
"//#{root}/#{resource_name}"
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.member_xpath
|
36
|
-
"//#{resource_name}"
|
37
|
-
end
|
38
|
-
|
39
|
-
def route
|
40
|
-
#@@r.route % @workspace.name
|
41
|
-
@@r.route % [@workspace.name , @name]
|
42
|
-
end
|
43
|
-
|
44
|
-
def message
|
45
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
46
|
-
xml.coverageStore {
|
47
|
-
xml.name @name
|
48
|
-
xml.enabled profile['enabled']
|
49
|
-
xml.type_ @data_type if data_type_changed?
|
50
|
-
xml.description @description if description_changed?
|
51
|
-
xml.url @url if url_changed?
|
52
|
-
}
|
53
|
-
end
|
54
|
-
return builder.doc.to_xml
|
55
|
-
end
|
56
|
-
|
57
|
-
# @param [RGeoServer::Catalog] catalog
|
58
|
-
# @param [RGeoServer::Workspace|String] workspace
|
59
|
-
# @param [String] name
|
60
|
-
def initialize catalog, options
|
61
|
-
super({})
|
62
|
-
_run_initialize_callbacks do
|
63
|
-
@catalog = catalog
|
64
|
-
workspace = options[:workspace] || 'default'
|
65
|
-
if workspace.instance_of? String
|
66
|
-
@workspace = @catalog.get_workspace(workspace)
|
67
|
-
elsif workspace.instance_of? Workspace
|
68
|
-
@workspace = workspace
|
69
|
-
else
|
70
|
-
raise "Not a valid workspace"
|
71
|
-
end
|
72
|
-
@name = options[:name].strip
|
73
|
-
@route = route
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def coverages
|
78
|
-
profile[:coverages].collect{ |name|
|
79
|
-
Coverage.new @catalog, :workspace => @workspace, :coverage_store => self, :name => name if name
|
80
|
-
}
|
81
|
-
end
|
82
|
-
|
83
|
-
def profile_xml_to_ng1 profile_xml
|
84
|
-
Nokogiri::XML(profile_xml).xpath(self.member_xpath)
|
85
|
-
end
|
86
|
-
|
87
|
-
def profile_xml_to_hash profile_xml
|
88
|
-
doc = profile_xml_to_ng profile_xml
|
89
|
-
{
|
90
|
-
'name' => doc.at_xpath('//name').text.strip,
|
91
|
-
'workspace' => @workspace.name,
|
92
|
-
'type' => doc.at_xpath('//type/text()').to_s,
|
93
|
-
'enabled' => doc.at_xpath('//enabled/text()').to_s,
|
94
|
-
'description' => doc.at_xpath('//description/text()').to_s,
|
95
|
-
'url' => doc.at_xpath('//url/text()').to_s
|
96
|
-
}
|
97
|
-
end
|
98
|
-
|
99
|
-
def profile_xml_to_hash1 profile_xml
|
100
|
-
doc = profile_xml_to_ng profile_xml
|
101
|
-
h = {:name => doc.at_xpath('//name').text.strip, :workspace => @workspace.name, :coverages => [] }
|
102
|
-
doc.xpath('//coverages/atom:link/@href', "xmlns:atom"=>"http://www.w3.org/2005/Atom" ).each{ |l|
|
103
|
-
h[:coverages] << {
|
104
|
-
:name => l.parent.parent.at_xpath('//name/text()').to_s,
|
105
|
-
:type => l.parent.parent.at_xpath('//type/text()').to_s,
|
106
|
-
:enabled => l.parent.parent.at_xpath('//enabled/text()').to_s,
|
107
|
-
:description => l.parent.parent.at_xpath('//description/text()').to_s,
|
108
|
-
:url => l.parent.parent.at_xpath('//url/text()').to_s
|
109
|
-
}
|
110
|
-
}
|
111
|
-
h
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
|
2
|
-
module RGeoServer
|
3
|
-
|
4
|
-
class DataStores < ResourceInfo
|
5
|
-
|
6
|
-
OBJ_ATTRIBUTES = {:enabled => "enabled", :catalog => "catalog", :workspace => "workspace", :name => "name"}
|
7
|
-
OBJ_DEFAULT_ATTRIBUTES = {:enabled => 'true', :catalog => nil, :workspace => nil, :name => nil, }
|
8
|
-
define_attribute_methods OBJ_ATTRIBUTES.keys
|
9
|
-
update_attribute_accessors OBJ_ATTRIBUTES
|
10
|
-
|
11
|
-
@@r = Confstruct::Configuration.new(
|
12
|
-
:route => "workspaces/%s/datastores",
|
13
|
-
:root => "dataStores",
|
14
|
-
:resource_name => "dataStore"
|
15
|
-
)
|
16
|
-
|
17
|
-
def self.root
|
18
|
-
@@r.root
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.create_method
|
22
|
-
:put
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.update_method
|
26
|
-
:put
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.resource_name
|
30
|
-
@@r.resource_name
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.root_xpath
|
34
|
-
"//#{root}/#{resource_name}"
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.member_xpath
|
38
|
-
"//#{resource_name}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def route
|
42
|
-
@@r.route % @workspace.name
|
43
|
-
end
|
44
|
-
|
45
|
-
def message
|
46
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
47
|
-
xml.dataStore {
|
48
|
-
xml.enabled @enabled
|
49
|
-
xml.name @name
|
50
|
-
}
|
51
|
-
end
|
52
|
-
return builder.doc.to_xml
|
53
|
-
end
|
54
|
-
|
55
|
-
# @param [RGeoServer::Catalog] catalog
|
56
|
-
# @param [RGeoServer::Workspace|String] workspace
|
57
|
-
# @param [String] name
|
58
|
-
def initialize catalog, options
|
59
|
-
super({})
|
60
|
-
_run_initialize_callbacks do
|
61
|
-
@catalog = catalog
|
62
|
-
workspace = options[:workspace] || 'default'
|
63
|
-
if workspace.instance_of? String
|
64
|
-
@workspace = @catalog.get_workspace(workspace)
|
65
|
-
elsif workspace.instance_of? Workspace
|
66
|
-
@workspace = workspace
|
67
|
-
else
|
68
|
-
raise "Not a valid workspace"
|
69
|
-
end
|
70
|
-
@name = options[:name].strip
|
71
|
-
@connection_parameters = options[:connection_parameters] || {}
|
72
|
-
@route = route
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def data_stores
|
77
|
-
profile['dataStores'].collect{ |name|
|
78
|
-
DataStore.new @catalog, :workspace => @workspace, :data_store => self, :name => name
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|