enhanced_mysql_tasks 0.2.0

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: 6f3cac74484c1e92ab42c1c5bdba6d76901babaf
4
+ data.tar.gz: 5e933049f05faeff11e6e9c6e295ab57b48443bd
5
+ SHA512:
6
+ metadata.gz: c8524a8c9310a3fbaaf1cd7faee61bee8668521d97a382f5cfb3399c0a093b54b7fd5253c69acb16cc36e13b5c92a82783778af51133f2c3746358d2f5ebe709
7
+ data.tar.gz: 28c77a38d212f6cb1764a036c28074a5f240cbf994385a74956a900011451fb29e5c763b712414aacac77d2dff13b0349b1ba11e4094caf3e1f7fa6eff302d81
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /gemfiles/*.lock
5
+ /gemfiles/vendor
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
5
+ gemfile:
6
+ - gemfiles/Gemfile-rails.4.1.x
7
+ - gemfiles/Gemfile-rails.4.2.x
8
+ - gemfiles/Gemfile-rails.edge
9
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in enhanced_mysql_tasks.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 ppworks
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # EnhancedMysqlTasks
2
+
3
+ [![Build Status](https://travis-ci.org/ppworks/enhanced_mysql_tasks.svg?branch=master)](https://travis-ci.org/ppworks/enhanced_mysql_tasks)
4
+
5
+ This gem provides clean `db/structure.sql`.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'enhanced_mysql_tasks'
13
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "enhanced_mysql_tasks"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'enhanced_mysql_tasks/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "enhanced_mysql_tasks"
7
+ spec.version = EnhancedMysqlTasks::VERSION
8
+ spec.authors = ["ppworks"]
9
+ spec.email = ["koshikawa@ppworks.jp"]
10
+
11
+ spec.summary = %q{Enhanced MySQL tasks for Rails}
12
+ spec.description = %q{This gem provides clean db/structure.sql.}
13
+ spec.homepage = "https://github.com/ppworks/enhanced_mysql_tasks"
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency 'rails', ['>= 4.1.0', '< 6']
20
+ spec.add_development_dependency "bundler", "~> 1.11"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "minitest", "~> 5.0"
23
+ spec.add_development_dependency "mocha", "~> 1.1.0"
24
+ end
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec :path => '../'
3
+ gem 'rails', '~> 4.1.14'
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec :path => '../'
3
+ gem 'rails', '~> 4.2.5'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec :path => '../'
3
+ git 'git://github.com/rails/rails.git' do
4
+ gem 'rails'
5
+ end
@@ -0,0 +1,15 @@
1
+ require 'enhanced_mysql_tasks/version'
2
+
3
+ module EnhancedMySQLTasks
4
+ end
5
+
6
+ if Gem::Version.create(ActiveRecord.version) >= Gem::Version.create('4.2.0')
7
+ require 'enhanced_mysql_tasks/rails42/mysql_database_tasks'
8
+ ActiveRecord::Tasks::MySQLDatabaseTasks.__send__(:prepend, EnhancedMySQLTasks::Rails42::MySQLDatabaseTasks)
9
+ elsif Gem::Version.create(ActiveRecord.version) >= Gem::Version.create('4.1.0')
10
+ require 'enhanced_mysql_tasks/rails41/mysql_database_tasks'
11
+ ActiveRecord::Tasks::MySQLDatabaseTasks.__send__(:prepend, EnhancedMySQLTasks::Rails41::MySQLDatabaseTasks)
12
+ end
13
+
14
+ require 'enhanced_mysql_tasks/schema_statements'
15
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.__send__(:prepend, EnhancedMySQLTasks::SchemaStatements)
@@ -0,0 +1,23 @@
1
+ module EnhancedMySQLTasks
2
+ module Rails41
3
+ module MySQLDatabaseTasks
4
+ def structure_dump(filename)
5
+ args = prepare_command_options('mysqldump')
6
+ args.concat(["--result-file", "#{filename}"])
7
+ args.concat(["--no-data"])
8
+ args.concat(["--routines"])
9
+ args.concat(["--skip-comments"])
10
+ args.concat(["--skip-dump-date"])
11
+ args.concat(["#{configuration['database']}"])
12
+
13
+ if Kernel.system(*args)
14
+ sql = File.read(filename)
15
+ File.write(filename, sql.gsub(/ AUTO_INCREMENT=[0-9]+/, ''))
16
+ else
17
+ $stderr.puts "Could not dump the database structure. "\
18
+ "Make sure `mysqldump` is in your PATH and check the command output for warnings."
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module EnhancedMySQLTasks
2
+ module Rails42
3
+ module MySQLDatabaseTasks
4
+ def structure_dump(filename)
5
+ args = prepare_command_options
6
+ args.concat(["--result-file", "#{filename}"])
7
+ args.concat(["--no-data"])
8
+ args.concat(["--routines"])
9
+ args.concat(["--skip-comments"])
10
+ args.concat(["--skip-dump-date"])
11
+ args.concat(["#{configuration['database']}"])
12
+
13
+ run_cmd('mysqldump', args, 'dumping')
14
+ sql = File.read(filename)
15
+ File.write(filename, sql.gsub(/ AUTO_INCREMENT=[0-9]+/, ''))
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module EnhancedMySQLTasks
2
+ module SchemaStatements
3
+ def dump_schema_information
4
+ sm_table = ActiveRecord::Migrator.schema_migrations_table_name
5
+
6
+ sql = String.new
7
+ sql << "INSERT INTO #{sm_table} (version) VALUES\n"
8
+ sql << ActiveRecord::SchemaMigration.order('version').map { |sm|
9
+ "('#{sm.version}')"
10
+ }.join(",\n")
11
+ sql << ";\n\n"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module EnhancedMysqlTasks
2
+ VERSION = "0.2.0"
3
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: enhanced_mysql_tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - ppworks
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.1.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.11'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.11'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: minitest
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '5.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '5.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: mocha
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 1.1.0
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.1.0
89
+ description: This gem provides clean db/structure.sql.
90
+ email:
91
+ - koshikawa@ppworks.jp
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".travis.yml"
98
+ - Gemfile
99
+ - MIT-LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - bin/console
103
+ - bin/setup
104
+ - enhanced_mysql_tasks.gemspec
105
+ - gemfiles/Gemfile-rails.4.1.x
106
+ - gemfiles/Gemfile-rails.4.2.x
107
+ - gemfiles/Gemfile-rails.edge
108
+ - lib/enhanced_mysql_tasks.rb
109
+ - lib/enhanced_mysql_tasks/rails41/mysql_database_tasks.rb
110
+ - lib/enhanced_mysql_tasks/rails42/mysql_database_tasks.rb
111
+ - lib/enhanced_mysql_tasks/schema_statements.rb
112
+ - lib/enhanced_mysql_tasks/version.rb
113
+ homepage: https://github.com/ppworks/enhanced_mysql_tasks
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.4.5.1
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Enhanced MySQL tasks for Rails
137
+ test_files: []