horntell 0.1.0 → 0.2.0

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: c1e9a25bd56f75eaff3ecb4006c9f2a19b68b8a1
4
- data.tar.gz: a7c449eb80509f8f50fd9812f7ef6d964bff6d32
3
+ metadata.gz: 3e59ea212c8612cec68559998a305e0375c8c848
4
+ data.tar.gz: b0bb08528724e12dfca9cba50fb47f7b17da7f44
5
5
  SHA512:
6
- metadata.gz: 63f82bca3f8311fee533c4bc7b71d79785023e2bd459b427736d748f109fa78b0b1e7bdb29cef834ba66eb1b6dccc3585413da80a1100480676d14dfb6b92064
7
- data.tar.gz: 8486ddbb167337758b49e4002185374c75e9ef2f64d840fd0599b550de51473bcc24626de804d5d410c70579fbe6626198af2e581aeca05fc395ac8876f8d463
6
+ metadata.gz: d37ad03a32b0834f2e2b656aad8ebc240f87028b900f03e0d5ef577050e1687bd035474314c9e1d7a5b058a1bc6d6478d6207380ac1f4151e50b5e24313717e8
7
+ data.tar.gz: f3e95161101a37b77fba2c83f7b33fa51b81d77a12c36128ec3f045ffc66a4d7bc47b34f60e97559cba24bb321ab31535ee8083c86facf752ef0d7fbb2ef227a
data/README.md CHANGED
@@ -1,31 +1,56 @@
1
- # Horntell::Ruby
1
+ Horntell SDK for Ruby
2
+ ====================
2
3
 
3
- TODO: Write a gem description
4
+ This SDK allows you to easily integrate Horntell in your Ruby applications.
5
+
6
+ ## Requirements
7
+ **Ruby 1.9.2 and later.**
8
+
9
+ **Gems: rest-client, json**
4
10
 
5
11
  ## Installation
12
+ You don't need this source code unless you want to modify the gem. If you just want to use the Horntell Ruby SDK, you should run:
13
+
14
+ ```
15
+ gem install horntell
16
+ ```
17
+
18
+ If you want to build the gem from source, run this:
19
+
20
+ ```
21
+ gem build horntell.gemspec
22
+ ```
6
23
 
7
- Add this line to your application's Gemfile:
24
+ ## Bundler
25
+ If you are installing via bundler, you should be sure to use the https rubygems source in your Gemfile, as any gems fetched over http could potentially be compromised in transit and alter the code of gems fetched securely over https:
8
26
 
9
27
  ```ruby
28
+ source 'https://rubygems.org'
29
+
10
30
  gem 'horntell'
11
31
  ```
12
32
 
13
33
  And then execute:
14
34
 
15
- $ bundle
35
+ ```
36
+ bundle install
37
+ ```
16
38
 
17
- Or install it yourself as:
39
+ ## Getting Started
18
40
 
19
- $ gem install horntell
41
+ You need to `init`ialize the SDK with the app's key and secret, which you can find in your account at [http://app.horntell.com](http://app.horntell.com). Sample usage looks like this.
20
42
 
21
- ## Usage
43
+ ```ruby
44
+ Horntell::init('YOUR_APP_KEY', 'YOUR_APP_SECRET');
45
+ Horntell::Profile.create({
46
+ :uid => "1337",
47
+ :first_name => "John",
48
+ :last_name => "Doe",
49
+ :signedup_at => 1383350400
50
+ })
22
51
 
23
- TODO: Write usage instructions here
52
+ ```
24
53
 
25
- ## Contributing
54
+ ## Documentation
26
55
 
