Skip to content

Commit

Permalink
turned it into a rubygem
Browse files Browse the repository at this point in the history
  • Loading branch information
jfahrenkrug committed Jun 12, 2013
1 parent 300f64e commit e4f2f5c
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 29 deletions.
16 changes: 16 additions & 0 deletions Gemfile
@@ -0,0 +1,16 @@
source "https://rubygems.org"

# If you make any changes in this file, please run `bundle install`.
# If new versions of your installed gems are available, run `bundle update`

gem "mechanize", "~> 2.7.1"
gem "json", "~> 1.8.0"
gem "highline", "~> 1.6.19"
gem "nokogiri", "~> 1.5.0"

group :development do
#gem "shoulda", ">= 0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.8.0"
gem "rcov", ">= 0"
end
49 changes: 49 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,49 @@
GEM
remote: https://rubygems.org/
specs:
domain_name (0.5.12)
unf (>= 0.0.5, < 1.0.0)
git (1.2.5)
highline (1.6.19)
http-cookie (1.0.1)
domain_name (~> 0.5)
jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.8.0)
mechanize (2.7.1)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0.0)
mime-types (~> 1.17, >= 1.17.2)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
mime-types (1.23)
net-http-digest_auth (1.3)
net-http-persistent (2.8)
nokogiri (1.5.10)
ntlm-http (0.1.1)
rake (10.0.4)
rcov (0.9.9)
rdoc (4.0.1)
json (~> 1.4)
unf (0.1.1)
unf_ext
unf_ext (0.0.6)
webrobots (0.1.1)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.0.0)
highline (~> 1.6.19)
jeweler (~> 1.8.0)
json (~> 1.8.0)
mechanize (~> 2.7.1)
nokogiri (~> 1.5.0)
rcov
20 changes: 20 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,20 @@
Copyright (c) 2013 Johannes Fahrenkrug

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 changes: 25 additions & 0 deletions Rakefile
@@ -0,0 +1,25 @@
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'

require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "wwdcdownloader"
gem.homepage = "https://github.com/jfahrenkrug/WWDC-Downloader"
gem.license = "MIT"
gem.summary = %Q{A small tool to download all the sample code of Apple's latest WWDC developer conference}
gem.description = %Q{At each year's WWDC, Apple releases great sample projects. Unfortunately it is very tedious to manually download all these treasures through your browser. WWDC-Downloader solves this problem for you!}
gem.email = "johannes@springenwerk.com"
gem.authors = ["Johannes Fahrenkrug"]

# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new
12 changes: 8 additions & 4 deletions Readme.md
Expand Up @@ -5,13 +5,17 @@
## Sad days are over

This script will download all the session material for you if you are a WWDC 2013 attendee OR NOT! This year you only need to have an Apple Developer account, that's it!
You'll need ruby and the `mechanize`, `highline` and `json` ruby gems. You can install them like this:
You can now simply install WWDC-Downloader as a ruby gem like this:

sudo gem install mechanize json highline
gem install wwdcdownloader

You simply run the script like this:
or

ruby wwdcdownloader.rb <your Apple ID> [<target-dir>]
sudo gem install wwdcdownloader

Run the script like this:

wwdcdownloader <your Apple ID> [<target-dir>]

The script will create a directory called "wwdc2013-assets" (or <target-dir> if given) in the directory you run the script from.

Expand Down
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
20.13.0
6 changes: 6 additions & 0 deletions bin/wwdcdownloader
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'wwdcdownloader.rb'

exit WWDCDownloader.run!(*ARGV)

50 changes: 25 additions & 25 deletions wwdcdownloader.rb → lib/wwdcdownloader.rb
@@ -1,4 +1,5 @@
# Have fun. Use at your own risk.
# Copyright (c) 2013 Johannes Fahrenkrug

require 'rubygems'
require 'fileutils'
Expand All @@ -13,31 +14,15 @@
puts "You need to have the mechanize, json and highline gems installed."
puts "Install them by running"
puts
puts " gem install mechanize json highline"
puts " bundle install"
puts
puts "or"
puts "and then run the script like this:"
puts
puts " sudo gem install mechanize json highline"
puts " bundle exec ruby lib/wwdcdownloader.rb"
puts
exit
end

puts "WWDC 2013 Session Material Downloader"
puts "by Johannes Fahrenkrug, @jfahrenkrug, springenwerk.com"
puts "See you next year!"
puts

if ARGV.size < 1
puts "Usage: ruby wwdcdownloader.rb <your Apple ID> [<target-dir>]"
exit
end

dl_dir = if ARGV.size > 1
ARGV.last
else
'wwdc2013-assets'
end

class WWDCDownloader
BASE_URI = 'https://developer.apple.com/wwdc-services/cy4p09ns/a4363cb15472b00287b/sessions.json'

Expand Down Expand Up @@ -230,11 +215,26 @@ def load

puts "Done."
end
end

w = WWDCDownloader.new(dl_dir, '2013-06-10')
w.login
w.load

def self.run!(*args)
puts "WWDC 2013 Session Material Downloader"
puts "by Johannes Fahrenkrug, @jfahrenkrug, springenwerk.com"
puts "See you next year!"
puts

if args.size < 1
puts "Usage: wwdcdownloader <your Apple ID> [<target-dir>]"
exit
end

dl_dir = if args.size > 1
args.last
else
'wwdc2013-assets'
end

w = WWDCDownloader.new(dl_dir, '2013-06-10')
w.login
w.load
end
end

0 comments on commit e4f2f5c

Please sign in to comment.