cash_register 0.0.2 → 0.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
  SHA1:
3
- metadata.gz: c4074732f9cf3422faad31d4e81e62448670e1bc
4
- data.tar.gz: 843e5d59a862ff02401ee747bc6492f0de7a5a96
3
+ metadata.gz: 52a2bb5fc6d54dc472ab92d68f6948f4a250c206
4
+ data.tar.gz: cd84b56a3b90ff8398aeae47d67ed1c4c10a2861
5
5
  SHA512:
6
- metadata.gz: 44bdbf55fac56939ec6a8fced720f6ca83f8ba7a9db374d972b1b22ec9bbc1224084a19f4eaa900a88469b9b122deba18b8f432516207a021da5f5dee4f312f8
7
- data.tar.gz: 97cb9a01f84869a0c05d9818fa1fee482b9f8b94b70cc5140e5cdd32cdf8c8a0e3e3d1abb6c303d6734f2a8cad59298b4e74ab0b0f6c763fabb4594e3c9a3289
6
+ metadata.gz: 34037ca8c24eccd8baca97d9146352651e02802abd1af9561c01068f0dec0a57954385b99dde67b09b19e9d9d86a20c81bbbfd92e5ccd5e0d13721dc79f94667
7
+ data.tar.gz: aa20a28b7e31b74aea28930588c36f388b548a385a1a8d8691686ed4cc78ee866d4232fc6190ef74e90aa0b42937553a57c834ce9a8612adc6992d4c3c239eb0
data/lib/cash_register.rb CHANGED
@@ -1,155 +1,75 @@
1
1
  # encoding: UTF-8
2
- class CashRegister
3
- SHOP_NAME = '没钱赚商店'
4
-
5
- #价格单位为百分之一分
6
- DEAL_INFOS = {
7
- 'ITEM000001': {
8
- name: '可口可乐',
9
- price: 30000,
10
- unit: '瓶'
11
- },
12
- 'ITEM000002': {
13
- name: '羽毛球',
14
- price: 10000,
15
- unit: '个'
16
- },
17
- 'ITEM000003': {
18
- name: '苹果',
19
- price: 55000,
20
- unit: '斤'
21
- },
22
- 'ITEM000004': {
23
- name: '牛奶',
24
- price: 50000,
25
- unit: '瓶'
26
- },
27
- 'ITEM000005': {
28
- name: '包子',
29
- price: 20000,
30
- unit: '个'
31
- }
32
- }
33
- #普通商品
34
- DEAL_NORMAL = 0
35
- #买二赠一商品
36
- DEAL_TWO_FOR_ONE = 1
37
- #打折商品
38
- DEAL_DISCOUNT = 2
39
-
40
- ON_SALE = {
41
- TWO_FOR_ONE: [
42
- 'ITEM000001',
43
- 'ITEM000002'
44
- ],
45
- DISCOUNT: [
46
- 'ITEM000002',
47
- 'ITEM000003'
48
- ]
49
- }
2
+ require 'json'
3
+ Dir["#{File.dirname(__FILE__)}/cash_register/*.rb"].sort.each { |f| require f }
50
4
 
5
+ module CashRegister
51
6
  class << self
52
- #***<没钱赚商店>购物清单***
53
- #名称:可口可乐,数量:3瓶,单价:3.00(元),小计:6.00(元)
54
- #名称:羽毛球,数量:6个,单价:1.00(),小计:4.00(元)
55
- #名称:苹果,数量:2斤,单价:5.50(元),小计:10.45(元),节省0.55(元)
56
- #----------------------
57
- #买二赠一商品:
58
- #名称:可口可乐,数量:1瓶
59
- #名称:羽毛球,数量:1个
60
- #----------------------
61
- #总计:20.45(元)
62
- #节省:4.55(元)
63
- #**********************
64
- def output_bill(input_array = [])
65
- data_to_print = calculate(input_array)
66
- p data_to_print
67
- output = "***<#{SHOP_NAME}>购物清单***\n"
68
- two4one_data = []
69
- total_price = 0
70
- total_saving = 0
71
- data_to_print.each do |data|
72
- output += "名称:#{data[:name]},数量:#{data[:count]}#{data[:unit]},单价:#{get_price data[:price]}(元),"
73
- if data[:saving] && !data[:free_num]
74
- output += "小计:#{get_price data[:billing]}(元),节省:#{get_price data[:saving]}(元)\n"
75
- else
76
- output += "小计:#{get_price data[:billing]}(元)\n"
77
- end
78
- if data[:free_num]
79
- two4one_data << data
80
- end
81
- total_price += data[:billing]
82
- total_saving += data[:saving].to_i
83
- end
84
- p total_saving
85
- if !two4one_data.empty?
86
- output += '-'*22 + "\n"
87
- output += "买二赠一商品:\n"
88
- end
89
- two4one_data.each do |data|
90
- output += "名称:#{data[:name]},数量:#{data[:free_num]}#{data[:unit]}\n"
7
+ include Util
8
+
9
+ def output_bill(input_list)
10
+ output = []
11
+ output << "***<没钱赚商店>购物清单***"
12
+ list_items = read_list(input_list).map do |code, count|
13
+ ListItem.new(code, count)
91
14
  end
92
- output += '-'*22 + "\n"
93
- output += "总计:#{get_price total_price}()\n"
94
- if total_saving > 0
95
- output += "节省:#{get_price total_saving}(元)\n"
15
+ output += output_list_items(list_items)
16
+ free_items = list_items.map(&:free_item).compact
17
+ if free_items.any?
18
+ output << dashed_line
19
+ output << "买二赠一商品:"
20
+ output += output_free_items(free_items)
96
21
  end
97
- output += "*"*22
22
+ output += output_summary(list_items.map(&:item))
98
23
  puts output
99
24
  output
100
25
  end
101
26
 
102
- def get_price(price)
103
- format('%.2f', price.to_f/10000)
27
+ def root
28
+ File.dirname __dir__
104
29
  end
105
30
 
106
- def calculate(deals = [])
107
- out_data = []
108
- deals = deals.inject({}) do |mem, deal|
109
- deal_id, deal_count = deal.split('-')
110
- if mem[deal_id].nil?
111
- mem[deal_id] = 0
112
- end
113
- if deal_count.nil?
114
- mem[deal_id] += 1
115
- else
116
- mem[deal_id] += deal_count.to_i
117
- end
118
- mem
119
- end
120
- deals.each do |deal, count|
121
- deal_type = get_deal_type(deal)
122
- out_data << calculate_item(deal, count, deal_type)
123
- end
124
- out_data
31
+ private
32
+ def dashed_line
33
+ '-'*22
34
+ end
35
+
36
+ def dotted_line
37
+ '*'*22
125
38
  end
126
39
 
127
- def calculate_item(deal_id = '', count = 0, deal_type = 0)
128
- result = {}
129
- deal_info = DEAL_INFOS[deal_id.to_sym]
130
- result[:count] = count
131
- case deal_type
132
- when DEAL_TWO_FOR_ONE
133
- result[:free_num] = count/3
134
- result[:billing] = (count - count/3)*deal_info[:price]
135
- result[:saving] = (count/3)*deal_info[:price]
136
- when DEAL_DISCOUNT
137
- result[:saving] = (count*deal_info[:price]*0.05).to_i
138
- result[:billing] = count*deal_info[:price] - result[:saving]
139
- else
140
- result[:billing] = count*deal_info[:price]
40
+ def output_summary(items)
41
+ p items.map(&:billing)
42
+ output = []
43
+ output << dashed_line
44
+ total_payment = items.map(&:billing).inject(&:+)
45
+ total_saving = items.map(&:saving).inject(&:+)
46
+ output << "总计:#{format_price total_payment}(元)"
47
+ if total_saving > 0
48
+ output << "节省:#{format_price total_saving}()"
141
49
  end
142
- result.merge!(deal_info)
143
- result
50
+ output << dotted_line
51
+ output
144
52
  end
145
53
 
146
- def get_deal_type(deal = '')
147
- if ON_SALE[:TWO_FOR_ONE].include?(deal)
148
- DEAL_TWO_FOR_ONE
149
- elsif ON_SALE[:DISCOUNT].include?(deal)
150
- DEAL_DISCOUNT
151
- else
152
- DEAL_NORMAL
54
+ def output_list_items(list_items)
55
+ list_items.map{ |list_item| list_item.to_s }
56
+ end
57
+
58
+ def output_free_items(free_items)
59
+ free_items.map{ |free_item| free_item.to_s }
60
+ end
61
+
62
+ def read_list(input_list)
63
+ input_list_path = File.join(CashRegister.root, input_list)
64
+ (JSON.parse(File.read(input_list_path)) rescue []).inject({}) do |mem, input_item|
65
+ code, count = input_item.split('-')
66
+ mem[code] ||= 0
67
+ if count.nil?
68
+ mem[code] += 1
69
+ else
70
+ mem[code] += count.to_i
71
+ end
72
+ mem
153
73
  end
154
74
  end
155
75
  end
@@ -0,0 +1,18 @@
1
+ require_relative '../../lib/cash_register/deal'
2
+
3
+ RSpec.describe CashRegister::Deal do
4
+ before do
5
+ @args = { "code" => "ITEM000001",
6
+ "name" => "可口可乐",
7
+ "price" => 3.0,
8
+ "unit" => "罐" }
9
+ end
10
+
11
+ it "Deal attributes" do
12
+ deal = CashRegister::Deal.new(@args)
13
+ expect(deal.code).to eq('ITEM000001')
14
+ expect(deal.name).to eq('可口可乐')
15
+ expect(deal.price).to eq(3.0)
16
+ expect(deal.unit).to eq('罐')
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../../lib/cash_register/deal'
2
+ require_relative '../../lib/cash_register/deals'
3
+
4
+ RSpec.describe CashRegister::Deals do
5
+ before do
6
+ CashRegister::Deals.init_deals('spec/fixture/all_deals.json')
7
+ end
8
+
9
+ it "Deals" do
10
+ deal = CashRegister::Deals.find_by_code('ITEM000001')
11
+ expect(deal.name).to eq('可口可乐')
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ require_relative '../../lib/cash_register/deal'
2
+ require_relative '../../lib/cash_register/discount_item'
3
+
4
+ RSpec.describe CashRegister::DiscountItem do
5
+ before do
6
+ @args = { "code" => "ITEM000001",
7
+ "name" => "可口可乐",
8
+ "price" => 3.0,
9
+ "unit" => "罐" }
10
+ @deal = CashRegister::Deal.new(@args)
11
+ @discount_item = CashRegister::DiscountItem.new(@deal, 5)
12
+ end
13
+
14
+ it "normal item billing" do
15
+ expect(@discount_item.billing).to eq(14.25)
16
+ end
17
+
18
+ it 'normal item saving' do
19
+ expect(@discount_item.saving).to eq(0.75)
20
+ end
21
+
22
+ it "normal item to_s" do
23
+ expect(@discount_item.to_s).to eq('名称:可口可乐,数量:5罐,单价:3.00(元),小计:14.25(元),节省:0.75(元)')
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../../lib/cash_register/deal'
2
+ require_relative '../../lib/cash_register/free_item'
3
+
4
+ RSpec.describe CashRegister::FreeItem do
5
+ before do
6
+ @args = { "code" => "ITEM000001",
7
+ "name" => "可口可乐",
8
+ "price" => 3.0,
9
+ "unit" => "罐" }
10
+ @deal = CashRegister::Deal.new(@args)
11
+ @free_item = CashRegister::FreeItem.new(@deal, 5)
12
+ end
13
+
14
+ it "free item to_s" do
15
+ expect(@free_item.to_s).to eq('名称:可口可乐,数量:5罐')
16
+ end
17
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: UTF-8
2
+ require_relative "../../lib/cash_register"
3
+
4
+ RSpec.describe CashRegister::ListItem do
5
+ before do
6
+ CashRegister::Promotions.init_promotions('spec/fixture/promotions.json')
7
+ CashRegister::Deals.init_deals('spec/fixture/all_deals.json')
8
+
9
+ @normal_item = CashRegister::ListItem.new('ITEM000004', 5)
10
+ @two4one_item = CashRegister::ListItem.new('ITEM000001', 5)
11
+ @discount_item = CashRegister::ListItem.new('ITEM000003', 5)
12
+ @dual_promotion_item = CashRegister::ListItem.new('ITEM000002', 5)
13
+ end
14
+
15
+ it "normal item" do
16
+ expect(@normal_item.item.class.name).to eq('CashRegister::NormalItem')
17
+ expect(@normal_item.to_s).to eq('名称:牛奶,数量:5瓶,单价:5.00(元),小计:25.00(元)')
18
+ end
19
+
20
+ it "two for one item" do
21
+ expect(@two4one_item.item.class.name).to eq('CashRegister::Two4OneItem')
22
+ expect(@two4one_item.free_item.class.name).to eq('CashRegister::FreeItem')
23
+ expect(@two4one_item.to_s).to eq('名称:可口可乐,数量:5罐,单价:3.00(元),小计:12.00(元)')
24
+ end
25
+
26
+ it "discount item" do
27
+ expect(@discount_item.item.class.name).to eq('CashRegister::DiscountItem')
28
+ expect(@discount_item.to_s).to eq('名称:苹果,数量:5斤,单价:5.50(元),小计:26.12(元),节省:1.38(元)')
29
+ end
30
+
31
+ it "dual promotions item" do
32
+ expect(@dual_promotion_item.item.class.name).to eq('CashRegister::Two4OneItem')
33
+ expect(@dual_promotion_item.to_s).to eq('名称:羽毛球,数量:5个,单价:1.00(元),小计:4.00(元)')
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../../lib/cash_register/deal'
2
+ require_relative '../../lib/cash_register/normal_item'
3
+
4
+ RSpec.describe CashRegister::NormalItem do
5
+ before do
6
+ @args = { "code" => "ITEM000001",
7
+ "name" => "可口可乐",
8
+ "price" => 3.0,
9
+ "unit" => "罐" }
10
+ @deal = CashRegister::Deal.new(@args)
11
+ @normal_item = CashRegister::NormalItem.new(@deal, 5)
12
+ end
13
+
14
+ it "normal item billing" do
15
+ expect(@normal_item.billing).to eq(15.0)
16
+ end
17
+
18
+ it "normal item to_s" do
19
+ expect(@normal_item.to_s).to eq('名称:可口可乐,数量:5罐,单价:3.00(元),小计:15.00(元)')
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../../lib/cash_register/promotions'
2
+
3
+ RSpec.describe CashRegister::Promotions do
4
+ before do
5
+ CashRegister::Promotions.init_promotions('spec/fixture/promotions.json')
6
+ end
7
+
8
+ it "is two for one" do
9
+ result = CashRegister::Promotions.is_two_for_one?('ITEM000001')
10
+ expect(result).to be true
11
+ end
12
+
13
+ it 'is discount' do
14
+ result = CashRegister::Promotions.is_discount?('ITEM000003')
15
+ expect(result).to be true
16
+ end
17
+
18
+ it 'normal deal' do
19
+ result = CashRegister::Promotions.is_discount?('ITEM000004')
20
+ expect(result).to be false
21
+ result = CashRegister::Promotions.is_two_for_one?('ITEM000004')
22
+ expect(result).to be false
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../../lib/cash_register/deal'
2
+ require_relative '../../lib/cash_register/two4one_item'
3
+
4
+ RSpec.describe CashRegister::Two4OneItem do
5
+ before do
6
+ @args = { "code" => "ITEM000001",
7
+ "name" => "可口可乐",
8
+ "price" => 3.0,
9
+ "unit" => "罐" }
10
+ @deal = CashRegister::Deal.new(@args)
11
+ @normal_item = CashRegister::Two4OneItem.new(@deal, 5)
12
+ end
13
+
14
+ it "normal item billing" do
15
+ expect(@normal_item.billing).to eq(12.0)
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../../lib/cash_register/util'
2
+
3
+ RSpec.describe CashRegister::Util do
4
+ include CashRegister::Util
5
+
6
+ it "format price" do
7
+ expect(format_price(1)).to eq('1.00')
8
+ end
9
+ end
@@ -1,48 +1,90 @@
1
- ENV["RAILS_ENV"] ||= 'test'
2
1
  require 'rubygems'
3
- require 'bundler/setup'
4
-
5
- Dir["#{File.dirname(__FILE__)}/../lib/*.rb"].sort.each { |f| require f }
2
+ require_relative "../lib/cash_register"
6
3
 
7
4
  RSpec.describe CashRegister do
8
- before(:example) do
9
- @two4one_deals = [
10
- 'ITEM000001',
11
- 'ITEM000001',
12
- 'ITEM000001',
13
- 'ITEM000001',
14
- 'ITEM000001',
15
- ]
16
- @two4one_deals2 = [
17
- 'ITEM000001',
18
- 'ITEM000001',
19
- 'ITEM000001',
20
- 'ITEM000001',
21
- 'ITEM000001',
22
- 'ITEM000001',
23
- 'ITEM000001',
24
- ]
25
- @discount_deals = [
26
- 'ITEM000003-2'
27
- ]
5
+ before do
6
+ CashRegister::Deals.init_deals('spec/fixture/all_deals.json')
7
+ CashRegister::Promotions.init_promotions('spec/fixture/promotions.json')
8
+ @two4one_deals = 'spec/fixture/only_two_for_one_deals.json'
9
+ @two4one_deals2 = 'spec/fixture/only_two_for_one_deals2.json'
10
+ @discount_deals = 'spec/fixture/only_discount_deals.json'
11
+ @normal_deals = 'spec/fixture/only_normal_deals.json'
12
+ @deals_dual_promotion = 'spec/fixture/deals_dual_promotion.json'
13
+ @various_deals = 'spec/fixture/various_deals.json'
14
+ end
15
+
16
+ it "one free" do
17
+ bill = CashRegister.output_bill(@two4one_deals)
18
+ expect(bill).to match_array(["***<没钱赚商店>购物清单***",
19
+ "名称:可口可乐,数量:5罐,单价:3.00(元),小计:12.00(元)",
20
+ "----------------------",
21
+ "买二赠一商品:", "名称:可口可乐,数量:1罐",
22
+ "----------------------",
23
+ "总计:12.00(元)",
24
+ "节省:3.00(元)",
25
+ "**********************"])
26
+ end
27
+
28
+ it "more than one free" do
29
+ bill = CashRegister.output_bill(@two4one_deals2)
30
+ expect(bill).to match_array(["***<没钱赚商店>购物清单***",
31
+ "名称:可口可乐,数量:7罐,单价:3.00(元),小计:15.00(元)",
32
+ "----------------------",
33
+ "买二赠一商品:",
34
+ "名称:可口可乐,数量:2罐",
35
+ "----------------------",
36
+ "总计:15.00(元)",
37
+ "节省:6.00(元)",
38
+ "**********************"])
39
+ end
40
+
41
+ it 'discount deals' do
42
+ bill = CashRegister.output_bill(@discount_deals)
43
+ expect(bill).to match_array(["***<没钱赚商店>购物清单***",
44
+ "名称:苹果,数量:2斤,单价:5.50(元),小计:10.45(元),节省:0.55(元)",
45
+ "----------------------",
46
+ "总计:10.45(元)",
47
+ "节省:0.55(元)",
48
+ "**********************"])
28
49
  end
29
50
 
30
- context 'input with only two-for-one deals' do
31
- it "one free" do
32
- bill = CashRegister.output_bill(@two4one_deals)
33
- expect(bill).to include('名称:可口可乐,数量:1瓶')
34
- end
51
+ it 'normal deals' do
52
+ bill = CashRegister.output_bill(@normal_deals)
53
+ expect(bill).to match_array(["***<没钱赚商店>购物清单***",
54
+ "名称:牛奶,数量:3瓶,单价:5.00(),小计:15.00()",
55
+ "名称:包子,数量:3个,单价:2.00(元),小计:6.00(元)",
56
+ "----------------------",
57
+ "总计:21.00(元)",
58
+ "**********************"])
59
+ end
35
60
 
36
- it "more than one" do
37
- bill = CashRegister.output_bill(@two4one_deals2)
38
- expect(bill).to include('名称:可口可乐,数量:2瓶')
39
- end
61
+ it 'deals with dual promotion' do
62
+ bill = CashRegister.output_bill(@deals_dual_promotion)
63
+ expect(bill).to match_array(["***<没钱赚商店>购物清单***",
64
+ "名称:羽毛球,数量:9个,单价:1.00(元),小计:6.00(元)",
65
+ "----------------------",
66
+ "买二赠一商品:",
67
+ "名称:羽毛球,数量:3个",
68
+ "----------------------",
69
+ "总计:6.00(元)",
70
+ "节省:3.00(元)",
71
+ "**********************"])
40
72
  end
41
73
 
42
- context 'input with only discount deals' do
43
- it 'discount deals' do
44
- bill = CashRegister.output_bill(@discount_deals)
45
- expect(bill).to include('名称:苹果,数量:2斤,单价:5.50(元),小计:10.45(元),节省:0.55(元)')
46
- end
74
+ it 'all kinds of deals' do
75
+ bill = CashRegister.output_bill(@various_deals)
76
+ expect(bill).to match_array(["***<没钱赚商店>购物清单***",
77
+ "名称:可口可乐,数量:5罐,单价:3.00(元),小计:12.00(元)",
78
+ "名称:羽毛球,数量:9个,单价:1.00(元),小计:6.00(元)",
79
+ "名称:苹果,数量:2斤,单价:5.50(元),小计:10.45(元),节省:0.55(元)",
80
+ "名称:包子,数量:3个,单价:2.00(元),小计:6.00(元)",
81
+ "----------------------",
82
+ "买二赠一商品:",
83
+ "名称:可口可乐,数量:1罐",
84
+ "名称:羽毛球,数量:3个",
85
+ "----------------------",
86
+ "总计:34.45(元)",
87
+ "节省:6.55(元)",
88
+ "**********************"])
47
89
  end
48
90
  end
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "code": "ITEM000001",
4
+ "name": "可口可乐",
5
+ "price": 3.00,
6
+ "unit": "罐"
7
+ },
8
+ {
9
+ "code": "ITEM000002",
10
+ "name": "羽毛球",
11
+ "price": 1.00,
12
+ "unit": "个"
13
+ },
14
+ {
15
+ "code": "ITEM000003",
16
+ "name": "苹果",
17
+ "price": 5.50,
18
+ "unit": "斤"
19
+ },
20
+ {
21
+ "code": "ITEM000004",
22
+ "name": "牛奶",
23
+ "price": 5.00,
24
+ "unit": "瓶"
25
+ },
26
+ {
27
+ "code": "ITEM000005",
28
+ "name": "包子",
29
+ "price": 2.00,
30
+ "unit": "个"
31
+ }
32
+ ]
@@ -0,0 +1,3 @@
1
+ [
2
+ "ITEM000002-9"
3
+ ]
@@ -0,0 +1,3 @@
1
+ [
2
+ "ITEM000003-2"
3
+ ]
@@ -0,0 +1,4 @@
1
+ [
2
+ "ITEM000004-3",
3
+ "ITEM000005-3"
4
+ ]
@@ -0,0 +1,7 @@
1
+ [
2
+ "ITEM000001",
3
+ "ITEM000001",
4
+ "ITEM000001",
5
+ "ITEM000001",
6
+ "ITEM000001"
7
+ ]
@@ -0,0 +1,9 @@
1
+ [
2
+ "ITEM000001",
3
+ "ITEM000001",
4
+ "ITEM000001",
5
+ "ITEM000001",
6
+ "ITEM000001",
7
+ "ITEM000001",
8
+ "ITEM000001"
9
+ ]
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "type": "TWO_FOR_ONE_FREE",
4
+ "deals": [
5
+ "ITEM000001",
6
+ "ITEM000002"
7
+ ]
8
+ },
9
+ {
10
+ "type": "DISCOUNT",
11
+ "deals": [
12
+ "ITEM000002",
13
+ "ITEM000003"
14
+ ]
15
+ }
16
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ "ITEM000001",
3
+ "ITEM000001",
4
+ "ITEM000001",
5
+ "ITEM000001",
6
+ "ITEM000001",
7
+ "ITEM000002-9",
8
+ "ITEM000003-2",
9
+ "ITEM000005-3"
10
+ ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cash_register
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clark King
@@ -31,7 +31,24 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/cash_register.rb
34
+ - spec/cash_register/deal_spec.rb
35
+ - spec/cash_register/deals_spec.rb
36
+ - spec/cash_register/discount_item_spec.rb
37
+ - spec/cash_register/free_item_spec.rb
38
+ - spec/cash_register/list_item_spec.rb
39
+ - spec/cash_register/normal_item_spec.rb
40
+ - spec/cash_register/promotions_spec.rb
41
+ - spec/cash_register/two4one_item_spec.rb
42
+ - spec/cash_register/util_spec.rb
34
43
  - spec/cash_register_spec.rb
44
+ - spec/fixture/all_deals.json
45
+ - spec/fixture/deals_dual_promotion.json
46
+ - spec/fixture/only_discount_deals.json
47
+ - spec/fixture/only_normal_deals.json
48
+ - spec/fixture/only_two_for_one_deals.json
49
+ - spec/fixture/only_two_for_one_deals2.json
50
+ - spec/fixture/promotions.json
51
+ - spec/fixture/various_deals.json
35
52
  - spec/spec_helper.rb
36
53
  homepage: https://github.com/wskongdesheng/homework-kongdesheng
37
54
  licenses:
@@ -58,5 +75,22 @@ signing_key:
58
75
  specification_version: 4
59
76
  summary: cash register
60
77
  test_files:
78
+ - spec/cash_register/free_item_spec.rb
79
+ - spec/cash_register/two4one_item_spec.rb
80
+ - spec/cash_register/deal_spec.rb
81
+ - spec/cash_register/normal_item_spec.rb
82
+ - spec/cash_register/deals_spec.rb
83
+ - spec/cash_register/list_item_spec.rb
84
+ - spec/cash_register/discount_item_spec.rb
85
+ - spec/cash_register/util_spec.rb
86
+ - spec/cash_register/promotions_spec.rb
61
87
  - spec/spec_helper.rb
62
88
  - spec/cash_register_spec.rb
89
+ - spec/fixture/promotions.json
90
+ - spec/fixture/only_discount_deals.json
91
+ - spec/fixture/various_deals.json
92
+ - spec/fixture/only_two_for_one_deals.json
93
+ - spec/fixture/only_two_for_one_deals2.json
94
+ - spec/fixture/deals_dual_promotion.json
95
+ - spec/fixture/only_normal_deals.json
96
+ - spec/fixture/all_deals.json