hyde-ftp 0.0.1

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.
Files changed (7) hide show
  1. data/CHANGELOG +1 -0
  2. data/LICENSE +21 -0
  3. data/README.md +30 -0
  4. data/bin/hyde +135 -0
  5. data/hyde-ftp.gemspec +36 -0
  6. data/lib/hyde.rb +135 -0
  7. metadata +85 -0
@@ -0,0 +1 @@
1
+ Version 0.0.1: Beta Released.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Jesse Herrick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ hyde-ftp
2
+ ========
3
+
4
+ Jekyll deployment using FTP.
5
+
6
+ #Commands
7
+
8
+ ##`hyde deploy`:
9
+ Build Jekyll site and deploy via FTP.
10
+ Usage: `hyde deploy _config.yml`
11
+
12
+ ##`hyde new_site`:
13
+ Create a new Jekyll site.
14
+ Usage: `hyde new site_name`
15
+
16
+ #How to Set Up Your Config
17
+ Your config can be the same as the one in your Jekyll site's folder. Just add these lines at the end of `_config.yml` file. (no quotes needed)
18
+
19
+ `
20
+ server: your-ftp-server.com
21
+ username: JohnDoe
22
+ password: myP4SSW0RD
23
+ local_dir: /home/username/my/website/directory
24
+ remote_dir: /MyRemoteDir/
25
+ `
26
+ **Mac OSX/Linux Users**
27
+ Make sure that you have the full path to your directory. Using `~/MyDirectory/Here/` is not supported at this time, so you must use `/home/username/MyDirectory/Here/`.
28
+
29
+ **Windows Users**
30
+ Your directory should look like this: `C:\Users\username\MyDirectory\Here\`
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'net/ftp'
5
+ require 'yaml'
6
+ require 'thor'
7
+
8
+ class Jekyll < Thor
9
+ $jekyll = Jekyll.new()
10
+
11
+ def initialize()
12
+ nil
13
+ end
14
+
15
+ # FTP Stuff
16
+ no_commands do
17
+ def mirror(path, ftp, initial_path = nil)
18
+ initial_path ||= path
19
+ Dir.entries(path).each do |file|
20
+ next if ['.', '..'].include? file
21
+
22
+ file_path = path + '/' + file
23
+ short_file_path = file_path[initial_path.length, file_path.length]
24
+ if File.directory?(file_path)
25
+ ftp.mkdir(file) unless ftp.nlst.index(file)
26
+ ftp.chdir(file)
27
+ mirror(file_path, ftp, initial_path)
28
+ ftp.chdir('..')
29
+ else
30
+ puts "Deploying: " + short_file_path
31
+ puts " To: " + ftp.pwd + '/' + file
32
+ ftp.putbinaryfile(path + '/' + file, file)
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ def ftp_directory?(ftp, file_name)
39
+ ftp.chdir(file_name)
40
+ ftp.chdir('..')
41
+ true
42
+ rescue
43
+ false
44
+ end
45
+
46
+ def clean_ftp(ftp)
47
+ ftp.nlst.each do |file|
48
+ next if ['.', '..', 'bup', 'backup'].include? file
49
+ if ftp_directory? ftp, file
50
+ ftp.chdir file
51
+ clean_ftp(ftp)
52
+ ftp.chdir '..'
53
+ puts "Deleting directory: " + ftp.pwd + "/" + file
54
+ ftp.rmdir(file)
55
+ else
56
+ puts "Deleting: " + ftp.pwd + "/" + file
57
+ ftp.delete file
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ # END FTP Stuff
64
+
65
+ desc "check for Jekyll", "Check if Jekyll is on the system"
66
+ def exists()
67
+ @jekyll_version = %x( jekyll -version )
68
+
69
+ if @jekyll_version[1] = "j"
70
+ nil
71
+ else
72
+ %x( gem install jekyll )
73
+ end
74
+ end
75
+
76
+ desc "new site", "Create a new Jekyll site."
77
+ def new_site(name)
78
+ $jekyll.exists()
79
+ %x( jekyll new #{name} )
80
+ puts "Site created."
81
+ end
82
+
83
+ desc "deploy site", "Deploy website via FTP."
84
+ def deploy()
85
+ # Build Site
86
+ %x( jekyll build )
87
+
88
+ # Declare Instance Variables
89
+ config = YAML.load(File.read(ARGV[1]))
90
+
91
+ @ftp_server = config['server']
92
+ @username = config['username']
93
+ @password = config['password']
94
+ @remote_dir = config['remote_dir']
95
+ @local_dir = config['local_dir']
96
+
97
+ # Initialize FTP
98
+ ftp = Net::FTP.new(@ftp_server);
99
+ ftp.login(@username, @password)
100
+ ftp.chdir(@remote_dir)
101
+
102
+ $jekyll.clean_ftp(ftp)
103
+
104
+ $jekyll.mirror @local_dir, ftp
105
+
106
+ ftp.quit
107
+ end
108
+
109
+ def help()
110
+ command2 = ARGV[1]
111
+ case command2
112
+ when "deploy"
113
+ puts "Build Jekyll site and deploy via FTP."
114
+ puts "Usage: hyde deploy _config.yml"
115
+ when "new_site"
116
+ puts "Create a new Jekyll site."
117
+ puts "Usage: hyde new site_name"
118
+ else
119
+ puts "Commands:"
120
+ puts " deploy\n new_site"
121
+ end
122
+ end
123
+ end
124
+
125
+ command1 = ARGV[0]
126
+ case command1
127
+ when "deploy"
128
+ $jekyll.deploy
129
+ when "new_site"
130
+ $jekyll.new_site
131
+ when "help"
132
+ $jekyll.help
133
+ else
134
+ puts "You didn't give me a command."
135
+ end
@@ -0,0 +1,36 @@
1
+ Gem::Specification.new do |s|
2
+ s.specification_version = 2 if s.respond_to? :specification_version=
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+ s.rubygems_version = '1.3.5'
5
+
6
+ s.name = 'hyde-ftp'
7
+ s.version = '0.0.1'
8
+ s.license = 'MIT'
9
+ s.date = '2013-09-12'
10
+
11
+ s.summary = "Jekyll deployment using FTP."
12
+ s.description = "Hyde is an addon to the amazing Jekyll that makes deploying with FTP easier."
13
+
14
+ s.authors = ["Jesse Herrick"]
15
+ s.email = 'jessegrantherrick@gmail.com'
16
+ s.homepage = 'http://github.com/JesseHerrick/hyde-ftp'
17
+
18
+ s.require_paths = %w[lib]
19
+
20
+ s.executables << 'hyde'
21
+
22
+ s.add_runtime_dependency("jekyll", "~> 1.0.0")
23
+
24
+ # = MANIFEST =
25
+ s.files = %w[
26
+ bin/hyde
27
+ lib/hyde.rb
28
+ CHANGELOG
29
+ LICENSE
30
+ README.md
31
+ hyde-ftp.gemspec
32
+ ]
33
+ # = MANIFEST =
34
+
35
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
36
+ end
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'net/ftp'
5
+ require 'yaml'
6
+ require 'thor'
7
+
8
+ class Jekyll < Thor
9
+ $jekyll = Jekyll.new()
10
+
11
+ def initialize()
12
+ nil
13
+ end
14
+
15
+ # FTP Stuff
16
+ no_commands do
17
+ def mirror(path, ftp, initial_path = nil)
18
+ initial_path ||= path
19
+ Dir.entries(path).each do |file|
20
+ next if ['.', '..'].include? file
21
+
22
+ file_path = path + '/' + file
23
+ short_file_path = file_path[initial_path.length, file_path.length]
24
+ if File.directory?(file_path)
25
+ ftp.mkdir(file) unless ftp.nlst.index(file)
26
+ ftp.chdir(file)
27
+ mirror(file_path, ftp, initial_path)
28
+ ftp.chdir('..')
29
+ else
30
+ puts "Deploying: " + short_file_path
31
+ puts " To: " + ftp.pwd + '/' + file
32
+ ftp.putbinaryfile(path + '/' + file, file)
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ def ftp_directory?(ftp, file_name)
39
+ ftp.chdir(file_name)
40
+ ftp.chdir('..')
41
+ true
42
+ rescue
43
+ false
44
+ end
45
+
46
+ def clean_ftp(ftp)
47
+ ftp.nlst.each do |file|
48
+ next if ['.', '..', 'bup', 'backup'].include? file
49
+ if ftp_directory? ftp, file
50
+ ftp.chdir file
51
+ clean_ftp(ftp)
52
+ ftp.chdir '..'
53
+ puts "Deleting directory: " + ftp.pwd + "/" + file
54
+ ftp.rmdir(file)
55
+ else
56
+ puts "Deleting: " + ftp.pwd + "/" + file
57
+ ftp.delete file
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ # END FTP Stuff
64
+
65
+ desc "check for Jekyll", "Check if Jekyll is on the system"
66
+ def exists()
67
+ @jekyll_version = %x( jekyll -version )
68
+
69
+ if @jekyll_version[1] = "j"
70
+ nil
71
+ else
72
+ %x( gem install jekyll )
73
+ end
74
+ end
75
+
76
+ desc "new site", "Create a new Jekyll site."
77
+ def new_site(name)
78
+ $jekyll.exists()
79
+ %x( jekyll new #{name} )
80
+ puts "Site created."
81
+ end
82
+
83
+ desc "deploy site", "Deploy website via FTP."
84
+ def deploy()
85
+ # Build Site
86
+ %x( jekyll build )
87
+
88
+ # Declare Instance Variables
89
+ config = YAML.load(File.read(ARGV[1]))
90
+
91
+ @ftp_server = config['server']
92
+ @username = config['username']
93
+ @password = config['password']
94
+ @remote_dir = config['remote_dir']
95
+ @local_dir = config['local_dir']
96
+
97
+ # Initialize FTP
98
+ ftp = Net::FTP.new(@ftp_server);
99
+ ftp.login(@username, @password)
100
+ ftp.chdir(@remote_dir)
101
+
102
+ $jekyll.clean_ftp(ftp)
103
+
104
+ $jekyll.mirror @local_dir, ftp
105
+
106
+ ftp.quit
107
+ end
108
+
109
+ def help()
110
+ command2 = ARGV[1]
111
+ case command2
112
+ when "deploy"
113
+ puts "Build Jekyll site and deploy via FTP."
114
+ puts "Usage: hyde deploy _config.yml"
115
+ when "new_site"
116
+ puts "Create a new Jekyll site."
117
+ puts "Usage: hyde new site_name"
118
+ else
119
+ puts "Commands:"
120
+ puts " deploy\n new_site"
121
+ end
122
+ end
123
+ end
124
+
125
+ command1 = ARGV[0]
126
+ case command1
127
+ when "deploy"
128
+ $jekyll.deploy
129
+ when "new_site"
130
+ $jekyll.new_site
131
+ when "help"
132
+ $jekyll.help
133
+ else
134
+ puts "You didn't give me a command."
135
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hyde-ftp
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jesse Herrick
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-09-12 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: jekyll
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 23
29
+ segments:
30
+ - 1
31
+ - 0
32
+ - 0
33
+ version: 1.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Hyde is an addon to the amazing Jekyll that makes deploying with FTP easier.
37
+ email: jessegrantherrick@gmail.com
38
+ executables:
39
+ - hyde
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - bin/hyde
46
+ - lib/hyde.rb
47
+ - CHANGELOG
48
+ - LICENSE
49
+ - README.md
50
+ - hyde-ftp.gemspec
51
+ homepage: http://github.com/JesseHerrick/hyde-ftp
52
+ licenses:
53
+ - MIT
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.8.15
81
+ signing_key:
82
+ specification_version: 2
83
+ summary: Jekyll deployment using FTP.
84
+ test_files: []
85
+