rwsc 0.0.2 → 0.0.3

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.
data/README.ja.rdoc ADDED
@@ -0,0 +1,77 @@
1
+ = RWSC
2
+ RWCはRakuten Web Service Clientの略で、楽天ウエブサービスのRubyラッパライブラリです。
3
+
4
+ READMEでは基本的な使い方を説明します。
5
+
6
+ == Step 1. gemのインストール
7
+ sudo gem install rwsc
8
+
9
+ == Step 2. Require the gem
10
+ require 'rubygems'
11
+ require 'rwsc'
12
+
13
+ インストール環境によっては、require 'rubygems'が不要です。
14
+
15
+ == Step 3. gemを使って、APIを呼び出す
16
+
17
+ result_object = Rwsc::ItemSearch.find(:keyword => "cool stuff that they only have in Japan",
18
+ :developerId => [Your_Rakuten_Developer_ID]*)
19
+
20
+ Other params to try:
21
+ :developerId
22
+ :affiliateId
23
+ :keyword
24
+ :shopCode
25
+ :genreId
26
+ :catalogCode,
27
+ :hits
28
+ :page
29
+ :sort
30
+ :minPrice
31
+ :maxPrice
32
+ :availability
33
+ :field
34
+ :carrier
35
+ :imageFlag
36
+ :orFlag
37
+ :NGKeyword
38
+ :genreInformationFlag
39
+ :purchaseType
40
+
41
+ == Step 4. 検索結果を取得する
42
+ 検索結果データは、ResultItemクラスのインスタンスになります。
43
+ アンダースコア区切りのメソッドを呼び出すことで、検索結果を取得できます。
44
+
45
+ Anyways, these are the keys of the big data_hash:
46
+ "items"
47
+ "hits"
48
+ "args"
49
+ "status"
50
+ "carrier"
51
+ "page_count"
52
+ "last"
53
+ "first"
54
+ "count"
55
+ "page"
56
+
57
+ 詳細の情報については、以下の楽天ウェブサービスのページAPIページを参照してください。
58
+
59
+ http://webservice.rakuten.co.jp/api/itemsearch/
60
+
61
+ == Proxy越しの通信
62
+
63
+ proxyサーバを通してしか通信できない環境の場合は、
64
+
65
+ Rwsc::Config.proxy_host = "YOUR_PROXY_HOST"
66
+ Rwsc::Config.proxy_port = YOUR_PROXY_PORT
67
+
68
+ を事前に設定しておくことで、プロキシサーバを通しての通信が行えます。
69
+
70
+ ------------------------------------------------------------------------------------------
71
+ \*Rakuten_Developer_IDとは?
72
+
73
+ 以下のリンクから、ユーザ登録を行うことで、ディベロッパーIDを取得できます。
74
+ http://webservice.rakuten.co.jp/
75
+
76
+ ** 他にも24のAPIがあります。実装中ですのでお待ちください。
77
+
data/README.rdoc CHANGED
@@ -1,3 +1,79 @@
1
1
  = RWSC
