warchiver 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +1 -0
- data/lib/warchiver.rb +57 -0
- data/lib/warchiver/version.rb +3 -0
- data/warchiver.gemspec +23 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e746628b1b220f3b242900de86be830aef1fe3f
|
4
|
+
data.tar.gz: cfc4a2070911e5ab0c4f0e6e7e4e9f2985417222
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0790a82802b6e86d05951137564dd39b42610cf35baefbe73062a64bdd078910459c0898f2bd5572014df9e9731be430cd0e410c53cb82c5256ca5750deac1d8
|
7
|
+
data.tar.gz: b653cfc109f64816de092ccab05be22b43fffc4fad29eecdeb6302e2ddacf93ebefd34dbc1d742f883946e740522fbf58be401e5b7c766e86716e3d6e7a65486
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jude Rosen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Warchiver
|
2
|
+
|
3
|
+
Warchiver is a simple Web Archiver. It will maintain a well-organized archive of files from the web. Find on https://rubygems.org/gems/warchiver.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'warchiver'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install warchiver
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### Installation
|
22
|
+
|
23
|
+
`[sudo] gem install warchiver`
|
24
|
+
|
25
|
+
Then just require it:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'warchiver'
|
29
|
+
```
|
30
|
+
|
31
|
+
### Configuration
|
32
|
+
|
33
|
+
Warchiver allows for some configurable options, like the user agent that the request will be made with and the base file system (where to store all of you stuff). You can configure Warchiver like so,
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Warchiver.configure do |config|
|
37
|
+
config.base_directory = "/path/to/archive/directory/"
|
38
|
+
config.user_agent = "Whatever/user/agent/you/want"
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
The defaults are:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
base_directory = "/"
|
46
|
+
user_agent = "Ruby/#{RUBY_VERSION}/Warchiver"
|
47
|
+
```
|
48
|
+
|
49
|
+
### Running
|
50
|
+
|
51
|
+
After configuration, just do this for whatever url you want:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Warchiver::Archiver.new("http://uppagus.com")
|
55
|
+
```
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create new Pull Request
|
64
|
+
|
65
|
+
# License
|
66
|
+
|
67
|
+
## The MIT License (MIT)
|
68
|
+
|
69
|
+
### Copyright (c) 2013 Jude Rosen
|
70
|
+
|
71
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
72
|
+
of this software and associated documentation files (the "Software"), to deal
|
73
|
+
in the Software without restriction, including without limitation the rights
|
74
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
75
|
+
copies of the Software, and to permit persons to whom the Software is
|
76
|
+
furnished to do so, subject to the following conditions:
|
77
|
+
|
78
|
+
The above copyright notice and this permission notice shall be included in
|
79
|
+
all copies or substantial portions of the Software.
|
80
|
+
|
81
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
82
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
83
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
84
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
85
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
86
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
87
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/warchiver.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "warchiver/version"
|
2
|
+
|
3
|
+
##
|
4
|
+
# Warchiver Module
|
5
|
+
module Warchiver
|
6
|
+
##
|
7
|
+
# Dependencies
|
8
|
+
require 'uri'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'fileutils'
|
11
|
+
|
12
|
+
##
|
13
|
+
# Configuration
|
14
|
+
class << self
|
15
|
+
attr_accessor :configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configure
|
19
|
+
self.configuration ||= Configuration.new
|
20
|
+
yield(configuration)
|
21
|
+
end
|
22
|
+
|
23
|
+
class Configuration
|
24
|
+
attr_accessor :user_agent, :base_directory
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@base_directory = "/"
|
28
|
+
@user_agent = "Ruby/#{RUBY_VERSION}/Warchiver"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
class Archiver
|
34
|
+
def checkMake(directory)
|
35
|
+
if File.directory?(directory)
|
36
|
+
FileUtils.cd(directory)
|
37
|
+
else
|
38
|
+
FileUtils.mkdir(directory)
|
39
|
+
FileUtils.cd(directory)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def initialize(url)
|
43
|
+
@url = url
|
44
|
+
config = Configuration.new
|
45
|
+
@string = ""
|
46
|
+
open(@url, "User-Agent" => config.instance_variable_get(:@user_agent)) do |f|
|
47
|
+
f.each_line { |line| @string << line }
|
48
|
+
end
|
49
|
+
FileUtils.cd(config.instance_variable_get(:@base_directory))
|
50
|
+
checkMake("archived")
|
51
|
+
checkMake(Time.now.to_i.to_s)
|
52
|
+
checkMake((@url.gsub(/(\:)+/i, "...colon...")).gsub(/(\/)+/i, "...slash..."))
|
53
|
+
FileUtils.touch("index")
|
54
|
+
File.open("index", 'w') { |file| file.write(@string) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/warchiver.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'warchiver/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "warchiver"
|
8
|
+
spec.version = Warchiver::VERSION
|
9
|
+
spec.authors = ["Jude Rosen"]
|
10
|
+
spec.email = ["higgs@uppagus.com"]
|
11
|
+
spec.description = %q{A simple web archiving library for Ruby.}
|
12
|
+
spec.summary = %q{Web Archiver}
|
13
|
+
spec.homepage = "http://uppagus.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: warchiver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jude Rosen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A simple web archiving library for Ruby.
|
42
|
+
email:
|
43
|
+
- higgs@uppagus.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/warchiver.rb
|
54
|
+
- lib/warchiver/version.rb
|
55
|
+
- warchiver-1.0.0-x64-mingw32.gem
|
56
|
+
- warchiver-1.1.0.gem
|
57
|
+
- warchiver.gemspec
|
58
|
+
homepage: http://uppagus.com
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.14
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Web Archiver
|
82
|
+
test_files: []
|