hamburger 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/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +3 -0
- data/hamburger.gemspec +23 -0
- data/lib/hamburger/version.rb +3 -0
- data/lib/hamburger.rb +6 -0
- data/lib/railties/hamburger.rb +7 -0
- data/lib/tasks/data_to_json.rb +53 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de5d56bafd8248d05670ffb314d9a6fc82ca05af
|
4
|
+
data.tar.gz: fcc15c53088f363ae7bc517510b55c176eceeca2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 175d1d5f8fb660ced0b6ad4f9ad5f649470c9f9eb05c80ce4eea0d66e6bf9539b8c07c84aa337ec7e2dfc4faebe114ffa825c8d4ed9e547e514fca825e7985d2
|
7
|
+
data.tar.gz: 4e226e14b65e50709387aa82d953a34015daf2cab7d92f083e28ea8068ca6ed915f017c51f7a3d676ecf8103e7f93650d7f07358b46365c4968037c0058646cf
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Travis Pessetto
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Travis Pessetto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Hamburger
|
2
|
+
|
3
|
+
Hamburger is designed to easily transfer data from one SQL database to another
|
4
|
+
using JSON and active record. By dumping the data to JSON the data remains
|
5
|
+
database agnostic to be uploaded later.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'hamburger'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
_Saving Data:_
|
21
|
+
|
22
|
+
1. rake db:schema:dump
|
23
|
+
2. rake hamburger:dump
|
24
|
+
3. If any models are off from what they may be in console write them to hamburger_model.txt as a hash. For example Paper Trail's Version would be the following hash {version: "PaperTrail::Version"}
|
25
|
+
|
26
|
+
_Restoring Data:_
|
27
|
+
1. rake db:schema:load
|
28
|
+
2. rake hamburger:load
|
29
|
+
3. You're done.
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/plowdawg/hamburger/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/hamburger.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hamburger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hamburger"
|
8
|
+
spec.version = Hamburger::VERSION
|
9
|
+
spec.authors = ["Travis Pessetto"]
|
10
|
+
spec.email = ["travis@pessetto.com"]
|
11
|
+
spec.summary = %q{Dumps all sql data to JSON for easy migration of DB}
|
12
|
+
spec.description = %q{Dumps all sql data to JSON for DB agnostic data storage}
|
13
|
+
spec.homepage = "https://helpsheets.co"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/hamburger.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
namespace :hamburger do
|
4
|
+
desc "dump the database data to json"
|
5
|
+
task :dump => :environment do
|
6
|
+
file_handle = File.open("database_dump.json","w")
|
7
|
+
puts "hello...starting the dump\n\r"
|
8
|
+
Rails.application.eager_load!
|
9
|
+
ActiveRecord::Base.descendants.each do |record|
|
10
|
+
record.all.each do |data|
|
11
|
+
file_handle.write(data.to_json)
|
12
|
+
file_handle.write("\n\r");
|
13
|
+
end
|
14
|
+
file_handle.write("\n\r")
|
15
|
+
end
|
16
|
+
file_handle.close
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "load the database back from the json file"
|
20
|
+
task :load => :environment do
|
21
|
+
puts "hello...restoring the database from json dump\n\r"
|
22
|
+
line_no = 0
|
23
|
+
fileRedefs = eval(File.open("hamburger_model.txt","r").read)
|
24
|
+
File.open("database_dump.json","r").each_line do |line|
|
25
|
+
line_no += 1
|
26
|
+
if !line.nil? && !(line =~ /^$/)
|
27
|
+
begin
|
28
|
+
jsonObj = JSON.load(line)
|
29
|
+
rescue JSON::ParserError
|
30
|
+
puts "Parser Error on #{line_no}"
|
31
|
+
end
|
32
|
+
if !jsonObj.nil?
|
33
|
+
jsonObj.each do |key, value|
|
34
|
+
model = nil
|
35
|
+
if !fileRedefs[key].nil?
|
36
|
+
model = fileRedefs[key].constantize
|
37
|
+
else
|
38
|
+
model = key.camelize.constantize
|
39
|
+
end
|
40
|
+
model.skip_callback(:create)
|
41
|
+
resource = model.new(value)
|
42
|
+
if resource.save(validate: false)
|
43
|
+
puts "Line ok\n\r"
|
44
|
+
else
|
45
|
+
puts "Bad key value #{key} #{value}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hamburger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Travis Pessetto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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
|
+
description: Dumps all sql data to JSON for DB agnostic data storage
|
42
|
+
email:
|
43
|
+
- travis@pessetto.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- hamburger.gemspec
|
55
|
+
- lib/hamburger.rb
|
56
|
+
- lib/hamburger/version.rb
|
57
|
+
- lib/railties/hamburger.rb
|
58
|
+
- lib/tasks/data_to_json.rb
|
59
|
+
homepage: https://helpsheets.co
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.0.14
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Dumps all sql data to JSON for easy migration of DB
|
83
|
+
test_files: []
|