wordstream_client 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,11 @@ module WordstreamClient
6
6
  attr_accessor :username, :password, :session_id
7
7
  end
8
8
 
9
- def self.instantiate # :nodoc:
10
- new( username: username, password: password, session_id: session_id )
9
+ # Instantiate new instance
10
+ # @private
11
+
12
+ def self.instantiate
13
+ new( :username => username, :password => password, :session_id => session_id )
11
14
  end
12
15
 
13
16
  def self.client
@@ -33,7 +36,6 @@ module WordstreamClient
33
36
  end
34
37
 
35
38
  def session_id=(new_session)
36
- # return false if new_session.to_s.empty?
37
39
  instance_variable_set "@session_id", new_session
38
40
  self.class.session_id = new_session
39
41
  end
@@ -4,7 +4,10 @@ module WordstreamClient
4
4
 
5
5
  class AuthError < WordstreamClientError
6
6
 
7
- def initialize(method, message) # :nodoc:
7
+ # Initialize new AuthError
8
+ # @private
9
+
10
+ def initialize(method, message)
8
11
  super "WordstreamClient::Auth.#{method} - #{message}"
9
12
  end
10
13
 
@@ -12,6 +15,9 @@ module WordstreamClient
12
15
 
13
16
  class KeywordToolError < WordstreamClientError
14
17
 
18
+ # Initialize new KeywordToolError
19
+ # @private
20
+
15
21
  def initialize(method, message) # :nodoc:
16
22
  super "WordstreamClient::KeywordTool.#{method} - #{message}"
17
23
  end
@@ -4,6 +4,23 @@ module WordstreamClient
4
4
 
5
5
  attr_accessor :keywords
6
6
 
7
+ ##
8
+ # == Description
9
+ #
10
+ # Initializing a KeywordTool object for the keywordtool API calls.
11
+ # It is more convenient to set the username and password for Wordstream::Config
12
+ # and use KeywordTool class methods for API calls.
13
+ #
14
+ # == Params
15
+ #
16
+ # [config] <b>Required</b> -
17
+ # WordstreamClient::Config object with valid username and passowrd
18
+ # [keywords] <em>Optional</em> -
19
+ # Defaults to an empty array. Can be an array of keywords or a string of
20
+ # keywords separated by newline "\n"
21
+ #
22
+ # @return [KeywordTool] With keywords instance variable set.
23
+
7
24
  def initialize(config, keywords = [])
8
25
  @config = config
9
26
  @keywords = keywords.is_a?(Array) ? keywords.join("\n") : keywords.to_s
@@ -13,15 +30,39 @@ module WordstreamClient
13
30
  @keywords = @keywords[0..3949]
14
31
  end
15
32
 
33
+ ##
34
+ # == Description
35
+ #
36
+ # get_keyword_volumes Wordstream API call. Takes list of keywords and returns
37
+ # an array of arrays of keywords and their volumes.
38
+ #
39
+ # == Params
40
+ #
41
+ # [keywords] <b>Required</b> -
42
+ # Array of keywords or string of keywords separated by newline "\n"
43
+ # [block_adult] <em>Optional</em> -
44
+ # Defaults to 'false'. Set to 'true' if you want to block adult results.
45
+ #
46
+ # @return [Array] Array of arrays of keywords and their volumes.
47
+ # @raise [KeywordToolError] If error is returned in response body from Wordstream.
48
+ # @raise [KeywordToolError] If bad JSON response from Wordstream.
49
+
16
50
  def self.get_volumes(keywords, block_adult = 'false')
17
51
  Config.client.keyword_tool(keywords).get_volumes(block_adult)
18
52
  end
19
53
 
54
+ ##
55
+ # == Description
56
+ #
57
+ # get_keyword_volumes Wordstream API call. Takes list of keywords and returns
58
+ # an array of arrays of keywords and their volumes. See class method {WordstreamClient::KeywordTool.get_volumes}.
59
+ #
60
+
20
61
  def get_volumes(block_adult = 'false')
21
62
  path = '/keywordtool/get_keyword_volumes'
22
63
  url_keywords = URI.encode( @keywords, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]") )
23
64
  query = "?session_id=#{@config.session_id}&keywords=#{url_keywords}&block_adult=#{block_adult}"
24
- resp = RestClient.get( @config.default_host + path + query )
65
+ resp = RestClient.post( @config.default_host + path + query, {} )
25
66
  data = JSON.parse resp.body
26
67
 
27
68
  raise KeywordToolError.new('get_volumes', data['detail']) if data['code'].match(/error/i)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordstream_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-28 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: simplecov
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  description: Wraps Wordstream API calls in a gem.
47
63
  email: ''
48
64
  executables: []