photocopier 0.0.7 → 0.0.8

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: c666cdda914fe37448653eb7d95de7411694b024
4
+ data.tar.gz: bf1c03551658df3e0e7668f613448bc6b3b2a63f
5
+ SHA512:
6
+ metadata.gz: 1354f8fb6fffd1a40aa8f62c6e45fc99ea6bcd59eb779ed71b4c913476ae406633bcb6b4b73e192bb539c690f08e328df5e2a94be6fc4948665844f8a0b9d8a7
7
+ data.tar.gz: 2a3c645df2cb80092c3d247c4115a4e6cba7bfac4ec005c54905b49de6d76ddcade35e80a90c98cbe9a63797f0e49c21f2b0a1275da5e50e63716f420f76552b
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- photocopier (0.0.5)
4
+ photocopier (0.0.8)
5
5
  activesupport
6
6
  escape
7
7
  i18n
@@ -12,18 +12,24 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (3.2.12)
16
- i18n (~> 0.6)
17
- multi_json (~> 1.0)
15
+ activesupport (4.0.0)
16
+ i18n (~> 0.6, >= 0.6.4)
17
+ minitest (~> 4.2)
18
+ multi_json (~> 1.3)
19
+ thread_safe (~> 0.1)
20
+ tzinfo (~> 0.3.37)
21
+ atomic (1.1.13)
18
22
  diff-lcs (1.1.3)
19
23
  escape (0.0.4)
20
- i18n (0.6.4)
21
- multi_json (1.7.0)
22
- net-scp (1.1.0)
24
+ i18n (0.6.5)
25
+ minitest (4.7.5)
26
+ multi_json (1.7.9)
27
+ net-scp (1.1.2)
23
28
  net-ssh (>= 2.6.5)
24
- net-ssh (2.6.6)
29
+ net-ssh (2.6.8)
25
30
  net-ssh-gateway (1.2.0)
26
31
  net-ssh (>= 2.6.5)
32
+ rake (10.1.0)
27
33
  rspec (2.11.0)
28
34
  rspec-core (~> 2.11.0)
29
35
  rspec-expectations (~> 2.11.0)
@@ -32,10 +38,14 @@ GEM
32
38
  rspec-expectations (2.11.3)
33
39
  diff-lcs (~> 1.1.3)
34
40
  rspec-mocks (2.11.3)
41
+ thread_safe (0.1.2)
42
+ atomic
43
+ tzinfo (0.3.37)
35
44
 
36
45
  PLATFORMS
37
46
  ruby
38
47
 
39
48
  DEPENDENCIES
40
49
  photocopier!
50
+ rake
41
51
  rspec
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  Photocopier provides handy FTP/SSH adapters to abstract away file and directory copying.
4
4
  To move directories to/from the remote server, it wraps efficient tools like lftp and rsync.
5
5
 
