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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5b3198ad3f585f7a38c263b7a83c0f3fff97a9c
4
- data.tar.gz: 169d46015a3554554dc43a079eb66a6a651c2ac5
3
+ metadata.gz: 8fd45b7891449a8c72cf946acd5c883f05869a66
4
+ data.tar.gz: 5f77f64ef2fdbb0bdf83af2eaf148a689d2cf461
5
5
  SHA512:
6
- metadata.gz: 4405845a3d05ea7ebe9bef0547b68271f7a7a8ba59ed818c17e82f8dcbae992799088da2ff7731a21b8c9cf04d7870dd599cffa470417ff6215c3af8e492e512
7
- data.tar.gz: 18d7ca32cf14d25da2877eb778710359fb353ec1508aaad96f199e8853dbe10eb647728d38b86c538ce8f5c7840728e5db586efa8f44ef3c108f389f10078386
6
+ metadata.gz: bd4191a6d60ce4a0368e82f917ab0d62d063973d1a70c546915e0a880c39d4998d1c46d14d825d292c87d69197336cb2389a6e1d6a941fad8dcd16ff8de7ea55
7
+ data.tar.gz: e84c388ca6fe4a2631c54bee18998b30114ab40e667edd4fb204bfdaad2fe01577cf696f54eb4dd99aa13ec61b01d4a772a5caf20d6770031913478a56c9a901
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ desc "Open an irb session preloaded with this library"
4
+ task :console do
5
+ sh "irb -rubygems -I lib -r blanko.rb"
6
+ end
7
+
data/lib/blanko.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "blanko/version"
2
2
  require "blanko/version"
3
- require "blanko/calculator"
3
+ require "blanko/calculators/row"
4
+ require "blanko/calculators/column"
4
5
  require "blanko/nullifier"
5
6
  require "blanko/reports/base"
6
7
  require "blanko/emitters/base"
@@ -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,13 @@
1
+ module Blanko
2
+ class Nullifier < BasicObject
3
+ attr_reader :default
4
+
5
+ def initialize(default="")
6
+ @default = default
7
+ end
8
+
9
+ def method_missing(method)
10
+ @default
11
+ end
12
+ end
13
+ 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
@@ -1,3 +1,3 @@
1
1
  module Blanko
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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: