Skip to content

Commit

Permalink
updated gemspec, added some instructions to readme, setup dummy app w…
Browse files Browse the repository at this point in the history
…ith basic models
  • Loading branch information
keithdoggett committed Mar 1, 2020
1 parent 5747be1 commit 9d85997
Show file tree
Hide file tree
Showing 17 changed files with 327 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ test/dummy/db/*.sqlite3-*
test/dummy/log/*.log
test/dummy/storage/
test/dummy/tmp/
test/dummy/test
151 changes: 151 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
PATH
remote: .
specs:
spatial_stats (0.1.0)
rails (~> 6.0.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.2.1)
actionpack (= 6.0.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
mail (>= 2.7.1)
actionmailer (6.0.2.1)
actionpack (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.2.1)
actionview (= 6.0.2.1)
activesupport (= 6.0.2.1)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.2.1)
actionpack (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
nokogiri (>= 1.8.5)
actionview (6.0.2.1)
activesupport (= 6.0.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.2.1)
activesupport (= 6.0.2.1)
globalid (>= 0.3.6)
activemodel (6.0.2.1)
activesupport (= 6.0.2.1)
activerecord (6.0.2.1)
activemodel (= 6.0.2.1)
activesupport (= 6.0.2.1)
activerecord-postgis-adapter (6.0.0)
activerecord (~> 6.0)
rgeo-activerecord (~> 6.0)
activestorage (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
marcel (~> 0.3.1)
activesupport (6.0.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
builder (3.2.4)
concurrent-ruby (1.1.6)
crass (1.0.6)
erubi (1.9.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
loofah (2.4.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.4)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
nio4r (2.5.2)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
pg (1.2.2)
rack (2.2.2)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.2.1)
actioncable (= 6.0.2.1)
actionmailbox (= 6.0.2.1)
actionmailer (= 6.0.2.1)
actionpack (= 6.0.2.1)
actiontext (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
activemodel (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
bundler (>= 1.3.0)
railties (= 6.0.2.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.2.1)
actionpack (= 6.0.2.1)
activesupport (= 6.0.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.1)
rgeo (2.1.1)
rgeo-activerecord (6.2.1)
activerecord (>= 5.0)
rgeo (>= 1.0.0)
sprockets (4.0.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.6)
thread_safe (~> 0.1)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
zeitwerk (2.2.2)

PLATFORMS
ruby

DEPENDENCIES
activerecord-postgis-adapter (~> 6.0.0)
pg (~> 1.0)
spatial_stats!

BUNDLED WITH
2.1.4
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
# SpatialStats

Short description and motivation.

## Usage

How to use my plugin.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'spatial_stats'
```

And then execute:

```bash
$ bundle
```

Or install it yourself as:

```bash
$ gem install spatial_stats
```

## Contributing
Contribution directions go here.

Once cloned, run the following commands to setup the test database.

```sh
cd ./spatial_stats
cd test/dummy
rake db:create
rake db:migrate
```

If you are getting an error, you may need to set the following environment variables.

```
$PGUSER # default "postgres"
$PGPASSWORD # default ""
$PGHOST # default "127.0.0.1"
$PGPORT # default "5432"
$PGDATABASE # default "spatial_stats_test"
```

If the dummy app is setup correctly, run the following:

```
cd ../..
rake
```

This will run the tests. If they all passed, then your environment is setup correctly.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

begin
require 'bundler/setup'
rescue LoadError
Expand All @@ -22,6 +24,7 @@ Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
t.warning = false # shut up annoying warnings
end

task default: :test
44 changes: 26 additions & 18 deletions spatial_stats.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
$:.push File.expand_path("lib", __dir__)
# frozen_string_literal: true

$LOAD_PATH.push File.expand_path('lib', __dir__)

# Maintain your gem's version:
require "spatial_stats/version"
require 'spatial_stats/version'

# Describe your gem and declare its dependencies:
Gem::Specification.new do |spec|
spec.name = "spatial_stats"
spec.name = 'spatial_stats'
spec.version = SpatialStats::VERSION
spec.authors = ["Keith Doggett"]
spec.email = ["[email protected]"]
spec.homepage = "TODO"
spec.summary = "TODO: Summary of SpatialStats."
spec.description = "TODO: Description of SpatialStats."
spec.license = "MIT"
spec.authors = ['Keith Doggett']
spec.email = ['[email protected]']
spec.homepage = 'https://www.github.com/Kdoggett887/spatial_stats'
spec.summary = 'An ActiveRecord/PostGIS extension that provides statistical methods to spatial postgresql databases.'
spec.description = 'An ActiveRecord/PostGIS extension that provides'\
'statistical methods to spatial postgresql databases.'\
'It integrates with ActiveRecord to perform spatial weighting'\
' in PostGIS and performs statistical computations '\
'inside your rails app. Supports contiguious and distance-based'\
' calculations.'
spec.license = 'MIT'

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end
# if spec.respond_to?(:metadata)
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
# else
# raise "RubyGems 2.0 or newer is required to protect against " \
# "public gem pushes."
# end

spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
spec.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']

spec.add_dependency "rails", "~> 6.0.2", ">= 6.0.2.1"
spec.add_dependency 'rails', '~> 6.0.0'

spec.add_development_dependency "sqlite3"
spec.add_development_dependency 'activerecord-postgis-adapter', '~> 6.0.0'
spec.add_development_dependency 'pg', '~> 1.0'
end
2 changes: 2 additions & 0 deletions test/dummy/app/models/geo_point_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class GeoPointModel < ApplicationRecord
end
2 changes: 2 additions & 0 deletions test/dummy/app/models/geo_polygon_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class GeoPolygonModel < ApplicationRecord
end
2 changes: 2 additions & 0 deletions test/dummy/app/models/point_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class PointModel < ApplicationRecord
end
2 changes: 2 additions & 0 deletions test/dummy/app/models/polygon_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class PolygonModel < ApplicationRecord
end
17 changes: 9 additions & 8 deletions test/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
adapter: postgis
host: <%= ENV.fetch("PGHOST") {"127.0.0.1"} %>
port: <%= ENV.fetch("PGPORT") {"5432"} %>
username: <%= ENV.fetch("PGUSER") {"postgres"} %>
password: <%= ENV.fetch("PGPASSWORD") {""} %>
encoding: unicode
schema_search_path: public
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

development:
<<: *default
database: db/development.sqlite3
database: <%= ENV.fetch("PGDATABASE") {"spatial_stats_development"} %>

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3

production:
<<: *default
database: db/production.sqlite3
database: <%= ENV.fetch("PGDATABASE") {"spatial_stats_test"} %>
10 changes: 10 additions & 0 deletions test/dummy/db/migrate/20200229235915_create_point_models.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreatePointModels < ActiveRecord::Migration[6.0]
def change
create_table :point_models do |t|
t.st_point :position
t.float :value

t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions test/dummy/db/migrate/20200301000228_create_geo_point_models.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateGeoPointModels < ActiveRecord::Migration[6.0]
def change
create_table :geo_point_models do |t|
t.st_point :latlon, geographic: true
t.float :value

t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions test/dummy/db/migrate/20200301000304_create_polygon_models.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreatePolygonModels < ActiveRecord::Migration[6.0]
def change
create_table :polygon_models do |t|
t.st_polygon :geom
t.float :value

t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions test/dummy/db/migrate/20200301000554_create_geo_polygon_models.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateGeoPolygonModels < ActiveRecord::Migration[6.0]
def change
create_table :geo_polygon_models do |t|
t.st_polygon :geom, geographic: true
t.float :value

t.timestamps
end
end
end
Loading

0 comments on commit 9d85997

Please sign in to comment.