sequel-rake 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f829c0aac27e097cb60ce782c391227c5c8548d
4
+ data.tar.gz: a52bdb119e6466e09a03c27886e53b319349b22d
5
+ SHA512:
6
+ metadata.gz: 74a5d9f0eaed4f29d7f835f8dba773579f0ab86ae392ab0fd06bf2a213262451ad5f8d6382f5db73ef324933065052df846646987b0e34ddc221d3028b847753
7
+ data.tar.gz: 2fb55e0d7908468b7c79b27c3c54a7cac11a67769158484cb2741c8f274e04b0cdb6a9f51e011fdb521e2d81ee8037b514461647d4620784b0daf2d92a10b4aa
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .DS_Store
10
+ /db
11
+ /database.yml
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ script: "bundle exec rake test:coverage --trace"
3
+ before_install: gem install bundler -v 1.11.2
4
+ rvm:
5
+ - 2.3.1
6
+ - ruby-head
7
+ - jruby-9.1.2.0
8
+ - jruby-head
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: jruby-head
12
+ - rvm: ruby-head
13
+ branches:
14
+ only:
15
+ - master
16
+ addons:
17
+ code_climate:
18
+ repo_token:
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at tobias@sandeli.us. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Tobias Sandelius
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # sequel-rake
2
+
3
+ Provides useful rake tasks when working with the awesome Sequel gem.
4
+
5
+ The `database.yml` must be located at `./database.yml` or `./config/database.yml` in
6
+ order to be located.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'sequel-rake'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install sequel-rake
23
+
24
+ ## Usage
25
+
26
+ ```ruby
27
+ # Rakefile
28
+
29
+ require 'sequel/rake'
30
+ ```
31
+
32
+ ```
33
+ $ bundle exec rake ...
34
+
35
+ sequel:generate[name] # Generate a new migration file `sequel:generate[create_books]`
36
+ sequel:init # Creates a database.yml file
37
+ sequel:migrate[version] # Migrate the database (you can specify the version with `db:migrate[N]`)
38
+ sequel:remigrate # Undo all migrations and migrate again
39
+ ```
40
+
41
+ ## TODO
42
+
43
+ * Rollback to previous version
44
+ * Write some tests
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sandelius/sequel-rake. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
49
+
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ require 'sequel/rake'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.pattern = 'test/**/*_test.rb'
8
+ t.libs.push 'test'
9
+ end
10
+
11
+ namespace :test do
12
+ task :coverage do
13
+ ENV['COVERAGE'] = 'true'
14
+ Rake::Task['test'].invoke
15
+ end
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1,26 @@
1
+ defaults: &defaults
2
+ migrations: db/migrations
3
+ adapter: postgres
4
+ max_connections: 5
5
+ host: localhost
6
+ user: postgres
7
+
8
+ development:
9
+ <<: *defaults
10
+ password:
11
+ database: app_development
12
+
13
+ test:
14
+ <<: *defaults
15
+ password:
16
+ database: app_test
17
+
18
+ staging:
19
+ <<: *defaults
20
+ password:
21
+ database: app_staging
22
+
23
+ production:
24
+ <<: *defaults
25
+ password:
26
+ database: app
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequel
4
+ module Rake
5
+ # Current version number.
6
+ VERSION = '0.0.1'
7
+ end
8
+ end
9
+
10
+ namespace :sequel do
11
+ require 'sequel'
12
+ require 'fileutils'
13
+ require 'yaml'
14
+
15
+ desc 'Creates a database.yml file'
16
+ task :init do
17
+ skeleton = "#{__dir__}/database.yml"
18
+
19
+ if File.directory?(path('config'))
20
+ FileUtils.cp(skeleton, path('config/database.yml'))
21
+ else
22
+ FileUtils.cp(skeleton, path('database.yml'))
23
+ end
24
+
25
+ FileUtils::mkdir_p path('db/migrations')
26
+ end
27
+
28
+ desc 'Generate a new migration file `sequel:generate[create_books]`'
29
+ task :generate, :name do |_, args|
30
+ name = args[:name]
31
+ abort('Missing migration file name') if name.nil?
32
+
33
+ content = "# frozen_string_literal: true\n\nSequel.migration do\n change do\n \n end\nend\n"
34
+ timestamp = Time.now.to_i
35
+ filename = File.join(config[env]['migrations'], "#{timestamp}_#{name}.rb")
36
+
37
+ File.write(filename, content)
38
+ end
39
+
40
+ desc 'Migrate the database (you can specify the version with `db:migrate[N]`)'
41
+ task :migrate, [:version] do |task, args|
42
+ version = args[:version] ? Integer(args[:version]) : nil
43
+ migrate(version)
44
+ end
45
+
46
+ desc 'Undo all migrations and migrate again'
47
+ task :remigrate do
48
+ migrate(0)
49
+ migrate
50
+ end
51
+
52
+ def migrate(version = nil)
53
+ databases.each do |db|
54
+ conn, opts = db
55
+ Sequel.extension :migration
56
+ Sequel::Migrator.apply(conn, opts['migrations'], version)
57
+ end
58
+ end
59
+
60
+ def databases
61
+ envs = []
62
+ if env == 'production' || env == 'staging'
63
+ envs << env
64
+ else
65
+ envs.concat(['development', 'test'])
66
+ end
67
+ envs.map { |e| [Sequel.connect(config[e]), config[env]] }
68
+ end
69
+
70
+ def path(path)
71
+ "#{Dir.pwd}/#{path}"
72
+ end
73
+
74
+ def connection
75
+ @connection ||= Sequel.connect(config)
76
+ end
77
+
78
+ def config
79
+ @config ||= begin
80
+ filepath = path('database.yml')
81
+
82
+ unless File.exist?(filepath)
83
+ filepath = path('config/database.yml')
84
+
85
+ unless File.exist?(filepath)
86
+ abort 'Missing database.yml file. Run `seqcli init` first'
87
+ end
88
+ end
89
+
90
+ @config = YAML.load_file(filepath)
91
+ end
92
+ end
93
+
94
+ def env
95
+ ENV['RACK_ENV'] || 'development'
96
+ end
97
+ end
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'sequel-rake'
3
+ spec.version = File.read('lib/sequel/rake.rb')[/VERSION += +([\'])([\d][\w\.]+)\1/, 2]
4
+ spec.summary = 'Rake tasks for the Sequel gem.'
5
+
6
+ spec.required_ruby_version = '>= 2.3.0'
7
+ spec.required_rubygems_version = '>= 2.5.0'
8
+
9
+ spec.license = 'MIT'
10
+
11
+ spec.author = 'Tobias Sandelius'
12
+ spec.email = 'tobias@sandeli.use'
13
+ spec.homepage = 'https://github.com/sandelius/sequel-rake'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.test_files = spec.files.grep(%r{^(test)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'thor', '~> 0.19'
20
+
21
+ spec.add_development_dependency 'sequel'
22
+ spec.add_development_dependency 'pg'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'minitest', '>= 5.7.0'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'simplecov'
27
+ spec.add_development_dependency 'codeclimate-test-reporter'
28
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV['RACK_ENV'] = 'test'
4
+
5
+ require 'bundler/setup'
6
+
7
+ if ENV['COVERAGE'] == 'true'
8
+ require 'simplecov'
9
+ require 'codeclimate-test-reporter'
10
+
11
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
12
+ SimpleCov::Formatter::HTMLFormatter,
13
+ CodeClimate::TestReporter::Formatter
14
+ ])
15
+
16
+ SimpleCov.start do
17
+ command_name 'test'
18
+ add_filter 'test'
19
+ end
20
+ end
21
+
22
+ require 'minitest/autorun'
23
+
24
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
25
+ require 'sequel/rake'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ describe Sequel::Rake do
6
+ it 'has a version number' do
7
+ assert Sequel::Rake::VERSION
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequel-rake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tobias Sandelius
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sequel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pg
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 5.7.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 5.7.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: codeclimate-test-reporter
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email: tobias@sandeli.use
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - ".gitignore"
132
+ - ".travis.yml"
133
+ - CODE_OF_CONDUCT.md
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - lib/sequel/database.yml
139
+ - lib/sequel/rake.rb
140
+ - sequel-rake.gemspec
141
+ - test/test_helper.rb
142
+ - test/unit/rake_test.rb
143
+ homepage: https://github.com/sandelius/sequel-rake
144
+ licenses:
145
+ - MIT
146
+ metadata: {}
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: 2.3.0
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 2.5.0
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 2.5.1
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: Rake tasks for the Sequel gem.
167
+ test_files:
168
+ - test/test_helper.rb
169
+ - test/unit/rake_test.rb