seedu 0.0.4
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +32 -0
- data/lib/seedu.rb +8 -0
- data/lib/seedu/action.rb +6 -0
- data/lib/seedu/action/link.rb +27 -0
- data/lib/seedu/card.rb +59 -0
- data/lib/seedu/card/request.rb +15 -0
- data/lib/seedu/card/response.rb +17 -0
- data/lib/seedu/exceptions.rb +15 -0
- data/lib/seedu/version.rb +3 -0
- data/lib/tasks/seedu_tasks.rake +4 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ff043eb6e3b74db5f14de24a88448d1aced8b2ef
|
4
|
+
data.tar.gz: 53b3272b225ec7998b11d51aef528830f75f7f4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0ff537da3fd7fa60925f5ca12af0664277907823a1ed4e0341d427c4398f35cf65391eeb66c037c90cac7ae80a418028e1564de46e90357f9d25cc9d80daff7
|
7
|
+
data.tar.gz: 91dfa59ac5bccaf7441198230a7f05bb5ae6f71ed36ffe7caf13e5e0d86eab3b5a68c72eb52951905415fbf60c8fc1bc8771fdf8b200024fb36c52caf9d77736
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Seedu'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
data/lib/seedu.rb
ADDED
data/lib/seedu/action.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Seedu
|
2
|
+
module Action
|
3
|
+
class Link
|
4
|
+
|
5
|
+
attr_accessor :title, :url, :icon
|
6
|
+
|
7
|
+
def initialize(details)
|
8
|
+
@title = details[:title]
|
9
|
+
@url = details[:url]
|
10
|
+
@icon = details[:icon]
|
11
|
+
end
|
12
|
+
|
13
|
+
def as_json
|
14
|
+
{
|
15
|
+
title: @title,
|
16
|
+
url: @url,
|
17
|
+
icon: @icon
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_json
|
22
|
+
as_json.to_json
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/seedu/card.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative "./card/request.rb"
|
2
|
+
|
3
|
+
module Seedu
|
4
|
+
class Card
|
5
|
+
|
6
|
+
attr_accessor :title, :description, :image
|
7
|
+
REQUIRED_FIELDS = [:title, :description, :duration, :coordinates].freeze
|
8
|
+
|
9
|
+
def initialize(options)
|
10
|
+
@title = options[:title]
|
11
|
+
@description = options[:description]
|
12
|
+
@image = options[:image]
|
13
|
+
@duration = options[:duration]
|
14
|
+
@coordinates = options[:coordinates]
|
15
|
+
@actions = []
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Adds an action to the card.
|
20
|
+
def add_action(action)
|
21
|
+
if Action.constants.any? {|sym| action.class.name == "Seedu::Action::#{sym}" }
|
22
|
+
@actions << action
|
23
|
+
else
|
24
|
+
raise NotASeeduAction
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Returns the card as a hash suitable for conversion to JSON
|
30
|
+
def as_json
|
31
|
+
{
|
32
|
+
title: @title,
|
33
|
+
description: @description,
|
34
|
+
image: @image,
|
35
|
+
duration: @duration,
|
36
|
+
coordinates: @coordinates,
|
37
|
+
actions: @actions.map(&:as_json)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Returns the card as a JSON string.
|
43
|
+
def to_json
|
44
|
+
as_json.to_json
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Sends the card to the Seedu service.
|
49
|
+
def send!(uri = nil)
|
50
|
+
self.as_json.tap {|payload|
|
51
|
+
REQUIRED_FIELDS.each {|field|
|
52
|
+
raise IncompleteCardDetails.new("Missing field: #{field}", payload) if !payload.has_key?(field) || !payload[field]
|
53
|
+
}
|
54
|
+
return Request.send("#{uri || API_URI}/cards.json", payload)
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'oj'
|
2
|
+
require 'httparty'
|
3
|
+
require_relative "./response.rb"
|
4
|
+
|
5
|
+
module Seedu
|
6
|
+
class Card
|
7
|
+
class Request
|
8
|
+
|
9
|
+
def self.send(uri, body)
|
10
|
+
Response.new(HTTParty.post(uri, {body: Oj.dump(body, {mode: :compat}), headers: {'Content-Type' => 'application/json', 'API-Version' => API_VERSION}}))
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Seedu
|
2
|
+
class Error < StandardError; end
|
3
|
+
class NotASeeduAction < Error; end
|
4
|
+
|
5
|
+
class IncompleteCardDetails < Error
|
6
|
+
attr_accessor :object
|
7
|
+
|
8
|
+
def initialize(message, object)
|
9
|
+
super(message)
|
10
|
+
self.object = object
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seedu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Richardson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 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'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.13.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.13'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.13.3
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: excon
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.27'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.27.5
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.27'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.27.5
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: oj
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '2.11'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.11.5
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.11'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.11.5
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rspec
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3.2'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.2.0
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.2.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: simplecov
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0.9'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.9.2
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.9'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 0.9.2
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: webmock
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '1.20'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.20.4
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.20'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 1.20.4
|
133
|
+
description: Enables easy access to the Seedu service.
|
134
|
+
email:
|
135
|
+
- sam@richardosn.co.nz
|
136
|
+
executables: []
|
137
|
+
extensions: []
|
138
|
+
extra_rdoc_files: []
|
139
|
+
files:
|
140
|
+
- MIT-LICENSE
|
141
|
+
- README.rdoc
|
142
|
+
- Rakefile
|
143
|
+
- lib/seedu.rb
|
144
|
+
- lib/seedu/action.rb
|
145
|
+
- lib/seedu/action/link.rb
|
146
|
+
- lib/seedu/card.rb
|
147
|
+
- lib/seedu/card/request.rb
|
148
|
+
- lib/seedu/card/response.rb
|
149
|
+
- lib/seedu/exceptions.rb
|
150
|
+
- lib/seedu/version.rb
|
151
|
+
- lib/tasks/seedu_tasks.rake
|
152
|
+
homepage: http://www.richardson.co.nz
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.2.2
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: Seedu API wrapper
|
176
|
+
test_files: []
|