Module: Softcover::Commands::Publisher
Constant Summary
Constants included
from Utils
Utils::UNITS
Instance Method Summary
collapse
Methods included from Output
should_output?, silence!, silent?, #system, unsilence!
Methods included from Utils
#add_highlight_class!, #as_size, #current_book, #digest, #executable, #execute, #in_book_directory?, #logged_in?, #mkdir, #path, #reset_current_book!, #rm, #silence, #source, #tmpify, #write_pygments_file
Instance Method Details
#exit_with_message ⇒ Object
85
86
87
|
# File 'lib/softcover/commands/publisher.rb', line 85
def exit_with_message
puts "Processed #{current_book.processed_screencasts.size} screencasts."
end
|
#process_screencasts ⇒ Object
81
82
83
|
# File 'lib/softcover/commands/publisher.rb', line 81
def process_screencasts
current_book.process_screencasts
end
|
#publish!(options = {}) ⇒ Object
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
|
# File 'lib/softcover/commands/publisher.rb', line 7
def publish!(options={})
return false unless current_book
if current_book.create_or_update
require 'ruby-progressbar'
require 'curb'
unless options[:quiet] || options[:silent]
puts "Uploading #{current_book.uploader.file_count} files " \
"(#{as_size current_book.uploader.total_size}):"
end
url = current_book.upload!(options)
unless options[:quiet] || options[:silent]
puts "Published! #{url}"
end
else
puts "Errors: #{current_book.errors}"
return false
end
true
rescue Softcover::BookManifest::NotFound => e
puts e.message
false
rescue Softcover::Book::UploadError => e
puts e.message
false
end
|
#publish_screencasts!(options = {}) ⇒ Object
TODO: refactor this flow out of file?
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/softcover/commands/publisher.rb', line 36
def publish_screencasts!(options={})
return false unless current_book
current_book.screencasts_dir = options[:dir] ||
Softcover::Book::DEFAULT_SCREENCASTS_DIR
@watch = options[:watch]
if options[:daemon]
pid = fork do
run_publish_screencasts
end
puts "Daemonized, pid: #{pid}"
else
run_publish_screencasts
end
current_book
end
|
#run_publish_screencasts ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/softcover/commands/publisher.rb', line 57
def run_publish_screencasts
if @watch
puts "Watching..."
Signal.trap("TERM") do
puts "SIGTERM received."
exit_with_message
end
begin
loop do
process_screencasts
sleep 1
end
rescue Interrupt
puts " Interrupt Received."
exit_with_message
end
else
process_screencasts
exit_with_message
end
end
|
#unpublish! ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/softcover/commands/publisher.rb', line 89
def unpublish!
return false unless current_book
if current_book.destroy
Softcover::BookConfig.remove
puts "Done!"
return true
else
puts "Errors: #{current_book.errors}"
return false
end
rescue RestClient::ResourceNotFound
puts "Book with ID=#{current_book.id} not found under this account."
false
rescue Softcover::BookManifest::NotFound => e
puts e.message
false
end
|