Class: Command::Send
Instance Method Summary
collapse
Methods inherited from CommandBase
execute!, #load_local_settings
Constructor Details
#initialize ⇒ Send
Returns a new instance of Send.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/command/send.rb', line 16
def initialize
super("<device> [<target1> <target2> ...]")
@opt.separator "\n \u30FB<target>\u3067\u6307\u5B9A\u3057\u305F\u5C0F\u8AAC\u306E\u96FB\u5B50\u66F8\u7C4D\u30C7\u30FC\u30BF(\#{Device::DEVICES.map{|_,d| d::EBOOK_FILE_EXT}.join(\", \")})\u3092<device>\u3067\u6307\u5B9A\u3057\u305F\u7AEF\u672B\u306B\u9001\u4FE1\u3057\u307E\u3059\u3002\n<device>\u306B\u306F\u73FE\u5728 \#{Device::DEVICES.keys.join(\", \")} \u304C\u6307\u5B9A\u51FA\u6765\u307E\u3059\u3002\n \u30FBnarou setting device=<device>\u3068\u3057\u3066\u304A\u3051\u3070\u3001<device>\u306E\u5165\u529B\u3092\u7701\u7565\u3067\u304D\u307E\u3059\u3002\n\u307E\u305F\u3001convert\u30B3\u30DE\u30F3\u30C9\u3067\u5909\u63DB\u6642\u306B(\u7AEF\u672B\u304CPC\u306B\u63A5\u7D9A\u3055\u308C\u3066\u3044\u308C\u3070)\u81EA\u52D5\u3067\u30C7\u30FC\u30BF\u3092\u9001\u4FE1\u3059\u308B\u3088\u3046\u306B\u306A\u308A\u307E\u3059\u3002\n \u30FB<target>\u3092\u7701\u7565\u3057\u305F\u5834\u5408\u3001\u7BA1\u7406\u3057\u3066\u3044\u308B\u5C0F\u8AAC\u5168\u3066\u306E\u30D5\u30A1\u30A4\u30EB\u306E\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3092\u7AEF\u672B\u306E\u3082\u306E\u3068\u6BD4\u3079\u3066\u65B0\u3057\u3051\u308C\u3070\u9001\u4FE1\u3057\u307E\u3059\u3002\n\n Example:\nnarou send kindle 6\nnarou send kobo 6\n\n# <device>\u306E\u7701\u7565\nnarou setting device=kindle\nnarou send 6\n\nnarou send # \u7AEF\u672B\u306E\u30D5\u30A1\u30A4\u30EB\u3088\u308A\u65B0\u3057\u3044\u30D5\u30A1\u30A4\u30EB\u304C\u3042\u308C\u3070\u9001\u4FE1\nnarou send --without-freeze # \u51CD\u7D50\u6E08\u306F\u5BFE\u8C61\u5916\u306B\n\n Options:\n EOS\n\n @opt.on(\"--without-freeze\", \"\u4E00\u62EC\u9001\u4FE1\u6642\u306B\u51CD\u7D50\u3055\u308C\u305F\u5C0F\u8AAC\u306F\u5BFE\u8C61\u5916\u306B\u3059\u308B\") {\n @options[\"without-freeze\"] = true\n }\nend\n"
|
Instance Method Details
#execute(argv) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/command/send.rb', line 52
def execute(argv)
load_local_settings
super
device = get_device(argv)
unless device
error "デバイス名が指定されていないか、間違っています。\n" +
"narou setting device=デバイス名 で指定出来ます。\n" +
"指定出来るデバイス名:" + Device::DEVICES.keys.join(", ")
exit 1
end
unless device.physical_support?
error "#{device.display_name} への直接送信は対応していません"
exit 1
end
unless device.connecting?
error "#{device.display_name} が接続されていません"
exit 1
end
send_all = false
titles = {}
if argv.empty?
send_all = true
Database.instance.each do |id, data|
next if @options["without-freeze"] && Narou.novel_frozen?(id)
argv << id
titles[id] = data["title"]
end
end
argv.each do |target|
ebook_path = Narou.get_ebook_file_path(target, device.ebook_file_ext)
unless ebook_path
error "#{target} は存在しません"
next
end
unless File.exists?(ebook_path)
error "まだファイル(#{File.basename(ebook_path)})が無いようです" unless send_all
next
end
if send_all
if device.ebook_file_old?(ebook_path)
puts "<green>ID:#{target} #{TermColor.escape(titles[target])}</green>".termcolor
else
next
end
end
print "#{device.name}へ送信しています"
exit_copy = false
copy_to_path = nil
Thread.new do
copy_to_path = device.copy_to_documents(ebook_path)
exit_copy = true
end
until exit_copy
print "."
sleep(0.5)
end
puts
if copy_to_path
puts copy_to_path + " へコピーしました"
else
error "#{device.name}が見つからなかったためコピー出来ませんでした"
exit 1
end
end
rescue Interrupt => e
puts "送信を中断しました"
exit 1
end
|
#get_device(argv) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/command/send.rb', line 45
def get_device(argv)
if argv.first && Device.exists?(argv.first)
return Narou.get_device(argv.shift)
end
Narou.get_device
end
|
#oneline_help ⇒ Object
12
13
14
|
# File 'lib/command/send.rb', line 12
def oneline_help
"変換したEPUB/MOBIを電子書籍端末に送信します"
end
|