gazelle 0.0.2
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.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/gazelle.gemspec +27 -0
- data/lib/gazelle.rb +1 -0
- data/lib/gazelle/base.rb +146 -0
- data/lib/gazelle/version.rb +3 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzBjZTFkNmQ1ZmM3MDZlYjk0Y2VkOWE4MzZmZGU1ZmMxNGI2NDA1YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTNmNjUwODQ3ZjlmNDk5YWU0MmE2MzcyMTZlYmZlZWVhMjAzMjQ2OQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTVkMDc3YTc5YmZkZmJiZmMyNWQxMTE2YWM0MjczY2ZkMzI1OTY5M2E0N2Vi
|
10
|
+
YmNiNmMyMmJlYTc3YjUyNjU2Njk0ZTZhZGNkMGNhMzM0Y2FkZDkzZDllNjI1
|
11
|
+
NDYyNWJjZWMzNzljZjlkMWMzMjg3ZDA3ZjhmZGU4YzEwMTI1OWI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmJjODMyZTQ2NDQwMmEwYzcwMTNmZjY1ZGY2ZjQwZmNjZjZlODBmZDdiNGYw
|
14
|
+
N2RiNGJlOWRmYTdmZjZhM2EzMTJkZTkwMDA4ZjdmMDBkMGMxNzY4Y2JmZWNh
|
15
|
+
ZDA4MWJhN2QxZTQzYzYzZjdhMDQ4ZmFhZDkyZTZhZjZhNWFhOTc=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Aaron Neyer
|
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,40 @@
|
|
1
|
+
# Gazelle
|
2
|
+
|
3
|
+
This gem is a wrapper around the what.cd Gazelle API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'gazelle'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install gazelle
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Include this at the beginning of your file.
|
22
|
+
```ruby
|
23
|
+
require 'gazelle'
|
24
|
+
include RubyGazelle
|
25
|
+
```
|
26
|
+
|
27
|
+
Connect with this:
|
28
|
+
```ruby
|
29
|
+
Gazelle.connect({username: "username", password: "password"})
|
30
|
+
```
|
31
|
+
|
32
|
+
Further documentation to come. Glance in the code to see the methods, all pretty self explanatory.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/gazelle.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gazelle/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gazelle"
|
8
|
+
spec.version = RubyGazelle::VERSION
|
9
|
+
spec.authors = ["Chasemgray, Aaron Neyer"]
|
10
|
+
spec.email = ["aaronneyer@gmail.com"]
|
11
|
+
spec.description = %q{Wrapper around what.cd Gazelle API}
|
12
|
+
spec.summary = %q{Used to interface with what.cd}
|
13
|
+
spec.homepage = "http://github.com/chasemgray/RubyGazelle"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "httparty"
|
24
|
+
spec.add_dependency "json"
|
25
|
+
spec.add_dependency "recursive-open-struct"
|
26
|
+
|
27
|
+
end
|
data/lib/gazelle.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'gazelle/base'
|
data/lib/gazelle/base.rb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
require 'recursive-open-struct'
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
module RubyGazelle
|
7
|
+
class Gazelle
|
8
|
+
include HTTParty
|
9
|
+
|
10
|
+
REQUESTS = {index: '/ajax.php?action=index', user_profile: '/ajax.php?action=user', inbox: '/ajax.php?action=inbox',
|
11
|
+
conversation: '/ajax.php?action=inbox&type=viewconv', top10: '/ajax.php?action=top10',
|
12
|
+
user_search: '/ajax.php?action=usersearch', request_search: '/ajax.php?action=requests',
|
13
|
+
torrent_search: '/ajax.php?action=browse', bookmarks: '/ajax.php?action=bookmarks',
|
14
|
+
subscriptions: '/ajax.php?action=subscriptions', forum_categories: '/ajax.php?action=forum&type=main',
|
15
|
+
forum: '/ajax.php?action=forum&type=viewforum', forum_thread: '/ajax.php?action=forum&type=viewthread',
|
16
|
+
artist: '/ajax.php?action=artist', torrent_group: '/ajax.php?action=torrentgroup',
|
17
|
+
request: '/ajax.php?action=request', notifications: '/ajax.php?action=notifications',
|
18
|
+
rippy: '/ajax.php?action=rippy&format=json', announcement: '/ajax.php?action=announcements'}
|
19
|
+
|
20
|
+
def initialize(login_page, username, password)
|
21
|
+
@username = username
|
22
|
+
response = Net::HTTP.post_form(URI(login_page), {username: username, password: password})
|
23
|
+
@cookie = response['Set-Cookie']
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.connect(options, &block)
|
27
|
+
options[:site] ||= 'https://ssl.what.cd'
|
28
|
+
|
29
|
+
options[:login] ||= '/login.php'
|
30
|
+
|
31
|
+
#throw exception for not providing username if !options[:username] || !options[:password]
|
32
|
+
|
33
|
+
base_uri options[:site]
|
34
|
+
|
35
|
+
gazelle_connection = new("#{options[:site]}#{options[:login]}", options[:username], options[:password])
|
36
|
+
|
37
|
+
if block_given?
|
38
|
+
gazelle_connection.instance_eval(&block)
|
39
|
+
end
|
40
|
+
|
41
|
+
gazelle_connection
|
42
|
+
end
|
43
|
+
|
44
|
+
def user(id)
|
45
|
+
make_request(REQUESTS[:user_profile], :id => id)
|
46
|
+
end
|
47
|
+
|
48
|
+
def index
|
49
|
+
make_request(REQUESTS[:index])
|
50
|
+
end
|
51
|
+
|
52
|
+
def inbox(options = {})
|
53
|
+
make_request(REQUESTS[:inbox], options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def conversation(id)
|
57
|
+
make_request(REQUESTS[:conversation], :id => id)
|
58
|
+
end
|
59
|
+
|
60
|
+
def top(limit = 10, type)
|
61
|
+
#Users returns empty results.
|
62
|
+
make_request(REQUESTS[:top10], :type => type, :limit => limit)
|
63
|
+
end
|
64
|
+
|
65
|
+
def search(type, options)
|
66
|
+
type = type.to_sym
|
67
|
+
if type == :users
|
68
|
+
make_request(REQUESTS[:user_search], options)
|
69
|
+
elsif type == :requests
|
70
|
+
make_request(REQUESTS[:request_search], options)
|
71
|
+
elsif type == :torrents
|
72
|
+
make_request(REQUESTS[:torrent_search], options)
|
73
|
+
else
|
74
|
+
throw Exception
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def bookmarks(options = {})
|
79
|
+
make_request(REQUESTS[:bookmarks], options)
|
80
|
+
end
|
81
|
+
|
82
|
+
def subscriptions(options = {})
|
83
|
+
make_request(REQUESTS[:subscriptions], options)
|
84
|
+
end
|
85
|
+
|
86
|
+
def forum_categories
|
87
|
+
make_request(REQUESTS[:forum_categories])
|
88
|
+
end
|
89
|
+
|
90
|
+
def forum(id, options = {})
|
91
|
+
make_request(REQUESTS[:forum], {:forumid => id}.merge(options))
|
92
|
+
end
|
93
|
+
|
94
|
+
def forum_thread(options = {})
|
95
|
+
make_request(REQUESTS[:forum_thread], options)
|
96
|
+
end
|
97
|
+
|
98
|
+
def artist(id)
|
99
|
+
make_request(REQUESTS[:artist], :id => id)
|
100
|
+
end
|
101
|
+
|
102
|
+
def torrent_group(id)
|
103
|
+
make_request(REQUESTS[:torrent_group], :id => id)
|
104
|
+
end
|
105
|
+
|
106
|
+
def request(id, options = {})
|
107
|
+
make_request(REQUESTS[:request], {:id => id}.merge(options))
|
108
|
+
end
|
109
|
+
|
110
|
+
def notifications(options = {})
|
111
|
+
make_request(REQUESTS[:notifications], options)
|
112
|
+
end
|
113
|
+
|
114
|
+
def rippy
|
115
|
+
self.class.get(REQUESTS[:rippy], :headers => {'Cookie' => @cookie})['rippy']
|
116
|
+
end
|
117
|
+
|
118
|
+
def announcements
|
119
|
+
make_request("#{REQUESTS[:announcement]}")
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def make_request(page, options = {})
|
125
|
+
response = self.class.get(page, :query => options, :headers => {'Cookie' => @cookie})
|
126
|
+
|
127
|
+
|
128
|
+
#response isn't consistently formatted
|
129
|
+
response = response.parsed_response || response
|
130
|
+
#not sure why sometimes the response doesn't get parsed correctly
|
131
|
+
response = JSON.parse(response) if response.is_a?(String)
|
132
|
+
|
133
|
+
status = response['status']
|
134
|
+
response = response['response']
|
135
|
+
|
136
|
+
throw Exception unless status.eql? 'success'
|
137
|
+
|
138
|
+
|
139
|
+
if response.is_a?(Array)
|
140
|
+
response.collect{|el| RecursiveOpenStruct.new(el)}
|
141
|
+
else
|
142
|
+
RecursiveOpenStruct.new(response)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gazelle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chasemgray, Aaron Neyer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-23 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: recursive-open-struct
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Wrapper around what.cd Gazelle API
|
84
|
+
email:
|
85
|
+
- aaronneyer@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- gazelle.gemspec
|
96
|
+
- lib/gazelle.rb
|
97
|
+
- lib/gazelle/base.rb
|
98
|
+
- lib/gazelle/version.rb
|
99
|
+
homepage: http://github.com/chasemgray/RubyGazelle
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.0.0
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Used to interface with what.cd
|
123
|
+
test_files: []
|