forked from codyfauser/ebay
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
162 lines (138 loc) · 4.76 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
$:.unshift File.join(File.dirname(__FILE__), 'lib')
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require "rubygems/package_task"
require 'rake/contrib/rubyforgepublisher'
PKG_VERSION = "0.12.0"
PKG_NAME = "ebayapi"
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_FILES = FileList[
"lib/**/*", "test/**/*", "examples/**/*", "[A-Z]*", "Rakefile", "init.rb"
].exclude(/~$|\.svn/)
response_dir = File.join(File.dirname(__FILE__), 'test', 'fixtures', 'responses')
desc "Default: Run all the unit tests"
task :default => [ 'test:units' ]
namespace :test do
desc 'Run all unit tests.'
Rake::TestTask.new(:units) do |t|
t.libs << "test"
t.pattern = "test/unit/**/*_test.rb"
t.verbose = true
end
desc 'Run all unit tests.'
Rake::TestTask.new(:mapping) do |t|
t.libs << "test"
t.pattern = "test/mapping/**/*_test.rb"
t.verbose = true
end
end
desc "Delete tar.gz / zip / rdoc"
task :cleanup => [ :clobber_package, :clobber_rdoc ]
namespace :schema do
desc 'Get the latest version of the eBay XML schema'
task :update do
puts 'Updating the eBay schema'
folder = File.dirname(__FILE__) + "/lib/ebay/schema"
url = 'http://developer.ebay.com/webservices/latest/ebaySvc.xsd'
cd folder do
rm_f 'ebaySvc.xsd'
system("wget #{url}")
end
end
desc "Update the schema version"
task :update_version do
schema = File.dirname(__FILE__) + '/lib/ebay/schema/ebaySvc.xsd'
# Update the schema version string
File.read(schema) =~ /Version (\d+)/m
if version = $1
version_file_path = File.dirname(__FILE__) + "/lib/ebay/schema/version.rb"
version_file = File.read(version_file_path)
version_file.gsub!(/VERSION = \d+/, "VERSION = #{version}")
File.open(version_file_path, 'w') do |f|
f.puts version_file
end
else
raise "Unable to parse the version from the schema"
end
end
end
namespace :classes do
desc "Remove the generated Ruby classes"
task :cleanup do
FileList[
"lib/ebay/requests.rb", "lib/ebay/responses.rb", "lib/ebay/types.rb", "lib/ebay/requests/*.rb", "lib/ebay/responses/*.rb", "lib/ebay/types/*.rb"
].each{|f| rm_rf f }
end
desc "Generate Ruby classes from the schema file and updates the schema version"
task :generate => [:cleanup, 'schema:update_version'] do
require 'ebay'
require 'ebay/schema/mapper'
%w(requests responses types).each do |dir|
folder = File.dirname(__FILE__) + "/lib/ebay/#{dir}"
Dir.mkdir(folder) unless File.directory?(folder)
end
schema = File.dirname(__FILE__) + '/lib/ebay/schema/ebaySvc.xsd'
data = File.read(schema)
Ebay::Schema::XSD2eBay.run(data, File.dirname(__FILE__) + '/lib/ebay')
end
end
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = "eBayAPI Ruby client for the eBay unified schema XML API"
rdoc.options << '--line-numbers' << '--inline-source' << '--main=README'
rdoc.rdoc_files.include('README', 'CHANGELOG')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.exclude('lib/ebay/schema')
rdoc.rdoc_files.exclude('lib/support')
end
spec = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.summary = "Ruby client for the eBay unified schema XML API"
s.has_rdoc = true
s.files = PKG_FILES
s.require_path = 'lib'
s.author = "Cody Fauser"
s.email = "[email protected]"
s.homepage = "http://ebayapi.rubyforge.org"
s.add_dependency('xml-mapping', '>= 0.8.1')
s.add_dependency('money', '= 1.7.1')
end
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = true
p.need_zip = true
end
desc "Release the gems and docs to RubyForge"
task :release => [ :publish, :upload ]
desc "Publish the release files to RubyForge."
task :publish => [ :package ] do
require 'rubyforge'
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
rubyforge = RubyForge.new
rubyforge.login
rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
end
desc 'Upload RDoc to RubyForge'
task :upload => :rdoc do
user = "[email protected]"
project = '/var/www/gforge-projects/ebayapi'
local_dir = 'doc'
pub = Rake::SshDirPublisher.new user, project, local_dir
pub.upload
end
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "ebay"
gem.homepage = "https://github.com/bkr/ebay"
gem.license = "MIT"
gem.summary = %Q{Ruby Gem to interact with Ebay APIs}
gem.description = %Q{Ruby Gem to interact with Ebay APIs - Extension of http://ebayapi.rubyforge.org by Cody Fauser}
gem.email = "[email protected]"
gem.authors = ["presmini"]
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new