poj_org 0.4.8 → 0.4.9

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.
Files changed (3) hide show
  1. data/lib/poj_org/code.rb +10 -16
  2. data/lib/poj_org/user.rb +1 -1
  3. metadata +2 -2
data/lib/poj_org/code.rb CHANGED
@@ -10,7 +10,16 @@ module PojOrg
10
10
 
11
11
  def initialize(id)
12
12
  @id = id
13
- fetch_details
13
+ html = Nokogiri::HTML(open("http://poj.org/status?top=#{@id+1}"))
14
+ raise PojOrg::Errors::CodeNotFound if html.xpath('/html/body/table[2]/tr[2]/td[1]').text.to_i != @id
15
+ @username = html.xpath('/html/body/table[2]/tr[2]/td[2]').text
16
+ @problem_id = html.xpath('/html/body/table[2]/tr[2]/td[3]').text.to_i
17
+ @result = html.xpath('/html/body/table[2]/tr[2]/td[4]').text
18
+ @memory_in_kb = html.xpath('/html/body/table[2]/tr[2]/td[5]').text.to_i
19
+ @time_in_ms = html.xpath('/html/body/table[2]/tr[2]/td[6]').text.to_i
20
+ @language = html.xpath('/html/body/table[2]/tr[2]/td[7]').text
21
+ @length_in_byte = html.xpath('/html/body/table[2]/tr[2]/td[8]').text.to_i
22
+ @submitted_at = html.xpath('/html/body/table[2]/tr[2]/td[9]').text
14
23
  end
15
24
 
16
25
  def url
@@ -28,20 +37,5 @@ module PojOrg
28
37
  @content = html.xpath('/html/body/pre').text
29
38
  end
30
39
  end
31
-
32
- private
33
-
34
- def fetch_details
35
- html = Nokogiri::HTML(open("http://poj.org/status?top=#{@id+1}"))
36
- raise PojOrg::Errors::CodeNotFound if html.xpath('/html/body/table[2]/tr[2]/td[1]').text.to_i != @id
37
- @username = html.xpath('/html/body/table[2]/tr[2]/td[2]').text
38
- @problem_id = html.xpath('/html/body/table[2]/tr[2]/td[3]').text.to_i
39
- @result = html.xpath('/html/body/table[2]/tr[2]/td[4]').text
40
- @memory_in_kb = html.xpath('/html/body/table[2]/tr[2]/td[5]').text.to_i
41
- @time_in_ms = html.xpath('/html/body/table[2]/tr[2]/td[6]').text.to_i
42
- @language = html.xpath('/html/body/table[2]/tr[2]/td[7]').text
43
- @length_in_byte = html.xpath('/html/body/table[2]/tr[2]/td[8]').text.to_i
44
- @submitted_at = html.xpath('/html/body/table[2]/tr[2]/td[9]').text
45
- end
46
40
  end
47
41
  end
data/lib/poj_org/user.rb CHANGED
@@ -31,7 +31,7 @@ module PojOrg
31
31
 
32
32
  def code(id)
33
33
  code = Code.new(id)
34
- code.fetch_content(self)
34
+ code.fetch_content(@password)
35
35
  code
36
36
  end
37
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poj_org
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri