riif 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b20c36b5498a01a063ae77e753b76eac27a8c78861f453e6e4825be81030cb3e
4
- data.tar.gz: 9bcc5c5905d3156eb54340d6304583a693ef6f85b31452adb6246f919b803d87
3
+ metadata.gz: 1a56ccfe5ea0177e0d909f225c82b3c109f0c67a81ecada953dc53a662297532
4
+ data.tar.gz: a12775175aa7214a7ddea3bff6b36646fc591d7f05a543b6706bcb87b4ff54f8
5
5
  SHA512:
6
- metadata.gz: a73111b8303ad440c89dfa4b5c51a80cd1e58c08617452a9b18ca46ec12796379fae0782fa25670e984047939dba4e5cc702fe5f6a82d5c67efc999edc32c735
7
- data.tar.gz: e6f1b0044e095032d3fe60de15d796fd87d3a62cbf1643c1695613f702c573f9da96c59f59bdb7633aea65c2830152f915b27b6ba345baabf8fd8d853a7f05a5
6
+ metadata.gz: c8d2308744c322019ee558d536fbf877beacac33e152b936e787307900a0204b6bba273e209d99194a13a5f1572df2553a618701405d7606450c0a161fe57a6a
7
+ data.tar.gz: bdf9f39f3ceb8410010fc0d45f75d80c83736d606ff90ed7a591493cf365d19debc7769c983366fe585ee763eb3df584cf5931d2ffc6b4c604a1ad529cae0a4a
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## NEXT (unreleased)
4
4
 
5
+ ## 1.1.0
6
+
7
+ - #45 DSL inner blocks accept argument to yield. [@mcelicalderon](https://github.com/mcelicalderon)
8
+
5
9
  ## 1.0.0
6
10
 
7
11
  - Requires Ruby >= 2.5.0.
@@ -1,14 +1,18 @@
1
1
  module Riif::DSL
2
2
  class Base
3
-
4
3
  def initialize
5
4
  @rows = []
6
5
  @current_row = []
7
6
  end
8
7
 
9
8
  def build(&block)
10
-
11
- instance_eval(&block)
9
+ if block_given?
10
+ if block.arity == 1
11
+ yield(self)
12
+ else
13
+ instance_eval(&block)
14
+ end
15
+ end
12
16
 
13
17
  output
14
18
  end
@@ -16,7 +20,13 @@ module Riif::DSL
16
20
  def row(&block)
17
21
  @current_row = [self.class::START_COLUMN]
18
22
 
19
- instance_eval(&block)
23
+ if block_given?
24
+ if block.arity == 1
25
+ yield(self)
26
+ else
27
+ instance_eval(&block)
28
+ end
29
+ end
20
30
 
21
31
  @rows << @current_row
22
32
  end
@@ -1,3 +1,3 @@
1
1
  module Riif
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,10 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Riif::DSL::Trns do
4
+ subject { trns }
4
5
 
5
6
  let(:expected) { File.read('spec/fixtures/trns.iif') }
6
7
 
7
- let(:trns) {
8
+ let(:trns) do
8
9
  Riif::IIF.new do
9
10
  trns do
10
11
  row do
@@ -16,7 +17,7 @@ describe Riif::DSL::Trns do
16
17
  amount 20
17
18
  docnum 1
18
19
  clear 'N'
19
- klass "foobar"
20
+ klass 'foobar'
20
21
  toprint 'N'
21
22
  addr1 'Baker'
22
23
  addr2 'Customer'
@@ -47,9 +48,57 @@ describe Riif::DSL::Trns do
47
48
  end
48
49
  end
49
50
  end
50
- }
51
-
52
- subject { trns }
51
+ end
53
52
 
54
53
  its(:output) { should eq expected }
54
+
55
+ context 'when arguments are passed to the block' do
56
+ let(:account) { 'Accounts Receivable' }
57
+ let(:trns) do
58
+ Riif::IIF.new do |riif|
59
+ riif.trns do |trns|
60
+ trns.row do |row|
61
+ row.trnsid 123
62
+ row.trnstype 'INVOICE'
63
+ row.date '8/31/1988'
64
+ row.accnt account
65
+ row.name 'Customer'
66
+ row.amount 20
67
+ row.docnum 1
68
+ row.clear 'N'
69
+ row.klass 'foobar'
70
+ row.toprint 'N'
71
+ row.addr1 'Baker'
72
+ row.addr2 'Customer'
73
+ row.saddr1 'Watson'
74
+ row.saddr2 'Recipient'
75
+ row.rep 'BOB'
76
+ end
77
+
78
+ trns.spl do
79
+ row do
80
+ splid '777'
81
+ trnstype 'INVOICE'
82
+ date '8/31/1988'
83
+ accnt 'Income Account'
84
+ amount '-20'
85
+ clear 'N'
86
+ qnty '-2'
87
+ price 10
88
+ invitem 'Sales Item'
89
+ taxable 'N'
90
+ end
91
+ end
92
+
93
+ trns.spl do
94
+ row do
95
+ splid '888'
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ its(:output) { should eq expected }
103
+ end
55
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riif
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jun Lin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-15 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -214,7 +214,7 @@ files:
214
214
  homepage: https://github.com/linjunpop/riif
215
215
  licenses: []
216
216
  metadata: {}
217
- post_install_message:
217
+ post_install_message:
218
218
  rdoc_options: []
219
219
  require_paths:
220
220
  - lib
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  version: '0'
231
231
  requirements: []
232
232
  rubygems_version: 3.0.1
233
- signing_key:
233
+ signing_key:
234
234
  specification_version: 4
235
235
  summary: A simple DSL to generate QuickBooks IIF file
236
236
  test_files: