doc/LIB_EXAMPLE.md in vtools-1.0.1 vs doc/LIB_EXAMPLE.md in vtools-1.0.2
- old
+ new
@@ -1,29 +1,19 @@
# Library example
Library can be required via `-r` option
-$ vtools start -- -r library
+ $ vtools start -- -r library
+ $ vtools start -- -r library.rb
-$ vtools start -- -r library.rb
-
```ruby
# encoding: binary
# path generator
VTools.path_generator("video") do |file_name|
-
- first = file_name[0...2]
- second = file_name[2...4]
- # create all parent dirs (storage... path .. )
- error = `mkdir -p #{VTools::CONFIG[:video_storage]}/#{first}/#{second}`
- if error.empty?
- "#{first}/#{second}"
- else
- raise Exception, "Can't create storage dirs (#{error})"
- end
+ "#{file_name[0...2]}/#{file_name[2...4]}"
end
# setup storage:
VTools::Storage.setup do
@@ -50,10 +40,15 @@
# message sender
# receives hash: { :data => execution_result, :action => executed_action }
# execution_result can be video object or array with thumbnails
send_action do |result|
- @push.send "#{result[:action]} #{result[:data].name}" if result[:action] =~ /convert|info/
+ case result[:action]
+ when /convert|info/ # video instance here
+ @push.send "#{result[:action]} #{result[:data].name}"
+ when /thumbs/ # array with thumbs here
+ @push.send "#{result[:action]} #{result[:data]}"
+ end
end
end
# hooks