hyde-ftp 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -1
- data/bin/hyde +2 -121
- data/hyde-ftp.gemspec +3 -1
- data/lib/hyde.rb +127 -0
- data/lib/hyde/ftp-transfer.rb +43 -0
- metadata +5 -3
data/CHANGELOG
CHANGED
@@ -9,4 +9,6 @@ Version 0.0.8: Cleaning up fix.
|
|
9
9
|
Version 0.1.0: No longer builds site before deployment to avoid jekyll config related errors.
|
10
10
|
Version 0.1.1: Fixed private method error.
|
11
11
|
Version 0.1.2: Fixing require error.
|
12
|
-
Version 0.1.3: Accidentally required nothing. Fixed that.
|
12
|
+
Version 0.1.3: Accidentally required nothing. Fixed that.
|
13
|
+
Version 0.1.4: Trying something new.
|
14
|
+
Version 0.1.5: Still trying new stuff.
|
data/bin/hyde
CHANGED
@@ -5,124 +5,5 @@
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'net/ftp'
|
7
7
|
require 'yaml'
|
8
|
-
|
9
|
-
|
10
|
-
initial_path ||= path
|
11
|
-
Dir.entries(path).each do |file|
|
12
|
-
next if ['.', '..'].include? file
|
13
|
-
|
14
|
-
file_path = path + '/' + file
|
15
|
-
short_file_path = file_path[initial_path.length, file_path.length]
|
16
|
-
if File.directory?(file_path)
|
17
|
-
ftp.mkdir(file) unless ftp.nlst.index(file)
|
18
|
-
ftp.chdir(file)
|
19
|
-
mirror(file_path, ftp, initial_path)
|
20
|
-
ftp.chdir('..')
|
21
|
-
else
|
22
|
-
puts "Deploying: " + short_file_path
|
23
|
-
puts " To: " + ftp.pwd + '/' + file
|
24
|
-
ftp.putbinaryfile(path + '/' + file, file)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def ftp_directory?(ftp, file_name)
|
30
|
-
ftp.chdir(file_name)
|
31
|
-
ftp.chdir('..')
|
32
|
-
true
|
33
|
-
rescue
|
34
|
-
false
|
35
|
-
end
|
36
|
-
|
37
|
-
def clean_ftp(ftp)
|
38
|
-
ftp.nlst.each do |file|
|
39
|
-
next if ['.', '..', 'bup', 'backup'].include? file
|
40
|
-
if ftp_directory? ftp, file
|
41
|
-
ftp.chdir file
|
42
|
-
clean_ftp(ftp)
|
43
|
-
ftp.chdir '..'
|
44
|
-
puts "Deleting directory: " + ftp.pwd + "/" + file
|
45
|
-
ftp.rmdir(file)
|
46
|
-
else
|
47
|
-
puts "Deleting: " + ftp.pwd + "/" + file
|
48
|
-
ftp.delete file
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class Jekyll
|
54
|
-
$jekyll = Jekyll.new()
|
55
|
-
|
56
|
-
def initialize()
|
57
|
-
nil
|
58
|
-
end
|
59
|
-
|
60
|
-
def exists()
|
61
|
-
@jekyll_version = %x( jekyll -version )
|
62
|
-
|
63
|
-
if @jekyll_version[1] = "j"
|
64
|
-
nil
|
65
|
-
else
|
66
|
-
%x( gem install jekyll )
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def new_site(name)
|
71
|
-
exists()
|
72
|
-
%x( jekyll new #{name} )
|
73
|
-
puts "Site created."
|
74
|
-
end
|
75
|
-
|
76
|
-
def deploy()
|
77
|
-
|
78
|
-
# Declare Instance Variables
|
79
|
-
config = YAML.load(File.read(ARGV[1]))
|
80
|
-
|
81
|
-
@ftp_server = config['server']
|
82
|
-
@username = config['username']
|
83
|
-
@password = config['password']
|
84
|
-
@remote_dir = config['remote_dir']
|
85
|
-
@local_dir = config['local_dir']
|
86
|
-
|
87
|
-
# Initialize FTP
|
88
|
-
ftp = Net::FTP.new(@ftp_server);
|
89
|
-
ftp.login(@username, @password)
|
90
|
-
ftp.chdir(@remote_dir)
|
91
|
-
|
92
|
-
clean_ftp(ftp)
|
93
|
-
|
94
|
-
mirror @local_dir, ftp
|
95
|
-
|
96
|
-
ftp.quit
|
97
|
-
end
|
98
|
-
|
99
|
-
def help()
|
100
|
-
command2 = ARGV[1]
|
101
|
-
case command2
|
102
|
-
when "deploy"
|
103
|
-
puts "Build Jekyll site and deploy via FTP."
|
104
|
-
puts "Usage: hyde deploy _config.yml"
|
105
|
-
when "new_site"
|
106
|
-
puts "Create a new Jekyll site."
|
107
|
-
puts "Usage: hyde new site_name"
|
108
|
-
else
|
109
|
-
puts "Commands:"
|
110
|
-
puts " deploy\n new_site"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
command1 = ARGV[0]
|
116
|
-
case command1
|
117
|
-
when "deploy"
|
118
|
-
$jekyll.deploy
|
119
|
-
when "new_site"
|
120
|
-
$jekyll.new_site
|
121
|
-
when "help"
|
122
|
-
$jekyll.help
|
123
|
-
when "list"
|
124
|
-
%x( hyde help )
|
125
|
-
else
|
126
|
-
puts "You didn't give me a command.\nRun 'hyde help' to see a command list."
|
127
|
-
end
|
128
|
-
|
8
|
+
require 'hyde.rb'
|
9
|
+
require 'hyde/ftp-transfer.rb'
|
data/hyde-ftp.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'hyde-ftp'
|
7
|
-
s.version = '0.1.
|
7
|
+
s.version = '0.1.5'
|
8
8
|
s.license = 'MIT'
|
9
9
|
s.date = '2013-06-11'
|
10
10
|
|
@@ -24,6 +24,8 @@ Gem::Specification.new do |s|
|
|
24
24
|
# = MANIFEST =
|
25
25
|
s.files = %w[
|
26
26
|
bin/hyde
|
27
|
+
lib/hyde/ftp-transfer.rb
|
28
|
+
lib/hyde.rb
|
27
29
|
CHANGELOG
|
28
30
|
LICENSE
|
29
31
|
README.md
|
data/lib/hyde.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'net/ftp'
|
5
|
+
require 'yaml'
|
6
|
+
require 'hyde/ftp-transfer.rb'
|
7
|
+
|
8
|
+
def mirror(path, ftp, initial_path = nil)
|
9
|
+
initial_path ||= path
|
10
|
+
Dir.entries(path).each do |file|
|
11
|
+
next if ['.', '..'].include? file
|
12
|
+
|
13
|
+
file_path = path + '/' + file
|
14
|
+
short_file_path = file_path[initial_path.length, file_path.length]
|
15
|
+
if File.directory?(file_path)
|
16
|
+
ftp.mkdir(file) unless ftp.nlst.index(file)
|
17
|
+
ftp.chdir(file)
|
18
|
+
mirror(file_path, ftp, initial_path)
|
19
|
+
ftp.chdir('..')
|
20
|
+
else
|
21
|
+
puts "Deploying: " + short_file_path
|
22
|
+
puts " To: " + ftp.pwd + '/' + file
|
23
|
+
ftp.putbinaryfile(path + '/' + file, file)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def ftp_directory?(ftp, file_name)
|
29
|
+
ftp.chdir(file_name)
|
30
|
+
ftp.chdir('..')
|
31
|
+
true
|
32
|
+
rescue
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
def clean_ftp(ftp)
|
37
|
+
ftp.nlst.each do |file|
|
38
|
+
next if ['.', '..', 'bup', 'backup'].include? file
|
39
|
+
if ftp_directory? ftp, file
|
40
|
+
ftp.chdir file
|
41
|
+
clean_ftp(ftp)
|
42
|
+
ftp.chdir '..'
|
43
|
+
puts "Deleting directory: " + ftp.pwd + "/" + file
|
44
|
+
ftp.rmdir(file)
|
45
|
+
else
|
46
|
+
puts "Deleting: " + ftp.pwd + "/" + file
|
47
|
+
ftp.delete file
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Jekyll
|
53
|
+
$jekyll = Jekyll.new()
|
54
|
+
|
55
|
+
def initialize()
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
59
|
+
def exists()
|
60
|
+
@jekyll_version = %x( jekyll -version )
|
61
|
+
|
62
|
+
if @jekyll_version[1] = "j"
|
63
|
+
nil
|
64
|
+
else
|
65
|
+
%x( gem install jekyll )
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def new_site(name)
|
70
|
+
exists()
|
71
|
+
%x( jekyll new #{name} )
|
72
|
+
puts "Site created."
|
73
|
+
end
|
74
|
+
|
75
|
+
def deploy()
|
76
|
+
|
77
|
+
# Declare Instance Variables
|
78
|
+
config = YAML.load(File.read(ARGV[1]))
|
79
|
+
|
80
|
+
@ftp_server = config['server']
|
81
|
+
@username = config['username']
|
82
|
+
@password = config['password']
|
83
|
+
@remote_dir = config['remote_dir']
|
84
|
+
@local_dir = config['local_dir']
|
85
|
+
|
86
|
+
# Initialize FTP
|
87
|
+
ftp = Net::FTP.new(@ftp_server);
|
88
|
+
ftp.login(@username, @password)
|
89
|
+
ftp.chdir(@remote_dir)
|
90
|
+
|
91
|
+
clean_ftp(ftp)
|
92
|
+
|
93
|
+
mirror @local_dir, ftp
|
94
|
+
|
95
|
+
ftp.quit
|
96
|
+
end
|
97
|
+
|
98
|
+
def help()
|
99
|
+
command2 = ARGV[1]
|
100
|
+
case command2
|
101
|
+
when "deploy"
|
102
|
+
puts "Build Jekyll site and deploy via FTP."
|
103
|
+
puts "Usage: hyde deploy _config.yml"
|
104
|
+
when "new_site"
|
105
|
+
puts "Create a new Jekyll site."
|
106
|
+
puts "Usage: hyde new site_name"
|
107
|
+
else
|
108
|
+
puts "Commands:"
|
109
|
+
puts " deploy\n new_site"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
command1 = ARGV[0]
|
115
|
+
case command1
|
116
|
+
when "deploy"
|
117
|
+
$jekyll.deploy
|
118
|
+
when "new_site"
|
119
|
+
$jekyll.new_site
|
120
|
+
when "help"
|
121
|
+
$jekyll.help
|
122
|
+
when "list"
|
123
|
+
%x( hyde help )
|
124
|
+
else
|
125
|
+
puts "You didn't give me a command.\nRun 'hyde help' to see a command list."
|
126
|
+
end
|
127
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
def mirror(path, ftp, initial_path = nil)
|
2
|
+
initial_path ||= path
|
3
|
+
Dir.entries(path).each do |file|
|
4
|
+
next if ['.', '..'].include? file
|
5
|
+
|
6
|
+
file_path = path + '/' + file
|
7
|
+
short_file_path = file_path[initial_path.length, file_path.length]
|
8
|
+
if File.directory?(file_path)
|
9
|
+
ftp.mkdir(file) unless ftp.nlst.index(file)
|
10
|
+
ftp.chdir(file)
|
11
|
+
mirror(file_path, ftp, initial_path)
|
12
|
+
ftp.chdir('..')
|
13
|
+
else
|
14
|
+
puts "Deploying: " + short_file_path
|
15
|
+
puts " To: " + ftp.pwd + '/' + file
|
16
|
+
ftp.putbinaryfile(path + '/' + file, file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def ftp_directory?(ftp, file_name)
|
22
|
+
ftp.chdir(file_name)
|
23
|
+
ftp.chdir('..')
|
24
|
+
true
|
25
|
+
rescue
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def clean_ftp(ftp)
|
30
|
+
ftp.nlst.each do |file|
|
31
|
+
next if ['.', '..', 'bup', 'backup'].include? file
|
32
|
+
if ftp_directory? ftp, file
|
33
|
+
ftp.chdir file
|
34
|
+
clean_ftp(ftp)
|
35
|
+
ftp.chdir '..'
|
36
|
+
puts "Deleting directory: " + ftp.pwd + "/" + file
|
37
|
+
ftp.rmdir(file)
|
38
|
+
else
|
39
|
+
puts "Deleting: " + ftp.pwd + "/" + file
|
40
|
+
ftp.delete file
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyde-ftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jesse Herrick
|
@@ -42,6 +42,8 @@ extra_rdoc_files: []
|
|
42
42
|
|
43
43
|
files:
|
44
44
|
- bin/hyde
|
45
|
+
- lib/hyde/ftp-transfer.rb
|
46
|
+
- lib/hyde.rb
|
45
47
|
- CHANGELOG
|
46
48
|
- LICENSE
|
47
49
|
- README.md
|