cloner 0.6.1 → 0.7.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4327a76f4dbae0a838b04277cf1dfc42e40bd493a6557453fe20dd094ae7a017
4
- data.tar.gz: 4b80a4c1ca652c01ab173b1711b84862a806c2318c246d700bd4abf21fa96cc0
3
+ metadata.gz: f8ad225c2837f9ea7b93560944d9ff6ad641e7d18df60c8cd4ac5524e939d79b
4
+ data.tar.gz: 4c69cf30e30e30802c8b8ad623717a2be50edba203504dfdae3fddac56ec64c0
5
5
  SHA512:
6
- metadata.gz: 39f309d98f2cd91d9df01ed50a0805590f8272bbf3be16302ae12891e0b27982816d25be76da99e5c38930027c9c5b5db473e55ad21e4a6f4ef5375a7490de68
7
- data.tar.gz: 7d2f51fc2ca8d95e509836970e1c74bdc5a1dba1a8a4f9da8b72361904b6ee86de67a59c0f322fcb75258879215c96198cf1c2bb9ebfe90b75944497b7686c45
6
+ metadata.gz: dde12ab0ebe23b74b0bcd341fd67fbf938167860fd09ed8b55a6948045fb35d25f863f6b6835ee72a18147a3127c127b4a9d1b2f2d6c7f40e31af68e6dc20ab6
7
+ data.tar.gz: 1d420ba6e269a1a6aa08339370ab4242181bd5f5db4b0185c9a641148c5fd25cc82a8964f820d582ac12294acd395b7a807ddc84f9f5937ec66a235dc290aa95
data/README.md CHANGED
@@ -20,37 +20,44 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- create ```lib/tasks/dl.thor``` with following content:
24
-
25
- require 'cloner'
26
-
27
- class Dl < Cloner::Base
28
- no_commands do
29
- def rails_path
30
- File.expand_path("../../../config/environment", __FILE__)
31
- end
32
- def ssh_host
33
- 'hottea.ru'
34
- end
35
- def ssh_user
36
- 'tea'
37
- end
38
- def remote_dump_path
39
- '/data/tea/dump'
40
- end
41
- def remote_app_path
42
- "/data/tea/app/current"
43
- end
44
- end
45
-
46
- desc "download", "clone files and DB from production"
47
- def download
48
- load_env
49
- clone_db
50
- rsync_public("ckeditor_assets")
51
- rsync_public("uploads")
52
- end
23
+ For generate cloner base template, run:
24
+
25
+ ```
26
+ bundle exec rails generate cloner
27
+ ```
28
+
29
+ This is create `lib/tasks/dl.thor` file with following content:
30
+ ```ruby
31
+ require 'cloner'
32
+
33
+ class Dl < Cloner::Base
34
+ no_commands do
35
+ def rails_path
36
+ File.expand_path("../../../config/environment", __FILE__)
53
37
  end
38
+ def ssh_host
39
+ 'hottea.ru'
40
+ end
41
+ def ssh_user
42
+ 'tea'
43
+ end
44
+ def remote_dump_path
45
+ '/data/tea/dump'
46
+ end
47
+ def remote_app_path
48
+ "/data/tea/app/current"
49
+ end
50
+ end
51
+
52
+ desc "download", "clone files and DB from production"
53
+ def download
54
+ load_env
55
+ clone_db
56
+ rsync_public("ckeditor_assets")
57
+ rsync_public("uploads")
58
+ end
59
+ end
60
+ ```
54
61
 
55
62
  Adjust it to your project and deployment.
56
63
 
@@ -58,6 +65,30 @@ Run it:
58
65
 
59
66
  thor dl
60
67
 
68
+
69
+ If you generate extended cloner template as: `rails g cloner -e`,
70
+ you can run `thor dl` with additional parameters, for example:
71
+ ```
72
+ bundle exec thor dl -D # For skip clone database
73
+ bundle exec thor dl -F # For skip clone files
74
+ ```
75
+
76
+ For details see help:
77
+ ```
78
+ bundle exec thor help dl:download
79
+
80
+ Usage:
81
+ thor dl:download
82
+
83
+ Options:
84
+ [--from=FROM] # stage name where cloner get data
85
+ # Default: production
86
+ -D, [--skip-database], [--no-skip-database] # skip clone database
87
+ -F, [--skip-files], [--no-skip-files] # skip clone files
88
+
89
+ clone files and DB from production
90
+ ```
91
+
61
92
  ## Additional
62
93
 
63
94
  All functions from cloner/internal.rb can be overriden, for example:
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "activesupport"
23
23
  spec.add_dependency 'net-ssh'
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.7"
26
- spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
27
27
  end
28
28
 
@@ -44,8 +44,8 @@ module Cloner::MySQL
44
44
 
45
45
  def my_dump_restore
46
46
  puts "restoring DB"
47
- host = ar_conf['host'].present? ? " -h #{e ar_conf['host']}" : ""
48
- port = ar_conf['port'].present? ? " -p #{e ar_conf['port']}" : ""
47
+ host = ar_conf['host'].present? ? " --host #{e ar_conf['host']}" : ""
48
+ port = ar_conf['port'].present? ? " --port #{e ar_conf['port']}" : ""
49
49
  restore = "#{my_bin_path 'mysql'} #{my_restore_param} --user #{e ar_conf['username']} #{my_local_auth}#{host}#{port} #{e ar_to} < #{e(my_path + '/cloner.sql')}"
