wanikani 0.0.7 → 0.0.8

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: 0ae0f71f7e7705766887892ba3ec88cc7167747c
4
- data.tar.gz: 385e83207b8becac1035c250903cca5347474bed
3
+ metadata.gz: 4a422657156f7b5c6ce91fc75e96848e304879e4
4
+ data.tar.gz: 5cccb5857dd0e12a58fb1ccd68038d5c1103dfa5
5
5
  SHA512:
6
- metadata.gz: 98d665e6b482fbb5a5d376074aed79ecbe60d3ed4175fa165ce6e194c01587d862b4042daa792e349253a03147cbcd8664f3935595fdbef8b4fcde26467911f1
7
- data.tar.gz: 0d73381cce1263179c5466761abd0f8bf34c217f0c9807a5bb13bd45edda1792f62d13b9674d9a1a8f6783f5d1fbfcc10bb705e27aa0c94fb6c17c6910566807
6
+ metadata.gz: d6bf6ff99a7263009425e38f8f92b874de95b1d8ab38cfbaf85a08b2b153b18f0833c1ed52c135655c302e48531f620ae3e3da98cba6e148807a5edc4b59383d
7
+ data.tar.gz: 662159ab0fb8543668deb10eb16f415048ea1db158c38a6c55f9a543028ed060b7901b2b037b5d55ca6f299f8b19aa261e2534e227be2e4147ed911f9ff27c77
@@ -18,7 +18,14 @@ module Wanikani
18
18
  levels = args.push
19
19
  levels = levels.join(',') if levels.is_a?(Array)
20
20
  api_response = Wanikani.api_response(name.to_s, levels)
21
- return api_response["requested_information"]
21
+
22
+ # The vocabulary API call without specifying levels returns a Hash instead
23
+ # of an Array, so this is a hacky way of dealing with it.
24
+ if api_response["requested_information"].is_a?(Hash)
25
+ return api_response["requested_information"]["general"]
26
+ else
27
+ return api_response["requested_information"]
28
+ end
22
29
  end
23
30
  end
24
31
  end
data/lib/wanikani/user.rb CHANGED
@@ -18,5 +18,29 @@ module Wanikani
18
18
  vacation_date = api_response["user_information"]["vacation_date"]
19
19
  return !vacation_date.nil?
20
20
  end
21
+
22
+ # Returns the Gravatar image URL using the Gravatar hash from the user's information.
23
+ #
24
+ # @param options [Hash] Optional settings for the gravatar URL.
25
+ # @return [String] The Gravatar URL, with the optional size parameter, nil if
26
+ # the user information contains no Gravatar hash.
27
+ def self.gravatar_url(options = {})
28
+ raise ArgumentError, "The size parameter must be an integer" if options[:size] && !options[:size].is_a?(Integer)
29
+ api_response = Wanikani.api_response("user-information")
30
+ hash = api_response["user_information"]["gravatar"]
31
+
32
+ return nil if hash.nil?
33
+ return build_gravatar_url(hash, options)
34
+ end
35
+
36
+ private
37
+
38
+ def self.build_gravatar_url(hash, options)
39
+ params = "d=mm" # Use 'Mystery Man' image if no image found.
40
+ params += "&size=#{options[:size]}" if options[:size]
41
+
42
+ return "https://secure.gravatar.com/avatar/#{hash}?#{params}" if options[:secure]
43
+ return "http://www.gravatar.com/avatar/#{hash}?#{params}"
44
+ end
21
45
  end
22
46
  end
@@ -1,3 +1,3 @@
1
1
  module Wanikani
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wanikani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Martinez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-23 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -72,7 +72,6 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
- - lib/version.rb
76
75
  - lib/wanikani.rb
77
76
  - lib/wanikani/critical_items.rb
78
77
  - lib/wanikani/level.rb
@@ -80,6 +79,7 @@ files:
80
79
  - lib/wanikani/srs.rb
81
80
  - lib/wanikani/study_queue.rb
82
81
  - lib/wanikani/user.rb
82
+ - lib/wanikani/version.rb
83
83
  homepage: http://github.com/dennmart/wanikani-gem
84
84
  licenses:
85
85
  - MIT