wordmove 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  tmp/*
2
+ pkg/*
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wordmove (0.0.1)
4
+ wordmove (0.0.5)
5
5
  activesupport (~> 3.0.0)
6
6
  colored
7
7
  escape
@@ -16,29 +16,29 @@ GEM
16
16
  remote: http://rubygems.org/
17
17
  specs:
18
18
  activesupport (3.0.11)
19
- aruba (0.4.7)
20
- childprocess (>= 0.2.2)
19
+ aruba (0.4.9)
20
+ childprocess (>= 0.2.3)
21
21
  cucumber (>= 1.1.1)
22
- ffi (= 1.0.9)
22
+ ffi (= 1.0.11)
23
23
  rspec (>= 2.7.0)
24
24
  builder (3.0.0)
25
25
  childprocess (0.2.3)
26
26
  ffi (~> 1.0.6)
27
27
  colored (1.2)
28
- cucumber (1.1.3)
28
+ cucumber (1.1.4)
29
29
  builder (>= 2.1.2)
30
30
  diff-lcs (>= 1.1.2)
31
- gherkin (~> 2.6.7)
31
+ gherkin (~> 2.7.1)
32
32
  json (>= 1.4.6)
33
33
  term-ansicolor (>= 1.0.6)
34
34
  diff-lcs (1.1.3)
35
35
  escape (0.0.4)
36
- ffi (1.0.9)
37
- gherkin (2.6.8)
36
+ ffi (1.0.11)
37
+ gherkin (2.7.1)
38
38
  json (>= 1.4.6)
39
39
  hashie (1.2.0)
40
40
  i18n (0.6.0)
41
- json (1.6.2)
41
+ json (1.6.3)
42
42
  net-scp (1.0.4)
43
43
  net-ssh (>= 1.99.1)
44
44
  net-ssh (2.2.1)
data/README.mdown CHANGED
@@ -51,8 +51,9 @@ remote:
51
51
  host: "host"
52
52
  ssh:
53
53
  username: "username"
54
- password: "password"
54
+ password: "password" # optional, will use SSH public key if available
55
55
  host: "host"
56
+ port: 2202 # optional
56
57
  ```
57
58
 
58
59
  ## Known problems and limitations
@@ -21,6 +21,6 @@ remote:
21
21
  host: "host"
22
22
  ssh:
23
23
  username: "username"
24
- password: "password"
24
+ password: "password" # Password is optional, will use public keys if available.
25
25
  host: "host"
26
-
26
+ # port: 22 # Port is optional
@@ -5,10 +5,15 @@ module Wordmove
5
5
 
6
6
  attr_reader :options
7
7
  attr_reader :logger
8
+ attr_reader :ssh_extras
8
9
 
9
10
  def initialize(options = {})
10
11
  @options = Hashie::Mash.new(options)
11
12
  @logger = @options[:logger]
13
+ @ssh_extras = {}
14
+ [ :port, :password ].each do |p|
15
+ @ssh_extras.merge!( { p => @options.ssh[p] } ) if @options.ssh and @options.ssh[p]
16
+ end
12
17
  end
13
18
 
14
19
  def run(*args)
@@ -14,7 +14,7 @@ module Wordmove
14
14
 
15
15
  def session
16
16
  logger.verbose "Connecting to #{options.ssh.host}..." unless @session.present?
17
- @session ||= Net::SSH.start(options.ssh.host, options.ssh.username, :password => options.ssh.password)
17
+ @session ||= Net::SSH.start(options.ssh.host, options.ssh.username, @ssh_extras )
18
18
  end
19
19
 
20
20
  def close
@@ -23,12 +23,16 @@ module Wordmove
23
23
 
24
24
  def upload_file(source_file, destination_file)
25
25
  logger.verbose "Copying remote #{source_file} to #{destination_file}..."
26
- Net::SCP.download!(options.ssh.host, options.ssh.username, source_file, destination_file, :password => options.ssh.password)
26
+ Net::SSH.start options.ssh.host, options.ssh.username, @ssh_extras do |ssh|
27
+ ssh.scp.download! source_file, destination_file
28
+ end
27
29
  end
28
30
 
29
31
  def download_file(source_file, destination_file)
30
32
  logger.verbose "Copying local #{source_file} to #{destination_file}..."
31
- Net::SCP.upload!(options.ssh.host, options.ssh.username, source_file, destination_file, :password => options.ssh.password)
33
+ Net::SSH.start options.ssh.host, options.ssh.username, @ssh_extras do |ssh|
34
+ ssh.scp.upload! source_file, destination_file
35
+ end
32
36
  end
33
37
 
34
38
  def download_dir(source_dir, destination_dir)
@@ -48,17 +52,33 @@ module Wordmove
48
52
  private
49
53
 
50
54
  def rsync(source_dir, destination_dir)
51
- password_file = Tempfile.new('rsync_password')
52
- password_file.write(options.ssh.password)
53
- password_file.close
54
55
 
55
56
  exclude_file = Tempfile.new('exclude')
56
57
  exclude_file.write(options.exclude.join("\n"))
57
58
  exclude_file.close
58
59
 
59
- locally_run "rsync", "-azLK", "--password-file=#{password_file.path}", "--exclude-from=#{exclude_file.path}", "--delete", source_dir, destination_dir
60
+ arguments = [ "-azLK" ]
60
61
 
61
- password_file.unlink
62
+ password_file = nil
63
+ if options.ssh
64
+
65
+ if options.ssh.port
66
+ arguments << [ '-e', "ssh -p #{options.ssh.port}" ]
67
+ end
68
+
69
+ if options.ssh.password
70
+ password_file = Tempfile.new('rsync_password')
71
+ password_file.write(options.ssh.password)
72
+ password_file.close
73
+ arguments << "--password-file=#{password_file.path}"
74
+ end
75
+ end
76
+
77
+ arguments << [ "--exclude-from=#{exclude_file.path}", "--delete", source_dir, destination_dir ]
78
+ arguments.flatten!
79
+ locally_run "rsync", *arguments
80
+
81
+ password_file.unlink if password_file
62
82
  exclude_file.unlink
63
83
  end
64
84
 
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,26 @@
1
+ local:
2
+ vhost: "http://vhost.local"
3
+ wordpress_path: "~/dev/sites/your_site"
4
+ database:
5
+ name: "database_name"
6
+ username: "username"
7
+ password: "password"
8
+ host: "host"
9
+ remote:
10
+ vhost: "http://remote.com"
11
+ wordpress_path: "/var/www/your_site"
12
+ exclude:
13
+ - .git
14
+ - .DS_Store
15
+ - .sass-cache
16
+ - Movefile
17
+ database:
18
+ name: "database_name"
19
+ username: "username"
20
+ password: "password"
21
+ host: "host"
22
+ ssh:
23
+ username: "username"
24
+ password: "password" # Password is optional, will use public keys if available.
25
+ host: "host"
26
+ # port: 22 # Port is optional
@@ -0,0 +1,24 @@
1
+ local:
2
+ vhost: "http://vhost.local"
3
+ wordpress_path: "~/dev/sites/your_site"
4
+ database:
5
+ name: "database_name"
6
+ username: "username"
7
+ password: "password"
8
+ host: "host"
9
+ remote:
10
+ vhost: "http://remote.com"
11
+ wordpress_path: "/var/www/your_site"
12
+ exclude:
13
+ - .git
14
+ - .DS_Store
15
+ - .sass-cache
16
+ - Movefile
17
+ database:
18
+ name: "database_name"
19
+ username: "username"
20
+ password: "password"
21
+ host: "host"
22
+ ssh:
23
+ username: "username"
24
+ host: "host"
@@ -0,0 +1,25 @@
1
+ local:
2
+ vhost: "http://vhost.local"
3
+ wordpress_path: "~/dev/sites/your_site"
4
+ database:
5
+ name: "database_name"
6
+ username: "username"
7
+ password: "password"
8
+ host: "host"
9
+ remote:
10
+ vhost: "http://remote.com"
11
+ wordpress_path: "/var/www/your_site"
12
+ exclude:
13
+ - .git
14
+ - .DS_Store
15
+ - .sass-cache
16
+ - Movefile
17
+ database:
18
+ name: "database_name"
19
+ username: "username"
20
+ password: "password"
21
+ host: "host"
22
+ ssh:
23
+ username: "username"
24
+ password: "password" # Password is optional, will use public keys if available.
25
+ host: "host"
@@ -0,0 +1,26 @@
1
+ local:
2
+ vhost: "http://vhost.local"
3
+ wordpress_path: "~/dev/sites/your_site"
4
+ database:
5
+ name: "database_name"
6
+ username: "username"
7
+ password: "password"
8
+ host: "host"
9
+ remote:
10
+ vhost: "http://remote.com"
11
+ wordpress_path: "/var/www/your_site"
12
+ exclude:
13
+ - .git
14
+ - .DS_Store
15
+ - .sass-cache
16
+ - Movefile
17
+ database:
18
+ name: "database_name"
19
+ username: "username"
20
+ password: "password"
21
+ host: "host"
22
+ ssh:
23
+ username: "username"
24
+ password: "password" # Password is optional, will use public keys if available.
25
+ host: "host"
26
+ port: 30000
@@ -0,0 +1,25 @@
1
+ local:
2
+ vhost: "http://vhost.local"
3
+ wordpress_path: "~/dev/sites/your_site"
4
+ database:
5
+ name: "database_name"
6
+ username: "username"
7
+ password: "password"
8
+ host: "host"
9
+ remote:
10
+ vhost: "http://remote.com"
11
+ wordpress_path: "/var/www/your_site"
12
+ exclude:
13
+ - .git
14
+ - .DS_Store
15
+ - .sass-cache
16
+ - Movefile
17
+ database:
18
+ name: "database_name"
19
+ username: "username"
20
+ password: "password"
21
+ host: "host"
22
+ ssh:
23
+ username: "username"
24
+ password: "hithere"
25
+ host: "host"
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wordmove::RemoteHost do
4
+
5
+ def load_config( config_path )
6
+ @config = Hashie::Mash.new(YAML::load(File.open(config_path)))
7
+ @logger = Wordmove::Logger.new
8
+ @logger.level = Logger::INFO
9
+ @config.remote[:logger] = @logger
10
+ @host = Wordmove::RemoteHost.new( @config.remote )
11
+ @host.stub!(:locally_run).and_return( 1 )
12
+ end
13
+
14
+ it "should use ports properly" do
15
+ load_config( File.join( File.dirname(__FILE__), "fixtures", "Movefile.port" ) )
16
+ @host.should_receive(:locally_run).with("rsync", "-azLK", "-e", "ssh -p 30000", anything(), anything(), "--delete", "username@host:foobar/", "barfoo" )
17
+ @host.upload_dir("foobar", "barfoo" )
18
+ end
19
+
20
+ it "should not use ports if missing" do
21
+ load_config( File.join( File.dirname(__FILE__), "fixtures", "Movefile.no_port" ) )
22
+ @host.should_receive(:locally_run).with("rsync", "-azLK", anything(), anything(), "--delete", "username@host:foobar/", "barfoo" )
23
+ @host.upload_dir("foobar", "barfoo" )
24
+ end
25
+
26
+ it "should skip password files when not using passwords" do
27
+ load_config( File.join( File.dirname(__FILE__), "fixtures", "Movefile.no_password" ) )
28
+ @host.should_receive(:locally_run).with("rsync", "-azLK", anything(), "--delete", "username@host:foobar/", "barfoo" )
29
+ @host.upload_dir("foobar", "barfoo" )
30
+ end
31
+
32
+ it "should have a password file when using passwords" do
33
+ load_config( File.join( File.dirname(__FILE__), "fixtures", "Movefile.with_password" ) )
34
+ @host.should_receive(:locally_run).with("rsync", "-azLK", /--password-file.*/, anything(), "--delete", "username@host:foobar/", "barfoo" )
35
+ @host.upload_dir("foobar", "barfoo" )
36
+ end
37
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'wordmove' # and any other gems you need
5
+ require 'hashie'
6
+ require 'wordmove/hosts/local_host'
7
+ require 'wordmove/hosts/remote_host'
8
+ require 'wordmove/logger'
9
+ require 'tempfile'
10
+ require 'active_support/core_ext'
11
+ require 'thor'
12
+
13
+ RSpec.configure do |config|
14
+ # some (optional) config here
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordmove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-13 00:00:00.000000000 Z
12
+ date: 2011-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
16
- requirement: &70351507049960 !ruby/object:Gem::Requirement
16
+ requirement: &70234736353880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70351507049960
24
+ version_requirements: *70234736353880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: escape
27
- requirement: &70351507049540 !ruby/object:Gem::Requirement
27
+ requirement: &70234736353340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70351507049540
35
+ version_requirements: *70234736353340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70351507049120 !ruby/object:Gem::Requirement
38
+ requirement: &70234736352780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70351507049120
46
+ version_requirements: *70234736352780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: net-ssh
49
- requirement: &70351507048700 !ruby/object:Gem::Requirement
49
+ requirement: &70234736352340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70351507048700
57
+ version_requirements: *70234736352340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: net-scp
60
- requirement: &70351507048280 !ruby/object:Gem::Requirement
60
+ requirement: &70234736351860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70351507048280
68
+ version_requirements: *70234736351860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: thor
71
- requirement: &70351507047860 !ruby/object:Gem::Requirement
71
+ requirement: &70234736351340 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70351507047860
79
+ version_requirements: *70234736351340
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: activesupport
82
- requirement: &70351507047360 !ruby/object:Gem::Requirement
82
+ requirement: &70234736350760 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 3.0.0
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70351507047360
90
+ version_requirements: *70234736350760
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: i18n
93
- requirement: &70351507046940 !ruby/object:Gem::Requirement
93
+ requirement: &70234736350260 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70351507046940
101
+ version_requirements: *70234736350260
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: hashie
104
- requirement: &70351507046480 !ruby/object:Gem::Requirement
104
+ requirement: &70234736349600 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70351507046480
112
+ version_requirements: *70234736349600
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &70351507046060 !ruby/object:Gem::Requirement
115
+ requirement: &70234736349120 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70351507046060
123
+ version_requirements: *70234736349120
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: cucumber
126
- requirement: &70351507045640 !ruby/object:Gem::Requirement
126
+ requirement: &70234736348540 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70351507045640
134
+ version_requirements: *70234736348540
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: aruba
137
- requirement: &70351507045220 !ruby/object:Gem::Requirement
137
+ requirement: &70234736347900 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70351507045220
145
+ version_requirements: *70234736347900
146
146
  description: Capistrano for Wordpress
