daiku 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/daiku.rb +3 -0
- data/lib/daiku/plugins/datamapper/cli.rb +1 -1
- data/lib/daiku/plugins/sequel.rb +11 -0
- data/lib/daiku/plugins/sequel/_templates/001_create_extension_hstore.rb.tt +9 -0
- data/lib/daiku/plugins/sequel/_templates/002_create_extension_postgis.rb.tt +15 -0
- data/lib/daiku/plugins/sequel/_templates/db.rake.tt +14 -0
- data/lib/daiku/plugins/sequel/_templates/sequel.rb.tt +27 -0
- data/lib/daiku/plugins/sequel/cli.rb +52 -0
- data/lib/daiku/version.rb +1 -1
- data/spec/daiku/plugins_spec.rb +3 -2
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea12ee95a2500430471e9afbae6a3348d1800a33
|
4
|
+
data.tar.gz: 70440ea6816cf4069e2d3992c973a29f224a107e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43a594f9f70de2468ab4bc093fb9b08de4f145780572b8db4f29b2a288df3d0d9454b5285a6c801004942958e2b08f7d1df1a4b4220a45ac2aa5aa50071cf8e0
|
7
|
+
data.tar.gz: 2810331d3b90801f397278fd8fc9b27ecee3fadab3bd352499a8a0019631bb6deedf0fb7294187744d26d8433094c6889b5adfb3058b2661b0692f358258c34c
|
data/lib/daiku.rb
CHANGED
@@ -27,6 +27,9 @@ require 'daiku/plugins/honeybadger/cli'
|
|
27
27
|
require 'daiku/plugins/newrelic'
|
28
28
|
require 'daiku/plugins/newrelic/cli'
|
29
29
|
|
30
|
+
require 'daiku/plugins/sequel'
|
31
|
+
require 'daiku/plugins/sequel/cli'
|
32
|
+
|
30
33
|
require 'daiku/plugins/sidekiq'
|
31
34
|
require 'daiku/plugins/sidekiq/cli'
|
32
35
|
|
@@ -17,7 +17,7 @@ module Daiku
|
|
17
17
|
insert_into_file "#{app}/lib/boot.rb", :after => "#models\n" do
|
18
18
|
<<-DMREQ.strip_heredoc
|
19
19
|
require File.join($app_root, 'config/datamapper')
|
20
|
-
#
|
20
|
+
# require models here
|
21
21
|
DataMapper.finalize
|
22
22
|
DMREQ
|
23
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
run 'CREATE EXTENSION postgis;'
|
4
|
+
run 'CREATE EXTENSION postgis_topology;'
|
5
|
+
run 'CREATE EXTENSION fuzzystrmatch;'
|
6
|
+
run 'CREATE EXTENSION postgis_tiger_geocoder;'
|
7
|
+
end
|
8
|
+
|
9
|
+
down do
|
10
|
+
run 'DROP EXTENSION IF EXISTS postgis;'
|
11
|
+
run 'DROP EXTENSION IF EXISTS postgis_topology;'
|
12
|
+
run 'DROP EXTENSION IF EXISTS fuzzystrmatch;'
|
13
|
+
run 'DROP EXTENSION IF EXISTS postgis_tiger_geocoder;'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc "Run Sequel migrations"
|
3
|
+
task :migrate => :environment, [:version] do |t, args|
|
4
|
+
Sequel.extension :migration
|
5
|
+
db = Sequel.connect(ENV.fetch("DATABASE_URL"))
|
6
|
+
if args[:version]
|
7
|
+
puts "Migrating to version #{args[:version]}"
|
8
|
+
Sequel::Migrator.run(db, "#{$app_root}/db/migrations", target: args[:version].to_i)
|
9
|
+
else
|
10
|
+
puts "Migrating to latest"
|
11
|
+
Sequel::Migrator.run(db, "#{$app_root}/db/migrations")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.require(:sequel)
|
5
|
+
|
6
|
+
# environment setup
|
7
|
+
ENV['DATABASE_LOG_LEVEL'] ||= 'info'
|
8
|
+
ENV['DATABASE_MAX_CONNECTIONS'] ||= 4
|
9
|
+
ENV['DATABASE_SSLMODE'] ||= 'prefer'
|
10
|
+
ENV['DATABASE_TIMEOUT'] ||= 10
|
11
|
+
|
12
|
+
# database instance options
|
13
|
+
sequel_opts = {
|
14
|
+
loggers: [Logger.new($stdout, ENV['DATABASE_LOG_LEVEL'])],
|
15
|
+
max_connections: ENV['DATABASE_MAX_CONNECTIONS'].to_i,
|
16
|
+
sslmode: ENV['DATABASE_SSLMODE'],
|
17
|
+
connect_timeout: ENV['DATABASE_TIMEOUT']
|
18
|
+
}
|
19
|
+
|
20
|
+
# database connection
|
21
|
+
DB = Sequel.connect(ENV['DATABASE_URL'], sequel_opts)
|
22
|
+
|
23
|
+
# load postgres specific datatype support
|
24
|
+
DB.extension :pg_array
|
25
|
+
DB.extension :pg_hstore
|
26
|
+
DB.extension :pg_json
|
27
|
+
DB.extension :pg_streaming
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module Daiku
|
6
|
+
class Plugins
|
7
|
+
class Sequel
|
8
|
+
class CLI < ::Thor::Group
|
9
|
+
include ::Thor::Actions
|
10
|
+
argument :app
|
11
|
+
class_option :'sequel-postgis', type: :boolean, desc: 'Enable postgis extension via Sequel migration', default: true
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.expand_path('../', __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def bootrb
|
18
|
+
insert_into_file "#{app}/lib/boot.rb", :after => "#models\n" do
|
19
|
+
<<-DMREQ.strip_heredoc
|
20
|
+
require File.join($app_root, 'config/sequel')
|
21
|
+
# require models here
|
22
|
+
DMREQ
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def config
|
27
|
+
template('_templates/sequel.rb.tt', "#{app}/config/sequel.rb")
|
28
|
+
end
|
29
|
+
|
30
|
+
def db_migrations
|
31
|
+
empty_directory("#{app}/db")
|
32
|
+
empty_directory("#{app}/db/migrations")
|
33
|
+
create_file("#{app}/db/migrations/.gitkeep", "")
|
34
|
+
template('_templates/001_create_extension_hstore.rb.tt', "#{app}/app/db/migrations/001_create_extension_hstore.rb")
|
35
|
+
if options[:'sequel-postgis']
|
36
|
+
template('_templates/002_create_extension_postgis.rb.tt', "#{app}/app/db/migrations/002_create_extension_postgis.rb")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
content = <<-SGEMS.strip_heredoc
|
42
|
+
group :sequel do
|
43
|
+
gem 'sequel'
|
44
|
+
gem 'sequel_pg'
|
45
|
+
end
|
46
|
+
SGEMS
|
47
|
+
append_to_file "#{app}/Gemfile", content
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/daiku/version.rb
CHANGED
data/spec/daiku/plugins_spec.rb
CHANGED
@@ -11,6 +11,7 @@ describe Daiku::Plugins do
|
|
11
11
|
Daiku::Plugins::Grunt,
|
12
12
|
Daiku::Plugins::Honeybadger,
|
13
13
|
Daiku::Plugins::Newrelic,
|
14
|
+
Daiku::Plugins::Sequel,
|
14
15
|
Daiku::Plugins::Sidekiq,
|
15
16
|
Daiku::Plugins::Vcr
|
16
17
|
]
|
@@ -47,7 +48,7 @@ describe Daiku::Plugins do
|
|
47
48
|
end
|
48
49
|
|
49
50
|
it "can filter plugins by type" do
|
50
|
-
subject.filter_plugins('models', :type).must_equal [subject::Datamapper.meta]
|
51
|
+
subject.filter_plugins('models', :type).must_equal [subject::Datamapper.meta, subject::Sequel.meta]
|
51
52
|
end
|
52
53
|
|
53
54
|
it "returns names of all plugins" do
|
@@ -55,6 +56,6 @@ describe Daiku::Plugins do
|
|
55
56
|
end
|
56
57
|
|
57
58
|
it "returns names of plugins of type: models" do
|
58
|
-
subject.plugin_names('models').must_equal ['datamapper']
|
59
|
+
subject.plugin_names('models').must_equal ['datamapper', 'sequel']
|
59
60
|
end
|
60
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daiku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Marden
|
@@ -133,6 +133,12 @@ files:
|
|
133
133
|
- lib/daiku/plugins/honeybadger/cli.rb
|
134
134
|
- lib/daiku/plugins/newrelic.rb
|
135
135
|
- lib/daiku/plugins/newrelic/cli.rb
|
136
|
+
- lib/daiku/plugins/sequel.rb
|
137
|
+
- lib/daiku/plugins/sequel/_templates/001_create_extension_hstore.rb.tt
|
138
|
+
- lib/daiku/plugins/sequel/_templates/002_create_extension_postgis.rb.tt
|
139
|
+
- lib/daiku/plugins/sequel/_templates/db.rake.tt
|
140
|
+
- lib/daiku/plugins/sequel/_templates/sequel.rb.tt
|
141
|
+
- lib/daiku/plugins/sequel/cli.rb
|
136
142
|
- lib/daiku/plugins/sidekiq.rb
|
137
143
|
- lib/daiku/plugins/sidekiq/_templates/sidekiq.rb.tt
|
138
144
|
- lib/daiku/plugins/sidekiq/cli.rb
|