bbmb 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/History.txt +5 -0
  2. data/LICENSE.txt +339 -0
  3. data/Manifest.txt +91 -0
  4. data/README.txt +25 -0
  5. data/Rakefile +28 -0
  6. data/bin/admin +71 -0
  7. data/bin/bbmbd +61 -0
  8. data/lib/bbmb.rb +9 -0
  9. data/lib/bbmb/config.rb +106 -0
  10. data/lib/bbmb/html/state/change_password.rb +50 -0
  11. data/lib/bbmb/html/state/current_order.rb +81 -0
  12. data/lib/bbmb/html/state/customer.rb +109 -0
  13. data/lib/bbmb/html/state/customers.rb +52 -0
  14. data/lib/bbmb/html/state/favorites.rb +19 -0
  15. data/lib/bbmb/html/state/favorites_result.rb +21 -0
  16. data/lib/bbmb/html/state/global.rb +62 -0
  17. data/lib/bbmb/html/state/history.rb +95 -0
  18. data/lib/bbmb/html/state/info.rb +23 -0
  19. data/lib/bbmb/html/state/json.rb +16 -0
  20. data/lib/bbmb/html/state/login.rb +76 -0
  21. data/lib/bbmb/html/state/order.rb +21 -0
  22. data/lib/bbmb/html/state/orders.rb +19 -0
  23. data/lib/bbmb/html/state/result.rb +64 -0
  24. data/lib/bbmb/html/state/show_pass.rb +16 -0
  25. data/lib/bbmb/html/state/viral/admin.rb +41 -0
  26. data/lib/bbmb/html/state/viral/customer.rb +143 -0
  27. data/lib/bbmb/html/util/known_user.rb +51 -0
  28. data/lib/bbmb/html/util/multilingual.rb +18 -0
  29. data/lib/bbmb/html/util/session.rb +52 -0
  30. data/lib/bbmb/html/util/validator.rb +55 -0
  31. data/lib/bbmb/html/view/backorder.rb +24 -0
  32. data/lib/bbmb/html/view/change_password.rb +42 -0
  33. data/lib/bbmb/html/view/copyleft.rb +41 -0
  34. data/lib/bbmb/html/view/current_order.rb +482 -0
  35. data/lib/bbmb/html/view/customer.rb +152 -0
  36. data/lib/bbmb/html/view/customers.rb +145 -0
  37. data/lib/bbmb/html/view/favorites.rb +162 -0
  38. data/lib/bbmb/html/view/favorites_result.rb +26 -0
  39. data/lib/bbmb/html/view/foot.rb +21 -0
  40. data/lib/bbmb/html/view/head.rb +32 -0
  41. data/lib/bbmb/html/view/history.rb +60 -0
  42. data/lib/bbmb/html/view/info.rb +33 -0
  43. data/lib/bbmb/html/view/json.rb +20 -0
  44. data/lib/bbmb/html/view/list_prices.rb +51 -0
  45. data/lib/bbmb/html/view/login.rb +46 -0
  46. data/lib/bbmb/html/view/multilingual.rb +17 -0
  47. data/lib/bbmb/html/view/navigation.rb +30 -0
  48. data/lib/bbmb/html/view/order.rb +123 -0
  49. data/lib/bbmb/html/view/orders.rb +50 -0
  50. data/lib/bbmb/html/view/result.rb +107 -0
  51. data/lib/bbmb/html/view/search.rb +28 -0
  52. data/lib/bbmb/html/view/show_pass.rb +60 -0
  53. data/lib/bbmb/html/view/template.rb +61 -0
  54. data/lib/bbmb/model/customer.rb +96 -0
  55. data/lib/bbmb/model/order.rb +255 -0
  56. data/lib/bbmb/model/product.rb +99 -0
  57. data/lib/bbmb/model/promotion.rb +52 -0
  58. data/lib/bbmb/model/quota.rb +27 -0
  59. data/lib/bbmb/model/subject.rb +46 -0
  60. data/lib/bbmb/persistence/none.rb +6 -0
  61. data/lib/bbmb/persistence/odba.rb +42 -0
  62. data/lib/bbmb/persistence/odba/model/customer.rb +47 -0
  63. data/lib/bbmb/persistence/odba/model/order.rb +50 -0
  64. data/lib/bbmb/persistence/odba/model/product.rb +26 -0
  65. data/lib/bbmb/persistence/odba/model/quota.rb +12 -0
  66. data/lib/bbmb/util/invoicer.rb +126 -0
  67. data/lib/bbmb/util/mail.rb +140 -0
  68. data/lib/bbmb/util/multilingual.rb +57 -0
  69. data/lib/bbmb/util/numbers.rb +67 -0
  70. data/lib/bbmb/util/password_generator.rb +44 -0
  71. data/lib/bbmb/util/polling_manager.rb +135 -0
  72. data/lib/bbmb/util/server.rb +159 -0
  73. data/lib/bbmb/util/target_dir.rb +36 -0
  74. data/lib/bbmb/util/transfer_dat.rb +34 -0
  75. data/lib/bbmb/util/updater.rb +27 -0
  76. data/test/data/ydim.yml +2 -0
  77. data/test/model/test_customer.rb +75 -0
  78. data/test/model/test_order.rb +426 -0
  79. data/test/model/test_product.rb +238 -0
  80. data/test/model/test_promotion.rb +40 -0
  81. data/test/stub/persistence.rb +57 -0
  82. data/test/suite.rb +12 -0
  83. data/test/test_bbmb.rb +18 -0
  84. data/test/util/test_invoicer.rb +189 -0
  85. data/test/util/test_mail.rb +359 -0
  86. data/test/util/test_money.rb +71 -0
  87. data/test/util/test_password_generator.rb +27 -0
  88. data/test/util/test_polling_manager.rb +312 -0
  89. data/test/util/test_server.rb +189 -0
  90. data/test/util/test_target_dir.rb +82 -0
  91. data/test/util/test_transfer_dat.rb +45 -0
  92. metadata +190 -0
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+ # Util::TestTargetDir -- bbmb -- 19.04.2007 -- hwyss@ywesee.com
3
+
4
+
5
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'bbmb/util/target_dir'
9
+ require 'flexmock'
10
+ require 'fileutils'
11
+
12
+ module BBMB
13
+ module Util
14
+ class TestTargetDir < Test::Unit::TestCase
15
+ include FlexMock::TestCase
16
+ def setup
17
+ super
18
+ BBMB.config = config = flexmock('config')
19
+ bbmb_dir = File.expand_path('..', File.dirname(__FILE__))
20
+ config.should_receive(:bbmb_dir).and_return(bbmb_dir)
21
+ @dir = File.expand_path('../data/destination',
22
+ File.dirname(__FILE__))
23
+ end
24
+ def teardown
25
+ super
26
+ FileUtils.rm_r(@dir) if(File.exist? @dir)
27
+ end
28
+ def test_send_order__ftp
29
+ config = BBMB.config
30
+ FileUtils.mkdir_p(@dir)
31
+ ftp = "ftp://user:pass@test.host.com#{@dir}"
32
+ config.should_receive(:order_destinations).and_return([ftp])
33
+ config.should_receive(:tmpfile_basename).and_return('bbmb')
34
+ order = flexmock('order')
35
+ order.should_receive(:to_target_format).and_return('data')
36
+ order.should_receive(:filename).and_return('order.csv')
37
+ flexstub(Net::FTP).should_receive(:open)\
38
+ .and_return { |host, user, pass, block|
39
+ assert_equal('test.host.com', host)
40
+ assert_equal('user', user)
41
+ assert_equal('pass', pass)
42
+ fsession = flexmock('ftp')
43
+ fsession.should_receive(:put).and_return { |local, remote|
44
+ assert_equal(File.join(@dir, 'order.csv'), remote)
45
+ }
46
+ block.call(fsession)
47
+ }
48
+ TargetDir.send_order(order)
49
+ end
50
+ def test_send_order__local
51
+ config = BBMB.config
52
+ FileUtils.mkdir_p(@dir)
53
+ config.should_receive(:order_destinations).and_return([@dir])
54
+ config.should_receive(:tmpfile_basename).and_return('bbmb')
55
+ order = flexmock('order')
56
+ order.should_receive(:to_target_format).and_return('data')
57
+ order.should_receive(:filename).and_return('order.csv')
58
+ flexstub(Net::FTP).should_receive(:open).times(0)
59
+
60
+ TargetDir.send_order(order)
61
+ path = File.join(@dir, 'order.csv')
62
+ assert File.exists?(path)
63
+ assert_equal("data\n", File.read(path))
64
+ end
65
+ def test_send_order__local__relative
66
+ FileUtils.mkdir_p(@dir)
67
+ config = BBMB.config
68
+ config.should_receive(:order_destinations).and_return(['data/destination'])
69
+ config.should_receive(:tmpfile_basename).and_return('bbmb')
70
+ order = flexmock('order')
71
+ order.should_receive(:to_target_format).and_return('data')
72
+ order.should_receive(:filename).and_return('order.csv')
73
+ flexstub(Net::FTP).should_receive(:open).times(0)
74
+
75
+ TargetDir.send_order(order)
76
+ path = File.join(@dir, 'order.csv')
77
+ assert File.exists?(path)
78
+ assert_equal("data\n", File.read(path))
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # Util::TestTransferDate -- bbmb.ch -- 04.10.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
5
+
6
+ require 'bbmb'
7
+ require 'bbmb/util/transfer_dat'
8
+ require 'flexmock'
9
+ require 'stringio'
10
+ require 'test/unit'
11
+
12
+ module BBMB
13
+ module Util
14
+ class TestTransferDat < Test::Unit::TestCase
15
+ include FlexMock::TestCase
16
+ def test_parse_line
17
+ src = "030201899 0624427Mycolog creme tube 15 g 000176803710902940"
18
+ info = TransferDat.parse_line(src)
19
+ assert_instance_of(Model::Order::Info, info)
20
+ assert_equal '624427', info.pcode
21
+ assert_equal 'Mycolog creme tube 15 g', info.description
22
+ assert_equal '7680371090294', info.ean13
23
+ assert_equal 1, info.quantity
24
+ end
25
+ def test_parse_line__error
26
+ BBMB.logger = flexmock('logger')
27
+ BBMB.logger.should_receive(:error).times(1)
28
+ info = nil
29
+ assert_nothing_raised { info = TransferDat.parse_line("") }
30
+ assert_nil(info)
31
+ end
32
+ def test_parse
33
+ src = <<-EOS.strip
34
+ 030201899 0624427Mycolog creme tube 15 g 000176803710902940
35
+ EOS
36
+ count = 0
37
+ TransferDat.parse(StringIO.new(src)) { |info|
38
+ assert_instance_of(Model::Order::Info, info)
39
+ count += 1
40
+ }
41
+ assert_equal(2, count)
42
+ end
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bbmb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Masaomi Hatakeyama, Zeno R.R. Davatz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-17 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hoe
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 47
30
+ segments:
31
+ - 2
32
+ - 8
33
+ - 0
34
+ version: 2.8.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: Browserbasierte Medikamenten Bestellung (bbmb).
38
+ email:
39
+ - mhatakeyama@ywesee.com, zdavatz@ywesee.com
40
+ executables:
41
+ - admin
42
+ - bbmbd
43
+ extensions: []
44
+
45
+ extra_rdoc_files:
46
+ - History.txt
47
+ - LICENSE.txt
48
+ - Manifest.txt
49
+ - README.txt
50
+ files:
51
+ - History.txt
52
+ - LICENSE.txt
53
+ - Manifest.txt
54
+ - README.txt
55
+ - Rakefile
56
+ - bin/admin
57
+ - bin/bbmbd
58
+ - lib/bbmb.rb
59
+ - lib/bbmb/config.rb
60
+ - lib/bbmb/html/state/change_password.rb
61
+ - lib/bbmb/html/state/current_order.rb
62
+ - lib/bbmb/html/state/customer.rb
63
+ - lib/bbmb/html/state/customers.rb
64
+ - lib/bbmb/html/state/favorites.rb
65
+ - lib/bbmb/html/state/favorites_result.rb
66
+ - lib/bbmb/html/state/global.rb
67
+ - lib/bbmb/html/state/history.rb
68
+ - lib/bbmb/html/state/info.rb
69
+ - lib/bbmb/html/state/json.rb
70
+ - lib/bbmb/html/state/login.rb
71
+ - lib/bbmb/html/state/order.rb
72
+ - lib/bbmb/html/state/orders.rb
73
+ - lib/bbmb/html/state/result.rb
74
+ - lib/bbmb/html/state/show_pass.rb
75
+ - lib/bbmb/html/state/viral/admin.rb
76
+ - lib/bbmb/html/state/viral/customer.rb
77
+ - lib/bbmb/html/util/known_user.rb
78
+ - lib/bbmb/html/util/multilingual.rb
79
+ - lib/bbmb/html/util/session.rb
80
+ - lib/bbmb/html/util/validator.rb
81
+ - lib/bbmb/html/view/backorder.rb
82
+ - lib/bbmb/html/view/change_password.rb
83
+ - lib/bbmb/html/view/copyleft.rb
84
+ - lib/bbmb/html/view/current_order.rb
85
+ - lib/bbmb/html/view/customer.rb
86
+ - lib/bbmb/html/view/customers.rb
87
+ - lib/bbmb/html/view/favorites.rb
88
+ - lib/bbmb/html/view/favorites_result.rb
89
+ - lib/bbmb/html/view/foot.rb
90
+ - lib/bbmb/html/view/head.rb
91
+ - lib/bbmb/html/view/history.rb
92
+ - lib/bbmb/html/view/info.rb
93
+ - lib/bbmb/html/view/json.rb
94
+ - lib/bbmb/html/view/list_prices.rb
95
+ - lib/bbmb/html/view/login.rb
96
+ - lib/bbmb/html/view/multilingual.rb
97
+ - lib/bbmb/html/view/navigation.rb
98
+ - lib/bbmb/html/view/order.rb
99
+ - lib/bbmb/html/view/orders.rb
100
+ - lib/bbmb/html/view/result.rb
101
+ - lib/bbmb/html/view/search.rb
102
+ - lib/bbmb/html/view/show_pass.rb
103
+ - lib/bbmb/html/view/template.rb
104
+ - lib/bbmb/model/customer.rb
105
+ - lib/bbmb/model/order.rb
106
+ - lib/bbmb/model/product.rb
107
+ - lib/bbmb/model/promotion.rb
108
+ - lib/bbmb/model/quota.rb
109
+ - lib/bbmb/model/subject.rb
110
+ - lib/bbmb/persistence/none.rb
111
+ - lib/bbmb/persistence/odba.rb
112
+ - lib/bbmb/persistence/odba/model/customer.rb
113
+ - lib/bbmb/persistence/odba/model/order.rb
114
+ - lib/bbmb/persistence/odba/model/product.rb
115
+ - lib/bbmb/persistence/odba/model/quota.rb
116
+ - lib/bbmb/util/invoicer.rb
117
+ - lib/bbmb/util/mail.rb
118
+ - lib/bbmb/util/multilingual.rb
119
+ - lib/bbmb/util/numbers.rb
120
+ - lib/bbmb/util/password_generator.rb
121
+ - lib/bbmb/util/polling_manager.rb
122
+ - lib/bbmb/util/server.rb
123
+ - lib/bbmb/util/target_dir.rb
124
+ - lib/bbmb/util/transfer_dat.rb
125
+ - lib/bbmb/util/updater.rb
126
+ - test/data/ydim.yml
127
+ - test/model/test_customer.rb
128
+ - test/model/test_order.rb
129
+ - test/model/test_product.rb
130
+ - test/model/test_promotion.rb
131
+ - test/stub/persistence.rb
132
+ - test/suite.rb
133
+ - test/test_bbmb.rb
134
+ - test/util/test_invoicer.rb
135
+ - test/util/test_mail.rb
136
+ - test/util/test_money.rb
137
+ - test/util/test_password_generator.rb
138
+ - test/util/test_polling_manager.rb
139
+ - test/util/test_server.rb
140
+ - test/util/test_target_dir.rb
141
+ - test/util/test_transfer_dat.rb
142
+ has_rdoc: true
143
+ homepage: http://scm.ywesee.com/?p=bbmb/.git;a=summary
144
+ licenses: []
145
+
146
+ post_install_message:
147
+ rdoc_options:
148
+ - --main
149
+ - README.txt
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 3
158
+ segments:
159
+ - 0
160
+ version: "0"
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ hash: 3
167
+ segments:
168
+ - 0
169
+ version: "0"
170
+ requirements: []
171
+
172
+ rubyforge_project: bbmb
173
+ rubygems_version: 1.3.7
174
+ signing_key:
175
+ specification_version: 3
176
+ summary: Browserbasierte Medikamenten Bestellung (bbmb).
177
+ test_files:
178
+ - test/model/test_customer.rb
179
+ - test/model/test_order.rb
180
+ - test/model/test_product.rb
181
+ - test/model/test_promotion.rb
182
+ - test/test_bbmb.rb
183
+ - test/util/test_invoicer.rb
184
+ - test/util/test_mail.rb
185
+ - test/util/test_money.rb
186
+ - test/util/test_password_generator.rb
187
+ - test/util/test_polling_manager.rb
188
+ - test/util/test_server.rb
189
+ - test/util/test_target_dir.rb
190
+ - test/util/test_transfer_dat.rb