hyperscore 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source :rubygems
2
- source "https://github.com"
3
2
 
4
3
  # Specify your gem's dependencies in hyperscore.gemspec
5
4
  gemspec
data/hyperscore.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Hyperscore::VERSION
17
17
 
18
18
  gem.add_dependency "virtus"
19
- gem.add_dependency "hyperclient"
19
+ gem.add_dependency "hyperclient", '>= 0.1.0'
20
20
 
21
21
  gem.add_development_dependency "pry"
22
22
  end
@@ -7,15 +7,14 @@ module Hyperscore
7
7
  class Client
8
8
  include Hyperclient
9
9
 
10
- http_options :headers => { "Accept-Encoding" => "gzip,deflate" }
11
- entry_point 'http://cs-api.heroku.com/api/'
12
-
13
- def initialize(url=nil)
14
- url and self.class.entry_point url
10
+ def initialize(url='http://cs-api.heroku.com/api/')
11
+ @client = Hyperclient::EntryPoint.new url, {
12
+ headers: { 'Accept-Encoding' => 'gzip,deflate' }
13
+ }
15
14
  end
16
15
 
17
16
  def news
18
- links.news.resources.news.map do |news|
17
+ @client.links.news.resources.news.map do |news|
19
18
  Hyperscore::Coercions::News.new( news.attributes.merge({
20
19
  :source => news.url,
21
20
  :site => news.links['alternate'].url
@@ -24,16 +23,35 @@ module Hyperscore
24
23
  end
25
24
 
26
25
  def submissions
27
- links.submissions.resources.submissions
26
+ @client.links.submissions.resources.submissions
28
27
  end
29
28
 
30
29
  def games
31
- links.games.resources.games
30
+ @client.links.games.resources.games
31
+ end
32
+
33
+ def user(username)
34
+ user = @client.links.users.links.search.expand({username: username}).get
35
+
36
+ user.key?('error') ? nil : user
37
+ end
38
+
39
+ def profile(username)
40
+ get_user(username).links.profile.url
41
+ end
42
+
43
+ def dashboard(username)
44
+ get_user(username).links.dashboard.url
32
45
  end
33
46
 
34
47
  def motd
35
- attributes['motd']
48
+ @client.attributes['motd']
49
+ end
50
+
51
+ private
52
+ def get_user(username)
53
+ user = @client.links.users.links.search.expand({username: username})
36
54
  end
37
55
  end
38
56
 
39
- end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module Hyperscore
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperscore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
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: 2012-09-29 00:00:00.000000000 Z
12
+ date: 2012-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: virtus
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: 0.1.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: 0.1.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: pry
48
48
  requirement: !ruby/object:Gem::Requirement