ideaoforder-shipping 1.6.0 → 1.6.1

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.
@@ -0,0 +1,13 @@
1
+ # The "checkoutlist" file is used to support additional version controlled
2
+ # administrative files in $CVSROOT/CVSROOT, such as template files.
3
+ #
4
+ # The first entry on a line is a filename which will be checked out from
5
+ # the corresponding RCS file in the $CVSROOT/CVSROOT directory.
6
+ # The remainder of the line is an error message to use if the file cannot
7
+ # be checked out.
8
+ #
9
+ # File format:
10
+ #
11
+ # [<whitespace>]<filename>[<whitespace><error message>]<end-of-line>
12
+ #
13
+ # comment lines begin with '#'
@@ -0,0 +1,15 @@
1
+ # The "commitinfo" file is used to control pre-commit checks.
2
+ # The filter on the right is invoked with the repository and a list
3
+ # of files to check. A non-zero exit of the filter program will
4
+ # cause the commit to be aborted.
5
+ #
6
+ # The first entry on a line is a regular expression which is tested
7
+ # against the directory that the change is being committed to, relative
8
+ # to the $CVSROOT. For the first match that is found, then the remainder
9
+ # of the line is the name of the filter to run.
10
+ #
11
+ # If the repository name does not match any of the regular expressions in this
12
+ # file, the "DEFAULT" line is used, if it is specified.
13
+ #
14
+ # If the name "ALL" appears as a regular expression it is always used
15
+ # in addition to the first matching regex or "DEFAULT".
@@ -0,0 +1,21 @@
1
+ # Set this to "no" if pserver shouldn't check system users/passwords
2
+ #SystemAuth=no
3
+
4
+ # Put CVS lock files in this directory rather than directly in the repository.
5
+ LockDir=/var/cvslocks/
6
+
7
+ # Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
8
+ # level of the new working directory when using the `cvs checkout'
9
+ # command.
10
+ #TopLevelAdmin=no
11
+
12
+ # Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the
13
+ # history file, or a subset as needed (ie `TMAR' logs all write operations)
14
+ #LogHistory=TOFEWGCMAR
15
+
16
+ # Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg
17
+ # script to change the log message. Set it to `stat' to force CVS to verify# that the file has changed before reading it (this can take up to an extra
18
+ # second per directory being committed, so it is not recommended for large
19
+ # repositories. Set it to `never' (the previous CVS behavior) to prevent
20
+ # verifymsg scripts from changing the log message.
21
+ #RereadLogAfterVerify=always
@@ -0,0 +1,75 @@
1
+ # This file affects handling of files based on their names.
2
+ #
3
+ # The -m option specifies whether CVS attempts to merge files.
4
+ #
5
+ # The -k option specifies keyword expansion (e.g. -kb for binary).
6
+ #
7
+ # Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
8
+ #
9
+ # wildcard [option value][option value]...
10
+ #
11
+ # where option is one of
12
+ # -f from cvs filter value: path to filter
13
+ # -t to cvs filter value: path to filter
14
+ # -m update methodology value: MERGE or COPY
15
+ # -k expansion mode value: b, o, kkv, &c
16
+ #
17
+ # and value is a single-quote delimited value.
18
+ # For example:
19
+ #*.gif -k 'b'
20
+ *.JPG -k 'b' -m 'COPY'
21
+ *.avi -k 'b' -m 'COPY'
22
+ *.bin -k 'b' -m 'COPY'
23
+ *.bz -k 'b' -m 'COPY'
24
+ *.bz2 -k 'b' -m 'COPY'
25
+ *.doc -k 'b' -m 'COPY'
26
+ *.exe -k 'b' -m 'COPY'
27
+ *.gif -k 'b' -m 'COPY'
28
+ *.gz -k 'b' -m 'COPY'
29
+ *.hqx -k 'b' -m 'COPY'
30
+ *.jar -k 'b' -m 'COPY'
31
+ *.jpeg -k 'b' -m 'COPY'
32
+ *.jpg -k 'b' -m 'COPY'
33
+ *.mov -k 'b' -m 'COPY'
34
+ *.mp3 -k 'b' -m 'COPY'
35
+ *.mpg -k 'b' -m 'COPY'
36
+ *.pdf -k 'b' -m 'COPY'
37
+ *.png -k 'b' -m 'COPY'
38
+ *.ppt -k 'b' -m 'COPY'
39
+ *.rpm -k 'b' -m 'COPY'
40
+ *.sit -k 'b' -m 'COPY'
41
+ *.srpm -k 'b' -m 'COPY'
42
+ *.swf -k 'b' -m 'COPY'
43
+ *.tar -k 'b' -m 'COPY'
44
+ *.tbz -k 'b' -m 'COPY'
45
+ *.tgz -k 'b' -m 'COPY'
46
+ *.tif -k 'b' -m 'COPY'
47
+ *.tiff -k 'b' -m 'COPY'
48
+ *.xbm -k 'b' -m 'COPY'
49
+ *.xls -k 'b' -m 'COPY'
50
+ *.zip -k 'b' -m 'COPY'
51
+ *.keystore -k 'b' -m 'COPY'
52
+ # File types added by Borland JBuilder
53
+ *.aiff -k 'b'
54
+ *.midi -k 'b'
55
+ *.jds -k 'b'
56
+ *.asx -k 'b'
57
+ *.wav -k 'b'
58
+ *.war -k 'b'
59
+ *.ear -k 'b'
60
+ *.obj -k 'b'
61
+ *.dcu -k 'b'
62
+ *.class -k 'b'
63
+ *.au -k 'b'
64
+ *.eargrp -k 'b'
65
+ *.jpe -k 'b'
66
+ *.o -k 'b'
67
+ *.asf -k 'b'
68
+ *.rar -k 'b'
69
+ *.library -k 'b'
70
+ *.ejbgrp -k 'b'
71
+ *.ram -k 'b'
72
+ *.ejbgrpx -k 'b'
73
+ *.mid -k 'b'
74
+ *.rmf -k 'b'
75
+
@@ -0,0 +1,21 @@
1
+ # The "editinfo" file is used to allow verification of logging
2
+ # information. It works best when a template (as specified in the
3
+ # rcsinfo file) is provided for the logging procedure. Given a
4
+ # template with locations for, a bug-id number, a list of people who
5
+ # reviewed the code before it can be checked in, and an external
6
+ # process to catalog the differences that were code reviewed, the
7
+ # following test can be applied to the code:
8
+ #
9
+ # Making sure that the entered bug-id number is correct.
10
+ # Validating that the code that was reviewed is indeed the code being
11
+ # checked in (using the bug-id number or a seperate review
12
+ # number to identify this particular code set.).
13
+ #
14
+ # If any of the above test failed, then the commit would be aborted.
15
+ #
16
+ # Actions such as mailing a copy of the report to each reviewer are
17
+ # better handled by an entry in the loginfo file.
18
+ #
19
+ # One thing that should be noted is the the ALL keyword is not
20
+ # supported. There can be only one entry that matches a given
21
+ # repository.
@@ -0,0 +1,27 @@
1
+ # The "loginfo" file controls where "cvs commit" log information
2
+ # is sent. The first entry on a line is a regular expression which must match
3
+ # the directory that the change is being made to, relative to the
4
+ # $CVSROOT. If a match is found, then the remainder of the line is a filter
5
+ # program that should expect log information on its standard input.
6
+ #
7
+ # If the repository name does not match any of the regular expressions in this
8
+ # file, the "DEFAULT" line is used, if it is specified.
9
+ #
10
+ # If the name ALL appears as a regular expression it is always used
11
+ # in addition to the first matching regex or DEFAULT.
12
+ #
13
+ # You may specify a format string as part of the
14
+ # filter. The string is composed of a `%' followed
15
+ # by a single format character, or followed by a set of format
16
+ # characters surrounded by `{' and `}' as separators. The format
17
+ # characters are:
18
+ #
19
+ # s = file name
20
+ # V = old version number (pre-checkin)
21
+ # v = new version number (post-checkin)
22
+ #
23
+ # For example:
24
+ #DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
25
+ # or
26
+ #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
27
+ #DEFAULT /var/cvs/commitmailer.sh %s tom@infoether.com
@@ -0,0 +1,26 @@
1
+ # Three different line formats are valid:
2
+ # key -a aliases...
3
+ # key [options] directory
4
+ # key [options] directory files...
5
+ #
6
+ # Where "options" are composed of:
7
+ # -i prog Run "prog" on "cvs commit" from top-level of module.
8
+ # -o prog Run "prog" on "cvs checkout" of module.
9
+ # -e prog Run "prog" on "cvs export" of module.
10
+ # -t prog Run "prog" on "cvs rtag" of module.
11
+ # -u prog Run "prog" on "cvs update" of module.
12
+ # -d dir Place module in directory "dir" instead of module name.
13
+ # -l Top-level directory only -- do not recurse.
14
+ #
15
+ # NOTE: If you change any of the "Run" options above, you'll have to
16
+ # release and re-checkout any working directories of these modules.
17
+ #
18
+ # And "directory" is a path to a directory relative to $CVSROOT.
19
+ #
20
+ # The "-a" option specifies an alias. An alias is interpreted as if
21
+ # everything on the right of the "-a" had been typed on the command line.
22
+ #
23
+ # You can encode a module within a module by using the special '&'
24
+ # character to interpose another module into the current module. This
25
+ # can be useful for creating a module that consists of many directories
26
+ # spread out over the entire source repository.
@@ -0,0 +1,12 @@
1
+ # The "notify" file controls where notifications from watches set by
2
+ # "cvs watch add" or "cvs edit" are sent. The first entry on a line is
3
+ # a regular expression which is tested against the directory that the
4
+ # change is being made to, relative to the $CVSROOT. If it matches,
5
+ # then the remainder of the line is a filter program that should contain
6
+ # one occurrence of %s for the user to notify, and information on its
7
+ # standard input.
8
+ #
9
+ # "ALL" or "DEFAULT" can be used in place of the regular expression.
10
+ #
11
+ # For example:
12
+ #ALL mail -s "CVS notification" %s
@@ -0,0 +1 @@
1
+ anonymous:$1$0H$2/LSjjwDfsSA0gaDYY5Df/:tutorials
@@ -0,0 +1,13 @@
1
+ # The "rcsinfo" file is used to control templates with which the editor
2
+ # is invoked on commit and import.
3
+ #
4
+ # The first entry on a line is a regular expression which is tested
5
+ # against the directory that the change is being made to, relative to the
6
+ # $CVSROOT. For the first match that is found, then the remainder of the
7
+ # line is the name of the file that contains the template.
8
+ #
9
+ # If the repository name does not match any of the regular expressions in this
10
+ # file, the "DEFAULT" line is used, if it is specified.
11
+ #
12
+ # If the name "ALL" appears as a regular expression it is always used
13
+ # in addition to the first matching regex or "DEFAULT".
@@ -0,0 +1,2 @@
1
+ anonymous::anonymous
2
+
@@ -0,0 +1,20 @@
1
+ # The "taginfo" file is used to control pre-tag checks.
2
+ # The filter on the right is invoked with the following arguments:
3
+ #
4
+ # $1 -- tagname
5
+ # $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
6
+ # $3 -- repository
7
+ # $4-> file revision [file revision ...]
8
+ #
9
+ # A non-zero exit of the filter program will cause the tag to be aborted.
10
+ #
11
+ # The first entry on a line is a regular expression which is tested
12
+ # against the directory that the change is being committed to, relative
13
+ # to the $CVSROOT. For the first match that is found, then the remainder
14
+ # of the line is the name of the filter to run.
15
+ #
16
+ # If the repository name does not match any of the regular expressions in this
17
+ # file, the "DEFAULT" line is used, if it is specified.
18
+ #
19
+ # If the name "ALL" appears as a regular expression it is always used
20
+ # in addition to the first matching regex or "DEFAULT".
@@ -0,0 +1,21 @@
1
+ # The "verifymsg" file is used to allow verification of logging
2
+ # information. It works best when a template (as specified in the
3
+ # rcsinfo file) is provided for the logging procedure. Given a
4
+ # template with locations for, a bug-id number, a list of people who
5
+ # reviewed the code before it can be checked in, and an external
6
+ # process to catalog the differences that were code reviewed, the
7
+ # following test can be applied to the code:
8
+ #
9
+ # Making sure that the entered bug-id number is correct.
10
+ # Validating that the code that was reviewed is indeed the code being
11
+ # checked in (using the bug-id number or a seperate review
12
+ # number to identify this particular code set.).
13
+ #
14
+ # If any of the above test failed, then the commit would be aborted.
15
+ #
16
+ # Actions such as mailing a copy of the report to each reviewer are
17
+ # better handled by an entry in the loginfo file.
18
+ #
19
+ # One thing that should be noted is the the ALL keyword is not
20
+ # supported. There can be only one entry that matches a given
21
+ # repository.
data/Rakefile CHANGED
@@ -1,251 +1,14 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rake/testtask'
4
- require 'rake/rdoctask'
5
- require 'rake/gempackagetask'
6
- require 'rake/contrib/rubyforgepublisher'
7
- require File.dirname(__FILE__) + '/lib/shipping'
8
-
9
- PKG_VERSION = Shipping::VERSION
10
- PKG_NAME = "shipping"
11
- PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
- RUBY_FORGE_PROJECT = "shipping"
13
- RUBY_FORGE_USER = ENV['RUBY_FORGE_USER'] || "cardmagic"
14
- RELEASE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
15
-
16
- PKG_FILES = FileList[
17
- "lib/**/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "doc/**/*"
18
- ]
19
-
20
- desc "Default Task"
21
- task :default => [ :test ]
22
-
23
- # Run the unit tests
24
- desc "Run all unit tests"
25
- Rake::TestTask.new("test") { |t|
26
- t.libs << "lib"
27
- t.pattern = 'test/*/*_test.rb'
28
- t.verbose = true
29
- }
30
-
31
- # Make a console, useful when working on tests
32
- desc "Generate a test console"
33
- task :console do
34
- verbose( false ) { sh "irb -I lib/ -r 'shipping'" }
35
- end
36
-
37
- # Genereate the RDoc documentation
38
- desc "Create documentation"
39
- Rake::RDocTask.new("doc") { |rdoc|
40
- rdoc.title = "Ruby Shipping - UPS, FedEx, USPS"
41
- rdoc.rdoc_dir = 'html'
42
- rdoc.rdoc_files.include('README')
43
- rdoc.rdoc_files.include('lib/**/*.rb')
44
- }
45
-
46
- # Genereate the package
47
- spec = Gem::Specification.new do |s|
48
-
49
- #### Basic information.
50
-
51
- s.name = 'shipping'
52
- s.version = PKG_VERSION
53
- s.summary = <<-EOF
54
- A general shipping module to find out the shipping prices via UPS or FedEx.
55
- EOF
56
- s.description = <<-EOF
57
- A general shipping module to find out the shipping prices via UPS or FedEx.
58
- EOF
59
-
60
- #### Which files are to be included in this gem? Everything! (Except CVS directories.)
61
-
62
- s.files = PKG_FILES
63
-
64
- #### Load-time details: library and application (you will need one or both).
65
-
66
- s.add_dependency('builder', '>= 1.2.0')
67
- s.requirements << "An xml-builder library."
68
-
69
- s.require_path = 'lib'
70
- s.autorequire = 'shipping'
71
-
72
- #### Documentation and testing.
73
-
74
- s.has_rdoc = true
75
-
76
- #### Author and project details.
77
-
78
- s.author = "Lucas Carlson"
79
- s.email = "lucas@rufy.com"
80
- s.homepage = "http://shipping.rufy.com/"
81
- end
82
-
83
- Rake::GemPackageTask.new(spec) do |pkg|
84
- pkg.need_zip = true
85
- pkg.need_tar = true
86
- end
87
-
88
- desc "Report code statistics (KLOCs, etc) from the application"
89
- task :stats do
90
- require 'code_statistics'
91
- CodeStatistics.new(
92
- ["Library", "lib"],
93
- ["Units", "test"]
94
- ).to_s
95
- end
96
-
97
- desc "Publish new documentation"
98
- task :publish do
99
- Rake::RubyForgePublisher.new('shipping', 'cardmagic').upload
100
- `ssh rufy update-shipping-doc`
101
- end
102
-
103
- desc "Publish the release files to RubyForge."
104
- task :upload => [:package] do
105
- files = ["gem", "tgz", "zip"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
106
-
107
- if RUBY_FORGE_PROJECT then
108
- require 'net/http'
109
- require 'open-uri'
110
-
111
- project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
112
- project_data = open(project_uri) { |data| data.read }
113
- group_id = project_data[/[?&]group_id=(\d+)/, 1]
114
- raise "Couldn't get group id" unless group_id
115
-
116
- # This echos password to shell which is a bit sucky
117
- if ENV["RUBY_FORGE_PASSWORD"]
118
- password = ENV["RUBY_FORGE_PASSWORD"]
119
- else
120
- password = Proc.new do
121
- sync = STDOUT.sync
122
- begin
123
- echo false
124
- STDOUT.sync = true
125
- print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
126
- STDIN.gets.chomp
127
- ensure
128
- echo true
129
- STDOUT.sync = sync
130
- puts
131
- end
132
- end.call
133
- end
134
-
135
- login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
136
- data = [
137
- "login=1",
138
- "form_loginname=#{RUBY_FORGE_USER}",
139
- "form_pw=#{password}"
140
- ].join("&")
141
- http.post("/account/login.php", data)
142
- end
143
-
144
- cookie = login_response["set-cookie"]
145
- raise "Login failed" unless cookie
146
- headers = { "Cookie" => cookie }
147
-
148
- release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
149
- release_data = open(release_uri, headers) { |data| data.read }
150
- package_id = release_data[/[?&]package_id=(\d+)/, 1]
151
- raise "Couldn't get package id" unless package_id
152
-
153
- first_file = true
154
- release_id = ""
155
-
156
- files.each do |filename|
157
- basename = File.basename(filename)
158
- file_ext = File.extname(filename)
159
- file_data = File.open(filename, "rb") { |file| file.read }
160
-
161
- puts "Releasing #{basename}..."
162
-
163
- release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
164
- release_date = Time.now.strftime("%Y-%m-%d %H:%M")
165
- type_map = {
166
- ".zip" => "3000",
167
- ".tgz" => "3110",
168
- ".gz" => "3110",
169
- ".gem" => "1400"
170
- }; type_map.default = "9999"
171
- type = type_map[file_ext]
172
- boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
173
-
174
- query_hash = if first_file then
175
- {
176
- "group_id" => group_id,
177
- "package_id" => package_id,
178
- "release_name" => RELEASE_NAME,
179
- "release_date" => release_date,
180
- "type_id" => type,
181
- "processor_id" => "8000", # Any
182
- "release_notes" => "",
183
- "release_changes" => "",
184
- "preformatted" => "1",
185
- "submit" => "1"
186
- }
187
- else
188
- {
189
- "group_id" => group_id,
190
- "release_id" => release_id,
191
- "package_id" => package_id,
192
- "step2" => "1",
193
- "type_id" => type,
194
- "processor_id" => "8000", # Any
195
- "submit" => "Add This File"
196
- }
197
- end
198
-
199
- query = "?" + query_hash.map do |(name, value)|
200
- [name, URI.encode(value)].join("=")
201
- end.join("&")
202
-
203
- data = [
204
- "--" + boundary,
205
- "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
206
- "Content-Type: application/octet-stream",
207
- "Content-Transfer-Encoding: binary",
208
- "", file_data, ""
209
- ].join("\x0D\x0A")
210
-
211
- release_headers = headers.merge(
212
- "Content-Type" => "multipart/form-data; boundary=#{boundary}"
213
- )
214
-
215
- target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
216
- http.post(target + query, data, release_headers)
217
- end
218
-
219
- if first_file then
220
- release_id = release_response.body[/release_id=(\d+)/, 1]
221
- raise("Couldn't get release id") unless release_id
222
- end
223
-
224
- first_file = false
225
- end
226
- end
227
- end
228
-
229
1
  begin
230
- if !defined?(USE_TERMIOS) || USE_TERMIOS
231
- require 'termios'
232
- else
233
- raise LoadError
234
- end
235
-
236
- # Enable or disable stdin echoing to the terminal.
237
- def echo(enable)
238
- term = Termios::getattr(STDIN)
239
-
240
- if enable
241
- term.c_lflag |= (Termios::ECHO | Termios::ICANON)
242
- else
243
- term.c_lflag &= ~Termios::ECHO
244
- end
245
-
246
- Termios::setattr(STDIN, Termios::TCSANOW, term)
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |s|
4
+ s.name = "shipping"
5
+ s.summary = "A general shipping module to find out the shipping prices via UPS or FedEx"
6
+ s.email = "mark@sitesteaders.com"
7
+ s.homepage = "http://github.com/ideaoforder/shipping"
8
+ s.description = "A general shipping module to find out the shipping prices via UPS or FedEx"
9
+ s.authors = ["Lucas Carlson", "Jimmy Baker", "Mark Dickson"]
10
+ s.add_dependency('builder', '>= 1.2.0')
247
11
  end
248
12
  rescue LoadError
249
- def echo(enable)
250
- end
13
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
251
14
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.6.1
@@ -0,0 +1,40 @@
1
+ require 'rbconfig'
2
+ require 'find'
3
+ require 'ftools'
4
+
5
+ include Config
6
+
7
+ # this was adapted from rdoc's install.rb by ways of Log4r
8
+
9
+ $sitedir = CONFIG["sitelibdir"]
10
+ unless $sitedir
11
+ version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
12
+ $libdir = File.join(CONFIG["libdir"], "ruby", version)
13
+ $sitedir = $:.find {|x| x =~ /site_ruby/ }
14
+ if !$sitedir
15
+ $sitedir = File.join($libdir, "site_ruby")
16
+ elsif $sitedir !~ Regexp.quote(version)
17
+ $sitedir = File.join($sitedir, version)
18
+ end
19
+ end
20
+
21
+ makedirs = %w{ shipping }
22
+ makedirs.each {|f| File::makedirs(File.join($sitedir, *f.split(/\//)))}
23
+
24
+ Dir.chdir("lib")
25
+ begin
26
+ require 'rubygems'
27
+ require 'rake'
28
+ rescue LoadError
29
+ puts
30
+ puts "Please install Gem and Rake from http://rubyforge.org/projects/rubygems and http://rubyforge.org/projects/rake"
31
+ puts
32
+ exit(-1)
33
+ end
34
+
35
+ files = FileList["**/*"]
36
+
37
+ # File::safe_unlink *deprecated.collect{|f| File.join($sitedir, f.split(/\//))}
38
+ files.each {|f|
39
+ File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
40
+ }
@@ -0,0 +1,11 @@
1
+ class Object
2
+ def blank?
3
+ if respond_to? :empty?
4
+ empty?
5
+ elsif respond_to? :zero?
6
+ zero?
7
+ else
8
+ !self
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,47 @@
1
+ #--
2
+ # Copyright (c) 2005 Lucas Carlson
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ # Author:: Lucas Carlson (mailto:lucas@rufy.com)
24
+ # Copyright:: Copyright (c) 2005 Lucas Carlson
25
+ # License:: LGPL
26
+
27
+ $:.unshift(File.dirname(__FILE__))
28
+
29
+ begin
30
+ require 'rubygems'
31
+ rescue LoadError
32
+ nil
33
+ end
34
+
35
+ require 'builder'
36
+ require 'yaml'
37
+ require 'rexml/document'
38
+ require 'net/http'
39
+ require 'net/https'
40
+ require 'base64'
41
+ require 'fileutils'
42
+ require 'tempfile'
43
+
44
+ require 'extensions'
45
+ require 'shipping/base'
46
+ require 'shipping/fedex'
47
+ require 'shipping/ups'
@@ -5,8 +5,6 @@
5
5
  # Updated:: 12-22-2008 by Mark Dickson (mailto:mark@sitesteaders.com)
6
6
 
7
7
  module Shipping
8
- VERSION = "1.6.0"
9
-
10
8
  class ShippingError < StandardError; end
11
9
  class ShippingRequiredFieldError < StandardError; end
12
10
 
@@ -30,7 +28,7 @@ module Shipping
30
28
  attr_accessor :weight_each, :quantity, :max_weight, :max_quantity, :items
31
29
 
32
30
  def initialize(options = {})
33
- prefs = File.expand_path(options[:prefs] || "~/.shipping.yml")
31
+ prefs = File.expand_path(options[:prefs] || RAILS_ROOT + "/config/shipping.yml")
34
32
  YAML.load(File.open(prefs)).each {|pref, value| eval("@#{pref} = #{value.inspect}")} if File.exists?(prefs)
35
33
 
36
34
  @required = Array.new
@@ -0,0 +1,2 @@
1
+ *
2
+ !.gitignore
@@ -0,0 +1,71 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{shipping}
5
+ s.version = "1.6.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Lucas Carlson", "Jimmy Baker", "Mark Dickson"]
9
+ s.date = %q{2009-09-08}
10
+ s.description = %q{A general shipping module to find out the shipping prices via UPS or FedEx}
11
+ s.email = %q{mark@sitesteaders.com}
12
+ s.extra_rdoc_files = [
13
+ "LICENSE",
14
+ "README"
15
+ ]
16
+ s.files = [
17
+ "CVSROOT/checkoutlist",
18
+ "CVSROOT/commitinfo",
19
+ "CVSROOT/config",
20
+ "CVSROOT/cvswrappers",
21
+ "CVSROOT/editinfo",
22
+ "CVSROOT/loginfo",
23
+ "CVSROOT/modules",
24
+ "CVSROOT/notify",
25
+ "CVSROOT/passwd",
26
+ "CVSROOT/rcsinfo",
27
+ "CVSROOT/readers",
28
+ "CVSROOT/taginfo",
29
+ "CVSROOT/verifymsg",
30
+ "LICENSE",
31
+ "README",
32
+ "Rakefile",
33
+ "VERSION",
34
+ "install.rb",
35
+ "lib/extensions.rb",
36
+ "lib/shipping.rb",
37
+ "lib/shipping/base.rb",
38
+ "lib/shipping/fedex.rb",
39
+ "lib/shipping/ups.rb",
40
+ "pkg/.gitignore",
41
+ "shipping.gemspec",
42
+ "test/base/base_test.rb",
43
+ "test/fedex/fedex_test.rb",
44
+ "test/test_helper.rb",
45
+ "test/ups/ups_test.rb"
46
+ ]
47
+ s.homepage = %q{http://github.com/ideaoforder/shipping}
48
+ s.rdoc_options = ["--charset=UTF-8"]
49
+ s.require_paths = ["lib"]
50
+ s.rubygems_version = %q{1.3.5}
51
+ s.summary = %q{A general shipping module to find out the shipping prices via UPS or FedEx}
52
+ s.test_files = [
53
+ "test/base/base_test.rb",
54
+ "test/fedex/fedex_test.rb",
55
+ "test/ups/ups_test.rb",
56
+ "test/test_helper.rb"
57
+ ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<builder>, [">= 1.2.0"])
65
+ else
66
+ s.add_dependency(%q<builder>, [">= 1.2.0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<builder>, [">= 1.2.0"])
70
+ end
71
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ class BaseTest < Test::Unit::TestCase
3
+ def setup
4
+ @ship = Shipping::Base.new(
5
+ :zip => 97202,
6
+ :state => "OR",
7
+ :sender_zip => 10001,
8
+ :sender_state => "New York",
9
+ :weight => 2
10
+ )
11
+ end
12
+
13
+ def test_ups
14
+ ups = @ship.ups
15
+ assert_instance_of Shipping::UPS, ups
16
+ assert_equal ups.zip, @ship.zip
17
+ end
18
+
19
+ def test_fedex
20
+ fedex = @ship.fedex
21
+ assert_instance_of Shipping::FedEx, fedex
22
+ assert_equal fedex.zip, @ship.zip
23
+ end
24
+ end
@@ -0,0 +1,88 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ class FedExTest < Test::Unit::TestCase
3
+ def setup
4
+ @ship = Shipping::FedEx.new(
5
+ :zip => 97202,
6
+ :state => "OR",
7
+ :sender_zip => 10001,
8
+ :sender_state => "New York",
9
+ :weight => 2
10
+ )
11
+
12
+ # use demo environment for tests
13
+ @ship.fedex_url = 'https://gatewaybeta.fedex.com/GatewayDC'
14
+ end
15
+
16
+ def test_price
17
+ assert_in_delta 5.80, @ship.price, 1
18
+ end
19
+
20
+ def test_discount_price
21
+ assert_in_delta 5.80, @ship.discount_price, 1
22
+ assert @ship.discount_price < @ship.price
23
+ end
24
+
25
+ def test_fails
26
+ ship = Shipping::FedEx.new :zip => 97202, :weight => 2
27
+ assert_raise(Shipping::ShippingError) { ship.price }
28
+ end
29
+
30
+ def test_label
31
+ @ship.name = "Package Receiver"
32
+ @ship.phone = "555-555-5555"
33
+ @ship.email = "lucas@rufy.com"
34
+ @ship.address = "Some address"
35
+ @ship.city = "Portland"
36
+
37
+ @ship.sender_name = "Package Sender"
38
+ @ship.sender_phone = "333-333-3333"
39
+ @ship.sender_email = "john@doe.com"
40
+ @ship.sender_address = "Ok old address"
41
+ @ship.sender_city = "New York"
42
+
43
+ assert_nothing_raised { @label = @ship.label }
44
+ assert_not_nil @label.tracking_number
45
+ assert_not_nil @label.image.path
46
+ #assert_equal `file -i -b #{@label.image.path}`, "image/png\n"
47
+ end
48
+
49
+ def test_void
50
+ @ship.name = "Package Receiver"
51
+ @ship.phone = "555-555-5555"
52
+ @ship.email = "lucas@rufy.com"
53
+ @ship.address = "Some address"
54
+ @ship.city = "Portland"
55
+
56
+ @ship.sender_name = "Package Sender"
57
+ @ship.sender_phone = "333-333-3333"
58
+ @ship.sender_email = "john@doe.com"
59
+ @ship.sender_address = "Ok old address"
60
+ @ship.sender_city = "New York"
61
+
62
+ assert_nothing_raised { @label = @ship.label }
63
+
64
+ assert @ship.void(@label.tracking_number)
65
+ end
66
+
67
+ def test_available_services
68
+ @ship.name = "Package Receiver"
69
+ @ship.phone = "555-555-5555"
70
+ @ship.email = "lucas@rufy.com"
71
+ @ship.address = "Some address"
72
+ @ship.city = "Portland"
73
+
74
+ @ship.sender_name = "Package Sender"
75
+ @ship.sender_phone = "333-333-3333"
76
+ @ship.sender_email = "john@doe.com"
77
+ @ship.sender_address = "Ok old address"
78
+ @ship.sender_city = "New York"
79
+
80
+ assert_nothing_raised { @available_services = @ship.available_services }
81
+ assert_not_nil @available_services
82
+ end
83
+
84
+ def test_void_fail
85
+ # made up tracking number
86
+ assert_raise(Shipping::ShippingError) { @ship.void('470012923511666') }
87
+ end
88
+ end
@@ -0,0 +1,4 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require 'test/unit'
4
+ require 'shipping'
@@ -0,0 +1,72 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ class UpsTest < Test::Unit::TestCase
3
+ def setup
4
+ @ship = Shipping::UPS.new(
5
+ :zip => 97202,
6
+ :state => "OR",
7
+ :sender_zip => 10001,
8
+ :sender_state => "New York",
9
+ :weight => 2
10
+ )
11
+
12
+ # use demo environment for tests
13
+ @ship.ups_url = 'https://wwwcie.ups.com/ups.app/xml'
14
+ end
15
+
16
+ def test_price
17
+ # price is subject to account details, it seems?
18
+ assert_in_delta 5.80, @ship.price, 1
19
+ end
20
+
21
+ def test_valid_address
22
+ assert !@ship.valid_address?
23
+ @ship.city = "Portland"
24
+ assert @ship.valid_address?
25
+ end
26
+
27
+ def test_label
28
+ @ship.name = "Package Receiver"
29
+ @ship.company = "Package Receiver Company"
30
+ @ship.phone = "555-555-5555"
31
+ @ship.email = "lucas@rufy.com"
32
+ @ship.address = "Some address"
33
+ @ship.city = "Portland"
34
+
35
+ @ship.sender_name = "Package Sender"
36
+ @ship.sender_company = "Package Sender Company"
37
+ @ship.sender_phone = "333-333-3333"
38
+ @ship.sender_email = "john@doe.com"
39
+ @ship.sender_address = "Ok old address"
40
+ @ship.sender_city = "New York"
41
+
42
+ assert_nothing_raised { @label = @ship.label }
43
+ assert_not_nil @label.tracking_number
44
+ assert_not_nil @label.image.path
45
+ #assert_equal `file -i -b #{@label.image.path}`, "image/gif\n"
46
+ end
47
+
48
+ def test_void
49
+ @ship.name = "Package Receiver"
50
+ @ship.company = "Package Receiver Company"
51
+ @ship.phone = "555-555-5555"
52
+ @ship.email = "lucas@rufy.com"
53
+ @ship.address = "Some address"
54
+ @ship.city = "Portland"
55
+
56
+ @ship.sender_name = "Package Sender"
57
+ @ship.sender_company = "Package Sender Company"
58
+ @ship.sender_phone = "333-333-3333"
59
+ @ship.sender_email = "john@doe.com"
60
+ @ship.sender_address = "Ok old address"
61
+ @ship.sender_city = "New York"
62
+
63
+ assert_nothing_raised { @label = @ship.label }
64
+
65
+ assert @ship.void(@label.tracking_number)
66
+ end
67
+
68
+ def test_void_fail
69
+ # Tracking number from certification process; Time for voiding has expired
70
+ assert_raise(Shipping::ShippingError) { @ship.void('1Z12345E0392508488') }
71
+ end
72
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ideaoforder-shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2008-11-25 00:00:00 -08:00
14
+ date: 2009-09-08 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -25,25 +25,49 @@ dependencies:
25
25
  version: 1.2.0
26
26
  version:
27
27
  description: A general shipping module to find out the shipping prices via UPS or FedEx
28
- email: lucas@rufy.com
28
+ email: mark@sitesteaders.com
29
29
  executables: []
30
30
 
31
31
  extensions: []
32
32
 
33
- extra_rdoc_files: []
34
-
33
+ extra_rdoc_files:
34
+ - LICENSE
35
+ - README
35
36
  files:
37
+ - CVSROOT/checkoutlist
38
+ - CVSROOT/commitinfo
39
+ - CVSROOT/config
40
+ - CVSROOT/cvswrappers
41
+ - CVSROOT/editinfo
42
+ - CVSROOT/loginfo
43
+ - CVSROOT/modules
44
+ - CVSROOT/notify
45
+ - CVSROOT/passwd
46
+ - CVSROOT/rcsinfo
47
+ - CVSROOT/readers
48
+ - CVSROOT/taginfo
49
+ - CVSROOT/verifymsg
36
50
  - LICENSE
37
- - Rakefile
38
51
  - README
52
+ - Rakefile
53
+ - VERSION
54
+ - install.rb
55
+ - lib/extensions.rb
56
+ - lib/shipping.rb
39
57
  - lib/shipping/base.rb
40
58
  - lib/shipping/fedex.rb
41
59
  - lib/shipping/ups.rb
60
+ - pkg/.gitignore
61
+ - shipping.gemspec
62
+ - test/base/base_test.rb
63
+ - test/fedex/fedex_test.rb
64
+ - test/test_helper.rb
65
+ - test/ups/ups_test.rb
42
66
  has_rdoc: false
43
67
  homepage: http://github.com/ideaoforder/shipping
44
68
  post_install_message:
45
- rdoc_options: []
46
-
69
+ rdoc_options:
70
+ - --charset=UTF-8
47
71
  require_paths:
48
72
  - lib
49
73
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -63,7 +87,10 @@ requirements: []
63
87
  rubyforge_project:
64
88
  rubygems_version: 1.2.0
65
89
  signing_key:
66
- specification_version: 2
90
+ specification_version: 3
67
91
  summary: A general shipping module to find out the shipping prices via UPS or FedEx
68
- test_files: []
69
-
92
+ test_files:
93
+ - test/base/base_test.rb
94
+ - test/fedex/fedex_test.rb
95
+ - test/ups/ups_test.rb
96
+ - test/test_helper.rb