suitoru 0.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 +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/suitoru +80 -0
- data/lib/suitoru.rb +5 -0
- data/lib/suitoru/version.rb +3 -0
- data/suitoru.gemspec +24 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f977139419e7641ca8fc546003ff589627b3fdb
|
4
|
+
data.tar.gz: 1e34470a9beb0a64dc75b8834ca77237a12e3348
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 233c928c32bf9e3e3adcfa214be4968c22d2eb2242fb22a44a21b66e82d0e5d3b985d74b2a889ac82e77b112f5ab3dff96e90ecfeae8423bf6e637128ebb5ae3
|
7
|
+
data.tar.gz: b11f68ef22e0cadd85afc6d5801b51d8ac9d4d85197693143f74805f19ddf9cab07c82695fde4183c10f007d4a43cce1e1b5ac390b8426e0308daa7283b459a4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Masafumi Yokoyama <myokoym@gmail.com>
|
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,26 @@
|
|
1
|
+
# Suitoru
|
2
|
+
|
3
|
+
A crawler for such as mailing lists.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install suitoru
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
$ suitoru DOMAIN PROJECT LIST
|
12
|
+
|
13
|
+
For example:
|
14
|
+
|
15
|
+
$ suitoru osdn.jp groonga dev
|
16
|
+
|
17
|
+
## Development
|
18
|
+
|
19
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
20
|
+
|
21
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/myokoym/suitoru.
|
26
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "suitoru"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/suitoru
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "net/https"
|
5
|
+
require "uri"
|
6
|
+
require "date"
|
7
|
+
|
8
|
+
if ARGV.size < 3
|
9
|
+
$stderr.puts("Error: arguments is not enough.")
|
10
|
+
$stderr.puts("Usage: #{$0} DOMAIN PROJECT LIST [FROM]")
|
11
|
+
exit(false)
|
12
|
+
end
|
13
|
+
|
14
|
+
domain = ARGV.shift
|
15
|
+
project = ARGV.shift
|
16
|
+
list = ARGV.shift
|
17
|
+
from = ARGV.shift || 2009
|
18
|
+
|
19
|
+
host_name = "http://#{domain}/"
|
20
|
+
base_path = "projects/#{project}/lists/archive/#{list}/"
|
21
|
+
|
22
|
+
now = Time.now
|
23
|
+
current_year = now.year
|
24
|
+
current_month = now.month
|
25
|
+
|
26
|
+
YEARS = from.upto(current_year).to_a
|
27
|
+
|
28
|
+
MONTHS = Date::MONTHNAMES[1..-1]
|
29
|
+
|
30
|
+
DATA_DIR = "data"
|
31
|
+
|
32
|
+
output_dir = File.join(DATA_DIR, "#{project}-#{list}")
|
33
|
+
FileUtils.mkdir_p(output_dir)
|
34
|
+
|
35
|
+
YEARS.reverse.product(MONTHS.reverse) do |pair|
|
36
|
+
year, month = *pair
|
37
|
+
basename = "#{year}-#{month}.txt"
|
38
|
+
output_path = File.join(output_dir, basename)
|
39
|
+
if File.exist?(output_path) &&
|
40
|
+
(current_year != year || Date::MONTHNAMES[current_month] != month)
|
41
|
+
$stderr.puts("#{basename} already exists.")
|
42
|
+
next
|
43
|
+
end
|
44
|
+
|
45
|
+
if current_year == year &&
|
46
|
+
(current_month < Date::MONTHNAMES.index(month))
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
50
|
+
uri = URI.parse("#{host_name}#{base_path}#{basename}")
|
51
|
+
res = nil
|
52
|
+
5.times do
|
53
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
54
|
+
http.use_ssl = (uri.scheme == 'https')
|
55
|
+
res = http.start do |h|
|
56
|
+
h.get(uri.request_uri)
|
57
|
+
end
|
58
|
+
|
59
|
+
case res
|
60
|
+
when Net::HTTPSuccess
|
61
|
+
break
|
62
|
+
when Net::HTTPRedirection
|
63
|
+
uri = URI.parse(res["Location"])
|
64
|
+
next
|
65
|
+
else
|
66
|
+
break
|
67
|
+
end
|
68
|
+
end
|
69
|
+
sleep 0.5 + rand
|
70
|
+
unless res.is_a?(Net::HTTPSuccess)
|
71
|
+
$stderr.puts("#{basename} is not found.")
|
72
|
+
next
|
73
|
+
end
|
74
|
+
|
75
|
+
File.open(output_path, "w") do |input_file|
|
76
|
+
euc_text = res.body
|
77
|
+
input_file.write(euc_text.encode("UTF-8", "EUC-JP"))
|
78
|
+
puts("#{output_path} is saved.")
|
79
|
+
end
|
80
|
+
end
|
data/lib/suitoru.rb
ADDED
data/suitoru.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'suitoru/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "suitoru"
|
8
|
+
spec.version = Suitoru::VERSION
|
9
|
+
spec.authors = ["Masafumi Yokoyama"]
|
10
|
+
spec.email = ["yokoyama@clear-code.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A crawler for such as mailing lists.}
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = "https://github.com/myokoym/suitoru"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency("bundler", "~> 1.11")
|
23
|
+
spec.add_development_dependency("rake", "~> 10.0")
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: suitoru
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masafumi Yokoyama
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-26 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A crawler for such as mailing lists.
|
42
|
+
email:
|
43
|
+
- yokoyama@clear-code.com
|
44
|
+
executables:
|
45
|
+
- suitoru
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- exe/suitoru
|
57
|
+
- lib/suitoru.rb
|
58
|
+
- lib/suitoru/version.rb
|
59
|
+
- suitoru.gemspec
|
60
|
+
homepage: https://github.com/myokoym/suitoru
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.5.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: A crawler for such as mailing lists.
|
84
|
+
test_files: []
|
85
|
+
has_rdoc:
|