glynn 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97e79c9d356db219138794c973897b9e6df229b0
4
- data.tar.gz: 8fa4e16bcc32bfeb2d82e8a3d0e1ecee1c85f0f0
3
+ metadata.gz: d8392284c1b29c23af2b8d6d5d9438afe6c0c7ee
4
+ data.tar.gz: 4f5c215bd533659209b1f91841953c0fad15c4c3
5
5
  SHA512:
6
- metadata.gz: 7a811cf2dee93667152c489d39053fd5813f7bc54295db79a3936ebb4efc66e6e4e17eaae782237e795e253f3aa3f3e819ee58d3bd14982908a1e5a80233401f
7
- data.tar.gz: f514fe9529376ad92371eb206b8735a67433c0f2ba33f44159ddc6c8271b00a7e5550aa431e7cf66568cb6f19d89f569a76b9e89af0096066ee2022785661b81
6
+ metadata.gz: f58e78373d9f384b5ac5294fbc5768acd32b6dc334f67a54521248b927103923f08cef820cbce39571bffcd214814f0cbe2a0c756a39184df9b5f923451bbb18
7
+ data.tar.gz: 4b310a8b9e9587c45b94c3d19b573c63320d7426b6a86d9a28f3311cfb90fd3746db69b4a12012238eadcb60d69834221df7825d9e3e0268786a01556a5db4fb
data/bin/glynn CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'jekyll'
4
4
  require 'glynn'
5
+ require 'io/console'
5
6
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
7
 
7
8
 
@@ -19,16 +20,22 @@ case ARGV.size
19
20
  options['ftp_username'] = ARGV[2]
20
21
  options['ftp_password'] = ARGV[3]
21
22
  end
22
- options = Jekyll.configuration(options)
23
- ftp_port = (options['ftp_port'] || 21).to_i
24
- passive = options['ftp_passive'] || true
23
+ options = Jekyll.configuration(options)
24
+ ftp_port = (options['ftp_port'] || 21).to_i
25
+ passive = options['ftp_passive'] || true
26
+ ftp_secure = options['ftp_secure'] || false
27
+
28
+ # If _glynn.yml exists, load and merge these options
29
+ if File.file?('_glynn.yml')
30
+ options = options.merge(YAML.load_file('_glynn.yml'))
31
+ end
25
32
 
26
33
  puts "Building site: #{options['source']} -> #{options['destination']}"
27
34
  jekyll = Glynn::Jekyll.new
28
35
  jekyll.build
29
36
  puts "Successfully generated site"
30
37
 
31
- puts "Sending site over FTP (host: #{options['ftp_host']}, port: #{ftp_port})"
38
+ puts "Sending site over FTP (host: #{options['ftp_host']}, port: #{ftp_port}, ftps: #{ftp_secure})"
32
39
  begin
33
40
  if options['ftp_username'].nil?
34
41
  print "FTP Username: "
@@ -39,10 +46,8 @@ begin
39
46
 
40
47
  if options['ftp_password'].nil?
41
48
  print "FTP Password: "
42
- # We hide the entered characters before to ask for the password
43
- system "stty -echo"
44
- password = $stdin.gets.chomp
45
- system "stty echo"
49
+ # Get the password without echoing characters
50
+ password = $stdin.noecho(&:gets).chomp
46
51
  else
47
52
  password = options['ftp_password']
48
53
  end
@@ -53,7 +58,12 @@ rescue NoMethodError, Interrupt
53
58
  exit
54
59
  end
55
60
 
56
- ftp = Glynn::Ftp.new(options['ftp_host'], ftp_port, {:username => username, :password => password, :passive => passive})
61
+ ftp = Glynn::Ftp.new(options['ftp_host'], ftp_port, {
62
+ :username => username,
63
+ :password => password,
64
+ :passive => passive,
65
+ :secure => ftp_secure
66
+ })
57
67
  puts "\r\nConnected to server. Sending site"
58
68
  ftp.sync(options['destination'], options['ftp_dir'])
59
69
  puts "Successfully sent site"
data/lib/glynn/ftp.rb CHANGED
@@ -1,14 +1,15 @@
1
1
  require 'net/ftp'
2
+ require 'double_bag_ftps'
2
3
 
3
4
  module Glynn
4
5
  class Ftp
5
- attr_reader :host, :port, :username, :password, :passive
6
+ attr_reader :host, :port, :username, :password, :passive, :secure
6
7
 
7
8
  def initialize(host, port = 21, options = Hash.new)
8
9
  options = {:username => nil, :password => nil}.merge(options)
9
10
  @host, @port = host, port
10
11
  @username, @password = options[:username], options[:password]
11
- @passive = options[:passive]
12
+ @passive, @secure = options[:passive], options[:secure]
12
13
  end
13
14
 
14
15
  def sync(local, distant)
@@ -19,7 +20,7 @@ module Glynn
19
20
 
20
21
  private
21
22
  def connect
22
- Net::FTP.open(host) do |ftp|
23
+ ftp_klass.open(host) do |ftp|
23
24
  ftp.passive = @passive
24
25
  ftp.connect(host, port)
25
26
  ftp.login(username, password)
@@ -27,6 +28,14 @@ module Glynn
27
28
  end
28
29
  end
29
30
 
31
+ def ftp_klass
32
+ if secure
33
+ DoubleBagFTPS
34
+ else
35
+ Net::FTP
36
+ end
37
+ end
38
+
30
39
  def send_dir(ftp, local, distant)
31
40
  begin
32
41
  ftp.mkdir(distant)
data/lib/glynn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Glynn
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glynn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien MATHIEU
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-20 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: double-bag-ftps
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.2
55
69
  description: Deploy a jekyll weblog through ftp
56
70
  email: 42@dmathieu.com
57
71
  executables:
@@ -85,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
99
  version: '0'
86
100
  requirements: []
87
101
  rubyforge_project:
88
- rubygems_version: 2.2.2
102
+ rubygems_version: 2.4.5
89
103
  signing_key:
90
104
  specification_version: 4
91
105
  summary: Deploy a jekyll weblog through ftp