cablegator 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +14 -0
- data/README.md +20 -0
- data/Rakefile +2 -0
- data/bin/download_cables +25 -0
- data/cablegator.gemspec +24 -0
- data/lib/cablegator/version.rb +3 -0
- data/lib/cablegator/wikileaks.rb +12 -0
- data/lib/cablegator.rb +11 -0
- metadata +99 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# cablegator
|
2
|
+
Downloads WikiLeaks CableGate cables for offline viewing and archiving
|
3
|
+
|
4
|
+
Install via:
|
5
|
+
<code>
|
6
|
+
> gem install cablegator
|
7
|
+
</code>
|
8
|
+
|
9
|
+
|
10
|
+
Run Via:
|
11
|
+
<code>
|
12
|
+
$ download_cables ..
|
13
|
+
Downloading cables to /Users/csquared/projects/cablegator
|
14
|
+
You already have 66BUENOSAIRES2481 in /Users/csquared/projects/cablegator/cable/1966/12/66BUENOSAIRES2481.html
|
15
|
+
You already have 72TEHRAN1164 in /Users/csquared/projects/cablegator/cable/1972/02/72TEHRAN1164.html
|
16
|
+
You already have 72TEHRAN5055 in /Users/csquared/projects/cablegator/cable/1972/08/72TEHRAN5055.htm
|
17
|
+
Downloading cable 75TEHRAN2069 to /Users/csquared/projects/cablegator//cable/1975/03/75TEHRAN2069.html
|
18
|
+
...
|
19
|
+
|
20
|
+
</code>
|
data/Rakefile
ADDED
data/bin/download_cables
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require 'cablegator'
|
3
|
+
require 'cablegator/wikileaks'
|
4
|
+
|
5
|
+
dir_prefix = ARGV[0] || Dir.pwd
|
6
|
+
|
7
|
+
puts "Downloading cables to #{File.expand_path(dir_prefix)}"
|
8
|
+
doc = Nokogiri::HTML(WikiLeaks.home)
|
9
|
+
|
10
|
+
doc.css(%{a[href^='/date']}).each do |link|
|
11
|
+
page_with_cables = Nokogiri::HTML(WikiLeaks.get(link.attributes['href'].value))
|
12
|
+
page_with_cables.css(%{a[href^='/cable']}).each do |cable|
|
13
|
+
cable_url = cable.attributes['href'].value
|
14
|
+
file_location = File.expand_path(dir_prefix + cable_url)
|
15
|
+
reference_id = File.basename(cable_url).gsub(File.extname(cable_url),'')
|
16
|
+
|
17
|
+
if !File.exist?(file_location)
|
18
|
+
FileUtils.mkdir_p(File.dirname(file_location))
|
19
|
+
STDOUT.puts "Downloading cable #{reference_id} to #{file_location}"
|
20
|
+
File.open(file_location, 'w') { |f| f << WikiLeaks.get(cable_url) }
|
21
|
+
else
|
22
|
+
STDOUT.puts "You already have #{reference_id} in #{file_location}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/cablegator.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "cablegator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "cablegator"
|
7
|
+
s.version = Cablegator::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["csquared"]
|
10
|
+
s.email = ["christopher.continanza@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Downloads Wikileaks Cables to current directory}
|
13
|
+
s.description = %q{Downloads Wikileaks Cables to current directory}
|
14
|
+
|
15
|
+
s.rubyforge_project = "cablegator"
|
16
|
+
|
17
|
+
s.add_dependency('nokogiri')
|
18
|
+
s.add_dependency('httparty')
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
data/lib/cablegator.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cablegator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 9
|
8
|
+
- 0
|
9
|
+
version: 0.9.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- csquared
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-11 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: nokogiri
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: httparty
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
description: Downloads Wikileaks Cables to current directory
|
47
|
+
email:
|
48
|
+
- christopher.continanza@gmail.com
|
49
|
+
executables:
|
50
|
+
- download_cables
|
51
|
+
extensions: []
|
52
|
+
|
53
|
+
extra_rdoc_files: []
|
54
|
+
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- Gemfile.lock
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- bin/download_cables
|
62
|
+
- cablegator.gemspec
|
63
|
+
- lib/cablegator.rb
|
64
|
+
- lib/cablegator/version.rb
|
65
|
+
- lib/cablegator/wikileaks.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: ""
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: cablegator
|
94
|
+
rubygems_version: 1.3.7
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Downloads Wikileaks Cables to current directory
|
98
|
+
test_files: []
|
99
|
+
|