2
- The RWSC means Rakuten Web Service Client .
3
- This is Rakuten Web Service library for Ruby .
2
+ RWSC stands for Rakuten Web Service Client. This is the Rakuten Web Service API Wrapper for Ruby.
3
+
4
+ This README covers the basic usage.
5
+
6
+ == Step 1. Install the gem:
7
+ sudo gem install rwsc
8
+
9
+ == Step 2. Require the gem (You may need to also require rubygems, depending on your setup):
10
+ require 'rubygems'
11
+ require 'rwsc'
12
+
13
+ == Step 3. Use the gem to make a call to the API:
14
+
15
+ result_object = Rwsc::ItemSearch.find(:keyword => "cool stuff that they only have in Japan", :developerId => [Your_Rakuten_Developer_ID]*)
16
+
17
+ Other params to try:
18
+ :developerId
19
+ :affiliateId
20
+ :keyword
21
+ :shopCode
22
+ :genreId
23
+ :catalogCode,
24
+ :hits
25
+ :page
26
+ :sort
27
+ :minPrice
28
+ :maxPrice
29
+ :availability
30
+ :field
31
+ :carrier
32
+ :imageFlag
33
+ :orFlag
34
+ :NGKeyword
35
+ :genreInformationFlag
36
+ :purchaseType
37
+
38
+
39
+ == Step 4. Get a response:
40
+
41
+ The information you get is in a data_hash, wrapped in the result_object. To access any underlying data, just
42
+ call the keys of the hash as methods on your result_object. (ie. result_object.items)
43
+
44
+ This is a hash of hashes and arrays, so you might have to drill down to get the info you're looking for.
45
+
46
+ Anyways, these are the keys of the big data_hash:
47
+ "items"
48
+ "hits"
49
+ "args"
50
+ "status"
51
+ "carrier"
52
+ "page_count"
53
+ "last"
54
+ "first"
55
+ "count"
56
+ "page"
57
+
58
+ For more info on what is supported by this particular API (Item search), check out http://webservice.rakuten.co.jp/api/itemsearch/ **
59
+
60
+ With google translate as your friend, you should be able to glean the request params and response body.
61
+
62
+ == Use of RWSC through a Proxy
63
+
64
+ When you have to connect through a proxy server, you should also set these variables before your call to Rwsc::ItemSearch.find:
65
+
66
+ Rwsc::Config.proxy_host = "YOUR_PROXY_HOST"
67
+ Rwsc::Config.proxy_port = YOUR_PROXY_PORT
68
+
69
+
70
+ ------------------------------------------------------------------------------------------
71
+ *What's that? You don't have a Rakuten developer ID?
72
+ You can click the top link on the blue box in the upper left corner on this page:
73
+ http://webservice.rakuten.co.jp/
74
+
75
+ With good luck and google translate, you might be able to get by.
76
+ But feel free to get in touch with github.com/evanburchard if you have any questions.
77
+
78
+
79
+ **And yes, those are 24 other APIs to the left, just waiting to be implemented. Fork away!
data/Rakefile CHANGED
@@ -2,14 +2,11 @@
2
2
  require 'rubygems'
3
3
  require 'rake'
4
4
  require 'spec/rake/spectask'
5
- require 'rake/gempackagetask'
6
- require "rtask"
7
-
5
+ require 'jeweler'
8
6
 
9
7
  # return rspec options
10
8
  def set_speck_opt(t)
11
9
  t.spec_files = FileList['spec/**/*_spec.rb']
12
- t.spec_opts = ['--color']
13
10
  t.warning = true
14
11
  end
15
12
 
@@ -26,6 +23,22 @@ Spec::Rake::SpecTask.new('spec:rcov') do |t|
26
23
  t.rcov = true
27
24
  end
28
25
 
26
+
27
+ require 'rake/rdoctask'
28
+ Rake::RDocTask.new do |rdoc|
29
+ begin
30
+ version = File.read('VERSION').chomp
31
+ rescue
32
+ version = "0.0.0"
33
+ puts "No version is set in file VERSION. Set by default to #{version}"
34
+ end
35
+
36
+ rdoc.rdoc_dir = 'rdoc'
37
+ rdoc.title = "rwsc #{version}"
38
+ rdoc.rdoc_files.include('README*')
39
+ rdoc.rdoc_files.include('lib/**/*.rb')
40
+ end
41
+
29
42
  # gem tasks
30
43
  PKG_FILES = FileList[
31
44
  '[A-Z]*',
@@ -36,81 +49,38 @@ PKG_FILES = FileList[
36
49
  'spec/**/*.rb',
37
50
  ]
38
51
 
39
- VER_NUM = `ruby -Ilib -e 'require "rwsc/version"; puts Rwsc::VERSION::STRING'`
40
-
41
- if VER_NUM =~ /([0-9.]+)$/
42
- CURRENT_VERSION = $1
43
- else
44
- CURRENT_VERSION = "0.0.0"
45
- end
46
-
47
- class RTask
48
- # overwrite init_spec
49
- # get version automaticaly .
50
- # get package files automaticaly .
51
- def init_spec
52
- ::Gem::Specification.new do |s|
53
- s.name = "rwsc"
54
- s.rubyforge_project = s.name
55
- s.version = CURRENT_VERSION
56
- s.summary = "Rakuten Webservice client library"
57
- s.description = <<-EOS
52
+ begin
53
+ require 'jeweler'
54
+ Jeweler::Tasks.new do |gemspec|
55
+ gemspec.name = "rwsc"
56
+ gemspec.rubyforge_project = gemspec.name
57
+ gemspec.summary = "Rakuten Webservice client library"
58
+ gemspec.description = "<<-EOS
58
59
  Rakuten Webservice client library
59
- EOS
60
- s.authors = ["byplayer", "takayoshi kohayakawa"]
61
- s.email = ["byplayer100@gmail.com",
62
- "takayoshi.kohayakawa@mail.rakuten.co.jp"]
63
- s.homepage = "http://wiki.github.com/byplayer/rwsc"
64
-
65
- s.files = PKG_FILES.to_a
60
+ EOS"
61
+ gemspec.email = ["byplayer100@gmail.com",
62
+ "takayoshi.kohayakawa@mail.rakuten.co.jp"]
63
+ gemspec.homepage = "http://wiki.github.com/byplayer/rwsc"
64
+ gemspec.authors = ["byplayer", "takayoshi kohayakawa"]
66
65
 
67
- s.require_path = 'lib'
66
+ gemspec.files = PKG_FILES.to_a
68
67
 
69
- s.has_rdoc = true
70
- s.rdoc_options << '--line-numbers' << '--inline-source' <<
71
- "--main" << "README.rdoc" << "-c UTF-8"
72
- s.extra_rdoc_files = ["README.rdoc"]
73
-
74
- s.add_dependency('nokogiri')
75
- s.add_dependency('rspec')
76
- end
77
- end
68
+ gemspec.require_path = 'lib'
69
+ gemspec.rdoc_options << '--line-numbers' << '--inline-source' <<
70
+ "--main" << "README.rdoc" << "-c UTF-8"
78
71
 
79
- # overwrite
80
- # get package files automaticaly
81
- def manifest
82
- PKG_FILES.to_a
72
+ gemspec.extra_rdoc_files = ["README.rdoc"]
73
+ gemspec.add_dependency('nokogiri')
74
+ gemspec.add_dependency('rspec')
83
75
  end
84
76
 
85
- def tgz
86
- base_name = "#{@package}-#{@version}"
87
- tgz_name = "#{base_name}.tgz"
77
+ Jeweler::GemcutterTasks.new
88
78
 
89
- to_base = File.expand_path(File.join(File.dirname(__FILE__),"#{base_name}"))
90
- FileUtils.mkdir_p(to_base)
91
-
92
- manifest.each do |fname|
93
- to_fname = File.join(to_base, fname)
94
- FileUtils.mkdir_p(File.dirname(to_fname))
95
- FileUtils.copy_entry(fname, to_fname)
96
- end
97
-
98
- sh "tar -c -z -f #{tgz_name} #{base_name}"
99
-
100
- FileUtils.remove_entry(to_base)
79
+ Jeweler::RubyforgeTasks.new do |rubyforge|
80
+ rubyforge.doc_task = "rdoc"
101
81
  end
102
82
 
103
- def rdoc
104
- require 'rake/rdoctask'
105
- Rake::RDocTask.new do |doc|
106
- doc.title = "#{@package}-#{@version} documentation"
107
- doc.main = "README.rdoc"
108
- doc.rdoc_files.include(manifest)
109
- doc.options << "--line-numbers" << "--inline-source" << "-c UTF-8"
110
- yield doc if block_given?
111
- end
112
- end
83
+ rescue LoadError
84
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
113
85
  end
114
86
 
115
- # create rtask tasks
116
- RTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
data/lib/rwsc.rb CHANGED
@@ -10,5 +10,7 @@ require 'rwsc/status_error'
10
10
  require 'rwsc/result_item'
11
11
  require 'rwsc/arg'
12
12
  require 'rwsc/status'
13
+ require 'rwsc/searcher'
13
14
  require 'rwsc/item_search'
15
+ require 'rwsc/books_total_search'
14
16
 
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rwsc/searcher'
3
+ require 'rwsc/result_item'
4
+
5
+ module Rwsc
6
+ # = BooksTotalSearch class
7
+ # this class is BooksTotalSearch API wrapper .
8
+ class BooksTotalSearch < ResultItem
9
+ extend Searcher
10
+
11
+ private
12
+ MUST_ITEMS = [:developerId]
13
+
14
+ def self.must_items
15
+ MUST_ITEMS
16
+ end
17
+
18
+ ACCEPT_ITEMS = [
19
+ :developerId,
20
+ :affiliateId,
21
+ :keyword,
22
+ :booksGenreId,
23
+ :hits,
24
+ :page,
25
+ :availability,
26
+ :outOfStockFlag,
27
+ :sort,
28
+ :field,
29
+ :carrier,
30
+ :orFlag,
31
+ :NGKeyword,
32
+ :genreInformationFlag
33
+ ]
34
+
35
+ def self.accept_items
36
+ ACCEPT_ITEMS
37
+ end
38
+
39
+ # == Additional Rakuten web service call option
40
+ ADD_RWSC_OPTS = {
41
+ :version => CONST::API_VERSION,
42
+ :operation => OPERATION::BOOKS_TOTAL_SEARCH,
43
+ }
44
+
45
+ # == get additional Rakuten web service call option
46
+ def self.add_rwsc_opts
47
+ ADD_RWSC_OPTS
48
+ end
49
+ end
50
+ end
@@ -1,30 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'rwsc/web/web_client'
2
+ require 'rwsc/searcher'
3
+ require 'rwsc/result_item'
3
4
 
4
5
  module Rwsc
5
6
  # = ItemSearch class
6
7
  # this class is ItemSearch API wrapper .
7
8
  class ItemSearch < ResultItem
8
- # == find item .
9
- def self.find(opts)
10
- if opts.nil?
11
- raise ArgError.new('no options')
12
- end
13
-
14
- self.must_items.each do |item|
15
- unless opts.include? item
16
- raise ArgError.new("#{item.to_s} needed")
17
- end
18
- end
19
-
20
- opts.each do |key, val|
21
- unless accept_items.include? key
22
- raise ArgError.new("#{key.to_s} is invalid option")
23
- end
24
- end
25
-
26
- self.rws_call(opts.merge(self.add_rwsc_opts))
27
- end
9
+ extend Searcher
28
10
 
29
11
  private
30
12
  MUST_ITEMS = [:developerId]
@@ -69,10 +51,5 @@ module Rwsc
69
51
  def self.add_rwsc_opts
70
52
  ADD_RWSC_OPTS
71
53
  end
72
-
73
- # == Rakuten web service call function
74
- def self.rws_call(opts)
75
- Rwsc::Web::WebClient.get_result(opts)
76
- end
77
54
  end
78
55
  end
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Rwsc
4
-
5
4
  # = this module define operation constatns .
6
5
  module OPERATION
7
6
  ITEM_SEARCH = 'ItemSearch'
7
+ BOOKS_TOTAL_SEARCH = 'BooksTotalSearch'
8
8
  end
9
9
  end
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rwsc/web/web_client'
3
+ require 'rwsc/result_item'
4
+
5
+ module Rwsc
6
+ module Searcher
7
+ # == find item .
8
+ def find(opts)
9
+ if opts.nil?
10
+ raise ArgError.new('no options')
11
+ end
12
+
13
+ self.must_items.each do |item|
14
+ unless opts.include? item
15
+ raise ArgError.new("#{item.to_s} needed")
16
+ end
17
+ end
18
+
19
+ opts.each do |key, val|
20
+ unless accept_items.include? key
21
+ raise ArgError.new("#{key.to_s} is invalid option")
22
+ end
23
+ end
24
+
25
+ self.rws_call(opts.merge(self.add_rwsc_opts))
26
+ end
27
+
28
+ # == Rakuten web service call function
29
+ def rws_call(opts)
30
+ Rwsc::Web::WebClient.get_result(opts)
31
+ end
32
+ end
33
+ end
data/lib/rwsc/version.rb CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  module Rwsc
4
4
  module VERSION
5
- MAJOR = 0
6
- MINOR = 0
7
- TINY = 2
5
+ STRING =
6
+ File.open(
7
+ File.join(
8
+ File.dirname(__FILE__), '..', '..', 'VERSION'), 'r'){ |f| f.gets.chomp }
8
9
 
9
- STRING = [MAJOR, MINOR, TINY].join('.')
10
+ MAJOR = $1.to_i if STRING =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)/
11
+ MINOR = $2.to_i if STRING =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)/
12
+ TINY = $3.to_i if STRING =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)/
10
13
  end
