rvista 0.5.6 → 0.6.0

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/CHANGELOG ADDED
@@ -0,0 +1,33 @@
1
+ v0.6.0 (20th May 2009)
2
+ - Ruby 1.9 compat. No behaviour changes
3
+
4
+ v0.5.6 (13th November 2008)
5
+ - Cap field lengths in invoices to the max allowed by the spec
6
+ - Remove decimal points from monetary values
7
+ - all prices should be specified in cents
8
+
9
+ v0.5.5 (15th October 2008)
10
+ - Ensure RVista::POA#to_s includes total ordered qty in the footer
11
+
12
+ v0.5.4 (7th October 2008)
13
+ - Fix calculation of footer totals in RVista::Invoice#to_s
14
+
15
+ v0.5.3 (4th July 2008)
16
+ - Add RVista::POA#status_text
17
+
18
+ v0.5.2 (2nd July 2008)
19
+ - Add support for retrieving invoice totals
20
+
21
+ v0.5.1 (12th November 2007)
22
+ * Added RVista::Message and PO::LineItem classes for backwards compatability with =< v0.2. A deprecation warning will be printed to stderr.
23
+
24
+ v0.5 (12th October 2007)
25
+ * added support for Vista purchase order acks (POAs)
26
+ * added support for Vista invoices
27
+ * ****WARNING**** API CHANGE: renamed RVista::Message to the more sensible RVista::PO
28
+
29
+ v0.2 (19th November 2006)
30
+ * added support for converting a RVista::Message object to a string
31
+
32
+ v0.1.0 (17th October 2006)
33
+ * Initial Release
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
5
5
  require "rake/gempackagetask"
6
6
  require "rubygems"
7
7
 
8
- PKG_VERSION = "0.5.6"
8
+ PKG_VERSION = "0.6.0"
9
9
  PKG_NAME = "rvista"
10
10
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
11
11
 
@@ -31,6 +31,7 @@ desc "Create documentation"
31
31
  Rake::RDocTask.new("doc") do |rdoc|
32
32
  rdoc.title = "RVista"
33
33
  rdoc.rdoc_dir = 'doc/html'
34
+ rdoc.rdoc_files.include('CHANGELOG')
34
35
  rdoc.rdoc_files.include('README')
35
36
  rdoc.rdoc_files.include('COPYING')
36
37
  rdoc.rdoc_files.include('LICENSE')
@@ -47,10 +48,9 @@ spec = Gem::Specification.new do |spec|
47
48
  spec.require_path = "lib"
48
49
  spec.test_files = Dir[ "test/test_*.rb" ]
49
50
  spec.has_rdoc = true
50
- spec.extra_rdoc_files = %w{README COPYING LICENSE}
51
+ spec.extra_rdoc_files = %w{README COPYING LICENSE CHANGELOG}
51
52
  spec.rdoc_options << '--title' << 'rvista Documentation' <<
52
53
  '--main' << 'README' << '-q'
53
- spec.add_dependency('fastercsv', '>= 1.2.1')
54
54
  spec.author = "James Healy"
55
55
  spec.email = "jimmy@deefa.com"
56
56
  spec.description = <<END_DESC
data/lib/rvista.rb CHANGED
@@ -1,3 +1,25 @@
1
+ # coding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ # faster csv is distributed with ruby 1.9 as "CSV", so we only
6
+ # need to load the gem on ruby < 1.9
7
+ #
8
+ # This shim borrowed from Gregory Brown
9
+ # http://ruport.blogspot.com/2008/03/fastercsv-api-shim-for-19.html
10
+ #
11
+ if RUBY_VERSION > "1.9"
12
+ require "csv"
13
+ unless defined? FasterCSV
14
+ class Object
15
+ FCSV = FasterCSV = CSV
16
+ alias_method :FasterCSV, :CSV
17
+ end
18
+ end
19
+ else
20
+ require "fastercsv"
21
+ end
22
+
1
23
 
