ruby2ch 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ruby2ch/board.rb CHANGED
@@ -9,15 +9,22 @@ module Ruby2ch
9
9
  def initialize(url)
10
10
  @agent = Mechanize.new
11
11
  @page = @agent.get(url)
12
- @links = @page.links.map{|link| link.href}.map{|link| link.split("/")[0]}
13
- @links.map!{|link| url.sub("/news/subback.html","/test/read.cgi/news/") + link}
14
- @links.select!{|x| /\/\d*$/ =~x}
12
+ @links = @page.links.map{|link| [link.href,link.text]}#.map{|link| link.split("/")[0]}
13
+
14
+ @links.map!{|link,title| [link.split("/")[0],title]}
15
+
16
+ @links.map!{|link,title|
17
+ puts link
18
+ [url.sub("/news/subback.html","/test/read.cgi/news/") + link,title]}
19
+
20
+ @links.select!{|link,title| /\/\d*$/ =~link}
15
21
  end
16
22
 
17
- def threads
23
+ def threads(num)
18
24
  threads = []
19
- @links.each{|link|
20
- threads << Thread.start(link){|link| Dat.new(link)}
25
+ thread_num = 100
26
+ num.times{|i|
27
+ threads << Thread.start(i){|i| Dat.new(@links[i][0],@links[i][1])}
21
28
  }
22
29
 
23
30
  threads.map!{|thre|
@@ -3,9 +3,10 @@ require 'mechanize'
3
3
  require 'kconv'
4
4
  module Ruby2ch
5
5
  class Dat
6
- def initialize(url)
6
+ def initialize(url,title)
7
7
  #http://uni.2ch.net/test/read.cgi/news/1322032301/l50
8
8
  #http://bg20.2ch.net/test/r.so/uni.2ch.net/news/1322032301/
9
+ @title = title.scan(/\d*\s(.*)\s\(\d*\)/).flatten[0]
9
10
  url_elements = url.split("/")
10
11
  @dat_url = "http://bg20.2ch.net/test/r.so/" + url_elements[2] + "/" + url_elements[5] + "/" + url_elements[6] + "/"
11
12
  @agent = Mechanize.new
@@ -38,9 +39,10 @@ module Ruby2ch
38
39
 
39
40
 
40
41
 
41
- attr_accessor :dat_url,:page
42
+ attr_accessor :dat_url,:page,:thre,:title
42
43
  end
43
44
 
44
45
  end
45
46
 
46
47
 
48
+
@@ -1,3 +1,3 @@
1
1
  module Ruby2ch
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2ch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-24 00:00:00.000000000Z
12
+ date: 2011-11-25 00:00:00.000000000 +09:00
13
+ default_executable:
13
14
  dependencies: []
14
15
  description: 2ch for ruby
15
16
  email:
@@ -29,6 +30,7 @@ files:
29
30
  - lib/ruby2ch/thre.rb
30
31
  - lib/ruby2ch/version.rb
31
32
  - ruby2ch.gemspec
33
+ has_rdoc: true
32
34
  homepage: ''
33
35
  licenses: []
34
36
  post_install_message:
@@ -49,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
51
  version: '0'
50
52
  requirements: []
51
53
  rubyforge_project: ruby2ch
52
- rubygems_version: 1.8.10
54
+ rubygems_version: 1.6.2
53
55
  signing_key:
54
56
  specification_version: 3
55
57
  summary: 2ch for ruby