raktojson 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7aca4689bf63d5f5d91e785f42c691bc41febb83
4
- data.tar.gz: d3a31285966d08d88cd92ff740aa367d49c6ec72
3
+ metadata.gz: 05d056f064846cf4fd6f281abddfb2c176cd57ac
4
+ data.tar.gz: 9451d74308bc6726fbc496215dd58d9e468fe08a
5
5
  SHA512:
6
- metadata.gz: 7e51a9629bccb84ff401966e59e84fc491364810e8128d9ba334b42970a5cbc9f8ee6533575b483d90c6fbd96ab2792f70a837198744eedc335676a147520120
7
- data.tar.gz: c21493a1f0ea4e5f15dea592bf2334c30f42b208a80e166ca719efd3d1a30ed6ad415662fd23970e46c754aa808d4f6153a397a00c958266c260997801b71807
6
+ metadata.gz: d56532586e0561dfabf25ac85e755c02c28ad75816c38bc7cf8bf89d9b1302de3f9f430be923b85b2f08860199a89af8b7fb64965d922b093084bfb2a01c0fa6
7
+ data.tar.gz: 29de6084b37ae872d6e6ef9abf511c9fa450860a38284f056c927fe0a16a9b7357232a8e9fca58417b48a5c6046d76ce2af8a1f44e46bfbdfb06b1abf0d713f7
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # :pizza: RAKToJSON
2
+ [![License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/maxmouchet/raktojson/blob/master/LICENSE.txt)
3
+ [![Gem Version](https://img.shields.io/gem/v/raktojson.svg?style=flat-square)](https://rubygems.org/gems/raktojson)
4
+ [![Travis Build Status](https://img.shields.io/travis/maxmouchet/raktojson.svg?style=flat-square)](https://travis-ci.org/maxmouchet/raktojson)
2
5
 
3
6
  Parser for Télécom Bretagne restaurant menus.
4
7
 
data/lib/raktojson/cli.rb CHANGED
@@ -19,13 +19,6 @@ module RAKToJSON
19
19
 
20
20
  end.parse(argv)
21
21
 
22
- def download_pdf(link, &block)
23
- destination = "/tmp/#{ SecureRandom.hex(16) }.pdf"
24
- `curl -o #{ destination } #{ link } 2&>/dev/null`
25
- block.call(destination)
26
- File.delete(destination)
27
- end
28
-
29
22
  options[:url] ||= 'http://services.telecom-bretagne.eu/rak/fr/menus_restaurant/'
30
23
 
31
24
  if options[:url].end_with?('.pdf')
@@ -33,17 +26,25 @@ module RAKToJSON
33
26
  links = [ options[:url] ]
34
27
  else
35
28
  $stderr.puts "Downloading menus from #{ options[:url] }"
36
- links = WeekListParser.parse(options[:url])
29
+ links = WeekListParser.parse(open(options[:url]))
37
30
  end
38
31
 
39
32
  $stderr.puts "#{ links.count } menus to parse"
40
33
  links.each do |link|
41
- download_pdf(link) do |pdf|
34
+ self.download_pdf(link) do |pdf|
42
35
  xml_menu = `pdftohtml -xml -stdout -enc UTF-8 #{ pdf }`
43
36
  puts XMLMenuParser.parse(xml_menu)
44
37
  end
45
38
  end
46
39
  end
47
40
 
41
+ private
42
+ def self.download_pdf(link, &block)
43
+ destination = "/tmp/#{ SecureRandom.hex(16) }.pdf"
44
+ `curl -o #{ destination } #{ link } 2&>/dev/null`
45
+ block.call(destination)
46
+ File.delete(destination)
47
+ end
48
+
48
49
  end
49
50
  end
@@ -1,3 +1,3 @@
1
1
  module RAKToJSON
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raktojson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Mouchet