2
24
  require File.dirname(__FILE__) + '/rvista/errors'
3
25
  require File.dirname(__FILE__) + '/rvista/invoice'
data/lib/rvista/errors.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
 
2
3
  module RVista
3
4
 
@@ -1,5 +1,4 @@
1
- require 'rubygems'
2
- require 'fastercsv'
1
+ # coding: utf-8
3
2
 
4
3
  module RVista
5
4
 
@@ -16,7 +15,7 @@ module RVista
16
15
  @items = []
17
16
  end
18
17
 
19
- # reads a vista invoice file into memory. input should be a string
18
+ # reads a vista invoice file into memory. input should be a string
20
19
  # that specifies the file path
21
20
  def self.load_from_file(input)
22
21
  raise InvalidFileError, 'Invalid file' unless File.exist?(input)
@@ -44,13 +43,13 @@ module RVista
44
43
  msg << "#{doc_date.to_s[0,8]},"
45
44
  msg << "#{delivery_location.to_s[0,10]},"
46
45
  msg << "#{currency.to_s[0,4]}\n"
47
-
46
+
48
47
  total_value = BigDecimal.new("0")
49
48
  total_qty = BigDecimal.new("0")
50
49
  total_gst = BigDecimal.new("0")
51
50
 
52
51
  # message line items
53
- @items.each do |item|
52
+ @items.each do |item|
54
53
  msg << item.to_s << "\n"
55
54
  total_value += item.nett_value + item.gst
56
55
  total_qty += item.qty
@@ -90,7 +89,7 @@ module RVista
90
89
  msg.currency = data[0][8]
91
90
 
92
91
  # load each lineitem into the message
93
- data[1,data.size - 2].each do |row|
92
+ data[1,data.size - 2].each do |row|
94
93
  raise InvalidLineItemError, 'Invalid line detected' unless row[0].eql?("D")
95
94
  item = InvoiceLineItem.load_from_array(row)
96
95
  msg.items << item
@@ -98,6 +97,7 @@ module RVista
98
97
 
99
98
  raise InvalidFileError, 'Last line isn\'t a footer' unless data[-1][0].eql?("S")
100
99
  raise InvalidFileError, 'Line item count doesn\'t match footer' unless data[-1][1].to_i.eql?(msg.items.size)
100
+
101
101
  msg.total_value = BigDecimal.new(data[-1][2])
102
102
  msg.total_qty = BigDecimal.new(data[-1][3])
103
103
  msg.total_gst = BigDecimal.new(data[-1][4])
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'bigdecimal'
2
4
 
3
5
  module RVista
data/lib/rvista/po.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'rubygems'
2
- require 'fastercsv'
1
+ # coding: utf-8
3
2
 
4
3
  module RVista
5
4
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'bigdecimal'
2
4
 
3
5
  module RVista
data/lib/rvista/poa.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'rubygems'
2
- require 'fastercsv'
1
+ # coding: utf-8
3
2
 
4
3
  module RVista
5
4
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'bigdecimal'
2
4
 
3
5
  module RVista
