traitify 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -7
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -0
- data/README.md +58 -69
- data/lib/traitify/client.rb +3 -9
- data/lib/traitify/client/assessments.rb +6 -6
- data/lib/traitify/client/decks.rb +12 -0
- data/lib/traitify/client/results.rb +14 -2
- data/lib/traitify/client/slides.rb +12 -19
- data/lib/traitify/error.rb +3 -5
- data/lib/traitify/version.rb +1 -1
- data/spec/support/mocks/decks.json +12 -0
- data/spec/support/mocks/personality_traits.json +82 -0
- data/spec/support/mocks/slide.json +1 -1
- data/spec/support/mocks/slides.json +1 -1
- data/spec/support/mocks/slides_complete.json +1 -1
- data/spec/traitify-ruby/client/deck_spec.rb +28 -0
- data/spec/traitify-ruby/client/result_spec.rb +27 -1
- data/spec/traitify-ruby/client/slide_spec.rb +18 -23
- data/traitify.gemspec +1 -0
- metadata +44 -34
- data/lib/traitify/assessments.rb +0 -36
- data/lib/traitify/badges.rb +0 -43
- data/lib/traitify/client/users.rb +0 -17
- data/lib/traitify/personality_blends.rb +0 -55
- data/lib/traitify/personality_types.rb +0 -39
- data/lib/traitify/results.rb +0 -31
- data/lib/traitify/slides.rb +0 -95
- data/lib/traitify/users.rb +0 -39
- data/spec/support/mocks/user.json +0 -8
- data/spec/traitify-ruby/client/user_spec.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc1513959fbaa40d7eee6277c6f8c78579750bb
|
4
|
+
data.tar.gz: f70c23b1ebd7962997aac709f8b596c8fd7e38ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fccc6837f3529e1c3fe1eaf46e62c3298b1aaf5683463168dbe6bf9509ebdf4d59aca0bb7ba503061517fdd78c038d3e5ff681984f58537eda3291e76bea0b86
|
7
|
+
data.tar.gz: 568cb75b501279b86d7eaea660893f068d92c7e30572a8400e6bd19590162684de06db3ecae8e22a2ea9db4d18c8714b79a3af0e81d80794165ba7eb582c3879
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
### 1.1.
|
1
|
+
### 1.1.1
|
2
2
|
|
3
3
|
* Features
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
* Bug Fixes
|
9
|
-
* Fixed error with package requires being capitalized (by [@cpreisinger])
|
4
|
+
* Get Decks
|
5
|
+
* Get/Create Assessments
|
6
|
+
* Get/Update Slides
|
7
|
+
* Get Personality Blend, Types, and Traits
|
10
8
|
|
11
9
|
[@cpreisinger]:https://github.com/cpreisinger
|
12
10
|
[@tomprats]:https://github.com/tomprats
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,6 +4,7 @@ PATH
|
|
4
4
|
traitify (1.1.0)
|
5
5
|
faraday (~> 0.8.0)
|
6
6
|
faraday_middleware (~> 0.9.0)
|
7
|
+
hashie
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -20,6 +21,7 @@ GEM
|
|
20
21
|
multipart-post (~> 1.2.0)
|
21
22
|
faraday_middleware (0.9.1)
|
22
23
|
faraday (>= 0.7.4, < 0.10)
|
24
|
+
hashie (2.1.1)
|
23
25
|
method_source (0.8.2)
|
24
26
|
multipart-post (1.2.0)
|
25
27
|
pry (0.9.12.6)
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Traitify is a ruby gem wrapper for the Traitify Developer's API
|
|
6
6
|
|
7
7
|
Add this line to your Gemfile (using bundler):
|
8
8
|
|
9
|
-
gem
|
9
|
+
gem "traitify"
|
10
10
|
|
11
11
|
Or install it yourself with:
|
12
12
|
|
@@ -14,77 +14,73 @@ Or install it yourself with:
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
First it is helpful to configure Traitify, otherwise everytime you create a Traitify object you must add the configuration
|
17
|
+
First, it is helpful to configure Traitify, otherwise everytime you create a Traitify object you must add the configuration
|
18
18
|
|
19
19
|
### Configuration
|
20
20
|
|
21
21
|
All the configuration options can be found in `lib/Traitify/configuration.rb`
|
22
22
|
|
23
|
-
Traitify.configure do |
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
Traitify.configure do |traitify|
|
24
|
+
traitify.secret = "secret"
|
25
|
+
traitify.api_host = "http://example.com"
|
26
|
+
traitify.api_version = "v1"
|
27
|
+
traitify.deck_id = "deck-uuid" # Optional
|
28
|
+
traitify.image_pack = "image-pack-type" # Optional
|
28
29
|
end
|
29
30
|
|
30
31
|
#### With config file:
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
traitify = Traitify.new
|
34
|
+
traitify.create_assessment
|
34
35
|
|
35
36
|
#### Without config file:
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
#### Creating a user:
|
43
|
-
|
44
|
-
user = tom.create_user(
|
45
|
-
first_name: "Tom",
|
46
|
-
last_name: "Prats",
|
47
|
-
email: "tom@tomprats.com"
|
38
|
+
traitify = Traitify.new(
|
39
|
+
api_host: "http://example.com",
|
40
|
+
api_version: "v1",
|
41
|
+
deck_id: "deck-uuid",
|
42
|
+
secret: "secret"
|
48
43
|
)
|
44
|
+
traitify.create_assessment
|
49
45
|
|
50
|
-
|
46
|
+
### Decks
|
51
47
|
|
52
|
-
|
53
|
-
user.first_name #=> "Tom"
|
54
|
-
user.last_name #=> "Prats"
|
55
|
-
user.email #=> "tom@tomprats.com"
|
48
|
+
#### Getting all the decks:
|
56
49
|
|
57
|
-
|
50
|
+
decks = traitify.decks
|
58
51
|
|
59
|
-
|
52
|
+
Returns an array of Deck objects:
|
60
53
|
|
61
|
-
|
54
|
+
deck = decks.first
|
55
|
+
deck.id #=> "deck-uuid"
|
56
|
+
deck.name #=> "Career"
|
57
|
+
deck.description #=> "Description of deck"
|
58
|
+
# And more
|
62
59
|
|
63
60
|
### Assessments
|
64
61
|
|
65
62
|
#### Creating an assessment:
|
66
63
|
|
67
|
-
assessment =
|
64
|
+
assessment = traitify.create_assessment
|
68
65
|
|
69
|
-
You can
|
66
|
+
You must can specify the deck in your configuration or override it here
|
70
67
|
|
71
|
-
assessment =
|
68
|
+
assessment = traitify.create_assessment(deck_id: "deck-uuid")
|
72
69
|
|
73
|
-
You
|
70
|
+
You can also specify an image pack, otherwise a default image pack associated with the secret is used
|
74
71
|
|
75
|
-
assessment =
|
72
|
+
assessment = traitify.create_assessment(image_pack: "full-color")
|
76
73
|
|
77
74
|
Returns an assessment object:
|
78
75
|
|
79
76
|
assessment.id #=> "assessment-uuid"
|
80
77
|
assessment.deck_id #=> "deck-uuid"
|
81
|
-
assessment.
|
82
|
-
assessment.created_at #=> 46197-10-17 12:29:08 -0400
|
78
|
+
assessment.created_at #=> Returns time in Epoch format
|
83
79
|
assessment.completed_at #=> nil
|
84
80
|
|
85
81
|
#### Finding an assessment:
|
86
82
|
|
87
|
-
assessment =
|
83
|
+
assessment = traitify.find_assessment("assessment-uuid")
|
88
84
|
|
89
85
|
Returns an assessment object as seen above
|
90
86
|
|
@@ -94,17 +90,13 @@ An assessment can be taken through our javascript plugin or by getting the slide
|
|
94
90
|
|
95
91
|
#### Finding an assessment's slides:
|
96
92
|
|
97
|
-
slides =
|
98
|
-
|
99
|
-
Returns a slides object which has the assessment id but also functions as an array
|
93
|
+
slides = traitify.find_slides("assessment-uuid")
|
100
94
|
|
101
|
-
|
102
|
-
slides.first #=> Slide object
|
103
|
-
slides.all #=> Array of slide objects
|
95
|
+
Returns an array of slides
|
104
96
|
|
105
97
|
#### Updating an assessment's slides:
|
106
98
|
|
107
|
-
slides.
|
99
|
+
slides.map! do |slide|
|
108
100
|
# true for me, false for not me
|
109
101
|
slide.response = true
|
110
102
|
# Pass in the time it took to make that choice (milliseconds)
|
@@ -112,30 +104,20 @@ Returns a slides object which has the assessment id but also functions as an arr
|
|
112
104
|
slide
|
113
105
|
end
|
114
106
|
|
115
|
-
|
107
|
+
traitify.update_slides("assessment-uuid", slides)
|
116
108
|
|
117
109
|
#### Updating a single assessment slide:
|
118
110
|
|
119
111
|
slide = assessment.slides.first
|
120
112
|
slide.response = true
|
121
113
|
slide.time_taken = 600
|
122
|
-
|
123
|
-
|
124
|
-
Or with a hash
|
125
|
-
|
126
|
-
assessment.slides.first = tom.update_slide(
|
127
|
-
assessment_id: assessment.id,
|
128
|
-
slide_id: assessment.slides.first.id,
|
129
|
-
response: 0,
|
130
|
-
time_taken: 600
|
131
|
-
)
|
132
|
-
|
114
|
+
traitify.update_slide(assessment.id, slide)
|
133
115
|
|
134
116
|
### Results
|
135
117
|
|
136
118
|
#### Getting an assessment's results
|
137
119
|
|
138
|
-
results =
|
120
|
+
results = traitify.find_results("assessment-uuid")
|
139
121
|
|
140
122
|
Returns a results object:
|
141
123
|
|
@@ -143,24 +125,31 @@ Returns a results object:
|
|
143
125
|
results.personality_types #=> Array of personality type objects (with scores)
|
144
126
|
|
145
127
|
personality_blend = results.personality_blend
|
146
|
-
personality_blend.
|
147
|
-
personality_blend.
|
148
|
-
personality_blend.name
|
149
|
-
personality_blend.description
|
150
|
-
personality_blend.compliments
|
151
|
-
personality_blend.conflicts
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
personality_type = results.personality_types.first
|
128
|
+
personality_blend.personality_type_1 #=> Personality type object
|
129
|
+
personality_blend.personality_type_2 #=> Personality type object
|
130
|
+
personality_blend.name #=> "Visionary Creator"
|
131
|
+
personality_blend.description #=> "Visionary Creator description"
|
132
|
+
personality_blend.compliments #=> "Visionary Creator compliments"
|
133
|
+
personality_blend.conflicts #=> "Visionary Creator conflicts"
|
134
|
+
|
135
|
+
type = results.personality_types.first
|
136
|
+
type.score #=> 100
|
137
|
+
personality_type = type.personality_type
|
158
138
|
personality_type.name #=> "Creator"
|
159
139
|
personality_type.description #=> "Creator description"
|
160
140
|
personality_type.badge #=> Badge object
|
161
|
-
personality_type.score #=> 100
|
162
141
|
|
163
142
|
badge = personality_type.badge
|
164
143
|
badge.image_small #=> "http://s3.amazonaws.com/traitify-api/badges/creator/flat/small"
|
165
144
|
badge.image_medium #=> "http://s3.amazonaws.com/traitify-api/badges/creator/flat/medium"
|
166
145
|
badge.image_large #=> "http://s3.amazonaws.com/traitify-api/badges/creator/flat/large"
|
146
|
+
|
147
|
+
#### Getting an assessment's personality traits
|
148
|
+
|
149
|
+
traits = traitify.assessment_personality_traits("assessment-uuid")
|
150
|
+
trait = traits.first
|
151
|
+
trait.score #=> 100
|
152
|
+
personality_trait = trait.personality_trait
|
153
|
+
personality_trait.name #=> "Imaginative"
|
154
|
+
personality_trait.definition #=> "Able to think symbolically and play with ideas."
|
155
|
+
personality_trait.description #=> "Coming Soon"
|
data/lib/traitify/client.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
# require base modules
|
2
2
|
require "traitify/connection"
|
3
3
|
require "traitify/request"
|
4
|
-
require "
|
5
|
-
require "traitify/badges"
|
6
|
-
require "traitify/personality_blends"
|
7
|
-
require "traitify/personality_types"
|
8
|
-
require "traitify/results"
|
9
|
-
require "traitify/slides"
|
10
|
-
require "traitify/users"
|
4
|
+
require "hashie"
|
11
5
|
# require client modules in lib/Traitify/client
|
12
6
|
Dir[File.expand_path("../client/*.rb", __FILE__)].each {|f| require f }
|
13
7
|
|
@@ -27,9 +21,9 @@ module Traitify
|
|
27
21
|
include Traitify::Configuration
|
28
22
|
include Traitify::Request
|
29
23
|
|
24
|
+
include Traitify::Client::Deck
|
30
25
|
include Traitify::Client::Assessment
|
31
|
-
include Traitify::Client::User
|
32
|
-
include Traitify::Client::Result
|
33
26
|
include Traitify::Client::Slide
|
27
|
+
include Traitify::Client::Result
|
34
28
|
end
|
35
29
|
end
|
@@ -2,19 +2,19 @@ module Traitify
|
|
2
2
|
class Client
|
3
3
|
module Assessment
|
4
4
|
def create_assessment(options = {})
|
5
|
-
|
6
|
-
assessment_params
|
7
|
-
assessment_params.merge!(user_id: options[:user_id]) if options[:user_id]
|
5
|
+
deck_id = options[:deck_id] || options["deck_id"] || self.deck_id
|
6
|
+
assessment_params = { deck_id: deck_id }
|
8
7
|
response = post("/assessments", assessment_params)
|
9
8
|
|
10
|
-
|
9
|
+
Hashie::Mash.new(response)
|
11
10
|
end
|
12
11
|
|
13
|
-
def
|
12
|
+
def assessment(assessment_id)
|
14
13
|
response = get("/assessments/#{assessment_id}")
|
15
14
|
|
16
|
-
|
15
|
+
Hashie::Mash.new(response)
|
17
16
|
end
|
17
|
+
alias_method :find_assessment, :assessment
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Traitify
|
2
2
|
class Client
|
3
3
|
module Result
|
4
|
-
def
|
4
|
+
def results(assessment_id, image_pack = nil)
|
5
5
|
image_pack ||= self.image_pack
|
6
6
|
|
7
7
|
if image_pack
|
@@ -10,8 +10,20 @@ module Traitify
|
|
10
10
|
response = get("/assessments/#{assessment_id}/personality_types")
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
Hashie::Mash.new(response)
|
14
14
|
end
|
15
|
+
alias_method :find_results, :results
|
16
|
+
|
17
|
+
def assessment_personality_traits(assessment_id, personality_type_id = nil)
|
18
|
+
if personality_type_id
|
19
|
+
response = get("/assessments/#{assessment_id}/personality_types/#{personality_type_id}/personality_traits")
|
20
|
+
else
|
21
|
+
response = get("/assessments/#{assessment_id}/personality_traits")
|
22
|
+
end
|
23
|
+
|
24
|
+
response.collect { |personality_trait| Hashie::Mash.new(personality_trait) }
|
25
|
+
end
|
26
|
+
alias_method :find_assessment_personality_traits, :assessment_personality_traits
|
15
27
|
end
|
16
28
|
end
|
17
29
|
end
|
@@ -4,32 +4,25 @@ module Traitify
|
|
4
4
|
def find_slides(assessment_id)
|
5
5
|
response = get("/assessments/#{assessment_id}/slides")
|
6
6
|
|
7
|
-
|
7
|
+
response.collect { |slide| Hashie::Mash.new(slide) }
|
8
8
|
end
|
9
9
|
|
10
|
-
def update_slides(slides)
|
11
|
-
response = put("/assessments/#{
|
10
|
+
def update_slides(assessment_id, slides)
|
11
|
+
response = put("/assessments/#{assessment_id}/slides", slides)
|
12
12
|
|
13
|
-
|
13
|
+
response.collect { |slide| Hashie::Mash.new(slide) }
|
14
14
|
end
|
15
15
|
|
16
|
-
def update_slide(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
assessment_id = hash_or_assessment_id[:assessment_id]
|
23
|
-
slide_id = hash_or_assessment_id[:slide_id]
|
24
|
-
hash = {
|
25
|
-
response: hash_or_assessment_id[:response],
|
26
|
-
time_taken: hash_or_assessment_id[:time_taken]
|
27
|
-
}
|
28
|
-
end
|
16
|
+
def update_slide(assessment_id, slide)
|
17
|
+
slide_id = slide["id"] || slide[:id] || slide.id
|
18
|
+
params = {
|
19
|
+
response: slide["response"] || slide[:response] || slide.response,
|
20
|
+
time_taken: slide["time_taken"] || slide[:time_taken] || slide.time_taken,
|
21
|
+
}
|
29
22
|
|
30
|
-
response = put("/assessments/#{assessment_id}/slides/#{slide_id}",
|
23
|
+
response = put("/assessments/#{assessment_id}/slides/#{slide_id}", params)
|
31
24
|
|
32
|
-
|
25
|
+
Hashie::Mash.new(response)
|
33
26
|
end
|
34
27
|
end
|
35
28
|
end
|
data/lib/traitify/error.rb
CHANGED
@@ -27,12 +27,10 @@ module Traitify
|
|
27
27
|
|
28
28
|
private
|
29
29
|
def error_message
|
30
|
-
message = "#{response.env[:method].upcase} "
|
30
|
+
message = "#{response.env[:method].upcase} | "
|
31
31
|
message << "#{response.env[:url].to_s} | "
|
32
|
-
message << "#{response.status}
|
33
|
-
|
34
|
-
message << "#{response.body.map{|k,v| "#{k}: #{v.first}"}.join(", ")}"
|
35
|
-
end
|
32
|
+
message << "#{response.status} | "
|
33
|
+
message << "#{response.body}"
|
36
34
|
message
|
37
35
|
end
|
38
36
|
end
|
data/lib/traitify/version.rb
CHANGED