cloner 0.14.0 → 0.14.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 +4 -4
- data/.ruby-version +1 -1
- data/lib/cloner/ar.rb +2 -2
- data/lib/cloner/internal.rb +20 -0
- data/lib/cloner/mongodb.rb +2 -2
- data/lib/cloner/mysql.rb +1 -1
- data/lib/cloner/postgres.rb +1 -1
- data/lib/cloner/rsync.rb +1 -1
- data/lib/cloner/version.rb +1 -1
- data/test/test_docker_compose.rb +13 -12
- data/test/test_without_rails.rb +111 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 268ab21d46f237ca283b4c52920bf61caa8b531af9a896018d3ab9e70cfed983
|
|
4
|
+
data.tar.gz: bd47524ebab6afdb3d1815cfb277a867bd380ba0b28cfcd6d5b0f040c808d5cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3439f1edac5eb30322a6b737cffc5909857b7095c5460bf260ac67cf8ee15a9b968578606022f9ae020b62c300a74d12013b7b89e298c9ad3eb8ca79c85613c0
|
|
7
|
+
data.tar.gz: dbe4a39eca86bf7031b45cb5f73efeee30295eb9df499244309f5e671f7cd1de5d4512ede2ee32459c19cbaf744ddba99aeac29670a5935a9f7d16dcd16eaaca
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.1
|
data/lib/cloner/ar.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Cloner::Ar
|
|
2
2
|
def read_ar_conf
|
|
3
3
|
@conf ||= begin
|
|
4
|
-
YAML.load(ERB.new(File.read(
|
|
4
|
+
YAML.load(ERB.new(File.read(File.join(project_root.to_s, 'config', 'database.yml'))).result, aliases: true)[env_database]
|
|
5
5
|
end
|
|
6
6
|
end
|
|
7
7
|
def ar_conf
|
|
@@ -22,7 +22,7 @@ module Cloner::Ar
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def env_database
|
|
25
|
-
|
|
25
|
+
project_env
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def ar_to
|
data/lib/cloner/internal.rb
CHANGED
|
@@ -19,6 +19,26 @@ module Cloner::Internal
|
|
|
19
19
|
require 'net/ssh'
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
# Returns the project root directory path.
|
|
23
|
+
# Override this method when not using Rails.
|
|
24
|
+
def project_root
|
|
25
|
+
if defined?(Rails)
|
|
26
|
+
Rails.root
|
|
27
|
+
else
|
|
28
|
+
raise NotImplementedError, "project_root must be defined when not using Rails"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns the current environment name.
|
|
33
|
+
# Override this method when not using Rails.
|
|
34
|
+
def project_env
|
|
35
|
+
if defined?(Rails)
|
|
36
|
+
Rails.env
|
|
37
|
+
else
|
|
38
|
+
raise NotImplementedError, "project_env must be defined when not using Rails"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
22
42
|
def verbose?
|
|
23
43
|
false
|
|
24
44
|
end
|
data/lib/cloner/mongodb.rb
CHANGED
|
@@ -3,7 +3,7 @@ module Cloner::MongoDB
|
|
|
3
3
|
|
|
4
4
|
def mongodb_conf
|
|
5
5
|
@conf ||= begin
|
|
6
|
-
yml = YAML.load_file(
|
|
6
|
+
yml = YAML.load_file(File.join(project_root.to_s, 'config', 'mongoid.yml'))[project_env]
|
|
7
7
|
if yml.key?('sessions')
|
|
8
8
|
yml['sessions']['default']
|
|
9
9
|
else
|
|
@@ -117,7 +117,7 @@ module Cloner::MongoDB
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
def mongodb_path
|
|
120
|
-
|
|
120
|
+
File.join(project_root.to_s, "tmp", "dump", mongodb_to)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def mongodb_dump_copy
|
data/lib/cloner/mysql.rb
CHANGED
data/lib/cloner/postgres.rb
CHANGED
data/lib/cloner/rsync.rb
CHANGED
data/lib/cloner/version.rb
CHANGED
data/test/test_docker_compose.rb
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require_relative '../lib/cloner'
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def self.root
|
|
9
|
-
Pathname.new(File.expand_path("../", __FILE__))
|
|
10
|
-
end
|
|
11
|
-
def self.env
|
|
12
|
-
"development"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
5
|
+
require 'pathname'
|
|
6
|
+
require 'cloner'
|
|
15
7
|
|
|
16
8
|
class TestDockerCompose < Cloner::Base
|
|
17
9
|
no_commands do
|
|
@@ -25,6 +17,15 @@ class TestDockerCompose < Cloner::Base
|
|
|
25
17
|
require 'active_support/core_ext/object'
|
|
26
18
|
end
|
|
27
19
|
|
|
20
|
+
# Override project_root and project_env for non-Rails usage
|
|
21
|
+
def project_root
|
|
22
|
+
Pathname.new(File.expand_path("../", __FILE__))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def project_env
|
|
26
|
+
"development"
|
|
27
|
+
end
|
|
28
|
+
|
|
28
29
|
# Test with mock SSH - no actual connection
|
|
29
30
|
def ssh_host
|
|
30
31
|
'localhost'
|
|
@@ -60,7 +61,7 @@ class TestDockerCompose < Cloner::Base
|
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
def local_docker_compose_path
|
|
63
|
-
|
|
64
|
+
project_root.parent.to_s
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
def remote_app_path
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Test that verifies the gem can be used without Rails
|
|
4
|
+
# by overriding project_root and project_env methods
|
|
5
|
+
|
|
6
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
|
7
|
+
|
|
8
|
+
require 'pathname'
|
|
9
|
+
require 'minitest/autorun'
|
|
10
|
+
require 'cloner'
|
|
11
|
+
|
|
12
|
+
# Ensure Rails is NOT defined for this test
|
|
13
|
+
if defined?(Rails)
|
|
14
|
+
raise "Rails should not be defined for this test"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class TestWithoutRails < Minitest::Test
|
|
18
|
+
class NonRailsCloner < Cloner::Base
|
|
19
|
+
no_commands do
|
|
20
|
+
def load_env
|
|
21
|
+
require 'net/ssh'
|
|
22
|
+
require 'shellwords'
|
|
23
|
+
require 'active_support/core_ext/object'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Required overrides for non-Rails usage
|
|
27
|
+
def project_root
|
|
28
|
+
Pathname.new(File.expand_path("../fixtures", __FILE__))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def project_env
|
|
32
|
+
"test"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Mock SSH config
|
|
36
|
+
def ssh_host
|
|
37
|
+
'localhost'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def ssh_user
|
|
41
|
+
'test'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def env_from
|
|
45
|
+
"production"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def remote_app_path
|
|
49
|
+
'/app'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def remote_dump_path
|
|
53
|
+
'/tmp/dump'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Mock database configs for testing path methods
|
|
57
|
+
def ar_conf
|
|
58
|
+
{
|
|
59
|
+
'adapter' => 'postgresql',
|
|
60
|
+
'database' => 'test_db',
|
|
61
|
+
'username' => 'test',
|
|
62
|
+
'password' => 'test'
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def ar_r_conf
|
|
67
|
+
ar_conf
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def mongodb_to
|
|
71
|
+
'test_mongodb'
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def setup
|
|
77
|
+
@cloner = NonRailsCloner.new
|
|
78
|
+
@cloner.load_env
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_project_root_returns_pathname
|
|
82
|
+
assert_kind_of Pathname, @cloner.project_root
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_project_env_returns_string
|
|
86
|
+
assert_equal "test", @cloner.project_env
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_pg_path_uses_project_root
|
|
90
|
+
expected = File.join(@cloner.project_root.to_s, "tmp", "dump")
|
|
91
|
+
assert_equal expected, @cloner.pg_path
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_my_path_uses_project_root
|
|
95
|
+
expected = File.join(@cloner.project_root.to_s, "tmp", "dump")
|
|
96
|
+
assert_equal expected, @cloner.my_path
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_mongodb_path_uses_project_root
|
|
100
|
+
expected = File.join(@cloner.project_root.to_s, "tmp", "dump", "test_mongodb")
|
|
101
|
+
assert_equal expected, @cloner.mongodb_path
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_env_database_uses_project_env
|
|
105
|
+
assert_equal "test", @cloner.env_database
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_rails_not_defined
|
|
109
|
+
refute defined?(Rails), "Rails should not be defined in this test"
|
|
110
|
+
end
|
|
111
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.
|
|
4
|
+
version: 0.14.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- glebtv
|
|
@@ -113,6 +113,7 @@ files:
|
|
|
113
113
|
- lib/generators/templates/cloner_extend.thor.erb
|
|
114
114
|
- test/dl_compose_test.thor
|
|
115
115
|
- test/test_docker_compose.rb
|
|
116
|
+
- test/test_without_rails.rb
|
|
116
117
|
- test/tmp/dump/cloner.bak
|
|
117
118
|
homepage: https://github.com/rs-pro/cloner
|
|
118
119
|
licenses:
|
|
@@ -132,10 +133,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
132
133
|
- !ruby/object:Gem::Version
|
|
133
134
|
version: '0'
|
|
134
135
|
requirements: []
|
|
135
|
-
rubygems_version:
|
|
136
|
+
rubygems_version: 4.0.3
|
|
136
137
|
specification_version: 4
|
|
137
138
|
summary: Easily clone your production Mongoid database and files for local development
|
|
138
139
|
test_files:
|
|
139
140
|
- test/dl_compose_test.thor
|
|
140
141
|
- test/test_docker_compose.rb
|
|
142
|
+
- test/test_without_rails.rb
|
|
141
143
|
- test/tmp/dump/cloner.bak
|