guard-flopbox 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/guard-flopbox.gemspec +1 -1
- metadata +1 -3
- data/lib/guard/guard-flopbox.rb +0 -93
- data/lib/guard/guard-flopbox/templates/Guardfile +0 -16
data/guard-flopbox.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "guard-flopbox"
|
6
|
-
s.version = 1.
|
6
|
+
s.version = 1.1
|
7
7
|
s.authors = ["Vincent Chu"]
|
8
8
|
s.email = ["vincentchu at gmail dot com"]
|
9
9
|
s.homepage = "http://github.com/vincentchu/guard-flopbox"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: guard-flopbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "1.
|
5
|
+
version: "1.1"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Vincent Chu
|
@@ -29,8 +29,6 @@ files:
|
|
29
29
|
- README.md
|
30
30
|
- Rakefile
|
31
31
|
- guard-flopbox.gemspec
|
32
|
-
- lib/guard/guard-flopbox.rb
|
33
|
-
- lib/guard/guard-flopbox/templates/Guardfile
|
34
32
|
has_rdoc: true
|
35
33
|
homepage: http://github.com/vincentchu/guard-flopbox
|
36
34
|
licenses: []
|
data/lib/guard/guard-flopbox.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'net/sftp'
|
2
|
-
require 'growl'
|
3
|
-
require 'guard'
|
4
|
-
require 'guard/guard'
|
5
|
-
|
6
|
-
module Guard
|
7
|
-
class Flopbox < Guard
|
8
|
-
|
9
|
-
attr_reader :sftp_session, :remote, :pwd, :growl_image
|
10
|
-
|
11
|
-
def initialize(watchers = [], options = {})
|
12
|
-
@sftp_session = Net::SFTP.start(options[:hostname], options[:user], options[:sftp_opts])
|
13
|
-
@remote = options[:remote]
|
14
|
-
@debug = options[:debug]
|
15
|
-
@growl = options[:growl]
|
16
|
-
@growl_image = options[:growl_image]
|
17
|
-
@pwd = Dir.pwd
|
18
|
-
|
19
|
-
log "Initialized with watchers = #{watchers.inspect}"
|
20
|
-
log "Initialized with options = #{options.inspect}"
|
21
|
-
|
22
|
-
super
|
23
|
-
end
|
24
|
-
|
25
|
-
def run_on_change(paths)
|
26
|
-
paths.each do |path|
|
27
|
-
local_file = File.join(pwd, path)
|
28
|
-
remote_file = File.join(remote, path)
|
29
|
-
|
30
|
-
attempts = 0
|
31
|
-
begin
|
32
|
-
log "Upload #{local_file} => #{remote_file}"
|
33
|
-
sftp_session.upload!(local_file, remote_file)
|
34
|
-
|
35
|
-
rescue Net::SFTP::StatusException => ex
|
36
|
-
log "Exception on upload #{path} - directory likely doesn't exist"
|
37
|
-
|
38
|
-
attempts += 1
|
39
|
-
remote_dir = File.dirname(remote_file)
|
40
|
-
recursively_create_dirs( remote_dir )
|
41
|
-
|
42
|
-
retry if (attempts < 3)
|
43
|
-
log "Exceeded 3 attempts to upload #{path}"
|
44
|
-
end
|
45
|
-
|
46
|
-
growl("Synced:\n#{paths.join("\n")}")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def growl?
|
53
|
-
@growl || false
|
54
|
-
end
|
55
|
-
|
56
|
-
def debug?
|
57
|
-
@debug || false
|
58
|
-
end
|
59
|
-
|
60
|
-
def growl(mesg)
|
61
|
-
return unless growl?
|
62
|
-
|
63
|
-
growl_opts = {
|
64
|
-
:name => "flopbox",
|
65
|
-
:title => "Flopbox: #{File.basename(pwd)}",
|
66
|
-
:message => mesg
|
67
|
-
:image => growl_image
|
68
|
-
}
|
69
|
-
|
70
|
-
Growl::Base.new(growl_opts).run
|
71
|
-
end
|
72
|
-
|
73
|
-
def log(mesg)
|
74
|
-
return unless debug?
|
75
|
-
|
76
|
-
puts "[#{Time.now}] #{mesg}"
|
77
|
-
end
|
78
|
-
|
79
|
-
def recursively_create_dirs(remote_dir)
|
80
|
-
new_dir = remote
|
81
|
-
remote_dir.gsub(remote, "").split("/").each do |dir|
|
82
|
-
|
83
|
-
new_dir = File.join(new_dir, dir)
|
84
|
-
|
85
|
-
begin
|
86
|
-
log "Creating #{new_dir}"
|
87
|
-
sftp_session.mkdir!(new_dir)
|
88
|
-
rescue Net::SFTP::StatusException => ex
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
# Configuration Options for guard-flopbox
|
3
|
-
opts = {
|
4
|
-
:hostname => "postercloud.com", # remote host
|
5
|
-
:user => "capuser", # remote user
|
6
|
-
:sftp_opts => {}, # options passed to Net::SFTP
|
7
|
-
:remote => "/home/capuser/test", # remote directory
|
8
|
-
:debug => true, # output debug information
|
9
|
-
:growl => true # growl on completion
|
10
|
-
}
|
11
|
-
|
12
|
-
group 'flopbox' do
|
13
|
-
guard 'flopbox', opts do
|
14
|
-
watch(/.*/)
|
15
|
-
end
|
16
|
-
end
|