Skip to content

Commit

Permalink
Merge pull request #28 from samvera-labs/27-rubocop
Browse files Browse the repository at this point in the history
Move to GitHub Actions and add rubocop check
  • Loading branch information
kelynch authored Feb 9, 2022
2 parents 7fc0578 + 402a437 commit b8e68e6
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 137 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on: [push, pull_request]

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install dependencies
run: bundle install
- name: Run linter
run: bundle exec rubocop

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7

- name: Install bundler
run: gem install bundler -v 2.1.1

- name: Install dependencies
run: bundle _2.1.1_ install

- name: Run tests
run: bundle exec rake spec

- name: Upload coverage artifacts
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/
7 changes: 5 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ AllCops:
TargetRubyVersion: 2.4
Exclude:
- 'bin/*'
Lint/UnusedMethodArgument:
Exclude:
- "lib/geoserver/publish/style.rb"
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
- '*.gemspec'
- "spec/**/*"
- "*.gemspec"
Naming/FileName:
Exclude:
- "geoserver-publish.gemspec"
Expand Down
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Geoserver::Publish

[![Build Status](https://img.shields.io/travis/samvera-labs/geoserver-publish/main.svg)](https://travis-ci.org/samvera-labs/geoserver-publish)
[![Coverage Status](https://img.shields.io/coveralls/samvera-labs/geoserver-publish/main.svg)](https://coveralls.io/github/samvera-labs/geoserver-publish?branch=main)
![CI](https://github.com/samvera-labs/geoserver-publish/actions/workflows/ruby.yml/badge.svg)
[![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)

Simple client for publishing Shapefiles and GeoTIFFs to Geoserver.

Expand Down
10 changes: 5 additions & 5 deletions lib/geoserver/publish/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def config

private

def config_yaml
file_path = File.join(Geoserver::Publish.root, "config", "config.yml")
YAML.safe_load(ERB.new(File.read(file_path)).result, [], [], true)
end
def config_yaml
file_path = File.join(Geoserver::Publish.root, "config", "config.yml")
YAML.safe_load(ERB.new(File.read(file_path)).result, [], [], true)
end

module_function :config, :config_yaml
module_function :config, :config_yaml
end
end
28 changes: 14 additions & 14 deletions lib/geoserver/publish/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ def update(workspace_name:, coverage_store_name:, coverage_name:, title:, additi

private

def coverage_url(workspace_name:, coverage_store_name:, coverage_name:)
last_path_component = coverage_name ? "/#{coverage_name}" : ""
"workspaces/#{workspace_name}/coveragestores/#{coverage_store_name}/coverages#{last_path_component}"
end

def payload_new(coverage_name:, title:, payload: nil)
{
coverage: {
enabled: true,
name: coverage_name,
title: title
}.merge(payload.to_h)
}.to_json
end
def coverage_url(workspace_name:, coverage_store_name:, coverage_name:)
last_path_component = coverage_name ? "/#{coverage_name}" : ""
"workspaces/#{workspace_name}/coveragestores/#{coverage_store_name}/coverages#{last_path_component}"
end

def payload_new(coverage_name:, title:, payload: nil)
{
coverage: {
enabled: true,
name: coverage_name,
title: title
}.merge(payload.to_h)
}.to_json
end
end
end
end
38 changes: 19 additions & 19 deletions lib/geoserver/publish/coverage_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ def update(workspace_name:, coverage_store_name:, url:, type: "GeoTIFF", additio

private

def coverage_store_url(workspace_name:, coverage_store_name:)
last_path_component = coverage_store_name ? "/#{coverage_store_name}" : ""
"workspaces/#{workspace_name}/coveragestores#{last_path_component}"
end

def payload_new(workspace_name:, coverage_store_name:, type:, url:, payload:)
{
coverageStore: {
name: coverage_store_name,
url: url,
enabled: true,
workspace: {
name: workspace_name
},
type: type,
_default: false
}.merge(payload.to_h)
}.to_json
end
def coverage_store_url(workspace_name:, coverage_store_name:)
last_path_component = coverage_store_name ? "/#{coverage_store_name}" : ""
"workspaces/#{workspace_name}/coveragestores#{last_path_component}"
end

def payload_new(workspace_name:, coverage_store_name:, type:, url:, payload:)
{
coverageStore: {
name: coverage_store_name,
url: url,
enabled: true,
workspace: {
name: workspace_name
},
type: type,
_default: false
}.merge(payload.to_h)
}.to_json
end
end
end
end
64 changes: 32 additions & 32 deletions lib/geoserver/publish/data_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,47 +35,47 @@ def create(workspace_name:, data_store_name:, url:)
# external == absolute path to existing file
# # @param method [String] Can be one of 'file', 'url', 'external'.
# See: https://docs.geoserver.org/stable/en/api/#1.0.0/datastores.yaml
def upload(workspace_name:, data_store_name:, file:, method: 'file')
content_type = 'application/zip'
def upload(workspace_name:, data_store_name:, file:, method: "file")
content_type = "application/zip"
path = upload_url(workspace: workspace_name, data_store: data_store_name, method: method)
connection.put(path: path, payload: file, content_type: content_type)
end

private

def data_store_url(workspace_name:, data_store_name:)
last_path_component = data_store_name ? "/#{data_store_name}" : ""
"workspaces/#{workspace_name}/datastores#{last_path_component}"
end
def data_store_url(workspace_name:, data_store_name:)
last_path_component = data_store_name ? "/#{data_store_name}" : ""
"workspaces/#{workspace_name}/datastores#{last_path_component}"
end

def upload_url(workspace:, data_store:, method:)
"workspaces/#{workspace}/datastores/#{data_store}/#{method}.shp"
end
def upload_url(workspace:, data_store:, method:)
"workspaces/#{workspace}/datastores/#{data_store}/#{method}.shp"
end

# rubocop:disable Metrics/MethodLength
def payload_new(data_store_name:, url:)
{
dataStore: {
name: data_store_name,
connectionParameters: {
entry: [
{
"@key": "create spatial index",
"$": "true"
},
{
"@key": "url",
"$": url
},
{
"@key": "cache and reuse memory maps",
"$": "false"
}
]
}
# rubocop:disable Metrics/MethodLength
def payload_new(data_store_name:, url:)
{
dataStore: {
name: data_store_name,
connectionParameters: {
entry: [
{
"@key": "create spatial index",
"$": "true"
},
{
"@key": "url",
"$": url
},
{
"@key": "cache and reuse memory maps",
"$": "false"
}
]
}
}.to_json
end
}
}.to_json
end
# rubocop:enable Metrics/MethodLength
end
end
Expand Down
28 changes: 14 additions & 14 deletions lib/geoserver/publish/feature_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ def update(workspace_name:, data_store_name:, feature_type_name:, title:, additi

private

def feature_type_url(workspace_name:, data_store_name:, feature_type_name:)
last_path_component = feature_type_name ? "/#{feature_type_name}" : ""
"workspaces/#{workspace_name}/datastores/#{data_store_name}/featuretypes#{last_path_component}"
end

def payload_new(feature_type_name:, title:, payload:)
{
featureType: {
name: feature_type_name,
title: title,
enabled: true
}.merge(payload.to_h)
}.to_json
end
def feature_type_url(workspace_name:, data_store_name:, feature_type_name:)
last_path_component = feature_type_name ? "/#{feature_type_name}" : ""
"workspaces/#{workspace_name}/datastores/#{data_store_name}/featuretypes#{last_path_component}"
end

def payload_new(feature_type_name:, title:, payload:)
{
featureType: {
name: feature_type_name,
title: title,
enabled: true
}.merge(payload.to_h)
}.to_json
end
end
end
end
16 changes: 8 additions & 8 deletions lib/geoserver/publish/layer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(conn = nil)
end

def delete(layer_name:, workspace_name: nil)
path = layer_url(layer_name: layer_name, workspace_name: nil)
path = layer_url(layer_name: layer_name, workspace_name: workspace_name)
connection.delete(path: path)
end

Expand All @@ -27,13 +27,13 @@ def update(layer_name:, workspace_name: nil, additional_payload: nil)

private

def layer_url(layer_name:, workspace_name: nil)
path = []
path.push("workspaces", workspace_name) if workspace_name
path.push "layers"
path.push layer_name if layer_name
path.join("/")
end
def layer_url(layer_name:, workspace_name: nil)
path = []
path.push("workspaces", workspace_name) if workspace_name
path.push "layers"
path.push layer_name if layer_name
path.join("/")
end
end
end
end
26 changes: 13 additions & 13 deletions lib/geoserver/publish/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ def update(style_name:, filename:, payload:)

private

def style_url(style_name:)
last_path_component = style_name ? "/#{style_name}" : ""
"styles#{last_path_component}"
end

def payload_new(style_name:, filename:, payload: nil)
{
style: {
name: style_name,
filename: filename,
}.merge(payload.to_h)
}.to_json
end
def style_url(style_name:)
last_path_component = style_name ? "/#{style_name}" : ""
"styles#{last_path_component}"
end

def payload_new(style_name:, filename:, payload: nil)
{
style: {
name: style_name,
filename: filename
}.merge(payload.to_h)
}.to_json
end
end
end
end
22 changes: 11 additions & 11 deletions lib/geoserver/publish/workspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ def create(workspace_name:)

private

def payload_new(workspace_name:)
{
workspace: {
name: workspace_name
}
}.to_json
end
def payload_new(workspace_name:)
{
workspace: {
name: workspace_name
}
}.to_json
end

def workspace_url(workspace_name:)
last_path_component = workspace_name ? "/#{workspace_name}" : ""
"workspaces#{last_path_component}"
end
def workspace_url(workspace_name:)
last_path_component = workspace_name ? "/#{workspace_name}" : ""
"workspaces#{last_path_component}"
end
end
end
end
Loading

0 comments on commit b8e68e6

Please sign in to comment.