11
14
  end
@@ -9,25 +9,33 @@ module Rwsc
9
9
 
10
10
  # = this class is Rakuten WebSearch web client .
11
11
  class WebClient
12
+ def initialize operation
13
+ @operation = operation
14
+ end
15
+
12
16
  # == this method call webservice api .
13
17
  def self.get_result(opts)
14
- WebClient.new.call_http(opts)
18
+ return WebClient.new(opts[:operation]).get_result(opts)
19
+ end
20
+
21
+ def get_result(opts)
22
+ parse_result(get_api_result(opts).body)
15
23
  end
16
24
 
25
+ private
17
26
  # == try proxy connect
18
27
  # use proxy connect if set proxy configuration .
19
- def call_http(opts)
28
+ def get_api_result(opts)
20
29
  uri = generate_uri(opts)
21
30
 
22
31
  Net::HTTP.Proxy(Config.proxy_host,
23
32
  Config.proxy_port).start(uri.host, uri.port) do |http|
24
33
  res = http.get("#{uri.path}?#{uri.query}",
25
34
  {'User-Agent' => Rwsc::CONST::USER_AGENT})
26
- parse_result(Nokogiri::XML(res.body))
35
+ return res
27
36
  end
28
37
  end
29
38
 
30
- private
31
39
  # == generate uri object from opts .
