capistrano-rails-synchronizer 0.1.4

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3706c9efe5661227f2168e27844df12f37ecfb1
4
+ data.tar.gz: 74d3cb30cdb3fc76698e5415915317390348d6f4
5
+ SHA512:
6
+ metadata.gz: 643b3b8e1bb507ee34d28f1aac05173d66142e3d881b7eddd58e33cabc31ee0e31208c8e20c265cd6696fc013fcde6c99bd941d4068c79408623d9093a86fa00
7
+ data.tar.gz: 2ba2a2c587bcbdfc1cd9687e6b1b26c562915d516de8ca5f0bc5dc4210430dfa07f037a68605c439b5dce528893e8f265a34b793f3ea331e2935134bffee5ae0
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
@@ -0,0 +1 @@
1
+ require 'synchronizer'
@@ -0,0 +1,5 @@
1
+ require 'synchronizer/db'
2
+ require 'synchronizer/assets'
3
+ require 'synchronizer/helper'
4
+
5
+ load File.expand_path("../tasks/sync.rake", __FILE__)
@@ -0,0 +1,30 @@
1
+ module Assets
2
+
3
+ def pack_assets
4
+ on roles :web do
5
+ execute "cd #{shared_path}; #{pack_assets_cmd}"
6
+ end
7
+ end
8
+
9
+
10
+ def copy_assets_to_local
11
+ download! "#{fetch(:assets_archive_file)}", "#{fetch(:assets_archive_file).split('/')[-1]}"
12
+ end
13
+
14
+ def copy_assets_cmd
15
+ if dest = fetch(:sync_assets_to, nil)
16
+ scp_file(fetch(:assets_archive_file), dest)
17
+ else
18
+ raise "missing variable sync_assets_to"
19
+ end
20
+ end
21
+
22
+
23
+ private
24
+
25
+ def pack_assets_cmd
26
+ assets_archive = "#{shared_path}/public-#{fetch(:stage)}.tgz"
27
+ set :assets_archive_file, assets_archive
28
+ "tar cvfzp #{assets_archive} ./public"
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ module DB
2
+
3
+ def dump_db
4
+ _stage = fetch(:stage, nil).to_s
5
+ cfg = read_db_config(_stage)
6
+ execute pg_dump_cmd(cfg)
7
+ end
8
+
9
+ def copy_db_cmd
10
+ if dest = fetch(:sync_db_to, nil)
11
+ scp_file(fetch(:db_dump_file), dest)
12
+ else
13
+ raise "missing variable sync_db_to"
14
+ end
15
+ end
16
+
17
+ def copy_db_to_local
18
+ download! "#{fetch(:db_dump_file)}", "#{fetch(:db_dump_file).split('/')[-1]}"
19
+ end
20
+
21
+ private
22
+
23
+ def pg_dump_cmd(opts)
24
+ db_dump_file = "#{shared_path}/#{opts.fetch('database')}.dump"
25
+ set :db_dump_file, db_dump_file
26
+ str = "PGPASSWORD=#{opts.fetch('password')} pg_dump -U #{opts.fetch('username')} -h #{opts.fetch('host')} -Fc #{opts.fetch('database')} -f #{db_dump_file}"
27
+ str
28
+ end
29
+
30
+
31
+ def read_db_config(stage)
32
+ db_cfg = YAML::load(capture("cat #{shared_path}/config/database.yml"))
33
+ db_cfg[stage]
34
+ end
35
+ end
@@ -0,0 +1,24 @@
1
+ module Helper
2
+
3
+ def destination
4
+ puts "deprecated... will vanish soon..."
5
+ _stage = fetch(:stage, nil).to_s
6
+ dest = fetch(:sync_to, nil)
7
+ if dest
8
+ dest
9
+ else
10
+ ask(:sync_to, stages.delete_if { |x| x == _stage }.join('|') )
11
+ dest = fetch(:sync_to, nil)
12
+ end
13
+ end
14
+
15
+ def scp_file(src, dest)
16
+ capture "scp #{src} #{dest}"
17
+ end
18
+
19
+ def _cset(name, *args, &block)
20
+ unless exists?(name)
21
+ set(name, *args, &block)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,109 @@
1
+ require 'pp'
2
+ require 'synchronizer'
3
+
4
+ include DB
5
+ include Assets
6
+ include Helper
7
+
8
+
9
+ desc 'copies database and assets to destination'
10
+ task :sync do
11
+ on roles :all do
12
+ info "synchronizing data to #{destination}"
13
+ end
14
+ invoke 'sync:db:transfer'
15
+ invoke 'sync:assets:transfer'
16
+ end
17
+
18
+ namespace :sync do
19
+
20
+ desc 'syncs db and assets to local'
21
+ task :local do
22
+ invoke 'sync:db:to_local'
23
+ invoke 'sync:assets:to_local'
24
+ end
25
+
26
+ desc 'dumps the database and copies the dump to destination stage'
27
+ task :db do
28
+ invoke 'sync:db:transfer'
29
+ end
30
+
31
+
32
+ desc 'tars assets and copies the archive to destination stage'
33
+ task :assets do
34
+ invoke 'sync:assets:transfer'
35
+ end
36
+
37
+ #desc 'restores assets and database on destination host'
38
+ #task :restore do
39
+ # invoke 'sync:db:restore'
40
+ # invoke 'sync:assets:unpack'
41
+ #end
42
+
43
+ namespace :db do
44
+
45
+ desc 'dump database'
46
+ task :dump do
47
+ on roles :db do
48
+ info 'dumping database'
49
+ dump_db
50
+ info 'finished dumping'
51
+ end
52
+ end
53
+
54
+ desc 'create db-dump and copy to local'
55
+ task :to_local do
56
+ on roles :db do
57
+ invoke 'sync:db:dump'
58
+ copy_db_to_local
59
+ end
60
+ end
61
+
62
+ desc 'copy database dump to other stage'
63
+ task :transfer do
64
+ on roles :db do |host|
65
+ invoke 'sync:db:dump'
66
+ info "copying database dump from #{host} to other stage #{fetch(:sync_db_to)}"
67
+ copy_db_cmd
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ namespace :assets do
74
+
75
+ desc 'copies asets to destination'
76
+ task :transfer do
77
+ on roles :web do
78
+ invoke 'sync:assets:pack'
79
+ info "copying assets to destination #{fetch(:sync_assets_to)}"
80
+ copy_assets_cmd
81
+ end
82
+ end
83
+
84
+ desc 'copy assets to local'
85
+ task :to_local do
86
+ on roles :web do
87
+ invoke 'sync:assets:pack'
88
+ copy_assets_to_local
89
+ end
90
+ end
91
+
92
+
93
+ #desc 'pack, copy and unpack assets on other stage'
94
+ #task :unpack do
95
+ # on roles :web do
96
+ # invoke 'sync:assets:copy'
97
+ # info 'unpacking assets'
98
+ # end
99
+ #end
100
+
101
+ #desc 'pack assets'
102
+ task :pack do
103
+ on roles :web do
104
+ pack_assets
105
+ end
106
+ end
107
+ end
108
+
109
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-rails-synchronizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - rene paulokat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDXDCCAkSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA6MQ0wCwYDVQQDDARyZW5l
14
+ MRQwEgYKCZImiZPyLGQBGRYEc28zNjETMBEGCgmSJomT8ixkARkWA25ldDAeFw0x
15
+ NTA3MTAxNTMyNDRaFw0xNjA3MDkxNTMyNDRaMDoxDTALBgNVBAMMBHJlbmUxFDAS
16
+ BgoJkiaJk/IsZAEZFgRzbzM2MRMwEQYKCZImiZPyLGQBGRYDbmV0MIIBIjANBgkq
17
+ hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8RqRHqGzIcZgYV9cC5DygM6rA5T3sadk
18
+ guHNaqV+VH8+eYOUpHFt4ej1iEPya5jBErsHZEKXLhQZ1Sh6yKpqvT4sQLrTkQ0Y
19
+ naOmQmueOvOoeJOE8eUMIGiCqsBmPFcUzIcpgZ2Sibu0VZsOGzurpT7Lzj6fXiu/
20
+ OugAVvclfVMy+MB8orB0GV2nmZ2Hs6V0DmspIvLXhp2c+y4HXWiqXvleFx9dTwWc
21
+ k5OND1vR9tYN+3EBte5ETnQ5N26ZYRgeuEKxVbxrDODzfeZUCSrfIqHqH8KDvc7X
22
+ 0ZvKlOZ58ZZ0TEm7BDLfCg9JdfJ5CPFwEuCDxZAyFfk7bFtobI0ubQIDAQABo20w
23
+ azAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU//+NDAgo3pOzGygK
24
+ S3orEjBTxJQwGAYDVR0RBBEwD4ENcmVuZUBzbzM2Lm5ldDAYBgNVHRIEETAPgQ1y
25
+ ZW5lQHNvMzYubmV0MA0GCSqGSIb3DQEBBQUAA4IBAQBmSt3BBM2Gf3y1YugJFpCj
26
+ J+XD0OjuRNfkXS67JkRcPeVydr6RZPS7IAx7LHmyvqSeMRLP4jp0VUyJbI/qNCN1
27
+ hhXMVdLM2bANjn/rlJEPvpdDgypuXk7AuMjXQpUU3EGq+EcPbot+RfSlGg4Ndn3D
28
+ cfD4sx2+gWoBefqQXp3D8DKUFWbny2sC3raPXdHVd0qQ03mldyrxMHxqPYmqDiOs
29
+ oSb+3px5AogC7i+BxZ28l/vs8zx8OnlDmS631gRSLH777KsaR6/oWntvsvPm8Jgr
30
+ EePKDI8r9ZSVkkt3XFn5MWAfX5hxvegGS5ExfyNtFeE8e+3B2Ha6ge9B6HTn+chR
31
+ -----END CERTIFICATE-----
32
+ date: 2015-07-10 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: capistrano-rails
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ description: Rails specific Capistrano tasks to synchonize stages
49
+ email:
50
+ - rene@so36.net
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - lib/capistrano-rails-synchronizer.rb
56
+ - lib/synchronizer.rb
57
+ - lib/synchronizer/assets.rb
58
+ - lib/synchronizer/db.rb
59
+ - lib/synchronizer/helper.rb
60
+ - lib/tasks/sync.rake
61
+ homepage: https://github.com/erpe/capistrano-rails-synchonizer
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message: "thanks for all the fish and \nadd 'require \"synchronizer\"'
66
+ to your Capfile"
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.8
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Rails specific Capistrano tasks to synchonize stages
86
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ��G!z � ���Q�>oԻ�el�S3�*tQʢ3�ϭ�|���!�� R%��͑ؿ��h�yxL^��S���!^�߂�}������1H���d���+[����z �n gK5g��fa�!���%�Ī�)�hx���xl�{�"7ho?m���]^�� ��3~mj��͉��yi9�ɞ�e��%<�S���ݢ�g��*�@o1�Q�pX�F�=�- ,���� ��2;6�GPh�j|I x��CD0��1 J��