orlydb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/LICENSE +20 -0
  2. data/lib/orlydb.rb +41 -0
  3. data/lib/orlydb/pre.rb +28 -0
  4. metadata +65 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Dominik Honnef
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "open-uri"
3
+ require "nokogiri"
4
+
5
+ require "orlydb/pre"
6
+ module Orlydb
7
+ # @param [String] query Search query
8
+ # @param [Number] pages How many pages to traverse
9
+ # @return [Array<Pre>] An array of pre-releases
10
+ def self.search(query, pages = 1)
11
+ pre_structs = []
12
+
13
+ i = 0
14
+ another_page = true
15
+ while i < pages && another_page
16
+ i += 1
17
+
18
+ code = open("http://www.orlydb.com/#{i}?q=#{CGI.escape(query)}").read
19
+ doc = Nokogiri::HTML(code)
20
+ another_page = code.include?("Next Page ►")
21
+
22
+ pres = doc.css("#releases > div")
23
+ pres.each do |pre|
24
+ h = {}
25
+ [:timestamp, :section, :release, :inforight, :nukeright].each do |key|
26
+ value = pre.css(".#{key}").first
27
+ h[key] = value && value.content
28
+ end
29
+
30
+ pre_structs << Pre.new({
31
+ :time => h[:timestamp],
32
+ :section => h[:section],
33
+ :title => h[:release],
34
+ :infos => h[:inforight],
35
+ :nuked => h[:nukeright],
36
+ })
37
+ end
38
+ end
39
+ pre_structs
40
+ end
41
+ end
@@ -0,0 +1,28 @@
1
+ require "ostruct"
2
+
3
+ module Orlydb
4
+ # Provides information about a pre-release.
5
+ #
6
+ # Available attributes:
7
+ # - title
8
+ # - section
9
+ # - time
10
+ # - infos
11
+ # - nuked
12
+ class Pre < OpenStruct
13
+ # @return [String] A formatted representation of the pre-release
14
+ def to_s
15
+ s = ""
16
+ s << "[#{self.section}] #{self.title} (#{self.time})"
17
+ if self.infos
18
+ s << " - #{self.infos}"
19
+ end
20
+
21
+ if self.nuked
22
+ s << " {Nuked: #{self.nuked}}"
23
+ end
24
+
25
+ s
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orlydb
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Dominik Honnef
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-14 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: A small library for querying orlydb.com
22
+ email:
23
+ - dominikh@fork-bomb.org
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - LICENSE
32
+ - lib/orlydb/pre.rb
33
+ - lib/orlydb.rb
34
+ has_rdoc: true
35
+ homepage: http://fork-bomb.org
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.6
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: A small library for querying orlydb.com
64
+ test_files: []
65
+