Class: Jekyll

Inherits:
Object
  • Object
show all
Defined in:
lib/hyde.rb

Instance Method Summary collapse

Constructor Details

#initializeJekyll



11
12
13
# File 'lib/hyde.rb', line 11

def initialize()
  nil
end

Instance Method Details

#clean!Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/hyde.rb', line 73

def clean!
  config = YAML.load(File.read(ARGV[1]))

  @ftp_server = config['server']
  @username = config['username']
  @password = config['password']
  @remote_dir = config['remote_dir']

  # Initialize FTP
  ftp = Net::FTP.new(@ftp_server);
  ftp.(@username, @password)
  ftp.chdir(@remote_dir)

  clean_ftp(ftp)

  puts "Directory cleared."
rescue
  puts "  Incorrectly configured or nonexistant config file."
end

#deployObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/hyde.rb', line 31

def deploy()
  # Declare Instance Variables
  config = YAML.load(File.read(ARGV[1]))

  @ftp_server = config['server']
  @username = config['username']
  @password = config['password']
  @remote_dir = config['remote_dir']
  @local_dir = config['local_dir']

  # Initialize FTP
  ftp = Net::FTP.new(@ftp_server);
  ftp.(@username, @password)
  ftp.chdir(@remote_dir)

  clean_ftp(ftp)

  mirror @local_dir, ftp

  ftp.quit

rescue
  puts "  Incorrectly configured or nonexistant config file."
  puts "  Usage: hyde deploy _config.yml"
end

#existsObject



15
16
17
18
19
20
21
22
23
# File 'lib/hyde.rb', line 15

def exists()
  @jekyll_version = %x( jekyll -version )

  if @jekyll_version[1] = "j"
    nil
  else
    %x( gem install jekyll )
  end
end

#helpObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/hyde.rb', line 57

def help()
  command2 = ARGV[1]
  case command2
  when "deploy"
    puts "  Build Jekyll site and deploy via FTP."
    puts "  Usage: hyde deploy _config.yml"
  when "new_site"
    puts "  Create a new Jekyll site."
    puts "  Usage: hyde new site_name"
  else
    puts "  Commands:"
    puts "         deploy _config.yml"
    puts "         new_site siteName"
  end
end

#new_site(name) ⇒ Object



25
26
27
28
29
# File 'lib/hyde.rb', line 25

def new_site(name)
  exists()
  %x( jekyll new #{name} )
  puts "Site created."
end