spartacus 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/spartacus.rb +57 -0
  3. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 425821114d70ff86b3b631fded69e0135511bf0d
4
+ data.tar.gz: ab43f58c89898c504e15d1d03c34c9feb7f30817
5
+ SHA512:
6
+ metadata.gz: fb1cc166cfe96431efdd5067b88296d76c37b8cf641ade017b7e312a45a5d0ba2385aa72b37d1ff3a18d15bd7cf0b7bdd8ed141f0c2065af710b254de7898981
7
+ data.tar.gz: 610a49366c3665204b6b7388f9481102f1056dd138c3901f0516d03986f1ef137ce070c90f4d3233e461e174fdbdf4c295363aab5904ee4d91e20f8719d86758
data/lib/spartacus.rb ADDED
@@ -0,0 +1,57 @@
1
+ require 'httparty'
2
+
3
+ class Spartacus
4
+ include HTTParty
5
+
6
+ def initialize(api_jwt)
7
+ @api_jwt = api_jwt
8
+ end
9
+
10
+ # Set Base API Path
11
+ # @return [String] The base api path
12
+ def base_path
13
+ "http://localhost:3000/api/v1"
14
+ end
15
+
16
+ # Handle API timouts
17
+ def handle_timeouts
18
+ begin
19
+ yield
20
+ rescue Net::OpenTimeout, Net::ReadTimeout
21
+ {}
22
+ end
23
+ end
24
+
25
+ # Update a checkpoint
26
+ #
27
+ # @param id [Integer] A checkpoint id
28
+ # @param options [Hash] A customizable set of options.
29
+ # @option options [String] :name Checkpoint name.
30
+ # @option options [String] :summary Checkpoint summary.
31
+ # @option options [String] :body Checkpoint body.
32
+ # @option options [String] :assignment Checkpoint assignment.
33
+ # @option options [Integer] :points Checkpoint point.
34
+ # @return [HTTParty::Response] The updated checkpoint
35
+ # @example Update a checkpoint
36
+ # SpartacusClient.new.update_checkpoint(129, {name: 'Real Cool Checkpoint'})
37
+ def update_checkpoint(id, options={})
38
+ accepted_params = [:name, :summary, :body, :assignment, :points]
39
+ checkpoint_params = options.select {|k, v| accepted_params.include?(k) }
40
+ update_checkpoint_url = "#{base_path}/checkpoints/#{id}"
41
+
42
+ handle_timeouts do
43
+ self.class.put(update_checkpoint_url,
44
+ headers: auth_header,
45
+ query: { checkpoint: checkpoint_params }).class
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ # Set the API Authorization Header
52
+ #
53
+ # @return [Hash] The authorization header
54
+ def auth_header
55
+ { "authorization" => @api_jwt }
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spartacus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben Neely
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.7
27
+ description: A client for the Bloc API
28
+ email: ben@bloc.to
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/spartacus.rb
34
+ homepage: http://rubygems.org/gems/spartacus
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.4.8
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: A client for the Bloc AP
58
+ test_files: []
59
+ has_rdoc: