brandeins 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  .DS_Store
2
2
  *.gem
3
3
  .bundle
4
+ .vagrant
4
5
  pkg/*
6
+ tags
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brandeins (0.2.1)
4
+ brandeins (0.2.2)
5
5
  nokogiri
6
6
  prawn
7
7
  rake
@@ -12,7 +12,6 @@ GEM
12
12
  specs:
13
13
  Ascii85 (1.0.2)
14
14
  addressable (2.3.2)
15
- afm (0.2.0)
16
15
  columnize (0.3.6)
17
16
  crack (0.3.2)
18
17
  debugger (1.3.1)
@@ -24,15 +23,13 @@ GEM
24
23
  debugger-ruby_core_source (1.1.8)
25
24
  hashery (2.1.0)
26
25
  nokogiri (1.5.6)
27
- pdf-reader (1.3.0)
26
+ pdf-reader (1.2.0)
28
27
  Ascii85 (~> 1.0.0)
29
- afm (~> 0.2.0)
30
28
  hashery (~> 2.0)
31
29
  ruby-rc4
32
- ttfunk
33
- prawn (0.12.0)
30
+ prawn (1.0.0.rc1)
34
31
  pdf-reader (>= 0.9.0)
35
- ttfunk (~> 1.0.2)
32
+ ttfunk (~> 1.0.3)
36
33
  rake (10.0.3)
37
34
  ruby-rc4 (0.1.5)
38
35
  thor (0.17.0)
data/README.md CHANGED
@@ -1,26 +1,54 @@
1
- # About BrandEins Downloader
1
+ [![Build Status](https://secure.travis-ci.org/guard/guard.png?branch=master)](http://travis-ci.org/grekko/brandeins) [![Gem Version](https://badge.fury.io/rb/brandeins.png)](http://badge.fury.io/rb/brandeins) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/grekko/brandeins)
2
+
3
+ BrandEins Downloader
4
+ --------
2
5
 
3
6
  BrandEins Downloader is a command line tool to download former volumes
4
- of the german oeconimic magazine "Brand Eins". The articles of former
5
- are available through there website and BrandEins Downloader takes all
6
- these fragmented PDFs, downloads and merges them into a single pdf.
7
+ of the german economy magazine [Brand Eins](http://www.brandeins.de/).
8
+ The articles are available on the websites archive and BrandEins Downloader
9
+ helps a little out to download all single fragmented files and merges them
10
+ into a single pdf.
7
11
 
8
12
 
9
- ## Requirements
13
+ Requirements
14
+ --------
10
15
  BrandEins Downloader uses [*pdftk*](http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) and depends on *ruby*, *rubygems*, and
11
16
  several ruby libraries (that you can get through rubygems)
12
17
 
13
18
 
14
- ## Install
15
- `gem install brandeins`
19
+ Install
20
+ --------
21
+
22
+ ```bash
23
+ gem install brandeins
24
+ ```
25
+
26
+
27
+ Usage
28
+ --------
29
+ Download just a certain single magazine
30
+
31
+ ```bash
32
+ brandeins download --path=/Path/where/to/download/the/files --year=2011 --volume=5
33
+ ```
34
+
35
+ Download the whole collection of a year
36
+
37
+ ```bash
38
+ brandeins download --path=/Path/where/to/download/the/files --year=2011 --all
39
+ ```
16
40
 
17
41
 
18
- ## Usage
42
+ Development
43
+ --------
44
+ Pull requests are very welcome! Please try to follow these simple rules if applicable:
45
+ - Please create a topic branch for every separate change you make.
46
+ - Update the README.
19
47
 
20
- Download just one magazine
21
48
 
22
- `brandeins download --path=/Path/where/to/download/the/files --year=2011 --volume=5`
49
+ ### Author
50
+ [Gregory Igelmund](https://github.com/grekko) [(@grekko)](https://twitter.com/grekko)
23
51
 
24
- Download the whole collecion of a certain year
25
52
 
26
- `brandeins download --path=/Path/where/to/download/the/files --year=2011 --all`
53
+ ### Contributors
54
+ [Thorben Schröder](https://github.com/walski)
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require './lib/brandeins/version'
4
3
 
5
4
  Rake::TestTask.new do |t|
6
5
  t.test_files = FileList['test/*_test.rb', 'specs/*_spec.rb']
@@ -8,11 +7,12 @@ Rake::TestTask.new do |t|
8
7
  end
9
8
 
10
9
  task :install do
10
+ require './lib/brandeins/version'
11
11
  sh "gem install ./pkg/brandeins-#{BrandEins::VERSION}.gem"
12
12
  end
13
13
 
14
14
  task publish: [ :build ] do
15
- version = BrandEins::VERSION
15
+ require './lib/brandeins/version'
16
16
  sh "gem push ./pkg/brandeins-#{BrandEins::VERSION}.gem"
17
17
  end
18
18
 
data/Vagrantfile ADDED
@@ -0,0 +1,99 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "archlinux"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ # config.vm.box_url = "http://domain.com/path/to/above.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ # config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file archlinux.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ # config.vm.provision :puppet do |puppet|
58
+ # puppet.manifests_path = "manifests"
59
+ # puppet.manifest_file = "archlinux.pp"
60
+ # end
61
+
62
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
63
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
64
+ # some recipes and/or roles.
65
+ #
66
+ # config.vm.provision :chef_solo do |chef|
67
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
68
+ # chef.roles_path = "../my-recipes/roles"
69
+ # chef.data_bags_path = "../my-recipes/data_bags"
70
+ # chef.add_recipe "mysql"
71
+ # chef.add_role "web"
72
+ #
73
+ # # You may also specify custom JSON attributes:
74
+ # chef.json = { :mysql_password => "foo" }
75
+ # end
76
+
77
+ # Enable provisioning with chef server, specifying the chef server URL,
78
+ # and the path to the validation key (relative to this Vagrantfile).
79
+ #
80
+ # The Opscode Platform uses HTTPS. Substitute your organization for
81
+ # ORGNAME in the URL and validation key.
82
+ #
83
+ # If you have your own Chef Server, use the appropriate URL, which may be
84
+ # HTTP instead of HTTPS depending on your configuration. Also change the
85
+ # validation key to validation.pem.
86
+ #
87
+ # config.vm.provision :chef_client do |chef|
88
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
89
+ # chef.validation_key_path = "ORGNAME-validator.pem"
90
+ # end
91
+ #
92
+ # If you're using the Opscode platform, your validator client is
93
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
94
+ #
95
+ # IF you have your own Chef Server, the default validation client name is
96
+ # chef-validator, unless you changed the configuration.
97
+ #
98
+ # chef.validation_client_name = "ORGNAME-validator"
99
+ end
data/brandeins.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- load File.expand_path("../lib/brandeins/version.rb", __FILE__)
3
+ require File.expand_path("../lib/brandeins/version.rb", __FILE__) unless defined? BrandEins::Version
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "brandeins"
data/lib/brandeins.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'brandeins/version'
4
+ require 'brandeins/errors'
4
5
  require 'brandeins/downloader'
5
6
  require 'brandeins/setup'
6
7
  require 'brandeins/cli'
@@ -69,12 +69,11 @@ module BrandEins
69
69
  pdf_files = download(pdf_links)
70
70
 
71
71
  pdf_cover = create_cover_pdf(year, volume)
72
- pdf_files = pdf_files.reverse.push(pdf_cover).reverse
72
+ pdf_files = pdf_files.unshift(pdf_cover)
73
73
 
74
- if !@pdftool.nil?
74
+ if @pdftool
75
75
  target_pdf_path = "#{@dl_dir}/#{target_pdf}"
76
- @pdftool.merge_pdf_files(pdf_files, target_pdf_path)
77
- cleanup
76
+ @pdftool.merge_pdf_files(pdf_files, target_pdf_path) && cleanup
78
77
  else
79
78
  puts 'brandeins wont merge the single pdf files since it didnt find an appropriate pdf tool' if $BE_VERBOSE
80
79
  end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module BrandEins
4
+ class Error < StandardError; end
5
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module BrandEins
4
4
  module Merger
5
- module Templates
5
+ module External
6
6
 
7
7
  class Base
8
8
 
@@ -29,7 +29,11 @@ module BrandEins
29
29
 
30
30
  private
31
31
  def _exec (cmd)
32
- IO.popen(cmd)
32
+ IO.popen(cmd) do |io|
33
+ io.each do |line|
34
+ puts line
35
+ end
36
+ end
33
37
  end
34
38
 
35
39
  def _cmd_available? (cmd, args)
@@ -2,9 +2,9 @@
2
2
 
3
3
  module BrandEins
4
4
  module Merger
5
- module Templates
5
+ module External
6
6
 
7
- class GhostscriptWin < BrandEins::Merger::Templates::Windows
7
+ class GhostscriptWindows < BrandEins::Merger::External::Base
8
8
 
9
9
  def cmd
10
10
  'gswin64c.exe'
@@ -2,9 +2,9 @@
2
2
 
3
3
  module BrandEins
4
4
  module Merger
5
- module Templates
5
+ module External
6
6
 
7
- class PdftkOSX < BrandEins::Merger::Templates::OSX
7
+ class Pdftk < BrandEins::Merger::External::Base
8
8
 
9
9
  def cmd
10
10
  'pdftk'
@@ -1,45 +1,29 @@
1
1
  # encoding: utf-8
2
- require 'brandeins/merger/extensions'
3
- require 'brandeins/merger/templates/base'
4
- require 'brandeins/merger/templates/osx'
5
- require 'brandeins/merger/templates/pdftk_osx'
6
- require 'brandeins/merger/templates/windows'
7
- require 'brandeins/merger/templates/ghostscript_windows'
2
+ require 'brandeins/merger/external/base'
3
+ require 'brandeins/merger/external/pdftk'
4
+ require 'brandeins/merger/external/ghostscript_windows'
8
5
 
9
6
  module BrandEins
10
7
  module Merger
11
8
  class PdfTools
12
9
 
13
10
  class << self
14
- def get_pdf_tool(env = nil)
15
- @env = env || {}
16
- @env[:os] ||= RUBY_PLATFORM
17
-
18
- init_pdf_tools and return_pdf_tool
11
+ def get_pdf_tool(env = {})
12
+ env = env || {}
13
+ env[:os] ||= RUBY_PLATFORM
14
+ get_klass_for_external(env).new
19
15
  end
20
16
 
21
17
  private
22
- def init_pdf_tools
23
- template_group = choose_template_group
24
- @pdf_tools = get_subclasses template_group
25
- end
26
-
27
- def choose_template_group
28
- return BrandEins::Merger::Templates::Windows if @env[:os].include? 'w32'
29
- return BrandEins::Merger::Templates::OSX if @env[:os].include? 'darwin'
30
- end
31
18
 
32
- def get_subclasses(klass)
33
- classes = []
34
- klass.subclasses.each do |sklass|
35
- classes << sklass.new
19
+ def get_klass_for_external(env)
20
+ if env[:os].include? 'w32'
21
+ BrandEins::Merger::External::GhostscriptWindows
22
+ else
23
+ BrandEins::Merger::External::Pdftk
36
24
  end
37
25
  end
38
26
 
39
- def return_pdf_tool
40
- @pdf_tools.first.new if @pdf_tools.length > 0
41
- end
42
-
43
27
  end
44
28
 
45
29
  end
@@ -4,7 +4,7 @@ module BrandEins
4
4
  class Setup
5
5
 
6
6
  def initialize(env = {})
7
- @os = env[:os] || RUBY_PLATFORM
7
+ @os = env[:os] || RUBY_PLATFORM
8
8
  @pdf_tool = env[:pdf_tool] || BrandEins::Merger::PdfTools.get_pdf_tool(env)
9
9
  end
10
10
 
@@ -1,3 +1,3 @@
1
1
  module BrandEins
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brandeins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -91,18 +91,17 @@ files:
91
91
  - README.md
92
92
  - Rakefile
93
93
  - TODOS.md
94
+ - Vagrantfile
94
95
  - bin/brandeins
95
96
  - brandeins.gemspec
96
97
  - lib/brandeins.rb
97
98
  - lib/brandeins/cli.rb
98
99
  - lib/brandeins/downloader.rb
99
- - lib/brandeins/merger/extensions.rb
100
+ - lib/brandeins/errors.rb
101
+ - lib/brandeins/merger/external/base.rb
102
+ - lib/brandeins/merger/external/ghostscript_windows.rb
103
+ - lib/brandeins/merger/external/pdftk.rb
100
104
  - lib/brandeins/merger/pdf_tools.rb
101
- - lib/brandeins/merger/templates/base.rb
102
- - lib/brandeins/merger/templates/ghostscript_windows.rb
103
- - lib/brandeins/merger/templates/osx.rb
104
- - lib/brandeins/merger/templates/pdftk_osx.rb
105
- - lib/brandeins/merger/templates/windows.rb
106
105
  - lib/brandeins/parser/archive_site.rb
107
106
  - lib/brandeins/parser/article_site.rb
108
107
  - lib/brandeins/parser/magazine_site.rb
@@ -134,21 +133,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
133
  - - ! '>='
135
134
  - !ruby/object:Gem::Version
136
135
  version: '0'
137
- segments:
138
- - 0
139
- hash: 1329463463916465473
140
136
  required_rubygems_version: !ruby/object:Gem::Requirement
141
137
  none: false
142
138
  requirements:
143
139
  - - ! '>='
144
140
  - !ruby/object:Gem::Version
145
141
  version: '0'
146
- segments:
147
- - 0
148
- hash: 1329463463916465473
149
142
  requirements: []
150
143
  rubyforge_project:
151
- rubygems_version: 1.8.24
144
+ rubygems_version: 1.8.25
152
145
  signing_key:
153
146
  specification_version: 3
154
147
  summary: BrandEins gem allows you to download past volumes of the Brand Eins magazine
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Class
4
-
5
- def subclasses
6
- ObjectSpace.each_object(Class).select { |klass| klass < self }
7
- end
8
-
9
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module BrandEins
4
- module Merger
5
- module Templates
6
-
7
- class OSX < BrandEins::Merger::Templates::Base; end
8
-
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module BrandEins
4
- module Merger
5
- module Templates
6
-
7
- class Windows < BrandEins::Merger::Templates::Base; end
8
-
9
- end
10
- end
11
- end