geoserver-publish 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +42 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +7 -4
- data/CONTRIBUTING.md +192 -0
- data/README.md +6 -2
- data/geoserver-publish.gemspec +1 -1
- data/lib/geoserver/publish/config.rb +5 -5
- data/lib/geoserver/publish/connection.rb +6 -6
- data/lib/geoserver/publish/coverage.rb +14 -14
- data/lib/geoserver/publish/coverage_store.rb +54 -19
- data/lib/geoserver/publish/data_store.rb +43 -33
- data/lib/geoserver/publish/feature_type.rb +14 -14
- data/lib/geoserver/publish/layer.rb +8 -8
- data/lib/geoserver/publish/style.rb +13 -13
- data/lib/geoserver/publish/version.rb +1 -1
- data/lib/geoserver/publish/workspace.rb +11 -11
- metadata +9 -8
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9db10b46d41ef044f7527b82aed3465f85382d743a04bc5fa1d6ada89cc848d
|
4
|
+
data.tar.gz: 8143a50b59ab0e9fbfa3d77fa0332bafcda2db79b70121dd01ebd3d6e081ab67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f2e5bc90e55b89bae11f1c577bbb0e95997425b7ab977035d0a1f9fd47f9bb64b944fb2c3c6be8559b2da9b222930839ed52dd45da0a5176fbef28029b4a800
|
7
|
+
data.tar.gz: e59bc180f9764ef886f2f58bc4a440d617a4758ada9c518265c06d53196607ff58784b408944c75245772cea2a766fdf0ddc1cfd2c49cd04615df2058fba0dfb
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
rubocop:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.7
|
14
|
+
- name: Install dependencies
|
15
|
+
run: bundle install
|
16
|
+
- name: Run linter
|
17
|
+
run: bundle exec rubocop
|
18
|
+
|
19
|
+
test:
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: 2.7
|
28
|
+
|
29
|
+
- name: Install bundler
|
30
|
+
run: gem install bundler -v 2.1.1
|
31
|
+
|
32
|
+
- name: Install dependencies
|
33
|
+
run: bundle _2.1.1_ install
|
34
|
+
|
35
|
+
- name: Run tests
|
36
|
+
run: bundle exec rake spec
|
37
|
+
|
38
|
+
- name: Upload coverage artifacts
|
39
|
+
uses: actions/upload-artifact@v2
|
40
|
+
with:
|
41
|
+
name: coverage
|
42
|
+
path: coverage/
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -2,15 +2,18 @@ inherit_gem:
|
|
2
2
|
bixby: bixby_default.yml
|
3
3
|
AllCops:
|
4
4
|
DisplayCopNames: true
|
5
|
-
TargetRubyVersion: 2.
|
5
|
+
TargetRubyVersion: 2.7
|
6
6
|
Exclude:
|
7
7
|
- 'bin/*'
|
8
|
+
Lint/UnusedMethodArgument:
|
9
|
+
Exclude:
|
10
|
+
- "lib/geoserver/publish/style.rb"
|
8
11
|
Metrics/BlockLength:
|
9
12
|
Exclude:
|
10
|
-
-
|
11
|
-
-
|
13
|
+
- "spec/**/*"
|
14
|
+
- "*.gemspec"
|
12
15
|
Naming/FileName:
|
13
|
-
Exclude:
|
16
|
+
Exclude:
|
14
17
|
- "geoserver-publish.gemspec"
|
15
18
|
- "Gemfile"
|
16
19
|
Style/StringLiterals:
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# How to Contribute
|
2
|
+
|
3
|
+
We want your help to make the Samvera community great. There are a few guidelines
|
4
|
+
that we need contributors to follow so that we can have a chance of
|
5
|
+
keeping on top of things.
|
6
|
+
|
7
|
+
## Code of Conduct
|
8
|
+
|
9
|
+
The Samvera Community is dedicated to providing a welcoming and positive
|
10
|
+
experience for all its members, whether they are at a formal gathering, in
|
11
|
+
a social setting, or taking part in activities online. Please see our
|
12
|
+
[Code of Conduct](CODE_OF_CONDUCT.md) for more information.
|
13
|
+
|
14
|
+
## Samvera Community Intellectual Property Licensing and Ownership
|
15
|
+
|
16
|
+
All code contributors must have an Individual Contributor License Agreement
|
17
|
+
(iCLA) on file with the Samvera Steering Group. If the contributor works for
|
18
|
+
an institution, the institution must have a Corporate Contributor License
|
19
|
+
Agreement (cCLA) on file.
|
20
|
+
|
21
|
+
https://wiki.duraspace.org/display/samvera/Samvera+Community+Intellectual+Property+Licensing+and+Ownership
|
22
|
+
|
23
|
+
You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
|
24
|
+
|
25
|
+
## Language
|
26
|
+
|
27
|
+
The language we use matters. Today, tomorrow, and for years to come
|
28
|
+
people will read the code we write. They will judge us for our
|
29
|
+
design, logic, and the words we use to describe the system.
|
30
|
+
|
31
|
+
Our words should be accessible. Favor descriptive words that give
|
32
|
+
meaning while avoiding reinforcing systemic inequities. For example,
|
33
|
+
in the Samvera community, we should favor using allowed\_list instead
|
34
|
+
of whitelist, denied\_list instead of blacklist, or source/copy
|
35
|
+
instead of master/slave.
|
36
|
+
|
37
|
+
We're going to get it wrong, but this is a call to keep working to
|
38
|
+
make it right. View our code and the words we choose as a chance to
|
39
|
+
have a conversation. A chance to grow an understanding of the systems
|
40
|
+
we develop as well as the systems in which we live.
|
41
|
+
|
42
|
+
See [“Blacklists” and “whitelists”: a salutary warning concerning the
|
43
|
+
prevalence of racist language in discussions of predatory
|
44
|
+
publishing](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6148600/) for
|
45
|
+
further details.
|
46
|
+
|
47
|
+
## Contribution Tasks
|
48
|
+
|
49
|
+
* Reporting Issues
|
50
|
+
* Making Changes
|
51
|
+
* Documenting Code
|
52
|
+
* Committing Changes
|
53
|
+
* Submitting Changes
|
54
|
+
* Reviewing and Merging Changes
|
55
|
+
|
56
|
+
### Reporting Issues
|
57
|
+
|
58
|
+
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
59
|
+
* Submit a [Github issue](https://github.com/samvera/{{library}}/issues/) by:
|
60
|
+
* Clearly describing the issue
|
61
|
+
* Provide a descriptive summary
|
62
|
+
* Explain the expected behavior
|
63
|
+
* Explain the actual behavior
|
64
|
+
* Provide steps to reproduce the actual behavior
|
65
|
+
|
66
|
+
### Making Changes
|
67
|
+
|
68
|
+
* Fork the repository on GitHub
|
69
|
+
* Create a topic branch from where you want to base your work.
|
70
|
+
* This is usually the `main` branch.
|
71
|
+
* To quickly create a topic branch based on `main`; `git branch fix/main/my_contribution main`
|
72
|
+
* Then checkout the new branch with `git checkout fix/main/my_contribution`.
|
73
|
+
* Please avoid working directly on the `main` branch.
|
74
|
+
* Please do not create a branch called `master`. (See note below.)
|
75
|
+
* You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
|
76
|
+
* Make sure you have added sufficient tests and documentation for your changes.
|
77
|
+
* Test functionality with RSpec; Test features / UI with Capybara.
|
78
|
+
* Run _all_ the tests to assure nothing else was accidentally broken.
|
79
|
+
|
80
|
+
NOTE: This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct)
|
81
|
+
and [language recommendations](#language).
|
82
|
+
Please ***do not*** create a branch called `master` for this repository or as part of
|
83
|
+
your pull request; the branch will either need to be removed or renamed before it can
|
84
|
+
be considered for inclusion in the code base and history of this repository.
|
85
|
+
|
86
|
+
### Documenting Code
|
87
|
+
|
88
|
+
* All new public methods, modules, and classes should include inline documentation in [YARD](http://yardoc.org/).
|
89
|
+
* Documentation should seek to answer the question "why does this code exist?"
|
90
|
+
* Document private / protected methods as desired.
|
91
|
+
* If you are working in a file with no prior documentation, do try to document as you gain understanding of the code.
|
92
|
+
* If you don't know exactly what a bit of code does, it is extra likely that it needs to be documented. Take a stab at it and ask for feedback in your pull request. You can use the 'blame' button on GitHub to identify the original developer of the code and @mention them in your comment.
|
93
|
+
* This work greatly increases the usability of the code base and supports the on-ramping of new committers.
|
94
|
+
* We will all be understanding of one another's time constraints in this area.
|
95
|
+
* [Getting started with YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
|
96
|
+
|
97
|
+
### Committing changes
|
98
|
+
|
99
|
+
* Make commits of logical units.
|
100
|
+
* Check for unnecessary whitespace with `git diff --check` before committing.
|
101
|
+
* Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
102
|
+
* If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
|
103
|
+
|
104
|
+
```
|
105
|
+
Present tense short summary (50 characters or less)
|
106
|
+
|
107
|
+
More detailed description, if necessary. It should be wrapped to 72
|
108
|
+
characters. Try to be as descriptive as you can, even if you think that
|
109
|
+
the commit content is obvious, it may not be obvious to others. You
|
110
|
+
should add such description also if it's already present in bug tracker,
|
111
|
+
it should not be necessary to visit a webpage to check the history.
|
112
|
+
|
113
|
+
Include Closes #<issue-number> when relavent.
|
114
|
+
|
115
|
+
Description can have multiple paragraphs and you can use code examples
|
116
|
+
inside, just indent it with 4 spaces:
|
117
|
+
|
118
|
+
class PostsController
|
119
|
+
def index
|
120
|
+
respond_to do |wants|
|
121
|
+
wants.html { render 'index' }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
You can also add bullet points:
|
127
|
+
|
128
|
+
- you can use dashes or asterisks
|
129
|
+
|
130
|
+
- also, try to indent next line of a point for readability, if it's too
|
131
|
+
long to fit in 72 characters
|
132
|
+
```
|
133
|
+
|
134
|
+
* Make sure you have added the necessary tests for your changes.
|
135
|
+
* Run _all_ the tests to assure nothing else was accidentally broken.
|
136
|
+
* When you are ready to submit a pull request
|
137
|
+
|
138
|
+
### Submitting Changes
|
139
|
+
|
140
|
+
* Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
141
|
+
* Make sure your branch is up to date with its parent branch (i.e. main)
|
142
|
+
* `git checkout main`
|
143
|
+
* `git pull --rebase`
|
144
|
+
* `git checkout <your-branch>`
|
145
|
+
* `git rebase main`
|
146
|
+
* It is a good idea to run your tests again.
|
147
|
+
* If you've made more than one commit take a moment to consider whether squashing commits together would help improve their logical grouping.
|
148
|
+
* [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
149
|
+
* `git rebase --interactive main` ([See Github help](https://help.github.com/articles/interactive-rebase))
|
150
|
+
* Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
|
151
|
+
* Push your changes to a topic branch in your fork of the repository.
|
152
|
+
* Submit a pull request from your fork to the project.
|
153
|
+
|
154
|
+
### Reviewing and Merging Changes
|
155
|
+
|
156
|
+
We adopted [Github's Pull Request Review](https://help.github.com/articles/about-pull-request-reviews/) for our repositories.
|
157
|
+
Common checks that may occur in our repositories:
|
158
|
+
|
159
|
+
1. [CircleCI](https://circleci.com/gh/samvera) - where our automated tests are running
|
160
|
+
2. RuboCop/Bixby - where we check for style violations
|
161
|
+
3. Approval Required - Github enforces at least one person approve a pull request. Also, all reviewers that have chimed in must approve.
|
162
|
+
4. CodeClimate - is our code remaining healthy (at least according to static code analysis)
|
163
|
+
|
164
|
+
If one or more of the required checks failed (or are incomplete), the code should not be merged (and the UI will not allow it). If all of the checks have passed, then anyone on the project (including the pull request submitter) may merge the code.
|
165
|
+
|
166
|
+
*Example: Carolyn submits a pull request, Justin reviews the pull request and approves. However, Justin is still waiting on other checks (CI tests are usually the culprit), so he does not merge the pull request. Eventually, all of the checks pass. At this point, Carolyn or anyone else may merge the pull request.*
|
167
|
+
|
168
|
+
#### Things to Consider When Reviewing
|
169
|
+
|
170
|
+
First, the person contributing the code is putting themselves out there. Be mindful of what you say in a review.
|
171
|
+
|
172
|
+
* Ask clarifying questions
|
173
|
+
* State your understanding and expectations
|
174
|
+
* Provide example code or alternate solutions, and explain why
|
175
|
+
|
176
|
+
This is your chance for a mentoring moment of another developer. Take time to give an honest and thorough review of what has changed. Things to consider:
|
177
|
+
|
178
|
+
* Does the commit message explain what is going on?
|
179
|
+
* Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
|
180
|
+
* Do new or changed methods, modules, and classes have documentation?
|
181
|
+
* Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
|
182
|
+
* Does the description of the new/changed specs match your understanding of what the spec is doing?
|
183
|
+
* Did the Continuous Integration tests complete successfully?
|
184
|
+
|
185
|
+
If you are uncertain, bring other contributors into the conversation by assigning them as a reviewer.
|
186
|
+
|
187
|
+
# Additional Resources
|
188
|
+
|
189
|
+
* [General GitHub documentation](http://help.github.com/)
|
190
|
+
* [GitHub pull request documentation](https://help.github.com/articles/about-pull-requests/)
|
191
|
+
* [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
|
192
|
+
* [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Geoserver::Publish
|
2
2
|
|
3
|
-
|
4
|
-
[![Coverage Status](https://img.shields.io/
|
3
|
+
![CI](https://github.com/samvera-labs/geoserver-publish/actions/workflows/ruby.yml/badge.svg)
|
4
|
+
[![Coverage Status](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/samvera-labs/geoserver-publish/blob/da3eef51705eea8e3c14ff0b88aea70064b979d4/spec/spec_helper.rb#L13)
|
5
5
|
|
6
6
|
Simple client for publishing Shapefiles and GeoTIFFs to Geoserver.
|
7
7
|
|
@@ -99,3 +99,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
99
99
|
## Contributing
|
100
100
|
|
101
101
|
Bug reports and pull requests are welcome on GitHub at https://github.com/samvera-labs/geoserver-publish.
|
102
|
+
|
103
|
+
If you're working on a PR for this project, create a feature branch off of `main`.
|
104
|
+
|
105
|
+
This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct) and [language recommendations](https://github.com/samvera/maintenance/blob/main/templates/CONTRIBUTING.md#language). Please ***do not*** create a branch called `master` for this repository or as part of your pull request; the branch will either need to be removed or renamed before it can be considered for inclusion in the code base and history of this repository.
|
data/geoserver-publish.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_dependency "faraday"
|
26
|
+
spec.add_dependency "faraday", "~> 2.2"
|
27
27
|
|
28
28
|
spec.add_development_dependency "bundler", "> 1.16.0", "< 3"
|
29
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -7,11 +7,11 @@ module Geoserver
|
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def config_yaml
|
11
|
+
file_path = File.join(Geoserver::Publish.root, "config", "config.yml")
|
12
|
+
YAML.safe_load(ERB.new(File.read(file_path)).result, [], [], true)
|
13
|
+
end
|
14
14
|
|
15
|
-
|
15
|
+
module_function :config, :config_yaml
|
16
16
|
end
|
17
17
|
end
|
@@ -38,7 +38,7 @@ module Geoserver
|
|
38
38
|
def put(path:, payload:, content_type:)
|
39
39
|
response = faraday_connection.put do |req|
|
40
40
|
req.url path
|
41
|
-
req.headers[
|
41
|
+
req.headers["Content-Type"] = content_type
|
42
42
|
req.body = payload
|
43
43
|
end
|
44
44
|
return true if response.status == 201 || response.status == 200
|
@@ -48,12 +48,12 @@ module Geoserver
|
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
51
|
+
def faraday_connection
|
52
|
+
Faraday.new(url: config["url"]) do |conn|
|
53
|
+
conn.adapter Faraday.default_adapter
|
54
|
+
conn.request(:authorization, :basic, config["user"], config["password"]) if config["user"]
|
56
55
|
end
|
56
|
+
end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -33,20 +33,20 @@ module Geoserver
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
36
|
+
def coverage_url(workspace_name:, coverage_store_name:, coverage_name:)
|
37
|
+
last_path_component = coverage_name ? "/#{coverage_name}" : ""
|
38
|
+
"workspaces/#{workspace_name}/coveragestores/#{coverage_store_name}/coverages#{last_path_component}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def payload_new(coverage_name:, title:, payload: nil)
|
42
|
+
{
|
43
|
+
coverage: {
|
44
|
+
enabled: true,
|
45
|
+
name: coverage_name,
|
46
|
+
title: title
|
47
|
+
}.merge(payload.to_h)
|
48
|
+
}.to_json
|
49
|
+
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -31,27 +31,62 @@ module Geoserver
|
|
31
31
|
connection.put(path: path, payload: payload, content_type: "application/json")
|
32
32
|
end
|
33
33
|
|
34
|
+
##
|
35
|
+
# Upload raster data files to a new coverage store
|
36
|
+
# # @param workspace_name [String]
|
37
|
+
# # @param coverage_store_name [String]
|
38
|
+
# # @param format [String] One of:
|
39
|
+
# geotiff == GeoTIFF
|
40
|
+
# worldimage == Georeferenced image (JPEG, PNG, TIFF)
|
41
|
+
# imagemosaic == Image mosaic
|
42
|
+
# See: https://docs.geoserver.org/stable/en/user/rest/api/coveragestores.html#extension
|
43
|
+
# # @param file [String] Depending on value of method:
|
44
|
+
# file == binary stream
|
45
|
+
# url == URL to publicly available raster files (DOESN'T ACTUALLY WORK).
|
46
|
+
# external == absolute path to existing file
|
47
|
+
# # @param content_type [String] Content-Type for file upload
|
48
|
+
# # @param method [String] Can be one of 'file', 'url', 'external'.
|
49
|
+
# See: https://docs.geoserver.org/latest/en/api/#1.0.0/coveragestores.yaml
|
50
|
+
# rubocop:disable Metrics/ParameterLists
|
51
|
+
def upload(workspace_name:, coverage_store_name:, format:, file:, method: "file", content_type: "application/zip")
|
52
|
+
path = upload_url(
|
53
|
+
workspace_name: workspace_name,
|
54
|
+
coverage_store_name: coverage_store_name,
|
55
|
+
method: method,
|
56
|
+
format: format
|
57
|
+
)
|
58
|
+
|
59
|
+
connection.put(path: path, payload: file, content_type: content_type)
|
60
|
+
end
|
61
|
+
# rubocop:enable Metrics/ParameterLists
|
62
|
+
|
34
63
|
private
|
35
64
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
65
|
+
def coverage_store_url(workspace_name:, coverage_store_name:)
|
66
|
+
last_path_component = coverage_store_name ? "/#{coverage_store_name}" : ""
|
67
|
+
"workspaces/#{workspace_name}/coveragestores#{last_path_component}"
|
68
|
+
end
|
69
|
+
|
70
|
+
# see: https://docs.geoserver.org/latest/en/api/#1.0.0/coveragestores.yaml
|
71
|
+
# /workspaces/{workspace}/coveragestores/{store}/{method}.{format}
|
72
|
+
def upload_url(workspace_name:, coverage_store_name:, method:, format:)
|
73
|
+
"workspaces/#{workspace_name}/coveragestores/#{coverage_store_name}/#{method}.#{format}?coverageName=#{coverage_store_name}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def payload_new(workspace_name:, coverage_store_name:, type:, url:, payload:)
|
77
|
+
{
|
78
|
+
coverageStore: {
|
79
|
+
name: coverage_store_name,
|
80
|
+
url: url,
|
81
|
+
enabled: true,
|
82
|
+
workspace: {
|
83
|
+
name: workspace_name
|
84
|
+
},
|
85
|
+
type: type,
|
86
|
+
_default: false
|
87
|
+
}.merge(payload.to_h)
|
88
|
+
}.to_json
|
89
|
+
end
|
55
90
|
end
|
56
91
|
end
|
57
92
|
end
|
@@ -25,47 +25,57 @@ module Geoserver
|
|
25
25
|
connection.post(path: path, payload: payload)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
##
|
29
|
+
# Upload a shapefile zip to a new datastore
|
30
|
+
# # @param workspace_name [String]
|
31
|
+
# # @param data_store_name [String]
|
32
|
+
# # @param file [String] Depending on value of method:
|
33
|
+
# file == binary stream
|
34
|
+
# url == URL to publicly available shapezip zip.
|
35
|
+
# external == absolute path to existing file
|
36
|
+
# # @param method [String] Can be one of 'file', 'url', 'external'.
|
37
|
+
# See: https://docs.geoserver.org/stable/en/api/#1.0.0/datastores.yaml
|
38
|
+
def upload(workspace_name:, data_store_name:, file:, method: "file")
|
39
|
+
content_type = "application/zip"
|
40
|
+
path = upload_url(workspace: workspace_name, data_store: data_store_name, method: method)
|
31
41
|
connection.put(path: path, payload: file, content_type: content_type)
|
32
42
|
end
|
33
43
|
|
34
44
|
private
|
35
45
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
46
|
+
def data_store_url(workspace_name:, data_store_name:)
|
47
|
+
last_path_component = data_store_name ? "/#{data_store_name}" : ""
|
48
|
+
"workspaces/#{workspace_name}/datastores#{last_path_component}"
|
49
|
+
end
|
40
50
|
|
41
|
-
|
42
|
-
|
43
|
-
|
51
|
+
def upload_url(workspace:, data_store:, method:)
|
52
|
+
"workspaces/#{workspace}/datastores/#{data_store}/#{method}.shp"
|
53
|
+
end
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
55
|
+
# rubocop:disable Metrics/MethodLength
|
56
|
+
def payload_new(data_store_name:, url:)
|
57
|
+
{
|
58
|
+
dataStore: {
|
59
|
+
name: data_store_name,
|
60
|
+
connectionParameters: {
|
61
|
+
entry: [
|
62
|
+
{
|
63
|
+
"@key": "create spatial index",
|
64
|
+
"$": "true"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"@key": "url",
|
68
|
+
"$": url
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"@key": "cache and reuse memory maps",
|
72
|
+
"$": "false"
|
73
|
+
}
|
74
|
+
]
|
66
75
|
}
|
67
|
-
}
|
68
|
-
|
76
|
+
}
|
77
|
+
}.to_json
|
78
|
+
end
|
69
79
|
# rubocop:enable Metrics/MethodLength
|
70
80
|
end
|
71
81
|
end
|
@@ -35,20 +35,20 @@ module Geoserver
|
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
38
|
+
def feature_type_url(workspace_name:, data_store_name:, feature_type_name:)
|
39
|
+
last_path_component = feature_type_name ? "/#{feature_type_name}" : ""
|
40
|
+
"workspaces/#{workspace_name}/datastores/#{data_store_name}/featuretypes#{last_path_component}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def payload_new(feature_type_name:, title:, payload:)
|
44
|
+
{
|
45
|
+
featureType: {
|
46
|
+
name: feature_type_name,
|
47
|
+
title: title,
|
48
|
+
enabled: true
|
49
|
+
}.merge(payload.to_h)
|
50
|
+
}.to_json
|
51
|
+
end
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -9,7 +9,7 @@ module Geoserver
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def delete(layer_name:, workspace_name: nil)
|
12
|
-
path = layer_url(layer_name: layer_name, workspace_name:
|
12
|
+
path = layer_url(layer_name: layer_name, workspace_name: workspace_name)
|
13
13
|
connection.delete(path: path)
|
14
14
|
end
|
15
15
|
|
@@ -27,13 +27,13 @@ module Geoserver
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
def layer_url(layer_name:, workspace_name: nil)
|
31
|
+
path = []
|
32
|
+
path.push("workspaces", workspace_name) if workspace_name
|
33
|
+
path.push "layers"
|
34
|
+
path.push layer_name if layer_name
|
35
|
+
path.join("/")
|
36
|
+
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -40,19 +40,19 @@ module Geoserver
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
def style_url(style_name:)
|
44
|
+
last_path_component = style_name ? "/#{style_name}" : ""
|
45
|
+
"styles#{last_path_component}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def payload_new(style_name:, filename:, payload: nil)
|
49
|
+
{
|
50
|
+
style: {
|
51
|
+
name: style_name,
|
52
|
+
filename: filename
|
53
|
+
}.merge(payload.to_h)
|
54
|
+
}.to_json
|
55
|
+
end
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -26,18 +26,18 @@ module Geoserver
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
def payload_new(workspace_name:)
|
30
|
+
{
|
31
|
+
workspace: {
|
32
|
+
name: workspace_name
|
33
|
+
}
|
34
|
+
}.to_json
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
def workspace_url(workspace_name:)
|
38
|
+
last_path_component = workspace_name ? "/#{workspace_name}" : ""
|
39
|
+
"workspaces#{last_path_component}"
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoserver-publish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eliot Jordan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,10 +79,11 @@ executables: []
|
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
|
+
- ".github/workflows/ruby.yml"
|
82
83
|
- ".gitignore"
|
83
84
|
- ".rspec"
|
84
85
|
- ".rubocop.yml"
|
85
|
-
-
|
86
|
+
- CONTRIBUTING.md
|
86
87
|
- Gemfile
|
87
88
|
- LICENSE.txt
|
88
89
|
- README.md
|
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.1.6
|
127
128
|
signing_key:
|
128
129
|
specification_version: 4
|
129
130
|
summary: Simple client for publishing Shapefiles and GeoTIFFs to Geoserver
|