@@ -15,7 +17,7 @@ module RVista
15
17
  STATUS = {
16
18
  1 => "Shipped as ordered",
17
19
  2 => "Title substituted",
18
- 6 => "Out of stock reprinting",
20
+ 6 => "Out of stock - reprinting",
19
21
  7 => "Back ordered",
20
22
  9 => "Part supply",
21
23
  10 => "Part back ordered",
@@ -1,4 +1,4 @@
1
1
  H,1111111,2222222,IN,Invoice,5678,071011,1111111,
2
- D,1,1234,EN,9781857230765,Eye of the World,2,EA,5.00,40.00,4.50,Y,10.00,6.00,9.50,1.00,F
3
- D,2,1234,EN,9780744590104,Eye of the Wolf,3,EA,5.00,40.00,4.50,Y,15.00,9.00,9.50,1.50,F
4
- S,2,25.00,5,2.50
2
+ D,1,1234,EN,9781857230765,Eye of the World,2,EA,500,4000,450,Y,1000,600,1000,100,F
3
+ D,2,1234,EN,9780744590104,Eye of the Wolf,3,EA,500,4000,450,Y,1500,900,1000,100,F
4
+ S,2,2200,5,200
@@ -2,7 +2,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rvista'
5
- require 'fastercsv'
6
5
 
7
6
  class InvoiceLineItemTest < Test::Unit::TestCase
8
7
 
@@ -16,9 +16,9 @@ class InvoiceTest < Test::Unit::TestCase
16
16
  msg = RVista::Invoice.load_from_file(VALID)
17
17
  assert_kind_of RVista::Invoice, msg
18
18
  assert_equal msg.items.size, 2
19
- assert_equal msg.total_value, BigDecimal.new("25.00")
19
+ assert_equal msg.total_value, BigDecimal.new("2200")
20
20
  assert_equal msg.total_qty, BigDecimal.new("5")
21
- assert_equal msg.total_gst, BigDecimal.new("2.50")
21
+ assert_equal msg.total_gst, BigDecimal.new("200")
22
22
 
23
23
  validate_msg(msg)
24
24
  end
@@ -28,14 +28,14 @@ class InvoiceTest < Test::Unit::TestCase
28
28
  msg = RVista::Invoice.load_from_string(File.read(VALID))
29
29
  assert_kind_of RVista::Invoice, msg
30
30
  assert_equal msg.items.size, 2
31
-
31
+
32
32
  validate_msg(msg)
33
33
  end
34
34
 
35
35
  # ensure the load_from_file method throws the correct exceptions
36
36
  # when it encounters a problem
37
37
  def test_product_validation
38
-
38
+
39
39
  assert_raise(RVista::InvalidFileError) {
40
40
  msg = RVista::Invoice.load_from_file(INVALID_MISSING_HEADER)
41
41
  }
@@ -43,7 +43,7 @@ class InvoiceTest < Test::Unit::TestCase
43
43
  assert_raise(RVista::InvalidFileError) {
44
44
  msg = RVista::Invoice.load_from_file(INVALID_MISSING_FOOTER)
45
45
  }
46
-
46
+
47
47
  assert_raise(RVista::InvalidLineItemError) {
48
48
  msg = RVista::Invoice.load_from_file(INVALID_LINE)
49
49
  }
@@ -2,7 +2,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rvista'
5
- require 'fastercsv'
6
5
 
7
6
  class POLineItemTest < Test::Unit::TestCase
8
7
 
@@ -2,7 +2,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rvista'
5
- require 'fastercsv'
6
5
 
7
6
  class POALineItemTest < Test::Unit::TestCase
8
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvista
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
@@ -9,19 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-13 00:00:00 +11:00
12
+ date: 2009-05-21 00:00:00 +10:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: fastercsv
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.2.1
24
- version:
14
+ dependencies: []
15
+
25
16
  description: rvista is a small library for reading Vista HDS order files.
26
17
  email: jimmy@deefa.com
27
18
  executables: []
@@ -32,6 +23,7 @@ extra_rdoc_files:
32
23
  - README
33
24
  - COPYING
34
25
  - LICENSE
26
+ - CHANGELOG
35
27
  files:
36
28
  - lib/rvista.rb
37
29
  - lib/rvista
@@ -71,6 +63,7 @@ files:
71
63
  - README
72
64
  - COPYING
73
65
  - LICENSE
66
+ - CHANGELOG
74
67
  has_rdoc: true
75
68
  homepage:
76
69
  post_install_message:
@@ -97,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
90
  requirements: []
98
91
 
99
92
  rubyforge_project:
100
- rubygems_version: 1.2.0
93
+ rubygems_version: 1.3.1
101
94
  signing_key:
102
95
  specification_version: 2
103
96
  summary: A small library for reading Vista HDS ecommerce files