devrant 0.0.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e46bf5083d80cf6c07ec0c1c808ca4aad80b3bb
4
- data.tar.gz: b8d578be48af67a7b559da52111f6f1d6f06e58e
3
+ metadata.gz: 3c4da7cf8bf7d3411efba3fcd419ec1e7a64fb1e
4
+ data.tar.gz: f81698d5ccdd68f4af78ab16d94db11c46d06efa
5
5
  SHA512:
6
- metadata.gz: 29f689a2dd7d9f1ea63bef471e489b2b81edc9db98cfa06ec1f21f3cabeff67a0fbad672de238bd36b77dc4eabc3c84d441cfa73be9d56d8245e22dd6854e141
7
- data.tar.gz: d7ba2e03796cd56f586a1092dee68800d09f5a494c35d66125e01a1c9c6e2a021c6657092522545332df1ec54db75a5a26b3e52ab6d2f314b0dcf732ce331fcb
6
+ metadata.gz: 506beae8ed00d19c049806f4a56d71011c866a3328339102c8c04ce9726c0ba70c28214c2699b98de80b50943248f8fa9c70d7d22eea797941967dd1c8e1acae
7
+ data.tar.gz: fd98539b4fecc834cc1ce02a6a115039ee07e20ac69f36a27e6f67c252df6a260436cea59adb663c5e7c7fb91f620733f14abf3b08186abf3a4747e69070e2ce
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in devrant.gemspec
4
3
  gemspec
@@ -26,5 +26,4 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'rspec', '~> 3.0'
27
27
  spec.add_runtime_dependency 'httparty'
28
28
  spec.add_runtime_dependency 'json'
29
- spec.add_runtime_dependency 'ostruct'
30
29
  end
@@ -1,9 +1,9 @@
1
1
  require "devrant/version"
2
2
  require "httparty"
3
3
  require "json"
4
- require "ostruct"
5
4
  require "devrant/api"
6
5
  require "devrant/rants"
6
+ require "devrant/users"
7
7
 
8
8
  module Devrant
9
9
 
@@ -1,19 +1,31 @@
1
1
  module Devrant
2
2
  class Api
3
- attr_reader :rants
4
-
5
- BASE_URI = 'https://www.devrant.io/api'
3
+ HTTP_OPTIONS = {
4
+ query: {
5
+ app: 3
6
+ },
7
+ base_uri: 'https://www.devrant.io/api'
8
+ }
6
9
 
7
10
  def initialize
8
- options = {
9
- query: {
10
- app: 3
11
- },
12
- base_uri: BASE_URI
11
+ subclasses = {
12
+ rants: Devrant::Rants,
13
+ users: Devrant::Users
13
14
  }
14
15
 
15
- @rants = Devrant::Rants.new
16
- @rants.class.default_options = options
16
+ initialize_subclasses(subclasses)
17
+ end
18
+
19
+ private
20
+
21
+ def initialize_subclasses(classes)
22
+ classes.each do |variable, classname|
23
+ self.instance_variable_set("@#{variable}", classname.new)
24
+ self.instance_variable_get("@#{variable}").class.default_options = HTTP_OPTIONS
25
+ self.singleton_class.class_eval do
26
+ attr_reader variable.to_sym
27
+ end
28
+ end
17
29
  end
18
30
  end
19
31
  end
@@ -2,10 +2,19 @@ module Devrant
2
2
  class Rants
3
3
  include HTTParty
4
4
  include Devrant
5
-
6
- def get_rants
5
+
6
+ def all
7
7
  structuralize(self.class.get('/devrant/rants')).rants
8
8
  end
9
+
10
+ def get_rant(id)
11
+ rant = structuralize(self.class.get("/devrant/rants/#{id}")).rant
12
+
13
+ return rant unless rant.nil?
14
+
15
+ raise ArgumentError.new("No rant found for id #{id}")
16
+ end
17
+
9
18
  end
10
19
  end
11
20
 
@@ -1,3 +1,3 @@
1
1
  module Devrant
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dovzhanyn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-31 00:00:00.000000000 Z
11
+ date: 2017-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: ostruct
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  description: Connects to the devRant API and provides convinient methods for communicating
98
84
  with the devRant servers
99
85
  email: