riif 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +3 -0
- data/README.md +29 -27
- data/config.ru +9 -0
- data/lib/riif.rb +3 -3
- data/lib/riif/iif.rb +19 -4
- data/lib/riif/rails/template_handler.rb +1 -0
- data/lib/riif/version.rb +1 -1
- data/riif.gemspec +3 -0
- data/spec/controllers/invoices_controller_spec.rb +14 -0
- data/spec/fixtures/mixed.iif +10 -0
- data/spec/fixtures/rails/invoices.iif +6 -0
- data/spec/internal/app/controllers/invoices_controller.rb +7 -0
- data/spec/internal/app/views/invoices/index.iif.riif +27 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/schema.rb +3 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/riif/dsl/accnt_spec.rb +8 -6
- data/spec/riif/dsl/bud_spec.rb +15 -8
- data/spec/riif/dsl/ctype_spec.rb +6 -4
- data/spec/riif/dsl/cust_spec.rb +7 -5
- data/spec/riif/dsl/emp_spec.rb +10 -9
- data/spec/riif/dsl/invitem_spec.rb +8 -6
- data/spec/riif/dsl/invmemo_spec.rb +6 -4
- data/spec/riif/dsl/klass_spec.rb +6 -4
- data/spec/riif/dsl/othername_spec.rb +9 -7
- data/spec/riif/dsl/paymeth_spec.rb +6 -4
- data/spec/riif/dsl/shipmeth_spec.rb +6 -4
- data/spec/riif/dsl/terms_spec.rb +10 -8
- data/spec/riif/dsl/timeact_spec.rb +4 -3
- data/spec/riif/dsl/trns_spec.rb +30 -28
- data/spec/riif/dsl/vend_spec.rb +8 -6
- data/spec/riif/dsl/vtype_spec.rb +6 -4
- data/spec/riif/iif_spec.rb +47 -0
- data/spec/spec_helper.rb +8 -13
- metadata +73 -2
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -82,39 +82,41 @@ end
|
|
82
82
|
### Without Rails
|
83
83
|
|
84
84
|
```ruby
|
85
|
-
Riif::IIF.new
|
86
|
-
|
87
|
-
trnsid 123
|
88
|
-
trnstype 'INVOICE'
|
89
|
-
date '8/31/1988'
|
90
|
-
accnt 'Accounts Receivable'
|
91
|
-
name 'Customer'
|
92
|
-
amount 20
|
93
|
-
docnum 1
|
94
|
-
clear 'N'
|
95
|
-
toprint 'N'
|
96
|
-
addr1 'Baker'
|
97
|
-
addr2 'Customer'
|
98
|
-
end
|
99
|
-
|
100
|
-
spl do
|
85
|
+
Riif::IIF.new do
|
86
|
+
trns do
|
101
87
|
row do
|
102
|
-
|
88
|
+
trnsid 123
|
103
89
|
trnstype 'INVOICE'
|
104
90
|
date '8/31/1988'
|
105
|
-
accnt '
|
106
|
-
|
91
|
+
accnt 'Accounts Receivable'
|
92
|
+
name 'Customer'
|
93
|
+
amount 20
|
94
|
+
docnum 1
|
107
95
|
clear 'N'
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
taxable 'N'
|
96
|
+
toprint 'N'
|
97
|
+
addr1 'Baker'
|
98
|
+
addr2 'Customer'
|
112
99
|
end
|
113
|
-
end
|
114
100
|
|
115
|
-
|
116
|
-
|
117
|
-
|
101
|
+
spl do
|
102
|
+
row do
|
103
|
+
splid '777'
|
104
|
+
trnstype 'INVOICE'
|
105
|
+
date '8/31/1988'
|
106
|
+
accnt 'Income Account'
|
107
|
+
amount '-20'
|
108
|
+
clear 'N'
|
109
|
+
qnty '-2'
|
110
|
+
price 10
|
111
|
+
invitem 'Sales Item'
|
112
|
+
taxable 'N'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
spl do
|
117
|
+
row do
|
118
|
+
splid '888'
|
119
|
+
end
|
118
120
|
end
|
119
121
|
end
|
120
122
|
end
|
data/config.ru
ADDED
data/lib/riif.rb
CHANGED
data/lib/riif/iif.rb
CHANGED
@@ -22,17 +22,32 @@ require 'riif/dsl/vtype'
|
|
22
22
|
|
23
23
|
module Riif
|
24
24
|
class IIF
|
25
|
-
def
|
26
|
-
|
25
|
+
def initialize(&block)
|
26
|
+
@output = {
|
27
|
+
headers: [],
|
28
|
+
rows: []
|
29
|
+
}
|
30
|
+
if block_given?
|
31
|
+
instance_eval(&block)
|
32
|
+
end
|
33
|
+
end
|
27
34
|
|
35
|
+
def output
|
28
36
|
CSV.generate(col_sep: "\t") do |tsv|
|
29
|
-
|
37
|
+
@output[:headers].uniq.each do |header|
|
30
38
|
tsv << header
|
31
39
|
end
|
32
|
-
|
40
|
+
@output[:rows].each do |row|
|
33
41
|
tsv << row
|
34
42
|
end
|
35
43
|
end
|
36
44
|
end
|
45
|
+
|
46
|
+
def method_missing(method_name, *args, &block)
|
47
|
+
result = eval("::Riif::DSL::#{method_name.capitalize}").new.build(&block)
|
48
|
+
|
49
|
+
@output[:headers].concat(result[:headers])
|
50
|
+
@output[:rows].concat(result[:rows])
|
51
|
+
end
|
37
52
|
end
|
38
53
|
end
|
data/lib/riif/version.rb
CHANGED
data/riif.gemspec
CHANGED
@@ -18,6 +18,9 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_development_dependency 'pry'
|
21
|
+
gem.add_development_dependency 'rails'
|
21
22
|
gem.add_development_dependency 'rspec'
|
23
|
+
gem.add_development_dependency 'rspec-rails'
|
22
24
|
gem.add_development_dependency 'awesome_print'
|
25
|
+
gem.add_development_dependency 'combustion', '~> 0.3.1'
|
23
26
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe InvoicesController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
let(:expected) { File.read('spec/fixtures/rails/invoices.iif') }
|
7
|
+
|
8
|
+
describe '#index' do
|
9
|
+
it 'respond with rendered iif' do
|
10
|
+
get :index, format: 'iif'
|
11
|
+
response.body.should eq expected
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
!BUD ACCNT PERIOD AMOUNT STARTDATE CLASS CUSTOMER
|
2
|
+
!TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 DUEDATE TERMS PAID SHIPDATE
|
3
|
+
!SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE REIMBEXP EXTRA
|
4
|
+
!ENDTRNS
|
5
|
+
BUD Accounts Receivable MONTH foo 3/14/12
|
6
|
+
BUD Accounts Payable MONTH 123 3/15/12
|
7
|
+
TRNS foo
|
8
|
+
SPL joker
|
9
|
+
SPL foobar
|
10
|
+
ENDTRNS
|
@@ -0,0 +1,6 @@
|
|
1
|
+
!TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 DUEDATE TERMS PAID SHIPDATE
|
2
|
+
!SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE REIMBEXP EXTRA
|
3
|
+
!ENDTRNS
|
4
|
+
TRNS 12345 BILL 3/14/1984 Accounts Payable EZ -300 12345 N
|
5
|
+
SPL 1 BILL 3/14/1984 Payable CMA 300 foo 3 150 Base Rate
|
6
|
+
ENDTRNS
|
@@ -0,0 +1,27 @@
|
|
1
|
+
iif.trns do
|
2
|
+
row do
|
3
|
+
trnsid 12345
|
4
|
+
trnstype 'BILL'
|
5
|
+
date '3/14/1984'
|
6
|
+
accnt 'Accounts Payable'
|
7
|
+
name 'EZ'
|
8
|
+
amount -300
|
9
|
+
docnum 12345
|
10
|
+
clear 'N'
|
11
|
+
end
|
12
|
+
|
13
|
+
spl do
|
14
|
+
row do
|
15
|
+
splid 001
|
16
|
+
trnstype 'BILL'
|
17
|
+
date '3/14/1984'
|
18
|
+
accnt 'Payable'
|
19
|
+
invitem 'Base Rate'
|
20
|
+
name 'CMA'
|
21
|
+
amount 300
|
22
|
+
memo "foo"
|
23
|
+
qnty 3
|
24
|
+
price 150
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
File without changes
|
data/spec/riif/dsl/accnt_spec.rb
CHANGED
@@ -5,16 +5,18 @@ describe Riif::DSL::Accnt do
|
|
5
5
|
let(:expected) { File.read('spec/fixtures/accnt.iif') }
|
6
6
|
|
7
7
|
let(:accnt) {
|
8
|
-
Riif::IIF.new
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
Riif::IIF.new do
|
9
|
+
accnt do
|
10
|
+
row do
|
11
|
+
name 'Jun Lin'
|
12
|
+
accnttype 'AR'
|
13
|
+
accnum 47
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
}
|
16
18
|
|
17
19
|
subject { accnt }
|
18
20
|
|
19
|
-
|
21
|
+
its(:output) { should eq expected }
|
20
22
|
end
|
data/spec/riif/dsl/bud_spec.rb
CHANGED
@@ -1,21 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
2
|
+
class Invoice
|
3
|
+
attr_accessor :name
|
4
|
+
def initialize(n)
|
5
|
+
@name = n
|
6
|
+
end
|
7
|
+
end
|
3
8
|
describe Riif::DSL::Bud do
|
4
9
|
|
5
10
|
let(:expected) { File.read('spec/fixtures/bud.iif') }
|
6
11
|
|
7
12
|
let(:bud) {
|
8
|
-
Riif::IIF.new
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
Riif::IIF.new do
|
14
|
+
bud do
|
15
|
+
row do
|
16
|
+
accnt 'Accounts Receivable'
|
17
|
+
period 'MONTH'
|
18
|
+
amount 'foo'
|
19
|
+
startdate '3/14/12'
|
20
|
+
end
|
14
21
|
end
|
15
22
|
end
|
16
23
|
}
|
17
24
|
|
18
25
|
subject { bud }
|
19
26
|
|
20
|
-
|
27
|
+
its(:output) { should eq expected }
|
21
28
|
end
|
data/spec/riif/dsl/ctype_spec.rb
CHANGED
@@ -4,14 +4,16 @@ describe Riif::DSL::Ctype do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/ctype.iif') }
|
5
5
|
|
6
6
|
let(:ctype) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
ctype do
|
9
|
+
row do
|
10
|
+
name 'Bar'
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
}
|
13
15
|
|
14
16
|
subject { ctype }
|
15
17
|
|
16
|
-
|
18
|
+
its(:output) { should eq expected }
|
17
19
|
end
|
data/spec/riif/dsl/cust_spec.rb
CHANGED
@@ -4,15 +4,17 @@ describe Riif::DSL::Cust do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/cust.iif') }
|
5
5
|
|
6
6
|
let(:cust) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
cust do
|
9
|
+
row do
|
10
|
+
name 'Jun Lin'
|
11
|
+
phone1 '12312323242'
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
}
|
14
16
|
|
15
17
|
subject { cust }
|
16
18
|
|
17
|
-
|
19
|
+
its(:output) { should eq expected }
|
18
20
|
end
|
data/spec/riif/dsl/emp_spec.rb
CHANGED
@@ -5,19 +5,20 @@ describe Riif::DSL::Emp do
|
|
5
5
|
let(:expected) { File.read('spec/fixtures/emp.iif') }
|
6
6
|
|
7
7
|
let(:emp) {
|
8
|
-
Riif::IIF.new
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
Riif::IIF.new do
|
9
|
+
emp do
|
10
|
+
row do
|
11
|
+
name 'Alfred'
|
12
|
+
init 'Master'
|
13
|
+
addr1 'Backer'
|
14
|
+
addr2 '37'
|
15
|
+
salutation 'Doctor'
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
}
|
18
20
|
|
19
21
|
subject { emp }
|
20
22
|
|
21
|
-
|
23
|
+
its(:output) { should eq expected }
|
22
24
|
end
|
23
|
-
|
@@ -4,16 +4,18 @@ describe Riif::DSL::Invitem do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/invitem.iif') }
|
5
5
|
|
6
6
|
let(:invitem) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
invitem do
|
9
|
+
row do
|
10
|
+
name 'invitem 1'
|
11
|
+
invitemtype 'INVENTORY'
|
12
|
+
dep_type 1
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
}
|
15
17
|
|
16
18
|
subject { invitem }
|
17
19
|
|
18
|
-
|
20
|
+
its(:output) { should eq expected }
|
19
21
|
end
|
@@ -4,14 +4,16 @@ describe Riif::DSL::Invmemo do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/invmemo.iif') }
|
5
5
|
|
6
6
|
let(:invmemo) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
invmemo do
|
9
|
+
row do
|
10
|
+
name 'invmemo 1'
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
}
|
13
15
|
|
14
16
|
subject { invmemo }
|
15
17
|
|
16
|
-
|
18
|
+
its(:output) { should eq expected }
|
17
19
|
end
|
data/spec/riif/dsl/klass_spec.rb
CHANGED
@@ -5,14 +5,16 @@ describe Riif::DSL::Klass do
|
|
5
5
|
let(:expected) { File.read('spec/fixtures/klass.iif') }
|
6
6
|
|
7
7
|
let(:klass) {
|
8
|
-
Riif::IIF.new
|
9
|
-
|
10
|
-
|
8
|
+
Riif::IIF.new do
|
9
|
+
klass do
|
10
|
+
row do
|
11
|
+
name 'Foo'
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
}
|
14
16
|
|
15
17
|
subject { klass }
|
16
18
|
|
17
|
-
|
19
|
+
its(:output) { should eq expected }
|
18
20
|
end
|
@@ -5,17 +5,19 @@ describe Riif::DSL::Othername do
|
|
5
5
|
let(:expected) { File.read('spec/fixtures/othername.iif') }
|
6
6
|
|
7
7
|
let(:othername) {
|
8
|
-
Riif::IIF.new
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
Riif::IIF.new do
|
9
|
+
othername do
|
10
|
+
row do
|
11
|
+
name 'Alfred'
|
12
|
+
baddr1 'Backer'
|
13
|
+
baddr2 '37'
|
14
|
+
faxnum '123'
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
}
|
17
19
|
|
18
20
|
subject { othername }
|
19
21
|
|
20
|
-
|
22
|
+
its(:output) { should eq expected }
|
21
23
|
end
|
@@ -4,14 +4,16 @@ describe Riif::DSL::Paymeth do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/paymeth.iif') }
|
5
5
|
|
6
6
|
let(:paymeth) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
paymeth do
|
9
|
+
row do
|
10
|
+
name 'paymeth 1'
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
}
|
13
15
|
|
14
16
|
subject { paymeth }
|
15
17
|
|
16
|
-
|
18
|
+
its(:output) { should eq expected }
|
17
19
|
end
|
@@ -4,14 +4,16 @@ describe Riif::DSL::Shipmeth do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/shipmeth.iif') }
|
5
5
|
|
6
6
|
let(:shipmeth) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
shipmeth do
|
9
|
+
row do
|
10
|
+
name 'shipmeth 1'
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
}
|
13
15
|
|
14
16
|
subject { shipmeth }
|
15
17
|
|
16
|
-
|
18
|
+
its(:output) { should eq expected }
|
17
19
|
end
|
data/spec/riif/dsl/terms_spec.rb
CHANGED
@@ -4,18 +4,20 @@ describe Riif::DSL::Terms do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/terms.iif') }
|
5
5
|
|
6
6
|
let(:terms) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
terms do
|
9
|
+
row do
|
10
|
+
name 'terms 1'
|
11
|
+
duedays 10
|
12
|
+
discper 0.3
|
13
|
+
discdays 1
|
14
|
+
termstype 0
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
}
|
17
19
|
|
18
20
|
subject { terms }
|
19
21
|
|
20
|
-
|
22
|
+
its(:output) { should eq expected }
|
21
23
|
end
|
@@ -4,7 +4,8 @@ describe Riif::DSL::Timeact do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/timeact.iif') }
|
5
5
|
|
6
6
|
let(:timeact) {
|
7
|
-
Riif::IIF.new
|
7
|
+
Riif::IIF.new do
|
8
|
+
timeact do
|
8
9
|
row do
|
9
10
|
date '06/21/97'
|
10
11
|
job 'job 1'
|
@@ -15,10 +16,10 @@ describe Riif::DSL::Timeact do
|
|
15
16
|
billingstatus 0
|
16
17
|
end
|
17
18
|
end
|
19
|
+
end
|
18
20
|
}
|
19
21
|
|
20
22
|
subject { timeact }
|
21
23
|
|
22
|
-
|
24
|
+
its(:output) { should eq expected }
|
23
25
|
end
|
24
|
-
|
data/spec/riif/dsl/trns_spec.rb
CHANGED
@@ -5,39 +5,41 @@ describe Riif::DSL::Trns do
|
|
5
5
|
let(:expected) { File.read('spec/fixtures/trns.iif') }
|
6
6
|
|
7
7
|
let(:trns) {
|
8
|
-
Riif::IIF.new
|
9
|
-
|
10
|
-
trnsid 123
|
11
|
-
trnstype 'INVOICE'
|
12
|
-
date '8/31/1988'
|
13
|
-
accnt 'Accounts Receivable'
|
14
|
-
name 'Customer'
|
15
|
-
amount 20
|
16
|
-
docnum 1
|
17
|
-
clear 'N'
|
18
|
-
toprint 'N'
|
19
|
-
addr1 'Baker'
|
20
|
-
addr2 'Customer'
|
21
|
-
end
|
22
|
-
|
23
|
-
spl do
|
8
|
+
Riif::IIF.new do
|
9
|
+
trns do
|
24
10
|
row do
|
25
|
-
|
11
|
+
trnsid 123
|
26
12
|
trnstype 'INVOICE'
|
27
13
|
date '8/31/1988'
|
28
|
-
accnt '
|
29
|
-
|
14
|
+
accnt 'Accounts Receivable'
|
15
|
+
name 'Customer'
|
16
|
+
amount 20
|
17
|
+
docnum 1
|
30
18
|
clear 'N'
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
taxable 'N'
|
19
|
+
toprint 'N'
|
20
|
+
addr1 'Baker'
|
21
|
+
addr2 'Customer'
|
35
22
|
end
|
36
|
-
end
|
37
23
|
|
38
|
-
|
39
|
-
|
40
|
-
|
24
|
+
spl do
|
25
|
+
row do
|
26
|
+
splid '777'
|
27
|
+
trnstype 'INVOICE'
|
28
|
+
date '8/31/1988'
|
29
|
+
accnt 'Income Account'
|
30
|
+
amount '-20'
|
31
|
+
clear 'N'
|
32
|
+
qnty '-2'
|
33
|
+
price 10
|
34
|
+
invitem 'Sales Item'
|
35
|
+
taxable 'N'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
spl do
|
40
|
+
row do
|
41
|
+
splid '888'
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -45,5 +47,5 @@ describe Riif::DSL::Trns do
|
|
45
47
|
|
46
48
|
subject { trns }
|
47
49
|
|
48
|
-
|
50
|
+
its(:output) { should eq expected }
|
49
51
|
end
|
data/spec/riif/dsl/vend_spec.rb
CHANGED
@@ -4,16 +4,18 @@ describe Riif::DSL::Vend do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/vend.iif') }
|
5
5
|
|
6
6
|
let(:vend) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
vend do
|
9
|
+
row do
|
10
|
+
name 'Jun Lin'
|
11
|
+
phone1 '12312323242'
|
12
|
+
_1099 'Y'
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
}
|
15
17
|
|
16
18
|
subject { vend }
|
17
19
|
|
18
|
-
|
20
|
+
its(:output) { should eq expected }
|
19
21
|
end
|
data/spec/riif/dsl/vtype_spec.rb
CHANGED
@@ -4,14 +4,16 @@ describe Riif::DSL::Vtype do
|
|
4
4
|
let(:expected) { File.read('spec/fixtures/vtype.iif') }
|
5
5
|
|
6
6
|
let(:vtype) {
|
7
|
-
Riif::IIF.new
|
8
|
-
|
9
|
-
|
7
|
+
Riif::IIF.new do
|
8
|
+
vtype do
|
9
|
+
row do
|
10
|
+
name 'vtype 1'
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
}
|
13
15
|
|
14
16
|
subject { vtype }
|
15
17
|
|
16
|
-
|
18
|
+
its(:output) { should eq expected }
|
17
19
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Riif::IIF do
|
4
|
+
|
5
|
+
context 'mixed document' do
|
6
|
+
let(:expected) { File.read('spec/fixtures/mixed.iif') }
|
7
|
+
|
8
|
+
let(:mixed) {
|
9
|
+
Riif::IIF.new do
|
10
|
+
bud do
|
11
|
+
row do
|
12
|
+
accnt 'Accounts Receivable'
|
13
|
+
period 'MONTH'
|
14
|
+
amount 'foo'
|
15
|
+
startdate '3/14/12'
|
16
|
+
end
|
17
|
+
row do
|
18
|
+
accnt 'Accounts Payable'
|
19
|
+
period 'MONTH'
|
20
|
+
amount '123'
|
21
|
+
startdate '3/15/12'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
trns do
|
26
|
+
row do
|
27
|
+
trnsid 'foo'
|
28
|
+
end
|
29
|
+
spl do
|
30
|
+
row do
|
31
|
+
splid 'joker'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
spl do
|
35
|
+
row do
|
36
|
+
splid 'foobar'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
}
|
42
|
+
|
43
|
+
subject { mixed }
|
44
|
+
|
45
|
+
its(:output) { should eq expected }
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
|
8
1
|
require 'bundler'
|
9
|
-
Bundler.require(:
|
2
|
+
Bundler.require(:development)
|
3
|
+
|
4
|
+
require 'riif'
|
5
|
+
|
6
|
+
# This line has to before require 'rspec/rails'
|
7
|
+
Combustion.initialize! :action_controller, :action_view
|
8
|
+
|
9
|
+
require 'rspec/rails'
|
10
10
|
|
11
11
|
RSpec.configure do |config|
|
12
12
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
13
|
config.run_all_when_everything_filtered = true
|
14
14
|
config.filter_run :focus
|
15
|
-
|
16
|
-
# Run specs in random order to surface order dependencies. If you find an
|
17
|
-
# order dependency and want to debug it, you can fix the order by providing
|
18
|
-
# the seed, which is printed after each run.
|
19
|
-
# --seed 1234
|
20
15
|
config.order = 'random'
|
21
16
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: riif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jun Lin
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
29
|
none: false
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
none: false
|
37
|
+
name: rails
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
none: false
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
version_requirements: !ruby/object:Gem::Requirement
|
32
48
|
requirements:
|
@@ -43,6 +59,22 @@ dependencies:
|
|
43
59
|
- !ruby/object:Gem::Version
|
44
60
|
version: '0'
|
45
61
|
none: false
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
none: false
|
69
|
+
name: rspec-rails
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
none: false
|
46
78
|
- !ruby/object:Gem::Dependency
|
47
79
|
version_requirements: !ruby/object:Gem::Requirement
|
48
80
|
requirements:
|
@@ -59,6 +91,22 @@ dependencies:
|
|
59
91
|
- !ruby/object:Gem::Version
|
60
92
|
version: '0'
|
61
93
|
none: false
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ~>
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.3.1
|
100
|
+
none: false
|
101
|
+
name: combustion
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ~>
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 0.3.1
|
109
|
+
none: false
|
62
110
|
description: DSL to generate IIF file
|
63
111
|
email:
|
64
112
|
- linjunpop@gmail.com
|
@@ -74,6 +122,7 @@ files:
|
|
74
122
|
- LICENSE.txt
|
75
123
|
- README.md
|
76
124
|
- Rakefile
|
125
|
+
- config.ru
|
77
126
|
- lib/riif.rb
|
78
127
|
- lib/riif/dsl/accnt.rb
|
79
128
|
- lib/riif/dsl/base.rb
|
@@ -98,6 +147,7 @@ files:
|
|
98
147
|
- lib/riif/railtie.rb
|
99
148
|
- lib/riif/version.rb
|
100
149
|
- riif.gemspec
|
150
|
+
- spec/controllers/invoices_controller_spec.rb
|
101
151
|
- spec/fixtures/accnt.iif
|
102
152
|
- spec/fixtures/bud.iif
|
103
153
|
- spec/fixtures/ctype.iif
|
@@ -106,14 +156,23 @@ files:
|
|
106
156
|
- spec/fixtures/invitem.iif
|
107
157
|
- spec/fixtures/invmemo.iif
|
108
158
|
- spec/fixtures/klass.iif
|
159
|
+
- spec/fixtures/mixed.iif
|
109
160
|
- spec/fixtures/othername.iif
|
110
161
|
- spec/fixtures/paymeth.iif
|
162
|
+
- spec/fixtures/rails/invoices.iif
|
111
163
|
- spec/fixtures/shipmeth.iif
|
112
164
|
- spec/fixtures/terms.iif
|
113
165
|
- spec/fixtures/timeact.iif
|
114
166
|
- spec/fixtures/trns.iif
|
115
167
|
- spec/fixtures/vend.iif
|
116
168
|
- spec/fixtures/vtype.iif
|
169
|
+
- spec/internal/app/controllers/invoices_controller.rb
|
170
|
+
- spec/internal/app/views/invoices/index.iif.riif
|
171
|
+
- spec/internal/config/database.yml
|
172
|
+
- spec/internal/config/routes.rb
|
173
|
+
- spec/internal/db/schema.rb
|
174
|
+
- spec/internal/log/.gitignore
|
175
|
+
- spec/internal/public/favicon.ico
|
117
176
|
- spec/riif/dsl/accnt_spec.rb
|
118
177
|
- spec/riif/dsl/bud_spec.rb
|
119
178
|
- spec/riif/dsl/ctype_spec.rb
|
@@ -130,6 +189,7 @@ files:
|
|
130
189
|
- spec/riif/dsl/trns_spec.rb
|
131
190
|
- spec/riif/dsl/vend_spec.rb
|
132
191
|
- spec/riif/dsl/vtype_spec.rb
|
192
|
+
- spec/riif/iif_spec.rb
|
133
193
|
- spec/spec_helper.rb
|
134
194
|
homepage: ''
|
135
195
|
licenses: []
|
@@ -156,6 +216,7 @@ signing_key:
|
|
156
216
|
specification_version: 3
|
157
217
|
summary: A simple DSL to generate iif file
|
158
218
|
test_files:
|
219
|
+
- spec/controllers/invoices_controller_spec.rb
|
159
220
|
- spec/fixtures/accnt.iif
|
160
221
|
- spec/fixtures/bud.iif
|
161
222
|
- spec/fixtures/ctype.iif
|
@@ -164,14 +225,23 @@ test_files:
|
|
164
225
|
- spec/fixtures/invitem.iif
|
165
226
|
- spec/fixtures/invmemo.iif
|
166
227
|
- spec/fixtures/klass.iif
|
228
|
+
- spec/fixtures/mixed.iif
|
167
229
|
- spec/fixtures/othername.iif
|
168
230
|
- spec/fixtures/paymeth.iif
|
231
|
+
- spec/fixtures/rails/invoices.iif
|
169
232
|
- spec/fixtures/shipmeth.iif
|
170
233
|
- spec/fixtures/terms.iif
|
171
234
|
- spec/fixtures/timeact.iif
|
172
235
|
- spec/fixtures/trns.iif
|
173
236
|
- spec/fixtures/vend.iif
|
174
237
|
- spec/fixtures/vtype.iif
|
238
|
+
- spec/internal/app/controllers/invoices_controller.rb
|
239
|
+
- spec/internal/app/views/invoices/index.iif.riif
|
240
|
+
- spec/internal/config/database.yml
|
241
|
+
- spec/internal/config/routes.rb
|
242
|
+
- spec/internal/db/schema.rb
|
243
|
+
- spec/internal/log/.gitignore
|
244
|
+
- spec/internal/public/favicon.ico
|
175
245
|
- spec/riif/dsl/accnt_spec.rb
|
176
246
|
- spec/riif/dsl/bud_spec.rb
|
177
247
|
- spec/riif/dsl/ctype_spec.rb
|
@@ -188,4 +258,5 @@ test_files:
|
|
188
258
|
- spec/riif/dsl/trns_spec.rb
|
189
259
|
- spec/riif/dsl/vend_spec.rb
|
190
260
|
- spec/riif/dsl/vtype_spec.rb
|
261
|
+
- spec/riif/iif_spec.rb
|
191
262
|
- spec/spec_helper.rb
|