table_copy 0.0.5

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.
@@ -0,0 +1,89 @@
1
+ require 'table_copy'
2
+
3
+ describe TableCopy do
4
+ let(:tc) { TableCopy }
5
+
6
+ describe '.logger' do
7
+ it 'defaults to a ruby logger' do
8
+ expect(tc.logger).to be_kind_of Logger
9
+ end
10
+ end
11
+
12
+ describe '.logger=' do
13
+ before { @old_logger = tc.logger }
14
+ after { tc.logger = @old_logger }
15
+
16
+ it 'reassigns .logger' do
17
+ val = 'asdf5678'
18
+ expect {
19
+ tc.logger = val
20
+ }.to change {
21
+ tc.logger
22
+ }.to(val)
23
+ end
24
+ end
25
+
26
+ describe '.links' do
27
+ context 'no config' do
28
+ it 'returns an empty hash' do
29
+ expect(tc.links).to eq({})
30
+ end
31
+ end
32
+
33
+ context 'config block defined' do
34
+ let(:source) { 'fake source' }
35
+ let(:destination) { 'fake destination' }
36
+ let(:link_name) { 'a link name' }
37
+ let(:expected_value) { 'an expected value' }
38
+
39
+ let(:config) { Proc.new {} }
40
+
41
+ before do
42
+ TableCopy.deferred_config(&config)
43
+ end
44
+
45
+ after do
46
+ TableCopy.links.clear
47
+ TableCopy.deferred_config {}
48
+ end
49
+
50
+ it 'returns a hash of link_name => Copier' do
51
+ expect(TableCopy::Copier).to receive(:new).with(source, destination).and_return(expected_value)
52
+
53
+ expect(config).to receive(:call) do
54
+ TableCopy.add_link(link_name, source, destination)
55
+ end
56
+
57
+ expect(tc.links.keys).to eq [ link_name ]
58
+ expect(tc.links[link_name]).to eq expected_value
59
+ end
60
+ end
61
+ end
62
+
63
+ describe '.deferred_config' do
64
+ it 'exists and is tested incidentally' do
65
+ expect { TableCopy.deferred_config }.not_to raise_error
66
+ end
67
+ end
68
+
69
+ describe '.add_link' do
70
+ let(:source) { 'fake source' }
71
+ let(:destination) { 'fake destination' }
72
+ let(:link_name) { 'a link name' }
73
+
74
+ after { TableCopy.links.clear }
75
+
76
+ it 'adds a Copier to the links hash' do
77
+ expect {
78
+ TableCopy.add_link(link_name, source, destination)
79
+ }.to change {
80
+ TableCopy.links
81
+ }.from({})
82
+
83
+ copier = tc.links[link_name]
84
+ expect(copier).to be_kind_of TableCopy::Copier
85
+ expect(copier.source_table).to eq source
86
+ expect(copier.destination_table).to eq destination
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,94 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'table_copy'
5
+ require 'pg'
6
+ # This file was generated by the `rspec --init` command. Conventionally, all
7
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
9
+ # file to always be loaded, without a need to explicitly require it in any files.
10
+ #
11
+ # Given that it is always loaded, you are encouraged to keep this file as
12
+ # light-weight as possible. Requiring heavyweight dependencies from this file
13
+ # will add to the boot time of your test suite on EVERY test run, even for an
14
+ # individual file that may not need all of that loaded. Instead, make a
15
+ # separate helper file that requires this one and then use it only in the specs
16
+ # that actually need it.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ config.before(:suite) do
24
+ TableCopy.logger.level = Logger::FATAL
25
+ system('dropdb table_copy_test')
26
+ system('createdb table_copy_test')
27
+ $pg_conn = PG::Connection.new(YAML.load_file('config/database.yml'))
28
+ end
29
+
30
+ config.after(:suite) do
31
+ $pg_conn.close
32
+ system('dropdb table_copy_test')
33
+ end
34
+ # The settings below are suggested to provide a good initial experience
35
+ # with RSpec, but feel free to customize to your heart's content.
36
+
37
+ # These two settings work together to allow you to limit a spec run
38
+ # to individual examples or groups you care about by tagging them with
39
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
40
+ # get run.
41
+ config.filter_run :focus
42
+ config.run_all_when_everything_filtered = true
43
+
44
+ # Many RSpec users commonly either run the entire suite or an individual
45
+ # file, and it's useful to allow more verbose output when running an
46
+ # individual spec file.
47
+ if config.files_to_run.one?
48
+ # Use the documentation formatter for detailed output,
49
+ # unless a formatter has already been configured
50
+ # (e.g. via a command-line flag).
51
+ config.default_formatter = 'doc'
52
+ end
53
+
54
+ # Print the 10 slowest examples and example groups at the
55
+ # end of the spec run, to help surface which specs are running
56
+ # particularly slow.
57
+ config.profile_examples = 3
58
+
59
+ # Run specs in random order to surface order dependencies. If you find an
60
+ # order dependency and want to debug it, you can fix the order by providing
61
+ # the seed, which is printed after each run.
62
+ # --seed 1234
63
+ config.order = :random
64
+
65
+ # Seed global randomization in this process using the `--seed` CLI option.
66
+ # Setting this allows you to use `--seed` to deterministically reproduce
67
+ # test failures related to randomization by passing the same `--seed` value
68
+ # as the one that triggered the failure.
69
+ Kernel.srand config.seed
70
+
71
+ # rspec-expectations config goes here. You can use an alternate
72
+ # assertion/expectation library such as wrong or the stdlib/minitest
73
+ # assertions if you prefer.
74
+ config.expect_with :rspec do |expectations|
75
+ # Enable only the newer, non-monkey-patching expect syntax.
76
+ # For more details, see:
77
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
78
+ expectations.syntax = :expect
79
+ end
80
+
81
+ # rspec-mocks config goes here. You can use an alternate test double
82
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
83
+ config.mock_with :rspec do |mocks|
84
+ # Enable only the newer, non-monkey-patching expect syntax.
85
+ # For more details, see:
86
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
87
+ mocks.syntax = :expect
88
+
89
+ # Prevents you from mocking or stubbing a method that does not exist on
90
+ # a real object. This is generally recommended.
91
+ mocks.verify_partial_doubles = true
92
+ end
93
+
94
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'table_copy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "table_copy"
8
+ spec.version = TableCopy::VERSION
9
+ spec.authors = ["TLH"]
10
+ spec.email = ["tylerhartland7@gmail.com"]
11
+ spec.summary = %q{ Move full tables between databases. }
12
+ spec.description = 'Move full Postgres tables between databases.'
13
+ spec.homepage = ""
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
+ spec.add_development_dependency "rspec", '~> 3.0'
24
+ spec.add_development_dependency "simplecov"
25
+
26
+ spec.add_development_dependency "pg", '~> 0.17.1'
27
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: table_copy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - TLH
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-29 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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
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: pg
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.17.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.17.1
83
+ description: Move full Postgres tables between databases.
84
+ email:
85
+ - tylerhartland7@gmail.com
86
+ executables:
87
+ - table_copy
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/table_copy
98
+ - config/database.yml
99
+ - config/initializers/table_copy.rb.example
100
+ - lib/table_copy.rb
101
+ - lib/table_copy/copier.rb
102
+ - lib/table_copy/pg.rb
103
+ - lib/table_copy/pg/destination.rb
104
+ - lib/table_copy/pg/field.rb
105
+ - lib/table_copy/pg/index.rb
106
+ - lib/table_copy/pg/source.rb
107
+ - lib/table_copy/version.rb
108
+ - spec/lib/table_copy/copier_spec.rb
109
+ - spec/lib/table_copy/pg/destination_spec.rb
110
+ - spec/lib/table_copy/pg/field_spec.rb
111
+ - spec/lib/table_copy/pg/index_spec.rb
112
+ - spec/lib/table_copy/pg/source_spec.rb
113
+ - spec/lib/table_copy_spec.rb
114
+ - spec/spec_helper.rb
115
+ - table_copy.gemspec
116
+ homepage: ''
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.1.11
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Move full tables between databases.
140
+ test_files:
141
+ - spec/lib/table_copy/copier_spec.rb
142
+ - spec/lib/table_copy/pg/destination_spec.rb
143
+ - spec/lib/table_copy/pg/field_spec.rb
144
+ - spec/lib/table_copy/pg/index_spec.rb
145
+ - spec/lib/table_copy/pg/source_spec.rb
146
+ - spec/lib/table_copy_spec.rb
147
+ - spec/spec_helper.rb