rakudax 0.0.1
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 +7 -0
- data/.codeclimate.yml +17 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +14 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/rakudax +13 -0
- data/lib/rakudax.rb +14 -0
- data/lib/rakudax/base.rb +217 -0
- data/lib/rakudax/settings.rb +7 -0
- data/lib/rakudax/skel.rb +116 -0
- data/lib/rakudax/tasks/generate.rb +166 -0
- data/lib/rakudax/tasks/migrate.rb +153 -0
- data/lib/rakudax/tasks/submit.rb +114 -0
- data/lib/rakudax/tasks/verify.rb +106 -0
- data/lib/rakudax/version.rb +3 -0
- data/rakudax.gemspec +28 -0
- metadata +153 -0
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.2.0
|
4
|
+
- 2.3.0
|
5
|
+
before_install: gem install bundler -v 1.11.2
|
6
|
+
cache:
|
7
|
+
directories:
|
8
|
+
- vendor/bundle
|
9
|
+
install: bundle install --path=vendor/bundle
|
10
|
+
script:
|
11
|
+
- bundle exec rake spec
|
12
|
+
addons:
|
13
|
+
code_climate:
|
14
|
+
repo_token: bb43f5a81bbc75fc12b8d510d664dbd90b73cdbb22adb4a0aaf7e064117687dd
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 takashi.yamashita.wy@hitachi-solutions.com. 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,8 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rakudax.gemspec
|
4
|
+
gemspec
|
5
|
+
gem 'sqlite3', group: "test"
|
6
|
+
gem 'pry', require: "false", group: "test"
|
7
|
+
gem 'simplecov', require: "false", group: "test"
|
8
|
+
gem "codeclimate-test-reporter", group: :test, require: nil
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 metalels, bon10
|
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,81 @@
|
|
1
|
+
# Rakudax
|
2
|
+
|
3
|
+
[](https://travis-ci.org/tlab-jp/rakudax)
|
4
|
+
[](https://codeclimate.com/github/tlab-jp/rakudax)
|
5
|
+
[](https://codeclimate.com/github/tlab-jp/rakudax/coverage)
|
6
|
+
|
7
|
+
Data migration tool using (ruby)Active Record.
|
8
|
+
For more information about [tlab-jp/rakuda](https://github.com/tlab-jp/rakuda).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'rakudax'
|
16
|
+
|
17
|
+
## If using sqlite database, then comment-in this line.
|
18
|
+
#gem 'sqlite3'
|
19
|
+
|
20
|
+
## If using mysql database, then comment-in this line.
|
21
|
+
#gem 'mysql2'
|
22
|
+
|
23
|
+
## If using postgresql database, then comment-in this line.
|
24
|
+
#gem 'pg'
|
25
|
+
|
26
|
+
## If using ms sqlserver datavase, then comment-in this line.
|
27
|
+
#gem 'tiny_tds'
|
28
|
+
#gem 'activerecord-sqlserver-adapter'
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
$ bundle
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
$ gem install rakudax
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
```
|
42
|
+
===========================================================================
|
43
|
+
<>: required
|
44
|
+
[]: optional
|
45
|
+
|
46
|
+
## new rakuda project creation
|
47
|
+
Usage: rakudax new [name]
|
48
|
+
|
49
|
+
name: project name
|
50
|
+
|
51
|
+
## rakuda project execution
|
52
|
+
Usage: rakudax <control> [Options]
|
53
|
+
|
54
|
+
control: generate, submit, migrate, verify
|
55
|
+
|
56
|
+
Options:
|
57
|
+
|
58
|
+
--setting <path> *path to control setting file (default: config/<control>.yml)
|
59
|
+
--database <path> *path to database setting file (default: config/database.yml)
|
60
|
+
--modules <path> path to modules directory
|
61
|
+
--env <enviroment> control-setting enviroment (default: development)
|
62
|
+
--intermediate <path> path to intermediate files (default: dist/intermediate_files)
|
63
|
+
--verify <path> path to verify files (default: dist/verify)
|
64
|
+
--threads <num> threads num in generate (deafult: 1)
|
65
|
+
--yaml change output type to yaml (default: json)
|
66
|
+
--debug print debugging information to console
|
67
|
+
--logging enable ActiveRecord's logging. (output: active_record.log)
|
68
|
+
|
69
|
+
*only support yaml setting file
|
70
|
+
===========================================================================
|
71
|
+
```
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tlab/rakudax. 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.
|
76
|
+
|
77
|
+
|
78
|
+
## License
|
79
|
+
|
80
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
81
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rakudax"
|
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
data/exe/rakudax
ADDED
data/lib/rakudax.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rakudax/version'
|
2
|
+
require 'active_record'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
require 'erb'
|
6
|
+
require 'logger'
|
7
|
+
require 'yaml'
|
8
|
+
require 'thread'
|
9
|
+
require 'settingslogic'
|
10
|
+
require 'rakudax/base'
|
11
|
+
|
12
|
+
module Rakudax
|
13
|
+
end
|
14
|
+
|
data/lib/rakudax/base.rb
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
module Rakudax
|
2
|
+
class Base
|
3
|
+
require 'pathname'
|
4
|
+
USAGE=<<-EOS
|
5
|
+
===========================================================================
|
6
|
+
<>: required
|
7
|
+
[]: optional
|
8
|
+
|
9
|
+
## new rakuda project creation
|
10
|
+
Usage: rakudax new [name]
|
11
|
+
|
12
|
+
name: project name
|
13
|
+
|
14
|
+
## rakuda project execution
|
15
|
+
Usage: rakudax <control> [Options]
|
16
|
+
|
17
|
+
control: generate, submit, migrate, verify
|
18
|
+
|
19
|
+
Options:
|
20
|
+
|
21
|
+
--setting <path> *path to control setting file (default: config/<control>.yml)
|
22
|
+
--database <path> *path to database setting file (default: config/database.yml)
|
23
|
+
--modules <path> path to modules directory
|
24
|
+
--env <enviroment> control-setting enviroment (default: development)
|
25
|
+
--intermediate <path> path to intermediate files (default: dist/intermediate_files)
|
26
|
+
--verify <path> path to verify files (default: dist/verify)
|
27
|
+
--threads <num> threads num in generate (deafult: 1)
|
28
|
+
--yaml change output type to yaml (default: json)
|
29
|
+
--debug print debugging information to console
|
30
|
+
--logging enable ActiveRecord's logging. (output: active_record.log)
|
31
|
+
|
32
|
+
*only support yaml setting file
|
33
|
+
===========================================================================
|
34
|
+
EOS
|
35
|
+
|
36
|
+
def self.exit_with_message(code, usage=false, msg=nil)
|
37
|
+
puts msg unless msg.nil?
|
38
|
+
puts USAGE if usage
|
39
|
+
exit code
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.root
|
43
|
+
@@root ||= Pathname.pwd
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.logging
|
47
|
+
@@debug ||= false
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.debug
|
51
|
+
@@debug ||= false
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.output_type
|
55
|
+
@@output_type ||= 'json'
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.threads
|
59
|
+
@@threads ||= 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.im_path
|
63
|
+
@@im_path ||= self.root.join("dist").join("intermediate_files")
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.im_path=(str)
|
67
|
+
@@im_path = Pathname.new str
|
68
|
+
@@im_path = self.root.join(str) unless @@im_path.absolute?
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.mods_path
|
72
|
+
@@mods_path ||= nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.mods_path=(str)
|
76
|
+
@@mods_path = Pathname.new str
|
77
|
+
@@mods_path = self.root.join(str) unless @@mods_path.absolute?
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.verify_path
|
81
|
+
@@verify_path ||= self.root.join("dist").join("verify")
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.verify_path=(str)
|
85
|
+
@@verify_path = Pathname.new str
|
86
|
+
@@verify_path = self.root.join(str) unless @@verify_path.absolute?
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.dbconfig
|
90
|
+
@@dbconfig ||= {}
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.load_dbconfig(str)
|
94
|
+
path = Pathname.new str
|
95
|
+
path = self.root.join(str) unless path.absolute?
|
96
|
+
@@dbconfig = YAML.load(
|
97
|
+
File.read(
|
98
|
+
Pathname.new(path)
|
99
|
+
)
|
100
|
+
)
|
101
|
+
@@dbconfig.each do |k, v|
|
102
|
+
next unless v["adapter"] == "sqlite3"
|
103
|
+
p = Pathname.new v["database"]
|
104
|
+
@@dbconfig[k]["database"] = self.root.join(v["database"]).to_s unless p.absolute?
|
105
|
+
end
|
106
|
+
@@dbconfig
|
107
|
+
rescue
|
108
|
+
@@dbconfig = nil
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.env
|
112
|
+
@@env ||= "production"
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.models
|
116
|
+
@@models ||= {}
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.control
|
120
|
+
@@control
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.settings_path
|
124
|
+
@@settings_path ||= nil
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.settings_path=(str)
|
128
|
+
@@settings_path = Pathname.new str
|
129
|
+
@@settings_path = self.root.join(str) unless @@settings_path.absolute?
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.parse_options(argv)
|
133
|
+
if argv.empty?
|
134
|
+
self.exit_with_message 2, true
|
135
|
+
end
|
136
|
+
|
137
|
+
@@control = argv.shift
|
138
|
+
|
139
|
+
|
140
|
+
if self.control == "--help" || self.control == "-h"
|
141
|
+
self.exit_with_message 0, true
|
142
|
+
end
|
143
|
+
|
144
|
+
c_c_path = "config/#{self.control}.yml"
|
145
|
+
d_c_path = "config/database.yml"
|
146
|
+
|
147
|
+
while arg = argv.shift
|
148
|
+
case arg
|
149
|
+
when /\A--setting\z/
|
150
|
+
c_c_path = argv.shift
|
151
|
+
when /\A--database\z/
|
152
|
+
d_c_path = argv.shift
|
153
|
+
when /\A--modules\z/
|
154
|
+
self.mods_path = argv.shift
|
155
|
+
when /\A--intermediate\z/
|
156
|
+
self.im_path = argv.shift
|
157
|
+
when /\A--verify\z/
|
158
|
+
self.verify_path = argv.shift
|
159
|
+
when /\A--env\z/
|
160
|
+
@@env = argv.shift
|
161
|
+
when /\A--threads\z/
|
162
|
+
th = argv.shift.to_i
|
163
|
+
if th <= 0
|
164
|
+
self.exit_with_message 1, false, "thread must be greater than 0."
|
165
|
+
end
|
166
|
+
@@threads = th
|
167
|
+
when /\A--logging\z/
|
168
|
+
@@logging = true
|
169
|
+
when /\A--yaml\z/
|
170
|
+
@@output_type = "yaml"
|
171
|
+
when /\A--debug\z/
|
172
|
+
@@debug = true
|
173
|
+
when /\A--help\z/, /\A-h\z/
|
174
|
+
self.exit_with_message 0, true
|
175
|
+
else
|
176
|
+
puts "unknown option #{arg}"
|
177
|
+
self.exit_with_message 2, true
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# validate control and config
|
182
|
+
case self.control
|
183
|
+
when "generate", "migrate", "verify", "submit"
|
184
|
+
self.settings_path = c_c_path
|
185
|
+
require "rakudax/tasks/#{self.control}"
|
186
|
+
else
|
187
|
+
self.exit_with_message 1, true, "Control must chose from (generate migrate verify submit)"
|
188
|
+
end
|
189
|
+
|
190
|
+
# validate dbconfig
|
191
|
+
if self.load_dbconfig(d_c_path).nil?
|
192
|
+
self.exit_with_message 1, false, "Database config is broken or not found."
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def self.execute
|
197
|
+
unless self.mods_path.nil?
|
198
|
+
Dir.glob(Rakudax::Base.mods_path.join("*.rb")).each do |file|
|
199
|
+
load file
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
load "rakudax/settings.rb"
|
204
|
+
puts "models: #{Rakudax::Settings.models}"
|
205
|
+
if Rakudax::Settings.models.nil?
|
206
|
+
self.exit_with_message 1, false, "models not defined."
|
207
|
+
end
|
208
|
+
|
209
|
+
if self.logging
|
210
|
+
ActiveRecord::Base.logger = Logger.new Rakudax::Base.root.join("active_record.log")
|
211
|
+
ActiveRecord::Base.logger.level = 0
|
212
|
+
end
|
213
|
+
|
214
|
+
Rakudax::Tasks.send self.control
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|