6
+ [![Build Status](https://travis-ci.org/welaika/photocopier.png?branch=master)](https://travis-ci.org/welaika/photocopier)
7
+
6
8
  ## Installation
7
9
 
8
10
  Add this line to your application's Gemfile:
@@ -79,6 +81,7 @@ to pass them all).
79
81
  user: '',
80
82
  password: '',
81
83
  port: '',
84
+ rsync_options: '',
82
85
  gateway: {
83
86
  host: '',
84
87
  user: '',
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  #!/usr/bin/env rake
2
+
2
3
  require "bundler/gem_tasks"
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
8
+
@@ -70,12 +70,10 @@ module Photocopier
70
70
  [ stdout, stderr, exit_code ]
71
71
  end
72
72
 
73
- private
74
-
75
73
  def rsync(source, destination, exclude = [])
76
74
  command = [
77
75
  "rsync", "--progress", "-e", rsh_arguments, "-rlpt", "--compress",
78
- "--omit-dir-times", "--delete"
76
+ "--omit-dir-times", "--delete", rsync_options
79
77
  ]
80
78
 
81
79
  exclude.map do |glob|
@@ -109,6 +107,8 @@ module Photocopier
109
107
  command
110
108
  end
111
109
 
110
+ private
111
+
112
112
  def gateway
113
113
  opts = gateway_options
114
114
  host = opts.delete(:host)
@@ -119,5 +119,10 @@ module Photocopier
119
119
  def gateway_options
120
120
  options[:gateway] || {}
121
121
  end
122
+
123
+ def rsync_options
124
+ options[:rsync_options] || ""
125
+ end
126
+
122
127
  end
123
128
  end
@@ -1,3 +1,3 @@
1
1
  module Photocopier
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/photocopier.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  require File.expand_path('../lib/photocopier/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Stefano Verna"]
6
- gem.email = ["stefano.verna@welaika.com"]
5
+ gem.authors = ["Stefano Verna", "Ju Liu"]
6
+ gem.email = ["stefano.verna@welaika.com", "ju.liu@welaika.com"]
7
7
  gem.description = %q{Photocopier provides FTP/SSH adapters to abstract away file and directory copying.}
8
8
  gem.summary = %q{Photocopier provides FTP/SSH adapters to abstract away file and directory copying.}
9
- gem.homepage = "https://github.com/stefanoverna/photocopier"
9
+ gem.homepage = "https://github.com/welaika/photocopier"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -22,5 +22,6 @@ Gem::Specification.new do |gem|
22
22
  gem.add_dependency "net-ssh-gateway"
23
23
  gem.add_dependency "escape"
24
24
 
25
+ gem.add_development_dependency "rake"
25
26
  gem.add_development_dependency "rspec"
26
27
  end
data/spec/ftp_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe Photocopier::FTP do
5
5
  it_behaves_like "a Photocopier adapter"
6
6
 
7
7
  let(:ftp) { Photocopier::FTP.new(options) }
8
- let(:options) do { :host => "host", :user => "user", :password => "password" } end
8
+ let(:options) do { host: "host", user: "user", password: "password" } end
9
9
 
10
10
  context "#session" do
11
11
  it "retrieves an FTP session" do
@@ -14,31 +14,32 @@ describe Photocopier::FTP do
14
14
  end
15
15
 
16
16
  context "passive mode" do
17
- let(:options) do { :host => "host", :passive => true } end
17
+ let(:options) do { host: "host", passive: true } end
18
+ let(:ftp) { double('ftp').as_null_object }
18
19
 
19
20
  it "should enable passive mode" do
20
- Net::FTP.stub(:open).and_return(stub.as_null_object)
21
+ Net::FTP.stub(:open).and_return(ftp)
21
22
  ftp.session.should be_passive
22
23
  end
23
24
  end
24
25
  end
25
26
 
26
27
  context "#remote_ftp_url" do
27
- let(:options) do { :host => "host" } end
28
+ let(:options) do { host: "host" } end
28
29
 
29
30
  it "should build an ftp url" do
30
31
  ftp.send(:remote_ftp_url).should == "ftp://host"
31
32
  end
32
33
 
33
34
  context "given an username" do
34
- let(:options) do { :host => "host", :user => "user" } end
35
+ let(:options) do { host: "host", user: "user" } end
35
36
 
36
37
  it "should add it to the url" do
37
38
  ftp.send(:remote_ftp_url).should == "ftp://user@host"
38
39
  end
39
40
 
40
41
  context "given a password" do
41
- let(:options) do { :host => "host", :user => "user", :password => "password" } end
42
+ let(:options) do { host: "host", user: "user", password: "password" } end
42
43
 
43
44
  it "should add it to the url" do
44
45
  ftp.send(:remote_ftp_url).should == "ftp://user:password@host"
@@ -109,10 +110,10 @@ describe Photocopier::FTP do
109
110
 
110
111
  context "adapter interface" do
111
112
 
112
- let(:remote_path) { stub }
113
- let(:local_path) { stub }
114
- let(:file_path) { stub }
115
- let(:session) { stub }
113
+ let(:remote_path) { double }
114
+ let(:local_path) { double }
115
+ let(:file_path) { double }
116
+ let(:session) { double }
116
117
 
117
118
  before(:each) do
118
119
  ftp.stub(:session).and_return(session)
@@ -20,7 +20,7 @@ shared_examples_for "a Photocopier adapter" do
20
20
 
21
21
  context "#put" do
22
22
  let(:file_path) { Tempfile.new("tmp").path }
23
- let(:remote_path) { stub }
23
+ let(:remote_path) { double }
24
24
 
25
25
  context "given a real file path" do
26
26
  it "should put a file" do
@@ -31,7 +31,7 @@ shared_examples_for "a Photocopier adapter" do
31
31
 
32
32
  context "given a string" do
33
33
  let(:string) { "foobar" }
34
- let(:file) { stub(:path => "path") }
34
+ let(:file) { double(path: "path") }
35
35
 
36
36
  it "should write it to file, put it and remove the file" do
37
37
  Tempfile.stub(:new).and_return(file)
@@ -46,8 +46,8 @@ shared_examples_for "a Photocopier adapter" do
46
46
  end
47
47
 
48
48
  context "#run" do
49
- let(:arg) { stub }
50
- let(:command) { stub }
49
+ let(:arg) { double }
50
+ let(:command) { double }
51
51
  before(:each) {
52
52
  Escape.stub(:shell_command).with([arg]).and_return(command)
53
53
  }
@@ -58,7 +58,7 @@ shared_examples_for "a Photocopier adapter" do
58
58
  end
59
59
 
60
60
  context "given a logger" do
61
- let(:logger) { stub }
61
+ let(:logger) { double }
62
62
 
63
63
  it "should send the command to the logger" do
64
64
  adapter.logger = logger
data/spec/ssh_spec.rb CHANGED
@@ -5,13 +5,13 @@ describe Photocopier::SSH do
5
5
  it_behaves_like "a Photocopier adapter"
6
6
 
7
7
  let(:ssh) { Photocopier::SSH.new(options) }
8
- let(:options) do { :host => "host", :user => "user" } end
9
- let(:gateway_config) do { :host => "gate_host", :user => "gate_user" } end
8
+ let(:options) do { host: "host", user: "user" } end
9
+ let(:gateway_config) do { host: "gate_host", user: "gate_user" } end
10
10
  let(:options_with_gateway) do
11
11
  {
12
- :host => "host",
13
- :user => "user",
14
- :gateway => gateway_config
12
+ host: "host",
13
+ user: "user",
14
+ gateway: gateway_config
15
15
  }
16
16
  end
17
17
 
@@ -23,7 +23,7 @@ describe Photocopier::SSH do
23
23
 
24
24
  context "given a gateway " do
25
25
  let(:options) { options_with_gateway }
26
- let(:gateway) { stub }
26
+ let(:gateway) { double }
27
27
 
28
28
  it "goes through it to retrieve a session" do
29
29
  Net::SSH::Gateway.stub(:new).with("gate_host", "gate_user", {}).and_return(gateway)
@@ -34,31 +34,31 @@ describe Photocopier::SSH do
34
34
  end
35
35
 
36
36
  context "#ssh_command" do
37
- let(:options) do { :host => "host" } end
37
+ let(:options) do { host: "host" } end
38
38
 
39
39
  it "should build an ssh command" do
40
- ssh.send(:ssh_command, options).should == "ssh host"
40
+ ssh.ssh_command(options).should == "ssh host"
41
41
  end
42
42
 
43
43
  context "given a port" do
44
- let(:options) do { :host => "host", :port => "port" } end
44
+ let(:options) do { host: "host", port: "port" } end
45
45
  it "should be added to the command" do
46
- ssh.send(:ssh_command, options).should == "ssh -p port host"
46
+ ssh.ssh_command(options).should == "ssh -p port host"
47
47
  end
48
48
  end
49
49
 
50
50
  context "given a user" do
51
- let(:options) do { :host => "host", :user => "user" } end
51
+ let(:options) do { host: "host", user: "user" } end
52
52
  it "should be added to the command" do
53
- ssh.send(:ssh_command, options).should == "ssh user@host"
53
+ ssh.ssh_command(options).should == "ssh user@host"
54
54
  end
55
55
  end
56
56
 
57
57
  context "given a password" do
58
- let(:options) do { :host => "host", :password => "password" } end
58
+ let(:options) do { host: "host", password: "password" } end
59
59
 
60
60
  it "sshpass should be added to the command" do
61
- ssh.send(:ssh_command, options).should == "sshpass -p password ssh host"
61
+ ssh.ssh_command(options).should == "sshpass -p password ssh host"
62
62
  end
63
63
  end
64
64
  end
@@ -66,15 +66,16 @@ describe Photocopier::SSH do
66
66
  context "#rsh_arguments" do
67
67
  it "should build arguments for rsync" do
68
68
  ssh.should_receive(:ssh_command).with(options)
69
- ssh.send(:rsh_arguments)
69
+ ssh.rsh_arguments
70
70
  end
71
71
 
72
72
  context "given a gateway" do
73
73
  let(:options) { options_with_gateway }
74
+
74
75
  it "should include gateway options" do
75
76
  ssh.should_receive(:ssh_command).with(gateway_config)
76
77
  ssh.should_receive(:ssh_command).with(options)
77
- ssh.send(:rsh_arguments)
78
+ ssh.rsh_arguments
78
79
  end
79
80
  end
80
81
  end
@@ -82,6 +83,7 @@ describe Photocopier::SSH do
82
83
  context "#rsync" do
83
84
  before(:each) do
84
85
  ssh.stub(:rsh_arguments).and_return("rsh_arguments")
86
+ ssh.stub(:rsync_options).and_return("rsync_options")
85
87
  end
86
88
 
87
89
  let(:rsync_command) {
@@ -94,13 +96,14 @@ describe Photocopier::SSH do
94
96
  --compress
95
97
  --omit-dir-times
96
98
  --delete
99
+ rsync_options
97
100
  )
98
101
  }
99
102
 
100
103
  it "should build an rsync command" do
101
104
  rsync_command << "source/" << "destination"
102
105
  ssh.should_receive(:run).with(*rsync_command)
103
- ssh.send(:rsync, "source", "destination")
106
+ ssh.rsync("source", "destination")
104
107
  end
105
108
 
106
109
  context "given an exclude list" do
@@ -108,18 +111,18 @@ describe Photocopier::SSH do
108
111
  rsync_command << "--exclude" << ".git"
109
112
  rsync_command << "source/" << "destination"
110
113
  ssh.should_receive(:run).with(*rsync_command)
111
- ssh.send(:rsync, "source", "destination", [".git"])
114
+ ssh.rsync("source", "destination", [".git"])
112
115
  end
113
116
  end
114
117
  end
115
118
 
116
119
  context "adapter interface" do
117
120
 
118
- let(:remote_path) { stub }
119
- let(:local_path) { stub }
120
- let(:file_path) { stub }
121
- let(:scp) { stub }
122
- let(:session) { stub(:scp => scp) }
121
+ let(:remote_path) { double }
122
+ let(:local_path) { double }
123
+ let(:file_path) { double }
124
+ let(:scp) { double }
125
+ let(:session) { double(scp: scp) }
123
126
 
124
127
  before(:each) do
125
128
  ssh.stub(:session).and_return(session)
metadata CHANGED
@@ -1,139 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photocopier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Stefano Verna
8
+ - Ju Liu
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-03 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
- - - ! '>='
18
+ - - '>='
20
19
  - !ruby/object:Gem::Version
21
20
  version: '0'
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
- - - ! '>='
25
+ - - '>='
28
26
  - !ruby/object:Gem::Version
29
27
  version: '0'
30
28
  - !ruby/object:Gem::Dependency
31
29
  name: i18n
32
30
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
- - - ! '>='
32
+ - - '>='
36
33
  - !ruby/object:Gem::Version
37
34
  version: '0'
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
- - - ! '>='
39
+ - - '>='
44
40
  - !ruby/object:Gem::Version
45
41
  version: '0'
46
42
  - !ruby/object:Gem::Dependency
47
43
  name: net-ssh
48
44
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
- - - ! '>='
46
+ - - '>='
52
47
  - !ruby/object:Gem::Version
53
48
  version: '0'
54
49
  type: :runtime
55
50
  prerelease: false
56
51
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
- - - ! '>='
53
+ - - '>='
60
54
  - !ruby/object:Gem::Version
61
55
  version: '0'
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: net-scp
64
58
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
59
  requirements:
67
- - - ! '>='
60
+ - - '>='
68
61
  - !ruby/object:Gem::Version
69
62
  version: '0'
70
63
  type: :runtime
71
64
  prerelease: false
72
65
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
- - - ! '>='
67
+ - - '>='
76
68
  - !ruby/object:Gem::Version
77
69
  version: '0'
78
70
  - !ruby/object:Gem::Dependency
79
71
  name: net-ssh-gateway
80
72
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
73
  requirements:
83
- - - ! '>='
74
+ - - '>='
84
75
  - !ruby/object:Gem::Version
85
76
  version: '0'
86
77
  type: :runtime
87
78
  prerelease: false
88
79
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
80
  requirements:
91
- - - ! '>='
81
+ - - '>='
92
82
  - !ruby/object:Gem::Version
93
83
  version: '0'
94
84
  - !ruby/object:Gem::Dependency
95
85
  name: escape
96
86
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
87
  requirements:
99
- - - ! '>='
88
+ - - '>='
100
89
  - !ruby/object:Gem::Version
101
90
  version: '0'
102
91
  type: :runtime
103
92
  prerelease: false
104
93
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
94
  requirements:
107
- - - ! '>='
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rake
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
108
110
  - !ruby/object:Gem::Version
109
111
  version: '0'
110
112
  - !ruby/object:Gem::Dependency
111
113
  name: rspec
112
114
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
115
  requirements:
115
- - - ! '>='
116
+ - - '>='
116
117
  - !ruby/object:Gem::Version
117
118
  version: '0'
118
119
  type: :development
119
120
  prerelease: false
120
121
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
122
  requirements:
123
- - - ! '>='
123
+ - - '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  description: Photocopier provides FTP/SSH adapters to abstract away file and directory
127
127
  copying.
128
128
  email:
129
129
  - stefano.verna@welaika.com
130
+ - ju.liu@welaika.com
130
131
  executables: []
131
132
  extensions: []
132
133
  extra_rdoc_files: []
133
134
  files:
134
135
  - .gitignore
135
136
  - .rspec
137
+ - .ruby-version
136
138
  - .rvmrc
139
+ - .travis.yml
137
140
  - Gemfile
138
141
  - Gemfile.lock
139
142
  - LICENSE
@@ -149,29 +152,28 @@ files:
149
152
  - spec/ftp_spec.rb
150
153
  - spec/shared_examples_for_adapter.rb
151
154
  - spec/ssh_spec.rb
152
- homepage: https://github.com/stefanoverna/photocopier
155
+ homepage: https://github.com/welaika/photocopier
153
156
  licenses: []
157
+ metadata: {}
154
158
  post_install_message:
155
159
  rdoc_options: []
156
160
  require_paths:
157
161
  - lib
158
162
  required_ruby_version: !ruby/object:Gem::Requirement
159
- none: false
160
163
  requirements:
161
- - - ! '>='
164
+ - - '>='
162
165
  - !ruby/object:Gem::Version
163
166
  version: '0'
164
167
  required_rubygems_version: !ruby/object:Gem::Requirement
165
- none: false
166
168
  requirements:
167
- - - ! '>='
169
+ - - '>='
168
170
  - !ruby/object:Gem::Version
169
171
  version: '0'
170
172
  requirements: []
171
173
  rubyforge_project:
172
- rubygems_version: 1.8.23
174
+ rubygems_version: 2.0.3
173
175
  signing_key:
174
- specification_version: 3
176
+ specification_version: 4
175
177
  summary: Photocopier provides FTP/SSH adapters to abstract away file and directory
176
178
  copying.
177
179
  test_files: