daiku 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dd1097cb00c2e89d1d4ac2ef0c7d7507951d849
4
- data.tar.gz: 65357c4faee3832c917bd05291e95df1c8a731dd
3
+ metadata.gz: ea12ee95a2500430471e9afbae6a3348d1800a33
4
+ data.tar.gz: 70440ea6816cf4069e2d3992c973a29f224a107e
5
5
  SHA512:
6
- metadata.gz: bb8d0624c0f23c8c6ea9b17d1bba949bbefb54092d2f585f68056fbdd3953bc337f99990459abcb8dddce675e91e35fac90a10c2291763b81f3dc06db36a5fb6
7
- data.tar.gz: b77e23dd95b9444e40358f34d8065405ccb9a162707efb30ae5685e968424738637e868d2d744505be98875adb88eea6c7bf40cf894d75466499f4035e4dfbcd
6
+ metadata.gz: 43a594f9f70de2468ab4bc093fb9b08de4f145780572b8db4f29b2a288df3d0d9454b5285a6c801004942958e2b08f7d1df1a4b4220a45ac2aa5aa50071cf8e0
7
+ data.tar.gz: 2810331d3b90801f397278fd8fc9b27ecee3fadab3bd352499a8a0019631bb6deedf0fb7294187744d26d8433094c6889b5adfb3058b2661b0692f358258c34c
@@ -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
- # insert require statements for models here
20
+ # require models here
21
21
  DataMapper.finalize
22
22
  DMREQ
23
23
  end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ module Daiku
4
+ class Plugins
5
+ class Sequel < ::Daiku::Plugin
6
+ plugin_name 'sequel'
7
+ plugin_type 'models'
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,9 @@
1
+ Sequel.migration do
2
+ up do
3
+ run 'CREATE EXTENSION hstore;'
4
+ end
5
+
6
+ down do
7
+ run 'DROP EXTENSION IF EXISTS hstore;'
8
+ end
9
+ 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
@@ -1,3 +1,3 @@
1
1
  module Daiku
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.1.1
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