147
147
  email:
148
148
  - stefano.verna@welaika.com
@@ -174,7 +174,13 @@ files:
174
174
  - lib/wordmove/version.rb
175
175
  - pkg/wordmove-0.0.1.gem
176
176
  - pkg/wordmove-0.0.2.gem
177
- - spec/foodie_spec.rb
177
+ - spec/fixtures/Movefile
178
+ - spec/fixtures/Movefile.no_password
179
+ - spec/fixtures/Movefile.no_port
180
+ - spec/fixtures/Movefile.port
181
+ - spec/fixtures/Movefile.with_password
182
+ - spec/remote_host_spec.rb
183
+ - spec/spec_helper.rb
178
184
  - wordmove.gemspec
179
185
  homepage: ''
180
186
  licenses: []
@@ -196,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
202
  version: '0'
197
203
  requirements: []
198
204
  rubyforge_project:
199
- rubygems_version: 1.8.10
205
+ rubygems_version: 1.8.11
200
206
  signing_key:
201
207
  specification_version: 3
202
208
  summary: Capistrano for Wordpress
@@ -206,4 +212,10 @@ test_files:
206
212
  - features/push.feature
207
213
  - features/step_definitions/aruba_ext_steps.rb
208
214
  - features/support/setup.rb
209
- - spec/foodie_spec.rb
215
+ - spec/fixtures/Movefile
216
+ - spec/fixtures/Movefile.no_password
217
+ - spec/fixtures/Movefile.no_port
218
+ - spec/fixtures/Movefile.port
219
+ - spec/fixtures/Movefile.with_password
220
+ - spec/remote_host_spec.rb
221
+ - spec/spec_helper.rb
data/spec/foodie_spec.rb DELETED
@@ -1,9 +0,0 @@
1
- describe Foodie::Food do
2
- it "broccoli is gross" do
3
- Foodie::Food.portray("Broccoli").should eql("Gross!")
4
- end
5
-
6
- it "anything else is delicious" do
7
- Foodie::Food.portray("Not Broccoli").should eql("Delicious!")
8
- end
9
- end