fluent-migrator-command-runner 0.6 → 0.7

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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OGRkZWNiZDk2YjAwYjhjZWJkMzBmODE4NTMxZGVjOGI1MzUyNmExMA==
5
- data.tar.gz: !binary |-
6
- ODhjODg1NzhiMzc4MDg5MDAyYTVhNmZhNWQyYTAwNWJlYWFlNTI5OA==
2
+ SHA256:
3
+ metadata.gz: 1120833152bd2339e2fd3eb88b4c8bff2033a9c7ad52853f28d8c9d1d3b25f1c
4
+ data.tar.gz: 0ebe5e145df2af646fe8b763ceb995665fccacc090000da1f67fcc01726512d4
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MzU0MmFiYzdmYjMxYmQxYThlOWQ3ZDFkNjIzMzlmOWY1YTU0YzNiYWYwYTY3
10
- YWM0NzMyYzcyNmRmZmIyYTIwOWM0MzZjOWEyZDRmNzNkMGQwZTdiYzI3ZDg1
11
- Zjk3MDk5NDJmNzc1MGExNGQ2NTVjNDY0NjJjZDJmMTZlZWIyZDE=
12
- data.tar.gz: !binary |-
13
- ZmM3OTZlNGIwMDE3ZmQwMTg1NTFkM2Y5N2ZkOGVhZjQyODhlMWZhNTAyMzIw
14
- NjYwOGIxZTNjNGQ0NzdiNGJkNDc0ZTBjZmRlM2Y2ZTIwZDQyYmZkZDdiN2E1
15
- MmYzMDM5OTUwMmVhM2FkZTRhNDdhMDU5Y2NlNWM4YTNmZTFkNDQ=
6
+ metadata.gz: 877f043fcc0648d79e2d16e2f6c2378a0412e44a20a53d624e50312b0a5ca164272dcc65612bb402e5b4bc5498429e000089930da1097a44eaf04cb353f11517
7
+ data.tar.gz: 4ba5084b4d3727aa0307e448ac789596084f8b47154333cd35fb7c2505f8ffe02a9fe0acf25b64ec75d8b246272f32bf0ab9ae2908550b399d6199ff1e5411d7
@@ -1,29 +1,39 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.2.5)
5
- fig_newton (0.10)
6
- yml_reader (>= 0.3)
7
- rake (10.3.2)
8
- rspec (3.1.0)
9
- rspec-core (~> 3.1.0)
10
- rspec-expectations (~> 3.1.0)
11
- rspec-mocks (~> 3.1.0)
12
- rspec-core (3.1.4)
13
- rspec-support (~> 3.1.0)
14
- rspec-expectations (3.1.1)
15
- diff-lcs (>= 1.2.0, < 2.0)
16
- rspec-support (~> 3.1.0)
17
- rspec-mocks (3.1.1)
18
- rspec-support (~> 3.1.0)
19
- rspec-support (3.1.0)
20
- yml_reader (0.4)
21
-
22
- PLATFORMS
23
- x86-mingw32
24
-
25
- DEPENDENCIES
26
- fig_newton
27
- rake
28
- rspec
29
- rspec-mocks
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-migrator-command-runner (0.7)
5
+ fig_newton
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ fig_newton (1.0)
12
+ yml_reader (>= 0.7)
13
+ rake (10.3.2)
14
+ rspec (3.1.0)
15
+ rspec-core (~> 3.1.0)
16
+ rspec-expectations (~> 3.1.0)
17
+ rspec-mocks (~> 3.1.0)
18
+ rspec-core (3.1.4)
19
+ rspec-support (~> 3.1.0)
20
+ rspec-expectations (3.1.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.1.0)
23
+ rspec-mocks (3.1.1)
24
+ rspec-support (~> 3.1.0)
25
+ rspec-support (3.1.0)
26
+ yml_reader (0.7)
27
+
28
+ PLATFORMS
29
+ x64-mingw32
30
+ x86-mingw32
31
+
32
+ DEPENDENCIES
33
+ fluent-migrator-command-runner!
34
+ rake
35
+ rspec
36
+ rspec-mocks
37
+
38
+ BUNDLED WITH
39
+ 2.1.4
data/README.md CHANGED
@@ -24,6 +24,16 @@ database:
24
24
  password: "p4ssw0rd"
25
25
  ````
26
26
 
27
+ #Optional Overrides
28
+
29
+ ##Oracle Data Provider
30
+
31
+ Defaults to use the unmanaged oracle client
32
+
33
+ ````
34
+ migration_provider: oraclemanaged
35
+ ````
36
+
27
37
  #Using exposed rake task
28
38
 
29
39
  Migrate with no tags or profiles