50
50
  puts restore if verbose?
51
51
  pipe = IO.popen(restore)
@@ -1,4 +1,4 @@
1
1
  module Cloner
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
4
4
 
@@ -0,0 +1,25 @@
1
+ class ClonerGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('templates', __dir__)
3
+
4
+ class_option :extend, default: false, type: :boolean, aliases: '-e'
5
+
6
+ desc "This generator create lib/tasks/dl.thor"
7
+ def create_task_file
8
+ unless options[:extend]
9
+ create_default_task_file
10
+ else
11
+ create_extended_task_file
12
+ end
13
+ end
14
+
15
+ private
16
+ def create_default_task_file
17
+ copy_file 'cloner_base.template', 'lib/tasks/dl.thor'
18
+ end
19
+
20
+ def create_extended_task_file
21
+ say 'Create extend file'
22
+ @username = Rails.application.class.parent_name.downcase
23
+ template 'cloner_extend.thor.erb', 'lib/tasks/dl.thor'
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ require 'cloner'
2
+
3
+ class Dl < Cloner::Base
4
+ no_commands do
5
+ def rails_path
6
+ File.expand_path("../../../config/environment", __FILE__)
7
+ end
8
+ def ssh_host
9
+ 'hottea.ru'
10
+ end
11
+ def ssh_user
12
+ 'tea'
13
+ end
14
+ def remote_dump_path
15
+ '/data/tea/dump'
16
+ end
17
+ def remote_app_path
18
+ "/data/tea/app/current"
19
+ end
20
+ end
21
+
22
+ desc "download", "clone files and DB from production"
23
+ def download
24
+ load_env
25
+ clone_db
26
+ rsync_public("ckeditor_assets")
27
+ rsync_public("uploads")
28
+ end
29
+ end
@@ -0,0 +1,72 @@
1
+ require 'cloner'
2
+
3
+ class Dl < Cloner::Base
4
+ no_commands do
5
+ def rails_path
6
+ File.expand_path("../../../config/environment", __FILE__)
7
+ end
8
+ def stages
9
+ @_stages ||= {
10
+ # TODO: Add new stages here if you needed
11
+ production: {
12
+ # TODO: Fix production settings
13
+ ssh_host: 'production.example.com',
14
+ ssh_user: '<%= @username %>'
15
+ },
16
+ staging: {
17
+ # TODO: Fix staging settings
18
+ ssh_host: 'production.example.com',
19
+ ssh_user: '<%= @username %>'
20
+ }
21
+ }
22
+ end
23
+ def ssh_host
24
+ stages.dig(options[:from].to_sym, :ssh_host)
25
+ end
26
+ def ssh_user
27
+ stages.dig(options[:from].to_sym, :ssh_user)
28
+ end
29
+ def remote_dump_path
30
+ # TODO: Fix remote dump path
31
+ '/data/<%= @username %>/dump'
32
+ end
33
+ def remote_app_path
34
+ # TODO: Fix remote app path
35
+ '/data/<%= @username %>/app/current'
36
+ end
37
+ end
38
+
39
+ class_option :from,
40
+ default: 'production',
41
+ type: :string,
42
+ desc: 'stage name where cloner get data'
43
+ class_option :skip_database,
44
+ default: false,
45
+ type: :boolean,
46
+ aliases: '-D',
47
+ desc: 'skip clone database'
48
+ class_option :skip_files,
49
+ default: false,
50
+ type: :boolean,
51
+ aliases: '-F',
52
+ desc: 'skip clone files'
53
+
54
+ desc "download", "clone files and DB from production"
55
+ def download
56
+ load_env
57
+ say "Clone from: #{options[:from]}", :green
58
+ if options[:skip_database]
59
+ say "Skip clone database!", :yellow
60
+ else
61
+ clone_db
62
+ end
63
+
64
+ if options[:skip_files]
65
+ say "Skip clone files!", :yellow
66
+ else
67
+ # TODO: Fix folders for synchronization here
68
+ rsync_public("ckeditor_assets")
69
+ rsync_public("uploads")
70
+ end
71
+ end
72
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-02 00:00:00.000000000 Z
11
+ date: 2019-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -56,30 +56,30 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.7'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.7'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '0'
83
83
  description: ''
84
84
  email:
85
85
  - glebtv@gmail.com
@@ -106,6 +106,9 @@ files:
106
106
  - lib/cloner/rsync.rb
107
107
  - lib/cloner/ssh.rb
108
108
  - lib/cloner/version.rb
109
+ - lib/generators/cloner_generator.rb
110
+ - lib/generators/templates/cloner_base.template
111
+ - lib/generators/templates/cloner_extend.thor.erb
109
112
  homepage: https://github.com/rs-pro/cloner
110
113
  licenses:
111
114
  - MIT
@@ -125,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
128
  - !ruby/object:Gem::Version
126
129
  version: '0'
127
130
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.7.7
131
+ rubygems_version: 3.0.3
130
132
  signing_key:
131
133
  specification_version: 4
132
134
  summary: Easily clone your production Mongoid database and files for local development