warchiver 1.0.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/warchiver.rb +86 -0
- data/test/warchiver_test.rb +7 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 81bdb3ffa558d88ad76d97a4072d669d1465a03b
|
4
|
+
data.tar.gz: 4d8bcb723fbe88595ad686dc191ec69ff33d7d3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0e3160fc09020442529f3ee5a611fa113b3311d6edd28ef3e70861bc8683cd3cb5546bfa7be4a7607add76be04e80e3badb0645b7acfb98a9e3727e65480d7f
|
7
|
+
data.tar.gz: be90ee10cd7c7b8b26bc9cfd525c8ff8e842d8f345b9bb1288e3abb9a723cc53f0f98d40ecacba5681f7f9541d7adf815d4b9044f9569daa9c2a57d2281aacf6
|
data/lib/warchiver.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Warchiver by Jude Rosen
|
2
|
+
#
|
3
|
+
# Licensed under the MIT License (http://opensource.org/licenses/MIT) because MIT is awesome.
|
4
|
+
#
|
5
|
+
################################################################################################################################
|
6
|
+
#
|
7
|
+
# The MIT License (MIT)
|
8
|
+
|
9
|
+
# Copyright (c) 2013 Jude Rosen
|
10
|
+
#
|
11
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
12
|
+
# of this software and associated documentation files (the "Software"), to deal
|
13
|
+
# in the Software without restriction, including without limitation the rights
|
14
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
15
|
+
# copies of the Software, and to permit persons to whom the Software is
|
16
|
+
# furnished to do so, subject to the following conditions:
|
17
|
+
#
|
18
|
+
# The above copyright notice and this permission notice shall be included in
|
19
|
+
# all copies or substantial portions of the Software.
|
20
|
+
#
|
21
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
22
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
23
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
24
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
25
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
26
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
27
|
+
# THE SOFTWARE.
|
28
|
+
#
|
29
|
+
################################################################################################################################
|
30
|
+
|
31
|
+
|
32
|
+
##
|
33
|
+
# Warchiver Module
|
34
|
+
module Warchiver
|
35
|
+
##
|
36
|
+
# Dependencies
|
37
|
+
require 'uri'
|
38
|
+
require 'open-uri'
|
39
|
+
require 'fileutils'
|
40
|
+
|
41
|
+
##
|
42
|
+
# Configuration
|
43
|
+
class << self
|
44
|
+
attr_accessor :configuration
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.configure
|
48
|
+
self.configuration ||= Configuration.new
|
49
|
+
yield(configuration)
|
50
|
+
end
|
51
|
+
|
52
|
+
class Configuration
|
53
|
+
attr_accessor :user_agent, :base_directory
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
@base_directory = "/"
|
57
|
+
@user_agent = "Ruby/#{RUBY_VERSION}/Warchiver"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
class Archiver
|
63
|
+
def checkMake(directory)
|
64
|
+
if File.directory?(directory)
|
65
|
+
FileUtils.cd(directory)
|
66
|
+
else
|
67
|
+
FileUtils.mkdir(directory)
|
68
|
+
FileUtils.cd(directory)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
def initialize(url)
|
72
|
+
@url = url
|
73
|
+
config = Configuration.new
|
74
|
+
@string = ""
|
75
|
+
open(@url, "User-Agent" => config.instance_variable_get(:@user_agent)) do |f|
|
76
|
+
f.each_line { |line| @string << line }
|
77
|
+
end
|
78
|
+
FileUtils.cd(config.instance_variable_get(:@base_directory))
|
79
|
+
checkMake("archived")
|
80
|
+
checkMake(Time.now.to_i.to_s)
|
81
|
+
checkMake((@url.gsub(/(\:)+/i, "...colon...")).gsub(/(\/)+/i, "...slash..."))
|
82
|
+
FileUtils.touch("index")
|
83
|
+
File.open("index", 'w') { |file| file.write(@string) }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: warchiver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: x64-mingw32
|
6
|
+
authors:
|
7
|
+
- Jude Rosen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Simple Web Archiver that does not rely on nokogiri (which is broken
|
14
|
+
on Ruby 2.0.0 x64).
|
15
|
+
email: higgs@uppagus.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/warchiver.rb
|
21
|
+
- test/warchiver_test.rb
|
22
|
+
homepage: http://uppagus.com
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message: Thanks for installing Warchiver.
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- - lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.0.0
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements:
|
41
|
+
- An internet connection
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.0.14
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Web Archiver
|
47
|
+
test_files:
|
48
|
+
- test/warchiver_test.rb
|