Class: Jekyll

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

Instance Method Summary collapse

Constructor Details

#initializeJekyll

Returns a new instance of Jekyll.



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

def initialize()
	nil
end

Instance Method Details

#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 "Invalid/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
# 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\n         new_site"
	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