sq 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sq +1 -0
  3. data/lib/sq.rb +9 -6
  4. data/lib/version.rb +9 -0
  5. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13322e186f26b4bfd9d0d549d9e431d11e5eb204
4
- data.tar.gz: 27fef1a017cedea1b8f624fa69933197b7914801
3
+ metadata.gz: 41ba49d5ce6c8cf47cbf2b2ac14b6cec6a937bd5
4
+ data.tar.gz: bea18aa8b03dd5770bd957befc8bb4f86f4f97a5
5
5
  SHA512:
6
- metadata.gz: c9323f2d65d1dae55a2d0ecceb979f983ef62584759dbcadc4a7c6cd63df1e1091f042c3f748df794ad9fa40e60aa0bbbcbb6c93d4b6e6815e00788c9117b815
7
- data.tar.gz: 4c1916d0f879fa8e16445e85beaa3545823bdb9e371373429469acdc0adb8ca7ee73d66ad2cdf1405792beb3d9085b091080f6b41f008d01be433d05b5163ddb
6
+ metadata.gz: d005f3c16ead6a5cfd85a5f5e0f155ebe7a041eaf8a295ad809645ccb28140dee885e11e26c28d8c795766b14318586ac02ba4e4c3bfa81c3ac64070618635a3
7
+ data.tar.gz: d648efad30b62583ae3da4d06dd658c95664321075cbe6917fc17031bbbf3554ecd58088b8469f7ba1f11d822f27a5ca4f7b6109400cddf2225796f43eb90427
data/bin/sq CHANGED
@@ -15,6 +15,7 @@ where [options] are:
15
15
  EOS
16
16
 
17
17
  opt :directory, 'Choose the output directory', :short => '-o', :type => :string, :default => '.'
18
+ opt :verbose, 'Print more info', :short => '-V', :type => :bool, :default => false
18
19
  end
19
20
 
20
21
  if ARGV.empty?
data/lib/sq.rb CHANGED
@@ -1,17 +1,13 @@
1
- #! /usr/bin/env ruby
2
1
  # -*- coding: UTF-8 -*-
3
2
 
4
3
  require 'uri'
5
4
  require 'open-uri'
6
5
  require 'nokogiri'
7
6
  require 'fileutils'
7
+ require File.expand_path(File.dirname __FILE__) + '/version'
8
8
 
9
9
  module SQ
10
10
  class << self
11
- def version
12
- '0.0.1'
13
- end
14
-
15
11
  def user_agent
16
12
  "SQ/#{version} +github.com/bfontaine/sq"
17
13
  end
@@ -35,13 +31,20 @@ module SQ
35
31
 
36
32
  def process(uri, regex=/./, opts={})
37
33
  uris = self.query(uri, regex)
34
+
35
+ puts "Found #{uris.count} PDFs." if opts[:verbose]
36
+
38
37
  return 0 if uris.empty?
39
38
 
40
39
  out = File.expand_path(opts[:directory] || '.')
41
40
 
42
- Dir.mkdir(out) unless Dir.exists?(out)
41
+ unless Dir.exists?(out)
42
+ puts "-> mkdir #{out}" if opts[:verbose]
43
+ Dir.mkdir(out)
44
+ end
43
45
 
44
46
  uris.each do |u|
47
+ puts "Downloading #{u[:name]}..." if opts[:verbose]
45
48
  open("#{out}/#{u[:name]}", 'wb') do |f|
46
49
  open(u[:uri], 'rb') do |resp|
47
50
  f.write(resp.read)
data/lib/version.rb ADDED
@@ -0,0 +1,9 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ module SQ
4
+ class << self
5
+ def version
6
+ '0.0.2'
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Baptiste Fontaine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-10 00:00:00.000000000 Z
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -116,6 +116,7 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - lib/sq.rb
119
+ - lib/version.rb
119
120
  - tests/tests.rb
120
121
  - bin/sq
121
122
  homepage: https://github.com/bfontaine/sq