@@ -46,4 +56,3 @@ FluentMigratorCommandRunner::Rake::Task.new(:migrate) do |t|
46
56
  - be able to run with multiple tags
47
57
 
48
58
  #Notes
49
- Has only been tested with FluentMigrator.Tools.1.1.2.1
@@ -1,7 +1,9 @@
1
1
  require 'fluent-migrator-command-runner/version'
2
2
  require 'fluent-migrator-command-runner/runner'
3
3
  require 'fluent-migrator-command-runner/command_builder'
4
- require 'fluent-migrator-command-runner/oracle_migration_command'
4
+ require 'fluent-migrator-command-runner/commands/migration_command'
5
+ require 'fluent-migrator-command-runner/commands/oracle_migration_command'
6
+ require 'fluent-migrator-command-runner/commands/sql_server_migration_command'
5
7
  require 'fluent-migrator-command-runner/task'
6
8
  require 'fig_newton'
7
9
 
@@ -3,7 +3,11 @@ module FluentMigratorCommandRunner
3
3
  class CommandBuilder
4
4
 
5
5
  def self.build(migration_options = {})
6
- command = OracleMigrationCommand.new(migration_options)
6
+ if FigNewton.migration_provider == 'sqlserver'
7
+ command = SqlServerMigrationCommand.new(migration_options)
8
+ else
9
+ command = OracleMigrationCommand.new(migration_options)
10
+ end
7
11
  command.build
8
12
  end
9
13
 
@@ -0,0 +1,40 @@
1
+ module FluentMigratorCommandRunner
2
+ class MigrationCommand
3
+ attr_reader :path_to_migrator,
4
+ :path_to_migration_assembly,
5
+ :connection_information,
6
+ :profile,
7
+ :tag,
8
+ :provider
9
+
10
+ PARAMETER_PREFIX = '--'
11
+ SPACE_CHAR = "\s"
12
+
13
+ MIGRATOR_DELIMITER = "#{SPACE_CHAR + PARAMETER_PREFIX}"
14
+ CONNECTION_STRING_DELIMITER = ';'
15
+
16
+ def initialize(options = {})
17
+ @profile = options[:profile] unless options[:profile].nil?
18
+ @tag = options[:tag] unless options[:tag].nil?
19
+ @provider = FigNewton.migration_provider('oracle')
20
+ @path_to_migrator = FigNewton.path_to_migrator_exe
21
+ @path_to_migration_assembly = FigNewton.path_to_migration_assembly
22
+ @connection_information = FigNewton.database.to_hash
23
+ @connection_information['password'] = options[:db_password] unless options[:db_password].nil?
24
+ end
25
+
26
+ def build
27
+ connection_string = build_connection_string(@connection_information)
28
+
29
+ command_sections = []
30
+ command_sections.push(@path_to_migrator)
31
+ command_sections.push("provider #{@provider}")
32
+ command_sections.push("conn \"#{connection_string}\"")
33
+ command_sections.push('task migrate')
34
+ command_sections.push("assembly \"#{@path_to_migration_assembly}\"")
35
+ command_sections.push("tag #{@tag}") if @tag
36
+ command_sections.push("profile=#{@profile}") if @profile
37
+ command_sections.join(MIGRATOR_DELIMITER)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ module FluentMigratorCommandRunner
2
+ class OracleMigrationCommand < MigrationCommand
3
+
4
+ protected
5
+
6
+ def build_connection_string(connection_information)
7
+ connection = []
8
+ connection.push("DATA SOURCE=#{connection_information['database']}")
9
+ connection.push("user id=#{connection_information['username']}")
10
+ connection.push("password=#{connection_information['password']}")
11
+ connection.join(CONNECTION_STRING_DELIMITER)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module FluentMigratorCommandRunner
2
+ class SqlServerMigrationCommand < MigrationCommand
3
+
4
+ protected
5
+
6
+ def build_connection_string(connection_information)
7
+ connection = []
8
+ connection.push("Server=#{connection_information['host']}")
9
+ connection.push("Database=#{connection_information['database']}")
10
+ connection.push("user id=#{connection_information['username']}")
11
+ connection.push("password=#{connection_information['password']}")
12
+ connection.join(CONNECTION_STRING_DELIMITER)
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module FluentMigratorCommandRunner
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  end
@@ -9,6 +9,7 @@ describe FluentMigratorCommandRunner::CommandBuilder do
9
9
 
10
10
  before { allow(oracle_command).to receive(:new).and_return(command_stub)}
11
11
  before { allow(command_stub).to receive(:build)}
12
+ before { allow(FigNewton).to receive(:migration_provider).and_return('')}
12
13
 
13
14
  it 'should create new oracle migration command with options' do
