brandeins 0.1.3 → 0.1.5

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.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  *.gem
2
3
  .bundle
3
4
  Gemfile.lock
data/Rakefile CHANGED
@@ -6,13 +6,13 @@ Rake::TestTask.new do |t|
6
6
  t.pattern = 'test/*_test.rb'
7
7
  end
8
8
 
9
- task :build do
10
- sh 'gem build brandeins.gemspec'
9
+ task :install do
10
+ sh "gem install ./pkg/brandeins-#{BrandEins::VERSION}.gem"
11
11
  end
12
12
 
13
- task :publish do
13
+ task publish: [ :build ] do
14
14
  version = BrandEins::VERSION
15
- sh "gem push brandeins-#{version}.gem"
15
+ sh "gem push ./pkg/brandeins-#{BrandEins::VERSION}.gem"
16
16
  end
17
17
 
18
18
  task :default => :test
@@ -32,7 +32,7 @@ module BrandEins
32
32
  method_option :all
33
33
  method_option :year, :type => :numeric
34
34
  def download
35
- path = options.path || Dir.pwd
35
+ path = options.path ? File.expand_path(options.path) : Dir.pwd
36
36
  year = options.year || Time.new.year
37
37
  all = options.all
38
38
  volume = options.volume
@@ -40,11 +40,11 @@ module BrandEins
40
40
  if volume.nil? && all.nil?
41
41
  puts "If you want to download a specific volune use the --volume flag or use --all to download all volumes of a year"
42
42
  else
43
- b1 = BrandEins::Downloader.new path
43
+ downloader = BrandEins::Downloader.new path
44
44
  if !all.nil?
45
- b1.get_magazines_of_year year
45
+ downloader.get_magazines_of_year year
46
46
  else
47
- b1.get_magazine year, volume
47
+ downloader.get_magazine year, volume
48
48
  end
49
49
  end
50
50
  end
@@ -112,7 +112,8 @@ module BrandEins
112
112
  pdf_files = pdf_files.reverse.push(pdf_cover).reverse
113
113
 
114
114
  if !@pdftool.nil?
115
- @pdftool.merge_pdf_files(pdf_files, target_pdf)
115
+ target_pdf_path = "#{@dl_dir}/#{target_pdf}"
116
+ @pdftool.merge_pdf_files(pdf_files, target_pdf_path)
116
117
  cleanup
117
118
  else
118
119
  if RUBY_PLATFORM.include? 'darwin'
@@ -20,11 +20,10 @@ module BrandEins
20
20
 
21
21
  def merge_pdf_files(pdf_files, target_pdf)
22
22
  begin
23
- puts "args: #{@args}"
24
- arg_files = pdf_files.join " "
25
- args = self.args.gsub(/__pdf_files__/, arg_files).gsub(/__target_pdf__/, target_pdf)
23
+ pdf_files_arg = pdf_files.map {|pdf_file| "'#{pdf_file}'" }.join ' '
24
+ args = self.args.join(' ').gsub(/__pdf_files__/, pdf_files_arg).gsub(/__target_pdf__/, target_pdf)
26
25
  puts "executing: #{@cmd} #{args}"
27
- open("|#{@cmd} #{args}").close
26
+ IO.popen("#{@cmd} #{args}") { |f| puts f.gets }
28
27
  rescue Exception => e
29
28
  puts "error: #{e.inspect}"
30
29
  return false
@@ -49,16 +48,16 @@ module BrandEins
49
48
  class PdftkOSX < TemplateOSX
50
49
  def initialize
51
50
  @cmd = 'pdftk'
52
- @args = '__pdf_files__ output __target_pdf__'
53
- @noop = ' --version'
51
+ @args = ['__pdf_files__', 'output', '__target_pdf__']
52
+ @noop = ['--version']
54
53
  end
55
54
  end
56
55
 
57
56
  class GhostscriptWin < TemplateWin
58
57
  def initialize
59
58
  @cmd = 'gswin64c.exe'
60
- @args = ' -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=__target_pdf__ __pdf_files__'
61
- @noop = ' --version'
59
+ @args = ['-dNOPAUSE', '-dBATCH', '-sDEVICE=pdfwrite', '-sOutputFile=__target_pdf__', '__pdf_files__']
60
+ @noop = ['--version']
62
61
  end
63
62
  end
64
63
 
@@ -1,3 +1,3 @@
1
1
  module BrandEins
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -13,14 +13,6 @@ class TestBrandEinsDownload < MiniTest::Unit::TestCase
13
13
  # testing im allgemeinen: http://holmwood.id.au/~lindsay/2008/04/26/hints-for-testing-your-evolving-ruby-scripts/
14
14
  end
15
15
 
16
- def test_tmp_directories_get_created
17
- skip
18
- FakeFS do
19
- #bdl = BrandEins::Downloader.new @dir
20
- #assert File.directory?(File.expand_path("./#{@dir}/tmp"))
21
- end
22
- end
23
-
24
16
  def test_magazine_url_scraping
25
17
  html = <<-EOF
26
18
  <div class="jahrgang jahrgang-2012 jahrgang-latest">
@@ -71,15 +63,4 @@ class TestBrandEinsDownload < MiniTest::Unit::TestCase
71
63
  assert_equal "Checking requirements for your system\n\nIt seems you have magic running on your system. You are ready to go!\n", out.string
72
64
  end
73
65
 
74
- def test_brandeins_setup_missing_pdf_tool_path
75
- pdf_tool = Object.new
76
- pdf_tool.define_singleton_method :available? do false end
77
- pdf_tool.define_singleton_method :cmd do 'magic' end
78
-
79
- capture_stdout do
80
- BrandEins::Setup.new :os => 'x86_64-darwin12.2.0', :pdf_tool => pdf_tool
81
- end
82
-
83
- assert_equal "Checking requirements for your system\n\nIt seems you have magic running on your system. You are ready to go!\n", out.string
84
- end
85
66
  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.1.3
4
+ version: 0.1.5
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: 2012-11-13 00:00:00.000000000 Z
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  segments:
121
121
  - 0
122
- hash: -590436749218099656
122
+ hash: 1431581098543037223
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  none: false
125
125
  requirements:
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  segments:
130
130
  - 0
131
- hash: -590436749218099656
131
+ hash: 1431581098543037223
132
132
  requirements: []
133
133
  rubyforge_project:
134
134
  rubygems_version: 1.8.24