blanko 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -0
- data/lib/blanko.rb +2 -1
- data/lib/blanko/calculators/column.rb +25 -0
- data/lib/blanko/calculators/row.rb +23 -0
- data/lib/blanko/emitters/base.rb +21 -0
- data/lib/blanko/nullifier.rb +13 -0
- data/lib/blanko/reports/base.rb +28 -0
- data/lib/blanko/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fd45b7891449a8c72cf946acd5c883f05869a66
|
4
|
+
data.tar.gz: 5f77f64ef2fdbb0bdf83af2eaf148a689d2cf461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd4191a6d60ce4a0368e82f917ab0d62d063973d1a70c546915e0a880c39d4998d1c46d14d825d292c87d69197336cb2389a6e1d6a941fad8dcd16ff8de7ea55
|
7
|
+
data.tar.gz: e84c388ca6fe4a2631c54bee18998b30114ab40e667edd4fb204bfdaad2fe01577cf696f54eb4dd99aa13ec61b01d4a772a5caf20d6770031913478a56c9a901
|
data/Rakefile
CHANGED
data/lib/blanko.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Blanko
|
2
|
+
module Calculators
|
3
|
+
class Column
|
4
|
+
attr_reader :report
|
5
|
+
|
6
|
+
def initialize(report)
|
7
|
+
@report = report
|
8
|
+
end
|
9
|
+
|
10
|
+
def calculate(columns)
|
11
|
+
totals = []
|
12
|
+
|
13
|
+
@report.data.each do |row|
|
14
|
+
columns.each do |column|
|
15
|
+
value = Money.from_string(row[column])
|
16
|
+
totals[column] ||= Money.from_string('0')
|
17
|
+
totals[column] += value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
report.append(totals)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Blanko
|
2
|
+
module Calculators
|
3
|
+
class Row
|
4
|
+
attr_reader :report
|
5
|
+
|
6
|
+
def initialize(report)
|
7
|
+
@report = report
|
8
|
+
end
|
9
|
+
|
10
|
+
def calculate(input_colums, output_column)
|
11
|
+
@report.data.each do |row|
|
12
|
+
total = Money.from_string('0')
|
13
|
+
|
14
|
+
input_colums.each do |column|
|
15
|
+
total += Money.from_string(row[column])
|
16
|
+
end
|
17
|
+
|
18
|
+
row[output_column] = total
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Blanko
|
2
|
+
module Emitters
|
3
|
+
class Base
|
4
|
+
attr_accessor :input, :output, :has_header
|
5
|
+
|
6
|
+
def initialize(input, has_header=false)
|
7
|
+
@input = input
|
8
|
+
@output = nil
|
9
|
+
@has_header = has_header
|
10
|
+
end
|
11
|
+
|
12
|
+
def transform
|
13
|
+
raise 'override this method!'
|
14
|
+
end
|
15
|
+
|
16
|
+
def header(data)
|
17
|
+
raise 'override this method!'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Blanko
|
2
|
+
module Reports
|
3
|
+
class Base
|
4
|
+
attr_reader :orders, :emitter, :data, :header
|
5
|
+
|
6
|
+
def initialize(orders, emitter)
|
7
|
+
@orders = orders
|
8
|
+
@emitter = emitter
|
9
|
+
@data = []
|
10
|
+
@header = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate
|
14
|
+
raise 'override!!!'
|
15
|
+
end
|
16
|
+
|
17
|
+
def iterate(&block)
|
18
|
+
@orders.each do |order|
|
19
|
+
block.call(order)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def append(row)
|
24
|
+
@data << row
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/blanko/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blanko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bjh
|
@@ -55,6 +55,11 @@ files:
|
|
55
55
|
- bin/setup
|
56
56
|
- blanko.gemspec
|
57
57
|
- lib/blanko.rb
|
58
|
+
- lib/blanko/calculators/column.rb
|
59
|
+
- lib/blanko/calculators/row.rb
|
60
|
+
- lib/blanko/emitters/base.rb
|
61
|
+
- lib/blanko/nullifier.rb
|
62
|
+
- lib/blanko/reports/base.rb
|
58
63
|
- lib/blanko/version.rb
|
59
64
|
homepage: ''
|
60
65
|
licenses:
|