Module: FYT
- Defined in:
- lib/fyt.rb,
lib/fyt/base.rb,
lib/fyt/config.rb,
lib/fyt/parser.rb,
lib/fyt/builder.rb,
lib/fyt/storage.rb
Overview
handles the general behaviour of FYT
Defined Under Namespace
Classes: Base, Builder, Config, Parser, Storage
Class Method Summary
collapse
Class Method Details
.add ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/fyt.rb', line 61
def self.add
print 'Please name of the feed e.g. "My Favorite Videos": '
name = STDIN.gets.rstrip
print 'Please enter feed url e.g. "https://www.youtube.com/feeds/videos.xml?channel_id=AbCdEf1234567890aBcDeF00": '
url = STDIN.gets.rstrip
raise 'No name given' if name.size.zero?
raise 'No feed url given' if url.size.zero?
config = FYT::Config.new
feeds = config[:feeds]
feeds << { name: name, url: url }
config[:feeds] = feeds
end
|
.config ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/fyt.rb', line 45
def self.config
config = FYT::Config.new
print "Please enter storage path [#{config[:storage_path]}]: "
config[:storage_path] = STDIN.gets.rstrip
print "Please enter server prefix [#{config[:server_prefix]}]: "
config[:server_prefix] = STDIN.gets.rstrip
print "Please enter format options [#{config[:format_options]}]: "
config[:format_options] = STDIN.gets.rstrip
print "Please enter output_format [#{config[:output_format]}]: "
config[:output_format] = STDIN.gets.rstrip
end
|
.lock ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/fyt.rb', line 12
def self.lock
lockfile = ENV['HOME'] + '/.fyt/pid.lock'
dirname = File.dirname(lockfile)
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
File.open(lockfile, ::File::CREAT | ::File::EXCL | ::File::WRONLY) do |f|
f.write(Process.pid.to_s)
end
at_exit { File.delete(lockfile) if File.exist?(lockfile) }
end
|
.run ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/fyt.rb', line 25
def self.run
config = FYT::Config.new
storage = FYT::Storage.new(
config[:storage_path],
config[:format_options],
config[:output_format],
config[:proxy]
)
config[:feeds].each do |feed_config|
source_feed = FYT::Parser.new(feed_config[:url], config[:proxy]).read
new_feed = FYT::Builder.new(source_feed, storage, config[:server_prefix], config[:proxy]).build
storage.add_feed(feed_config[:name], new_feed)
end
storage.cleanup!
end
|