Html2Feedbooks 1.0.10 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/html2fb.rb +27 -1
- data/lib/conf.rb +4 -0
- metadata +20 -42
data/bin/html2fb.rb
CHANGED
@@ -8,6 +8,7 @@ require 'parser.rb'
|
|
8
8
|
require 'feedbooks.rb'
|
9
9
|
require 'tmpdir'
|
10
10
|
require 'launchy'
|
11
|
+
require 'digest/md5'
|
11
12
|
|
12
13
|
include HTML2FB
|
13
14
|
|
@@ -27,10 +28,13 @@ OptionParser.new do |opts|
|
|
27
28
|
opts.on("-nc", "--no-conv","No charset conversion") do |f|
|
28
29
|
options[:conv] = !f
|
29
30
|
end
|
31
|
+
opts.on("-C", "--cache", String,"Configuration file") do |f|
|
32
|
+
options[:cache] = !f
|
33
|
+
end
|
30
34
|
end.parse!
|
31
|
-
|
32
35
|
valid=false
|
33
36
|
entry=ARGV[0]
|
37
|
+
basedir=Dir.tmpdir+'/'
|
34
38
|
while !valid
|
35
39
|
url=nil
|
36
40
|
begin
|
@@ -45,9 +49,31 @@ while !valid
|
|
45
49
|
entry=STDIN.readline.strip unless valid
|
46
50
|
end
|
47
51
|
conf=Conf.new(options[:conf],options[:conv])
|
52
|
+
abridged_conf=conf.to_h.reject{|k,v| k=='fb'}
|
48
53
|
content=Downloader.download(url)
|
54
|
+
cache={}
|
55
|
+
ok=false
|
56
|
+
if options[:cache] && File.exists?(basedir+'.cache')
|
57
|
+
cache=Marshal.restore(File.open(basedir+'.cache','r'))
|
58
|
+
ok=Digest::MD5.hexdigest(content)==Digest::MD5.hexdigest(cache[:content])
|
59
|
+
abridged_conf.each do |k,v|
|
60
|
+
# puts (abridged_conf[k]==cache[:conf][k]).inspect
|
61
|
+
# puts (abridged_conf[k]).inspect
|
62
|
+
# puts (cache[:conf][k]).inspect
|
63
|
+
# puts "-_-_-_-_"
|
64
|
+
ok&&=abridged_conf[k]==cache[:conf][k]
|
65
|
+
end
|
66
|
+
end
|
49
67
|
#puts content.size
|
68
|
+
if options[:cache] && ok
|
69
|
+
puts "Using cache file"
|
70
|
+
doc=cache[:doc]
|
71
|
+
else
|
50
72
|
doc=Parser.new(conf).parse(content)
|
73
|
+
end
|
74
|
+
File.open(basedir+'.cache','w') do |e|
|
75
|
+
Marshal.dump({:url => url,:conf => abridged_conf, :content => content, :doc => doc},e)
|
76
|
+
end
|
51
77
|
puts doc.toc.to_yaml
|
52
78
|
if options[:preview]
|
53
79
|
page=File.join(Dir.tmpdir(),Digest::MD5.hexdigest(url.to_s))+'.html'
|
data/lib/conf.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Html2Feedbooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 10
|
9
|
-
version: 1.0.10
|
4
|
+
version: 1.1.0
|
10
5
|
platform: ruby
|
11
6
|
authors:
|
12
7
|
- Benoit Larroque
|
@@ -19,59 +14,44 @@ default_executable: html2fb.rb
|
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: hpricot
|
22
|
-
|
23
|
-
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
- 8
|
30
|
-
- 1
|
31
23
|
version: 0.8.1
|
32
|
-
|
33
|
-
version_requirements: *id001
|
24
|
+
version:
|
34
25
|
- !ruby/object:Gem::Dependency
|
35
26
|
name: htmlentities
|
36
|
-
|
37
|
-
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
30
|
requirements:
|
39
31
|
- - ">="
|
40
32
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 4
|
43
|
-
- 2
|
44
|
-
- 1
|
45
33
|
version: 4.2.1
|
46
|
-
|
47
|
-
version_requirements: *id002
|
34
|
+
version:
|
48
35
|
- !ruby/object:Gem::Dependency
|
49
36
|
name: launchy
|
50
|
-
|
51
|
-
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
40
|
requirements:
|
53
41
|
- - ">="
|
54
42
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
- 3
|
58
43
|
version: "0.3"
|
59
|
-
|
60
|
-
version_requirements: *id003
|
44
|
+
version:
|
61
45
|
- !ruby/object:Gem::Dependency
|
62
46
|
name: progressbar
|
63
|
-
|
64
|
-
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
50
|
requirements:
|
66
51
|
- - ">="
|
67
52
|
- !ruby/object:Gem::Version
|
68
|
-
segments:
|
69
|
-
- 0
|
70
|
-
- 0
|
71
|
-
- 3
|
72
53
|
version: 0.0.3
|
73
|
-
|
74
|
-
version_requirements: *id004
|
54
|
+
version:
|
75
55
|
description: Html2Feedbooks is script to automate basic publishing on feedbooks.com
|
76
56
|
email: zeta dot ben at gmail dot com
|
77
57
|
executables:
|
@@ -103,20 +83,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
83
|
requirements:
|
104
84
|
- - ">="
|
105
85
|
- !ruby/object:Gem::Version
|
106
|
-
segments:
|
107
|
-
- 0
|
108
86
|
version: "0"
|
87
|
+
version:
|
109
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
89
|
requirements:
|
111
90
|
- - ">="
|
112
91
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
92
|
version: "0"
|
93
|
+
version:
|
116
94
|
requirements: []
|
117
95
|
|
118
96
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.3.
|
97
|
+
rubygems_version: 1.3.5
|
120
98
|
signing_key:
|
121
99
|
specification_version: 3
|
122
100
|
summary: Html2Feedbooks is script to automate basic publishing on feedbooks.com
|