14
15
  expected_options = {}
@@ -20,7 +20,7 @@ describe FluentMigratorCommandRunner::CommandBuilder do
20
20
  allow(kernel).to receive(:system)
21
21
  allow(system_error).to receive(:exitstatus).and_return(1)
22
22
 
23
- expect{runner.execute('')}.to raise_error()
23
+ expect{runner.execute('')}.to raise_error
24
24
  end
25
25
 
26
26
  it "should raise exception when command is invalid" do
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+ require 'socket'
3
+
4
+ describe FluentMigratorCommandRunner::SqlServerMigrationCommand do
5
+
6
+ before do
7
+ @connection_information = {
8
+ 'database' => '',
9
+ 'host' => '',
10
+ 'username' => '',
11
+ 'password' => ''
12
+ }
13
+ allow(FigNewton).to receive(:database).and_return(@connection_information)
14
+ allow(FigNewton).to receive(:path_to_migration_assembly)
15
+ allow(FigNewton).to receive(:path_to_migrator_exe)
16
+ allow(FigNewton).to receive(:migration_provider)
17
+ end
18
+
19
+ describe 'initialize' do
20
+
21
+ it "should include profile when provided" do
22
+ expected_profile = "--profile=TestData"
23
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new({:profile => 'TestData'}).build
24
+ expect(command).to include(expected_profile)
25
+ end
26
+
27
+ it "should not include profile when not provided" do
28
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new.build
29
+ expect(command).to_not include('--profile')
30
+ end
31
+
32
+ it "should include tag when provided" do
33
+ expected_tag = "--tag Data"
34
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new({:tag => 'Data'}).build
35
+ expect(command).to include(expected_tag)
36
+ end
37
+
38
+ it "should not include tag when not provided" do
39
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new.build
40
+ expect(command).to_not include('--tag')
41
+ end
42
+
43
+ it 'should override password' do
44
+ expected_password = 'my_new_password'
45
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new({:db_password => expected_password}).build
46
+ expect(command).to include(expected_password)
47
+ end
48
+
49
+ it "should allow overriding of default provider" do
50
+ expected_provider = 'mynewprovider'
51
+ allow(FigNewton).to receive(:migration_provider).and_return(expected_provider)
52
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new.build
53
+ expect(command).to include("--provider #{expected_provider}")
54
+ end
55
+ end
56
+
57
+ describe "build" do
58
+ let(:oracle_command) { FluentMigratorCommandRunner::SqlServerMigrationCommand.new }
59
+
60
+ it "should include path to migrator" do
61
+ expected = "/My/Path/To/Migrator"
62
+ allow(FigNewton).to receive(:path_to_migrator_exe).and_return(expected)
63
+
64
+ command = oracle_command.build
65
+ expect(command).to include(expected)
66
+ end
67
+
68
+ it "should include default provider" do
69
+ oracle_command.build
70
+ expect(FigNewton).to have_received(:migration_provider).with('oracle')
71
+ end
72
+
73
+ it "should include path to assembly" do
74
+ expected = "--assembly \"/My/Path/To/Assembly\""
75
+ allow(FigNewton).to receive(:path_to_migration_assembly).and_return('/My/Path/To/Assembly')
76
+
77
+ command = oracle_command.build
78
+ expect(command).to include(expected)
79
+ end
80
+
81
+ it "should include task" do
82
+ expected_task = "--task migrate"
83
+ command = oracle_command.build
84
+ expect(command).to include(expected_task)
85
+ end
86
+
87
+ it "should include connection string" do
88
+ command = oracle_command.build()
89
+ expect(command).to include('--conn ')
90
+ end
91
+
92
+ describe "database connection string" do
93
+
94
+ it "should include DATA SOURCE in connection string" do
95
+ expected = 'localhost'
96
+ @connection_information['host'] = expected
97
+ command = oracle_command.build
98
+ expect(command).to include "Server=#{expected}"
99
+ end
100
+
101
+ it "should include user name in connection string" do
102
+ expected = 'user'
103
+ @connection_information['username'] = expected
104
+ command = oracle_command.build
105
+ expect(command).to include "user id=#{expected}"
106
+ end
107
+
108
+ it "should include password in connection string" do
109
+ expected = 'MyPassword'
110
+ @connection_information['password'] = expected
111
+ command = oracle_command.build
112
+ expect(command).to include "password=#{expected}"
113
+ end
114
+ end
115
+
116
+ end
117
+ end
@@ -4,4 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'rspec/mocks'
5
5
  require 'rspec'
6
6
  require 'fluent-migrator-command-runner'
