feedle 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/feedle +28 -0
- data/lib/feedle.rb +74 -0
- metadata +97 -0
data/bin/feedle
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'feedle'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
|
7
|
+
config = ARGV[0]
|
8
|
+
|
9
|
+
if config.nil?
|
10
|
+
puts 'No config file specified'
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
if ! File.exist?(config)
|
15
|
+
puts "Cannot read configuration file at: #{config}"
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
configuration = nil
|
20
|
+
begin
|
21
|
+
configuration = YAML.load_file(config)
|
22
|
+
rescue
|
23
|
+
puts "Unable to parse YML configuration file at: #{config}"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
Feedle.run configuration
|
data/lib/feedle.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'kindle-feeds'
|
2
|
+
require 'mail'
|
3
|
+
|
4
|
+
|
5
|
+
# In the original class the output file can't be customized
|
6
|
+
class KindleFeeds
|
7
|
+
def generate_html(file)
|
8
|
+
erb = ERB.new(File.read(ERB_TEMPLATE))
|
9
|
+
out = erb.result(binding())
|
10
|
+
File.open(file, "w") { |f| f.write out }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
# Mailer class
|
16
|
+
class Mailer
|
17
|
+
|
18
|
+
def initialize(config)
|
19
|
+
@config = config['mailer'] || {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def send(file)
|
23
|
+
|
24
|
+
mail = Mail.new
|
25
|
+
mail.from = @config['from_address']
|
26
|
+
mail.to = @config['to_address']
|
27
|
+
mail.subject = 'Kindle delivery'
|
28
|
+
mail.add_file file
|
29
|
+
|
30
|
+
if @config['delivery_method']
|
31
|
+
mail.delivery_method @config['delivery_method'], @config['options'].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
32
|
+
end
|
33
|
+
|
34
|
+
mail.deliver!
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
# Feedle main class
|
41
|
+
class Feedle
|
42
|
+
def self.run(config)
|
43
|
+
|
44
|
+
# Create KindleFeeds configuration format
|
45
|
+
sections = config['sections'] || []
|
46
|
+
kfConfig = ""
|
47
|
+
|
48
|
+
sections.each do |section|
|
49
|
+
name = section['name'] || 'Other feeds'
|
50
|
+
items = section['items'] || []
|
51
|
+
|
52
|
+
kfConfig += name + "\n"
|
53
|
+
items.each do |item|
|
54
|
+
kfConfig += item + "\n"
|
55
|
+
end
|
56
|
+
kfConfig += "\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Generate feed HTML file
|
60
|
+
puts "Reading RSS feeds"
|
61
|
+
kfOutput = '/tmp/feeds.html'
|
62
|
+
#kf = KindleFeeds.new(kfConfig)
|
63
|
+
#kf.generate_html(kfOutput)
|
64
|
+
|
65
|
+
# Send created HTML file via email
|
66
|
+
puts "Sending content to Kindle..."
|
67
|
+
m = Mailer.new(config)
|
68
|
+
m.send(kfOutput)
|
69
|
+
|
70
|
+
# Delete created file
|
71
|
+
File.delete(kfOutput)
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: feedle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Rocco Zanni
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-04-08 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: kindle-feeds
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 27
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 6
|
33
|
+
version: 1.0.6
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mail
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 31
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 4
|
48
|
+
- 0
|
49
|
+
version: 2.4.0
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
description: ""
|
53
|
+
email: rocco.zanni@gmail.com
|
54
|
+
executables:
|
55
|
+
- feedle
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files: []
|
59
|
+
|
60
|
+
files:
|
61
|
+
- lib/feedle.rb
|
62
|
+
- bin/feedle
|
63
|
+
homepage: http://github.com/roccozanni/feedle
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.21
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Ruby RSS to Kindle
|
96
|
+
test_files: []
|
97
|
+
|