Module: Kodiak
- Defined in:
- lib/kodiak.rb,
lib/kodiak/cli.rb,
lib/kodiak/utils.rb,
lib/kodiak/watcher.rb,
lib/kodiak/generator.rb,
lib/kodiak/transporter.rb,
lib/kodiak/notification.rb,
lib/kodiak/config_reader.rb
Defined Under Namespace
Classes: ConfigReader, Generator, Notification, Transporter, Watcher
Constant Summary
collapse
- APP_NAME =
"Kodiak"
- VERSION =
"0.0.1"
- ROOT_PATH =
Dir.pwd
- CONFIG_PATH =
File.expand_path(File.dirname(__FILE__) + "/../config")
- CONFIG_FILENAME =
"kodiak.yaml"
- CONFIG_ICON =
"kodiak-icon.png"
- USAGE_FILENAME =
"kodiak-usage.txt"
- GLOBAL_CONFIG =
".kodiak_config"
- LOG_FILENAME =
".kodiak_log"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
21
22
23
|
# File 'lib/kodiak.rb', line 21
def user
@user
end
|
Class Method Details
.log(params = {}) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/kodiak/utils.rb', line 3
def self.log(params={})
pushed = params[:pushed]
ignored = params[:ignored]
file = File.open("#{Kodiak::LOG_FILENAME}", "a+")
time = Time.now.strftime("%A, %m/%d/%Y at %I:%M:%3N %p")
message = "#{time} | #{Kodiak.user['name']} (#{Kodiak.user['email']})\n"
message += "---------------------------------------------------------------------------------\n"
message += "Pushed #{pushed.length} files and ignored #{ignored.length} files\n"
message += "---------------------------------------------------------------------------------\n"
pushed.each do |file|
message += "Pushed [#{file[:source]}] --> [#{file[:destination]}]\n"
end
ignored.each do |file|
message += "Ignored #{file[:source]} because #{file[:reason].downcase}\n"
end
message += "\n\n\n"
file.write(message)
file.close
end
|
.push(options) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/kodiak/cli.rb', line 3
def self.push(options)
ARGV.shift
if ! ARGV[0]
Kodiak::Notification.new "Push requires an environment parameter\n", "failure"
puts "Example: 'kodiak push remote'"
exit
end
options[:environment] = ARGV[0]
config = Kodiak::ConfigReader.new(options)
if options[:safe]
continue = "yes"
else
puts "[environment = #{options[:environment]}]\n"
puts "\nPush these files?"
config.files.each do |file|
puts " - #{file[:source]} --> #{file[:destination]}"
end
puts "\nContinue? [yes|no]"
continue = STDIN.gets.chomp
end
if continue =~ /([Yy][Ee][Ss]|[Yy]|1)/
Kodiak::Transporter.new(config, options).transport
else
puts "Push canceled by user"
exit
end
end
|
.user ⇒ Object
27
28
29
|
# File 'lib/kodiak.rb', line 27
def self.user
@user
end
|
.user=(user) ⇒ Object
23
24
25
|
# File 'lib/kodiak.rb', line 23
def self.user=(user)
@user = user
end
|
.view_log ⇒ Object
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/kodiak/cli.rb', line 81
def self.view_log
if not File.exists? Kodiak::LOG_FILENAME
puts "Log file does not exist. Sorry."
exit
end
file = File.open("#{Kodiak::LOG_FILENAME}", "r")
puts file.read
file.close
end
|
.watch(options) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/kodiak/cli.rb', line 37
def self.watch(options)
ARGV.shift
if ! ARGV[0]
puts "Watch requires an environment parameter"
puts "Example: 'kodiak watch remote'"
exit
end
options[:environment] = ARGV[0]
config = Kodiak::ConfigReader.new(options)
if options[:safe]
continue = "yes"
else
puts "Start Kodiak server? [yes|no]"
continue = STDIN.gets.chomp
end
if continue =~ /([Yy][Ee][Ss]|[Yy]|1)/
Kodiak::Watcher.new(config, options)
end
end
|