32
40
  def generate_uri(opts)
33
41
  url = Rwsc::CONST::WS_URL + "?"
@@ -41,46 +49,51 @@ module Rwsc
41
49
  end
42
50
 
43
51
  # == parse xml items
44
- def parse_result(doc)
45
- @item_search = ItemSearch.new
46
- parse_status(doc)
47
- parse_args(doc)
48
- parse_common_info(doc)
49
- parse_items(doc)
50
-
51
- @item_search
52
+ def parse_result(xml_string)
53
+ @doc = Nokogiri::XML(xml_string)
54
+ @namespaces = {}
55
+ @doc.traverse { |d| @namespaces.merge! d.namespaces }
56
+
57
+ #@item_search = ItemSearch.new
58
+ @result_item = eval("#{@operation}.new")
59
+ parse_status()
60
+ parse_args()
61
+ parse_common_info()
62
+ parse_items()
63
+
64
+ @result_item
52
65
  end
53
66
 
54
67
  # == parse status
55
68
  # if status is not success, this function raise
56
69
  #
57
- def parse_status(doc)
70
+ def parse_status()
58
71
  status = Status.new
59
- status.status = first_item_content(doc, '/Response/header:Header/Status')
72
+ status.status = first_item_content('/Response/header:Header/Status')
60
73
  status.status_msg =
61
- first_item_content(doc, '/Response/header:Header/StatusMsg')
62
- @item_search.status = status
74
+ first_item_content('/Response/header:Header/StatusMsg')
75
+ @result_item.status = status
63
76
 
64
- unless @item_search.status.status == Status::SUCCESS
65
- raise StatusError.new("API Error(#{@item_search.status.status}):" +
66
- "#{@item_search.status.status_msg}")
77
+ unless @result_item.status.status == Status::SUCCESS
78
+ raise StatusError.new("API Error(#{@result_item.status.status}):" +
79
+ "#{@result_item.status.status_msg}")
67
80
  end
68
81
  end
69
82
 
70
83
  # == parse ARG items
71
- def parse_args(doc)
84
+ def parse_args()
72
85
  args = []
73
- doc.xpath('/Response/header:Header/Args/Arg', doc.namespaces).each do |a|
86
+ @doc.xpath('/Response/header:Header/Args/Arg', @namespaces).each do |a|
74
87
  args << Arg.new(a.attribute('key'),
75
88
  a.attribute('value'),
76
89
  a.content)
77
90
  end
78
91
 
79
- @item_search.args = args
92
+ @result_item.args = args
80
93
  end
81
94
 
82
95
  # == parse common info
83
- def parse_common_info(doc)
96
+ def parse_common_info()
84
97
  {
85
98
  'count' => 'count',
86
99
  'page' => 'page',
@@ -90,18 +103,18 @@ module Rwsc
90
103
  'carrier' => 'carrier',
91
104
  'pageCount' => 'page_count',
92
105
  }.each do |xml_tag, func|
93
- @item_search.send("#{func}=",
94
- first_item_content(doc,
95
- "/Response/Body/itemSearch:ItemSearch/#{xml_tag}"))
106
+ @result_item.send("#{func}=",
107
+ first_item_content(
108
+ "/Response/Body/#{@operation[0,1].downcase + @operation[1,@operation.length]}:#{@operation}/#{xml_tag}"))
96
109
  end
