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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63fba7187cd2db760a452ee645019b4b3c7f4639
4
- data.tar.gz: a4679dc09c00cf736d46499ce4d8b48b35880ed3
3
+ metadata.gz: ddc1513959fbaa40d7eee6277c6f8c78579750bb
4
+ data.tar.gz: f70c23b1ebd7962997aac709f8b596c8fd7e38ad
5
5
  SHA512:
6
- metadata.gz: a11b1f2283ab1414f20c8e7cab20a9ce555bd90dc17becf00f8af96d15e6c0a1ac78c02b87492f350f19c9884e74b328541da66419ca805977a1eb5a88917b6b
7
- data.tar.gz: 10f132345ad8f3a41005ad0aaf07c80f38daf94c7c7c283a5a8ef1e07fd7f47d89f1c76ba6b836a827d7ab530b986a6693b21370af0cd1afcaeb11b079b45bee
6
+ metadata.gz: fccc6837f3529e1c3fe1eaf46e62c3298b1aaf5683463168dbe6bf9509ebdf4d59aca0bb7ba503061517fdd78c038d3e5ff681984f58537eda3291e76bea0b86
7
+ data.tar.gz: 568cb75b501279b86d7eaea660893f068d92c7e30572a8400e6bd19590162684de06db3ecae8e22a2ea9db4d18c8714b79a3af0e81d80794165ba7eb582c3879
@@ -1,12 +1,10 @@
1
- ### 1.1.0
1
+ ### 1.1.1
2
2
 
3
3
  * Features
4
- * Added ability to get results (by [@tomprats])
5
-
6
- ### 1.0.1
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
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in simplewoo.gemspec
3
+ # Specify your gem's dependencies in traitify.gemspec
4
4
  gemspec
@@ -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 'traitify'
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 |tom|
24
- tom.secret = "secret"
25
- tom.api_host = "http://example.com"
26
- tom.api_version = "v1"
27
- tom.deck_id = "deck-uuid"
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
- tom = Traitify.new
33
- tom.create_assessment
33
+ traitify = Traitify.new
34
+ traitify.create_assessment
34
35
 
35
36
  #### Without config file:
36
37
 
37
- tom = Traitify.new(api_host: "http://example.com", api_version: "v1", deck_id: "deck-uuid", secret: "secret")
38
- tom.create_assessment
39
-
40
- ### Users
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
- Returns a user object:
46
+ ### Decks
51
47
 
52
- user.id #=> "toms-uuid"
53
- user.first_name #=> "Tom"
54
- user.last_name #=> "Prats"
55
- user.email #=> "tom@tomprats.com"
48
+ #### Getting all the decks:
56
49
 
57
- #### Finding a user:
50
+ decks = traitify.decks
58
51
 
59
- tom.find_user("toms-uuid")
52
+ Returns an array of Deck objects:
60
53
 
61
- Returns a user object as seen above
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 = tom.create_assessment
64
+ assessment = traitify.create_assessment
68
65
 
69
- You can also pass a user id to tie it to a user
66
+ You must can specify the deck in your configuration or override it here
70
67
 
71
- assessment = tom.create_assessment(user_id: "toms-uuid")
68
+ assessment = traitify.create_assessment(deck_id: "deck-uuid")
72
69
 
73
- You must can specify the deck in your configuration or override it here
70
+ You can also specify an image pack, otherwise a default image pack associated with the secret is used
74
71
 
75
- assessment = tom.create_assessment(deck_id: "deck-uuid")
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.user_id #=> "toms-uuid"
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 = tom.find_assessment("assessment-uuid")
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 = tom.find_slides("assessment_id")
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
- slides.assessment_id #=> "assessment-uuid"
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.all.map! do |slide|
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
- tom.update_slides(slides)
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
- slides.first = tom.update_slide(assessment.id, slide)
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 = tom.find_results("assessment-uuid")
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.personality_type1 #=> Personality type object (without score)
147
- personality_blend.personality_type2 #=> Personality type object (without score)
148
- personality_blend.name #=> "Visionary Creator"
149
- personality_blend.description #=> "Visionary Creator description"
150
- personality_blend.compliments #=> "Visionary Creator compliments"
151
- personality_blend.conflicts #=> "Visionary Creator conflicts"
152
- personality_blend.compatible_work_environment_1 #=> "Example text here"
153
- personality_blend.compatible_work_environment_2 #=> "Example text here"
154
- personality_blend.compatible_work_environment_3 #=> "Example text here"
155
- personality_blend.compatible_work_environment_4 #=> "Example text here"
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"
@@ -1,13 +1,7 @@
1
1
  # require base modules
2
2
  require "traitify/connection"
3
3
  require "traitify/request"
4
- require "traitify/assessments"
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
- assessment_params = { deck_id: self.deck_id }
6
- assessment_params.merge!(deck_id: options[:deck_id]) if options[:deck_id]
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
- Traitify::Assessment.parse_json(response)
9
+ Hashie::Mash.new(response)
11
10
  end
12
11
 
13
- def find_assessment(assessment_id)
12
+ def assessment(assessment_id)
14
13
  response = get("/assessments/#{assessment_id}")
15
14
 
16
- Traitify::Assessment.parse_json(response)
15
+ Hashie::Mash.new(response)
17
16
  end
17
+ alias_method :find_assessment, :assessment
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,12 @@
1
+ module Traitify
2
+ class Client
3
+ module Deck
4
+ def decks
5
+ response = get("/decks")
6
+
7
+ response.collect { |deck| Hashie::Mash.new(deck) }
8
+ end
9
+ alias_method :find_decks, :decks
10
+ end
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  module Traitify
2
2
  class Client
3
3
  module Result
4
- def find_results(assessment_id, image_pack = nil)
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
- Traitify::Result.parse_json(response)
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
- Traitify::Slides.parse_json(assessment_id, response)
7
+ response.collect { |slide| Hashie::Mash.new(slide) }
8
8
  end
9
9
 
10
- def update_slides(slides)
11
- response = put("/assessments/#{slides.assessment_id}/slides", slides.to_update_params)
10
+ def update_slides(assessment_id, slides)
11
+ response = put("/assessments/#{assessment_id}/slides", slides)
12
12
 
13
- Traitify::Slides.parse_json(slides.assessment_id, response)
13
+ response.collect { |slide| Hashie::Mash.new(slide) }
14
14
  end
15
15
 
16
- def update_slide(hash_or_assessment_id, slide = nil)
17
- if slide
18
- assessment_id = hash_or_assessment_id
19
- slide_id = slide.id
20
- hash = slide.to_update_params.tap { |s| s.delete(:id) }
21
- else
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}", hash)
23
+ response = put("/assessments/#{assessment_id}/slides/#{slide_id}", params)
31
24
 
32
- Traitify::Slide.parse_json(response)
25
+ Hashie::Mash.new(response)
33
26
  end
34
27
  end
35
28
  end
@@ -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
- if response.body && response.body.respond_to?(map)
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
@@ -1,3 +1,3 @@
1
1
  module Traitify
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "id": "deck-uuid",
4
+ "name": "Career Deck",
5
+ "personality_group_id": "personality-group-uuid",
6
+ "personality_group_name": null,
7
+ "created_at": 1396230166317,
8
+ "active": true,
9
+ "slide_count": null,
10
+ "personality_group": null
11
+ }
12
+ ]