ferry 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/README.md +78 -0
- data/bin/ferry +6 -0
- data/ferry.gemspec +1 -0
- data/lib/ferry.rb +42 -1
- data/lib/ferry/version.rb +1 -1
- data/spec/spec_helper.rb +78 -0
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d6e9a00c4fe515bd810869dffb3667e7080f5c
|
4
|
+
data.tar.gz: cd77f263a4774959d6c6fb0253b4992ac54ecd21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24aab9f214d73e21188541171a560b772914ed141f026e5b7f58dcf6fb0d41ef66d171fdc6e9e6a51c13a2df353b3141d6bcae40b41310f79b5d9ea62b5da265
|
7
|
+
data.tar.gz: 2a918e7c071296411a42c99dae4dc56ffb876b527b5b1a8d5c3f765959b2a5c68e5889badd34a992d2ddf5e33f6f224b0bf7d068765a4fcb84798ee445ba20f4
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -35,6 +35,84 @@ Or install it yourself as:
|
|
35
35
|
Usage pending. See examples / submit PR's for your ideas.
|
36
36
|
|
37
37
|
## Example(s)
|
38
|
+
###### 3 September 2014
|
39
|
+
Use Case Ideas
|
40
|
+
|
41
|
+
Note: Demo app can initially function with RoR and Postgres.
|
42
|
+
Instantiate the command line tool for ferry ...
|
43
|
+
- Init the project with ferry rake namespace (ferry.rake)
|
44
|
+
- Run the tasks containing the methods we write in ferry
|
45
|
+
|
46
|
+
Manipulation Use Cases
|
47
|
+
- CRUD for Columns
|
48
|
+
- Copy & Paste Columns
|
49
|
+
- CRUD for Rows
|
50
|
+
- Understanding relationships between generating migrations and migration files in place
|
51
|
+
|
52
|
+
Migration
|
53
|
+
- Exporting data to various file formats (.csv, .sql, .yml)
|
54
|
+
- Importing data from various file formats
|
55
|
+
- Migrating data to third party hosts (Amazon S3, Oracle)
|
56
|
+
- Migrating data to a different database
|
57
|
+
|
58
|
+
Important things to consider and remember
|
59
|
+
- Rolling back on errors / mishaps during migrations and manipulations
|
60
|
+
- Host documentation site via GitHub pages
|
61
|
+
|
62
|
+
|
63
|
+
###### 30 August 2014
|
64
|
+
Below is an initial implementation of how ferry will work
|
65
|
+
|
66
|
+
```
|
67
|
+
# encoding: UTF-8
|
68
|
+
require 'consortium'
|
69
|
+
|
70
|
+
task :load_wm_design do
|
71
|
+
class WmDesign < Design
|
72
|
+
self.table_name = :wm_design
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
namespace :consortium_example do
|
77
|
+
desc "writes design cigs to individual xml files using consortium"
|
78
|
+
task :write_local => [:load_wm_design] do
|
79
|
+
hostname = Socket.gethostname
|
80
|
+
FileUtils.mkdir "consortium_migration_#{hostname}" unless Dir["consortium_migration_#{hostname}"].present?
|
81
|
+
homedir = "consortium_migration_#{hostname}"
|
82
|
+
|
83
|
+
range = Design.where("savedate > ?", 15.hours.ago.strftime("%d.%m.%Y %H").to_datetime)
|
84
|
+
|
85
|
+
consortium_runtime = Benchmark.measure do
|
86
|
+
range.migrate({max_workers: 4, batch_size: 500}) do |collection|
|
87
|
+
collection.each do |design|
|
88
|
+
cons_place_design_content_in_batch(design, homedir, design.composite_id)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
puts "#{consortium_runtime}"
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def cons_place_design_content_in_batch(design, homedir, composite_id)
|
98
|
+
begin
|
99
|
+
create_xml_file(homedir, composite_id, design)
|
100
|
+
rescue Exception => e
|
101
|
+
File.rename("#{homedir}/#{composite_id}.xml", "#{homedir}/#{composite_id}.xml.failed")
|
102
|
+
raise e
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def create_xml_file(homedir, composite_id, design)
|
107
|
+
design.updated_at ? updated_at = design.updated_at.to_time : updated_at = design.created_at.to_time
|
108
|
+
FileUtils.touch "#{homedir}/#{composite_id}.xml"
|
109
|
+
file = File.open("#{homedir}/#{composite_id}.xml", 'w')
|
110
|
+
file.puts design.content
|
111
|
+
file.close
|
112
|
+
FileUtils.touch "#{homedir}/#{composite_id}.xml", :mtime => updated_at
|
113
|
+
end
|
114
|
+
end
|
115
|
+
```
|
38
116
|
|
39
117
|
###### 29 July 2014
|
40
118
|
Version 0.0.1 is functional with the rake task defined here :: https://github.com/customink/design_content_migration/blob/master/lib/tasks/ferry_example.rake#L10
|
data/bin/ferry
ADDED
data/ferry.gemspec
CHANGED
data/lib/ferry.rb
CHANGED
@@ -3,5 +3,46 @@ require "ferry/engine"
|
|
3
3
|
require "ferry/logger"
|
4
4
|
|
5
5
|
module Ferry
|
6
|
-
#
|
6
|
+
#
|
7
|
+
class ActiveRecord::Relation
|
8
|
+
def migrate(options, &block)
|
9
|
+
options[:max_workers] ||= 4
|
10
|
+
options[:batch_size] ||= 10_000
|
11
|
+
|
12
|
+
log = Logger.new()
|
13
|
+
|
14
|
+
active_workers = []
|
15
|
+
collection = self
|
16
|
+
collection.find_in_batches(batch_size: options[:batch_size]) do |batch|
|
17
|
+
if active_workers.length >= options[:max_workers]
|
18
|
+
log.write "active_workers oversized at capacity of #{active_workers.length}/#{options[:max_workers]}"
|
19
|
+
finished_process = Process.wait
|
20
|
+
log.write "finished_process: #{finished_process}"
|
21
|
+
active_workers.delete finished_process
|
22
|
+
log.write "active_workers capacity now at: #{active_workers.length}/#{options[:max_workers]}"
|
23
|
+
else
|
24
|
+
active_workers << fork do
|
25
|
+
ActiveRecord::Base.connection.reconnect!
|
26
|
+
log.write "kicking off engine on batch(#{batch.first}-#{batch.last})"
|
27
|
+
engine = Engine.new()
|
28
|
+
engine.run({log: log, batch: batch}, &block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
ActiveRecord::Base.connection.reconnect!
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Exporter
|
37
|
+
def speak
|
38
|
+
puts "exporting!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Importer
|
43
|
+
def speak
|
44
|
+
puts "importing!"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
7
48
|
end
|
data/lib/ferry/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, make a
|
10
|
+
# separate helper file that requires this one and then use it only in the specs
|
11
|
+
# that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# The settings below are suggested to provide a good initial experience
|
19
|
+
# with RSpec, but feel free to customize to your heart's content.
|
20
|
+
=begin
|
21
|
+
# These two settings work together to allow you to limit a spec run
|
22
|
+
# to individual examples or groups you care about by tagging them with
|
23
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
24
|
+
# get run.
|
25
|
+
config.filter_run :focus
|
26
|
+
config.run_all_when_everything_filtered = true
|
27
|
+
|
28
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
29
|
+
# file, and it's useful to allow more verbose output when running an
|
30
|
+
# individual spec file.
|
31
|
+
if config.files_to_run.one?
|
32
|
+
# Use the documentation formatter for detailed output,
|
33
|
+
# unless a formatter has already been configured
|
34
|
+
# (e.g. via a command-line flag).
|
35
|
+
config.default_formatter = 'doc'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Print the 10 slowest examples and example groups at the
|
39
|
+
# end of the spec run, to help surface which specs are running
|
40
|
+
# particularly slow.
|
41
|
+
config.profile_examples = 10
|
42
|
+
|
43
|
+
# Run specs in random order to surface order dependencies. If you find an
|
44
|
+
# order dependency and want to debug it, you can fix the order by providing
|
45
|
+
# the seed, which is printed after each run.
|
46
|
+
# --seed 1234
|
47
|
+
config.order = :random
|
48
|
+
|
49
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
50
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
51
|
+
# test failures related to randomization by passing the same `--seed` value
|
52
|
+
# as the one that triggered the failure.
|
53
|
+
Kernel.srand config.seed
|
54
|
+
|
55
|
+
# rspec-expectations config goes here. You can use an alternate
|
56
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
57
|
+
# assertions if you prefer.
|
58
|
+
config.expect_with :rspec do |expectations|
|
59
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
60
|
+
# For more details, see:
|
61
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
62
|
+
expectations.syntax = :expect
|
63
|
+
end
|
64
|
+
|
65
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
66
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
67
|
+
config.mock_with :rspec do |mocks|
|
68
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
69
|
+
# For more details, see:
|
70
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
71
|
+
mocks.syntax = :expect
|
72
|
+
|
73
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
74
|
+
# a real object. This is generally recommended.
|
75
|
+
mocks.verify_partial_doubles = true
|
76
|
+
end
|
77
|
+
=end
|
78
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ferry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Corletti
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -82,26 +82,44 @@ dependencies:
|
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rspec
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
85
99
|
description: Ferry is a data migration and data manipulation tool that seeks to simplify
|
86
100
|
the increasingly prevalent big data problems that tech companies face
|
87
101
|
email:
|
88
102
|
- anthcor@gmail.com
|
89
103
|
- loganwatanabe@gmail.com
|
90
104
|
- profh@cmu.edu
|
91
|
-
executables:
|
105
|
+
executables:
|
106
|
+
- ferry
|
92
107
|
extensions: []
|
93
108
|
extra_rdoc_files: []
|
94
109
|
files:
|
95
110
|
- ".gitignore"
|
111
|
+
- ".rspec"
|
96
112
|
- Gemfile
|
97
113
|
- LICENSE.txt
|
98
114
|
- README.md
|
99
115
|
- Rakefile
|
116
|
+
- bin/ferry
|
100
117
|
- ferry.gemspec
|
101
118
|
- lib/ferry.rb
|
102
119
|
- lib/ferry/engine.rb
|
103
120
|
- lib/ferry/logger.rb
|
104
121
|
- lib/ferry/version.rb
|
122
|
+
- spec/spec_helper.rb
|
105
123
|
homepage: https://github.com/cmu-is-projects/
|
106
124
|
licenses:
|
107
125
|
- MIT
|
@@ -126,4 +144,5 @@ rubygems_version: 2.2.2
|
|
126
144
|
signing_key:
|
127
145
|
specification_version: 4
|
128
146
|
summary: Ferry is a data migration and data manipulation tool
|
129
|
-
test_files:
|
147
|
+
test_files:
|
148
|
+
- spec/spec_helper.rb
|