97
110
  end
98
111
 
99
112
  # == parse items
100
- def parse_items(doc)
113
+ def parse_items()
101
114
  items = []
102
115
 
103
- doc.xpath('/Response/Body/itemSearch:ItemSearch/Items/Item',
104
- doc.namespaces).each do |i|
116
+ @doc.xpath("/Response/Body/#{@operation[0,1].downcase + @operation[1,@operation.length]}:#{@operation}/Items/Item",
117
+ @namespaces).each do |i|
105
118
  item = ResultItem.new
106
119
 
107
120
  i.children.each do |element|
@@ -113,13 +126,13 @@ module Rwsc
113
126
  items << item
114
127
  end
115
128
 
116
- @item_search.items = items
129
+ @result_item.items = items
117
130
  end
118
131
 
119
132
  # == get first item
120
133
  # if item not exists, return nil
121
- def first_item(doc, xpath)
122
- items = doc.xpath(xpath, doc.namespaces)
134
+ def first_item(xpath)
135
+ items = @doc.xpath(xpath, @namespaces)
123
136
  if items && !items.empty?
124
137
  return items.first
125
138
  end
@@ -129,8 +142,8 @@ module Rwsc
129
142
 
130
143
  # == get first item content
131
144
  # if item not exist, return nil
132
- def first_item_content(doc, xpath)
133
- item = first_item(doc, xpath)
145
+ def first_item_content(xpath)
146
+ item = first_item(xpath)
134
147
  if item
135
148
  return item.content
136
149
  end
@@ -4,10 +4,34 @@ require File.expand_path(File.join(File.dirname(__FILE__),
4
4
  '..', 'spec_helper'))
5
5
  require 'rwsc/version'
6
6
 
7
- describe Rwsc::VERSION do
7
+ describe "Rwsc::VERSION::STRING" do
8
8
  subject { Rwsc::VERSION::STRING }
9
9
 
10
10
  it { should == "#{Rwsc::VERSION::MAJOR}." +
11
11
  "#{Rwsc::VERSION::MINOR}." +
12
12
  "#{Rwsc::VERSION::TINY}" }
13
+
14
+ it { should == File.open(
15
+ File.join(
16
+ File.dirname(__FILE__), '..', '..',
17
+ 'VERSION'), 'r'){ |f| f.gets.chomp } }
18
+ end
19
+
20
+ describe "Rwsc::VERSION numbers" do
21
+ before(:each) do
22
+ @file_version =
23
+ File.open(
24
+ File.join(
25
+ File.dirname(__FILE__), '..', '..',
26
+ 'VERSION'), 'r'){ |f| f.gets.chomp }
27
+ if @file_version =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)/
28
+ @file_major = $1.to_i
29
+ @file_minor = $2.to_i
30
+ @file_tiny = $3.to_i
31
+ end
32
+ end
33
+
34
+ it { Rwsc::VERSION::MAJOR.should == @file_major }
35
+ it { Rwsc::VERSION::MINOR.should == @file_minor }
36
+ it { Rwsc::VERSION::TINY.should == @file_tiny }
13
37
  end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path(File.join(File.dirname(__FILE__),
3
+ '..','..', 'spec_helper'))
4
+ require 'rwsc'
5
+
6
+
7
+ describe Rwsc::Web::WebClient do
8
+ SEARCH_OPTS = {
9
+ :affiliateId=>"testAflId",
10
+ :operation=>"ItemSearch",
11
+ :keyword=>"sample",
12
+ :version=>"2009-04-15",
13
+ :developerId=>"testdeveloperId"
14
+ }
15
+
16
+ subject {
17
+ wc = Rwsc::Web::WebClient.new(SEARCH_OPTS[:operation])
18
+
19
+ http_res = Object.new
20
+ mock(http_res).body{
21
+ body = ''
22
+ File.open(File.join(File.dirname(__FILE__), 'sample.xml')){ |f|
23
+ body = f.read
24
+ }
25
+ body
26
+ }
27
+ mock(wc).get_api_result(SEARCH_OPTS){ http_res }
28
+ wc.get_result(SEARCH_OPTS)
29
+ }
30
+
31
+ it { subject.items.size.should == 30 }
32
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,4 +3,9 @@ require 'rubygems'
3
3
  require 'spec'
