zetaben-Html2Feedbooks 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/html2fb.rb +5 -2
  2. data/lib/parser.rb +4 -0
  3. metadata +11 -1
data/bin/html2fb.rb CHANGED
@@ -6,6 +6,8 @@ require 'downloader.rb'
6
6
  require 'document.rb'
7
7
  require 'parser.rb'
8
8
  require 'feedbooks.rb'
9
+ require 'tmpdir'
10
+ require 'launchy'
9
11
 
10
12
  include HTML2FB
11
13
 
@@ -44,10 +46,11 @@ content=Downloader.download(url)
44
46
  doc=Parser.new(conf).parse(content)
45
47
  puts doc.toc.to_yaml
46
48
  if options[:preview]
47
- f=File.open('/tmp/plop.html','w')
49
+ page=File.join(Dir.tmpdir(),Digest::MD5.hexdigest(url))+'.html'
50
+ f=File.open(page,'w')
48
51
  f.write doc.to_html
49
52
  f.close
50
- `firefox /tmp/plop.html`
53
+ Launchy::Browser.run('file://'+page)
51
54
  else
52
55
  doc.to_feedbooks(conf)
53
56
  end
data/lib/parser.rb CHANGED
@@ -67,6 +67,10 @@ module HTML2FB
67
67
 
68
68
  def parse_text(doc,ret)
69
69
  ti = doc.search('//'+@conf['select']['expr'])
70
+ if ti.nil?
71
+ STDERR.puts "No #{@conf['select']['expr']} found"
72
+ return
73
+ end
70
74
  tit = ti.zip ti[1..-1]+[nil]
71
75
 
72
76
  tit.each do |a|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zetaben-Html2Feedbooks
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.2"
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoit Larroque
@@ -32,6 +32,16 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: "4.0"
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: launchy
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0.3"
44
+ version:
35
45
  description: Html2Feedbooks is script to automate basic publishing on feedbooks.com
36
46
  email: zeta dot ben at gmail dot com
37
47
  executables: