Class: Feedle

Inherits:
Object
  • Object
show all
Defined in:
lib/feedle.rb

Overview

Feedle main class

Class Method Summary collapse

Class Method Details

.run(config) ⇒ Object



42
43
44
45
46
47
48
49
50
51
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
# File 'lib/feedle.rb', line 42

def self.run(config)

	# Create KindleFeeds configuration format
	sections = config['sections'] || []
	kfConfig = ""

	sections.each do |section|
		name  = section['name']  || 'Other feeds'
		items = section['items'] || []

		kfConfig += name + "\n"
		items.each do |item|
			kfConfig += item + "\n"
		end
		kfConfig += "\n"
	end

	# Generate feed HTML file
	puts "Reading RSS feeds..."
	kfOutput = '/tmp/feeds.html'
	kf = KindleFeeds.new(kfConfig)
	kf.generate_html(kfOutput)

	# Send created HTML file via email
	puts "Sending content to Kindle..."
	m = Mailer.new(config)
	m.send(kfOutput)
	
	puts "Cleaning temporary files..."
	# Delete created file
	File.delete(kfOutput)

	puts "Done!"

end