7
- require 'rake'
7
+ require 'rake'
8
+
9
+ # Supress Command Line Warnings
10
+ # TODO: Remove need for these
11
+ RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
12
+ RSpec::Expectations.configuration.on_potential_false_positives = :nothing
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-migrator-command-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mosaic
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: fig_newton
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: Build and Execute Fluent Migrator Commands
@@ -30,7 +30,7 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
- - .gitignore
33
+ - ".gitignore"
34
34
  - Gemfile
35
35
  - Gemfile.lock
36
36
  - README.md
@@ -38,7 +38,9 @@ files:
38
38
  - fluent-migrator-command-runner.gemspec
39
39
  - lib/fluent-migrator-command-runner.rb
40
40
  - lib/fluent-migrator-command-runner/command_builder.rb
41
- - lib/fluent-migrator-command-runner/oracle_migration_command.rb
41
+ - lib/fluent-migrator-command-runner/commands/migration_command.rb
42
+ - lib/fluent-migrator-command-runner/commands/oracle_migration_command.rb
43
+ - lib/fluent-migrator-command-runner/commands/sql_server_migration_command.rb
42
44
  - lib/fluent-migrator-command-runner/runner.rb
43
45
  - lib/fluent-migrator-command-runner/task.rb
44
46
  - lib/fluent-migrator-command-runner/version.rb
@@ -46,6 +48,7 @@ files:
46
48
  - spec/fluent-migrator-command-runner/oracle_migration_command_spec.rb
47
49
  - spec/fluent-migrator-command-runner/rake_task_spec.rb
48
50
  - spec/fluent-migrator-command-runner/runner_spec.rb
51
+ - spec/fluent-migrator-command-runner/sql_server_migration_command_spec.rb
49
52
  - spec/spec_helper.rb
50
53
  homepage: ''
51
54
  licenses:
@@ -57,17 +60,17 @@ require_paths:
57
60
  - lib
58
61
  required_ruby_version: !ruby/object:Gem::Requirement
59
62
  requirements:
60
- - - ! '>='
63
+ - - ">="
61
64
  - !ruby/object:Gem::Version
62
65
  version: '0'
63
66
  required_rubygems_version: !ruby/object:Gem::Requirement
64
67
  requirements:
65
- - - ! '>='
68
+ - - ">="
66
69
  - !ruby/object:Gem::Version
67
70
  version: '0'
68
71
  requirements: []
69
72
  rubyforge_project:
70
- rubygems_version: 2.4.5
73
+ rubygems_version: 2.7.6
71
74
  signing_key:
72
75
  specification_version: 4
73
76
  summary: Rake Tasks For Fluent Migrator
@@ -1,51 +0,0 @@
1
- module FluentMigratorCommandRunner
2
- class OracleMigrationCommand
3
- attr_reader :path_to_migrator,
4
- :path_to_migration_assembly,
5
- :connection_information,
6
- :profile,
7
- :tag,
8
- :provider
9
-
10
- PARAMETER_PREFIX = '--'
11
- SPACE_CHAR = "\s"
12
-
13
- MIGRATOR_DELIMITER = "#{SPACE_CHAR + PARAMETER_PREFIX}"
14
- CONNECTION_STRING_DELIMITER = ';'
15
-
16
- def initialize(options = {})
17
- @profile = options[:profile] unless options[:profile].nil?
18
- @tag = options[:tag] unless options[:tag].nil?
19
- @provider = FigNewton.migration_provider('oracle')
20
- @path_to_migrator = FigNewton.path_to_migrator_exe
21
- @path_to_migration_assembly = FigNewton.path_to_migration_assembly
22
- @connection_information = FigNewton.database.to_hash
23
- @connection_information['password'] = options[:db_password] unless options[:db_password].nil?
24
- end
25
-
26
- def build
27
- connection_string = build_connection_string(@connection_information)
28
-
29
- command_sections = []
30
- command_sections.push(@path_to_migrator)
31
- command_sections.push("provider #{@provider}")
32
- command_sections.push("conn \"#{connection_string}\"")
33
- command_sections.push('task migrate')
34
- command_sections.push("assembly \"#{@path_to_migration_assembly}\"")
35
- command_sections.push("tag #{@tag}") if @tag
36
- command_sections.push("profile=#{@profile}") if @profile
37
- command_sections.join(MIGRATOR_DELIMITER)
38
- end
39
-
40
- private
41
-
42
- def build_connection_string(connection_information)
43
- connection = []
44
- connection.push("DATA SOURCE=#{connection_information['database']}")
45
- connection.push("user id=#{connection_information['username']}")
46
- connection.push("password=#{connection_information['password']}")
47
- connection.join(CONNECTION_STRING_DELIMITER)
48
- end
49
-
50
- end
51
- end