brandeins-dl 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,4 +3,14 @@ require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
5
  t.pattern = 'test/*_test.rb'
6
+ end
7
+
8
+ task :build do
9
+ sh 'gem build brandeins-dl.gemspec'
10
+ end
11
+
12
+ task :publish do
13
+ require 'lib/brandeins-dl/version'
14
+ version = BrandEins::VERSION
15
+ sh "gem push brandeins-dl-#{version}.gem"
6
16
  end
data/lib/brandeins-dl.rb CHANGED
@@ -12,7 +12,7 @@ end
12
12
  module BrandEins
13
13
 
14
14
  class CLI < Thor
15
- desc "download_all", "Download all magazines of the defined year"
15
+ desc 'download_all', 'Download all magazines of the defined year'
16
16
  method_option :year, :type => :numeric, :required => true
17
17
  method_option :path, :type => :string, :required => true
18
18
  def download_all
@@ -20,7 +20,7 @@ module BrandEins
20
20
  b1.get_magazines_of_year(options.year)
21
21
  end
22
22
 
23
- desc "download", "Download all magazines of the defined year"
23
+ desc 'download', 'Download all magazines of the defined year'
24
24
  method_option :path, :type => :string, :required => true
25
25
  method_option :volume, :type => :numeric, :required => true
26
26
  method_option :year, :type => :numeric, :required => true
@@ -30,6 +30,11 @@ module BrandEins
30
30
  end
31
31
  end
32
32
 
33
+ desc 'version', 'Displays current version'
34
+ def version
35
+ puts BrandEins::VERSION
36
+ end
37
+
33
38
  class Downloader
34
39
  attr_reader :archive
35
40
 
@@ -1,3 +1,3 @@
1
1
  module BrandEins
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -0,0 +1,38 @@
1
+ require File.expand_path('../../lib/brandeins-dl' , __FILE__)
2
+ require 'minitest/autorun'
3
+ require 'fakefs/safe'
4
+
5
+ class TestBrandEinsDownload < MiniTest::Unit::TestCase
6
+ def setup
7
+ @base_url = 'http://www.brandeins.de'
8
+ @dir = 'bdl'
9
+ # Es muss eine Moeglichkeit geben beim Testen zu verhindern, dass
10
+ # die Existenz des Pfades geprueft wird.
11
+ # testing im allgemeinen: http://holmwood.id.au/~lindsay/2008/04/26/hints-for-testing-your-evolving-ruby-scripts/
12
+ end
13
+
14
+ def test_tmp_directories_get_created
15
+ FakeFS do
16
+ bdl = BrandEins::Downloader.new @dir
17
+ assert File.directory?(File.expand_path("./#{@dir}/tmp"))
18
+ end
19
+ end
20
+
21
+ def test_magazine_url_scraping
22
+ html = <<-EOF
23
+ <div class="jahrgang jahrgang-2012 jahrgang-latest">
24
+ <h4>2012</h4>
25
+ <ul>
26
+ <li><a href="magazin/nein-sagen.html" title="Zum Magazin brand eins Online 1 2012" onmouseover="switch_magazine(2012, 1)" onfocus="switch_magazine(2012, 1)"><img src="typo3temp/pics/b9d755e0d1.jpg" width="55" height="73" alt="Ausgabe 01/2012 SCHWERPUNKT NEIN SAGEN"></a> 1</li>
27
+ <li><a href="magazin/markenkommunikation.html" title="Zum Magazin brand eins Online 2 2012" onmouseover="switch_magazine(2012, 2)" onfocus="switch_magazine(2012, 2)"><img src="typo3temp/pics/1dccfc2c74.jpg" width="55" height="73" alt="Ausgabe 02/2012 SCHWERPUNKT Markenkommunikation"></a> 2</li>
28
+ </ul>
29
+ </div>
30
+ EOF
31
+
32
+ archive_site = BrandEins::Downloader::ArchiveSite.new @base_url, html
33
+ magazine_links = archive_site.get_magazine_links_by_year(2012)
34
+ assert_equal magazine_links.length, 2
35
+ assert_equal magazine_links[0], (@base_url + '/magazin/nein-sagen.html')
36
+ assert_equal magazine_links[1], (@base_url + '/magazin/markenkommunikation.html')
37
+ end
38
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: brandeins-dl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gregory Igelmund
@@ -14,7 +14,6 @@ date: 2012-10-06 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
- prerelease: false
18
17
  requirement: &id001 !ruby/object:Gem::Requirement
19
18
  none: false
20
19
  requirements:
@@ -22,10 +21,10 @@ dependencies:
22
21
  - !ruby/object:Gem::Version
23
22
  version: "0"
24
23
  type: :runtime
24
+ prerelease: false
25
25
  version_requirements: *id001
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: thor
28
- prerelease: false
29
28
  requirement: &id002 !ruby/object:Gem::Requirement
30
29
  none: false
31
30
  requirements:
@@ -33,10 +32,10 @@ dependencies:
33
32
  - !ruby/object:Gem::Version
34
33
  version: "0"
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: nokogiri
39
- prerelease: false
40
39
  requirement: &id003 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
@@ -44,6 +43,7 @@ dependencies:
44
43
  - !ruby/object:Gem::Version
45
44
  version: "0"
46
45
  type: :runtime
46
+ prerelease: false
47
47
  version_requirements: *id003
48
48
  description: "BrandEins Downloader offers two commands: 'brandeins download YEAR' and 'brandeins download YEAR --volume=NUMBER'"
49
49
  email:
@@ -64,6 +64,7 @@ files:
64
64
  - brandeins-dl.gemspec
65
65
  - lib/brandeins-dl.rb
66
66
  - lib/brandeins-dl/version.rb
67
+ - test/brandeins-dl_test.rb
67
68
  homepage: http://www.grekko.de
68
69
  licenses: []
69
70
 
@@ -77,12 +78,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
78
  requirements:
78
79
  - - ">="
79
80
  - !ruby/object:Gem::Version
81
+ hash: -3056306205063539156
82
+ segments:
83
+ - 0
80
84
  version: "0"
81
85
  required_rubygems_version: !ruby/object:Gem::Requirement
82
86
  none: false
83
87
  requirements:
84
88
  - - ">="
85
89
  - !ruby/object:Gem::Version
90
+ hash: -3056306205063539156
91
+ segments:
92
+ - 0
86
93
  version: "0"
87
94
  requirements: []
88
95
 
@@ -91,5 +98,5 @@ rubygems_version: 1.8.15
91
98
  signing_key:
92
99
  specification_version: 3
93
100
  summary: BrandEins Downloader allows you to download past volumes of the Brand Eins magazine
94
- test_files: []
95
-
101
+ test_files:
102
+ - test/brandeins-dl_test.rb