27
- 1. Fork it ( https://github.com/[my-github-username]/horntell-ruby/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
56
+ Please see [http://docs.horntell.com/api](http://docs.horntell.com/api/?ruby) for up-to-date documentation.
@@ -1,4 +1,6 @@
1
1
  module Horntell
2
- class AuthenticationError < Error
2
+ module Errors
3
+ class AuthenticationError < Error
4
+ end
3
5
  end
4
6
  end
@@ -1,13 +1,15 @@
1
1
  module Horntell
2
- class Error < StandardError
3
- attr_reader :message
4
- attr_reader :code
5
- attr_reader :type
2
+ module Errors
3
+ class Error < StandardError
4
+ attr_reader :message
5
+ attr_reader :code
6
+ attr_reader :type
6
7
 
7
- def initialize(message = nil, code = nil, type = nil)
8
- @message = message
9
- @code = code
10
- @type = type
8
+ def initialize(message = nil, code = nil, type = nil)
9
+ @message = message
10
+ @code = code
11
+ @type = type
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -1,4 +1,6 @@
1
1
  module Horntell
2
- class ForbiddenError < InvalidRequestError
2
+ module Errors
3
+ class ForbiddenError < InvalidRequestError
4
+ end
3
5
  end
4
6
  end
@@ -1,4 +1,6 @@
1
1
  module Horntell
2
- class InvalidRequestError < Error
2
+ module Errors
3
+ class InvalidRequestError < Error
4
+ end
3
5
  end
4
6
  end
@@ -1,12 +1,14 @@
1
1
  module Horntell
2
- class NetworkError < Error
3
- attr_accessor :message
4
- attr_accessor :type
2
+ module Errors
3
+ class NetworkError < Error
4
+ attr_accessor :message
5
+ attr_accessor :type
5
6
 
6
- def initialize(message = nil, code = nil, type = nil)
7
- super(message, code, type)
8
- @message = "Could not connect to Horntell. Please check your network connection and try again. If the problem persists, please get in touch with us at hello@horntell.com."
9
- @type = 'network_error'
7
+ def initialize(message = nil, code = nil, type = nil)
8
+ super(message, code, type)
9
+ @message = "Could not connect to Horntell. Please check your network connection and try again. If the problem persists, please get in touch with us at hello@horntell.com."
10
+ @type = 'network_error'
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -1,4 +1,6 @@
1
1
  module Horntell
2
- class NotFoundError < InvalidRequestError
2
+ module Errors
3
+ class NotFoundError < InvalidRequestError
4
+ end
3
5
  end
4
6
  end
@@ -1,4 +1,6 @@
1
1
  module Horntell
2
- class ServiceError < Error
2
+ module Errors
3
+ class ServiceError < Error
4
+ end
3
5
  end
4
6
  end
@@ -21,10 +21,10 @@ module Horntell
21
21
  if code = e.http_code and body = e.http_body
22
22
  return handle_api_error(code, body)
23
23
  else
24
- raise Horntell::NetworkError.new
24
+ raise Horntell::Errors::NetworkError.new
25
25
  end
26
26
  rescue Exception => e
27
- raise Horntell::NetworkError.new
27
+ raise Horntell::Errors::NetworkError.new
28
28
  end
29
29
  end
30
30
 
@@ -49,27 +49,27 @@ module Horntell
49
49
  end
50
50
 
51
51
  def authentication_error(error, code)
52
- AuthenticationError.new(error["message"], code, error["type"])
52
+ Horntell::Errors::AuthenticationError.new(error["message"], code, error["type"])
53
53
  end
54
54
 
55
55
  def forbidden_error(error, code)
56
- ForbiddenError.new(error["message"], code, error["type"])
56
+ Horntell::Errors::ForbiddenError.new(error["message"], code, error["type"])
57
57
  end
58
58
 
59
59
  def horntell_error(error, code)
60
- HorntellError.new(error["message"], code, error["type"])
60
+ Horntell::Errors::HorntellError.new(error["message"], code, error["type"])
61
61
  end
62
62
 
63
63
  def invalid_request_error(error, code)
64
- InvalidRequestError.new(error["message"], code, error["type"])
64
+ Horntell::Errors::InvalidRequestError.new(error["message"], code, error["type"])
65
65
  end
66
66
 
67
67
  def not_found_error(error, code)
68
- NotFoundError.new(error["message"], code, error["type"])
68
+ Horntell::Errors::NotFoundError.new(error["message"], code, error["type"])
69
69
  end
70
70
 
71
71
  def service_error(error, code)
72
- ServiceError.new(error["message"], code, error["type"])
72
+ Horntell::Errors::ServiceError.new(error["message"], code, error["type"])
73
73
  end
74
74
  end
75
75
  end
@@ -1,3 +1,3 @@
1
1
  module Horntell
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/horntell.rb CHANGED
@@ -45,5 +45,9 @@ module Horntell
45
45
  def get_secret()
46
46
  return @secret
47
47
  end
48
+
49
+ def set_version(version=nil)
50
+ @version = version
51
+ end
48
52
  end
49
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: horntell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohit Mamoria