4
4
 
5
5
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ Dir[File.dirname(__FILE__) + "/mock/**/*.rb"].each {|f| require f}
6
7
  Dir[File.dirname(__FILE__) + "/matchers/**/*.rb"].each {|f| require f}
8
+
9
+ Spec::Runner.configure do |config|
10
+ config.mock_with :rr
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rwsc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - byplayer
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-10-24 00:00:00 +09:00
13
+ date: 2009-12-28 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -33,9 +33,10 @@ dependencies:
33
33
  - !ruby/object:Gem::Version
34
34
  version: "0"
35
35
  version:
36
- description: |
36
+ description: |-
37
+ <<-EOS
37
38
  Rakuten Webservice client library
38
-
39
+ EOS
39
40
  email:
40
41
  - byplayer100@gmail.com
41
42
  - takayoshi.kohayakawa@mail.rakuten.co.jp
@@ -47,35 +48,41 @@ extra_rdoc_files:
47
48
  - README.rdoc
48
49
  files:
49
50
  - MIT-LICENSE
50
- - Rakefile
51
+ - README.ja.rdoc
51
52
  - README.rdoc
52
- - lib/rwsc/web/web_client.rb
53
+ - Rakefile
54
+ - VERSION
55
+ - lib/rwsc.rb
53
56
  - lib/rwsc/arg.rb
54
- - lib/rwsc/utils/string_utils.rb
57
+ - lib/rwsc/arg_error.rb
58
+ - lib/rwsc/books_total_search.rb
55
59
  - lib/rwsc/config.rb
60
+ - lib/rwsc/const.rb
61
+ - lib/rwsc/item_search.rb
56
62
  - lib/rwsc/operation.rb
57
- - lib/rwsc/arg_error.rb
58
63
  - lib/rwsc/result_item.rb
59
- - lib/rwsc/item_search.rb
60
- - lib/rwsc/version.rb
64
+ - lib/rwsc/searcher.rb
61
65
  - lib/rwsc/status.rb
62
- - lib/rwsc/const.rb
63
66
  - lib/rwsc/status_error.rb
64
- - lib/rwsc.rb
65
- - spec/rwsc/const_spec.rb
66
- - spec/rwsc/utils/string_utils_spec.rb
67
- - spec/rwsc/config_spec.rb
67
+ - lib/rwsc/utils/string_utils.rb
68
+ - lib/rwsc/version.rb
69
+ - lib/rwsc/web/web_client.rb
70
+ - spec/matchers/utils/be_underscore_of.rb
68
71
  - spec/rwsc/arg_error_spec.rb
72
+ - spec/rwsc/config_spec.rb
73
+ - spec/rwsc/const_spec.rb
69
74
  - spec/rwsc/item_search_spec.rb
75
+ - spec/rwsc/utils/string_utils_spec.rb
70
76
  - spec/rwsc/version_spec.rb
77
+ - spec/rwsc/web/web_client_spec.rb
71
78
  - spec/spec_helper.rb
72
- - spec/matchers/utils/be_underscore_of.rb
73
79
  has_rdoc: true
74
80
  homepage: http://wiki.github.com/byplayer/rwsc
75
81
  licenses: []
76
82
 
77
83
  post_install_message:
78
84
  rdoc_options:
85
+ - --charset=UTF-8
79
86
  - --line-numbers
80
87
  - --inline-source
81
88
  - --main
@@ -102,5 +109,13 @@ rubygems_version: 1.3.5
102
109
  signing_key:
103
110
  specification_version: 3
104
111
  summary: Rakuten Webservice client library
105
- test_files: []
106
-
112
+ test_files:
113
+ - spec/rwsc/const_spec.rb
114
+ - spec/rwsc/web/web_client_spec.rb
115
+ - spec/rwsc/utils/string_utils_spec.rb
116
+ - spec/rwsc/config_spec.rb
117
+ - spec/rwsc/arg_error_spec.rb
118
+ - spec/rwsc/item_search_spec.rb
119
+ - spec/rwsc/version_spec.rb
120
+ - spec/spec_helper.rb
121
+ - spec/matchers/utils/be_underscore_of.rb