This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
forked from bruchu/ebay
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
147 lines (131 loc) · 4.39 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
$:.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'
require 'bundler/setup'
require 'xml'
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 = 'https://developer.ebay.com/webservices/latest/ebaySvc.xsd'
cd folder do
system("curl #{url} > ebaySvc.xsd")
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
desc "Sellbrite configs"
task :update_sellbrite do
desc 'Always make some nodes optional'
schema = File.dirname(__FILE__) + '/lib/ebay/schema/ebaySvc.xsd'
overrides = %w(
ShowBidderNoticePreferences
ShowCombinedPaymentPreferences
ShowCrossPromotionPreferences
ShowSellerPaymentPreferences
ShowSellerProfilePreferences
ShippingDiscount
ItemRevised
AllowPaymentEdit
CheckoutEnabled
CIPBankAccountStored
GoodStanding
QualifiesForB2BVAT
StoreOwner
StoreCategoryID
StoreCategory2ID
)
text = File.read(schema)
overrides.each do |override|
match = /(?!.*minOccur.*$)(element.*"#{override}")(.*)(>)/
replace = '\1\2 minOccurs="0"\3'
text.gsub!(match,replace)
end
File.open(schema, "w") {|file| file.puts text }
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
Rake::RDocTask.new { |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')
}
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/#{Ebay::PKG_NAME}-#{Ebay::VERSION}.#{ext}" }
rubyforge = RubyForge.new
rubyforge.login
rubyforge.add_release(Ebay::PKG_NAME, Ebay::PKG_NAME, "REL #{Ebay::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