amrita2 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. data/README +5 -5
  2. data/Rakefile +85 -0
  3. data/lib/amrita2/gettext.rb +9 -4
  4. data/lib/amrita2/template.rb +20 -9
  5. data/lib/amrita2/testsupport.rb +25 -0
  6. data/lib/amrita2/version.rb +1 -1
  7. data/sample/depot/README +160 -0
  8. data/sample/depot/Rakefile +10 -0
  9. data/sample/depot/app/views/admin/_form.html.a2 +23 -0
  10. data/sample/depot/app/views/admin/_form.html.erb +14 -0
  11. data/sample/depot/app/views/admin/edit.html.a2 +22 -0
  12. data/sample/depot/app/views/admin/edit.html.erb +10 -0
  13. data/sample/depot/app/views/admin/list.html.a2 +34 -0
  14. data/sample/depot/app/views/admin/list.html.erb +37 -0
  15. data/sample/depot/app/views/admin/new.html.a2 +21 -0
  16. data/sample/depot/app/views/admin/new.html.erb +9 -0
  17. data/sample/depot/app/views/admin/show.html.a2 +12 -0
  18. data/sample/depot/app/views/admin/show.html.erb +13 -0
  19. data/sample/depot/app/views/info/who_bought.rhtml +14 -0
  20. data/sample/depot/app/views/info/who_bought.rxml +8 -0
  21. data/sample/depot/app/views/layouts/admin.a2html +32 -0
  22. data/sample/depot/app/views/layouts/admin.rhtml +40 -0
  23. data/sample/depot/app/views/layouts/store.a2html +37 -0
  24. data/sample/depot/app/views/layouts/store.rhtml +43 -0
  25. data/sample/depot/app/views/login/add_user.rhtml +33 -0
  26. data/sample/depot/app/views/login/index.rhtml +9 -0
  27. data/sample/depot/app/views/login/list_users.rhtml +20 -0
  28. data/sample/depot/app/views/login/login.rhtml +26 -0
  29. data/sample/depot/app/views/store/_cart.html.a2 +18 -0
  30. data/sample/depot/app/views/store/_cart.html.erb +17 -0
  31. data/sample/depot/app/views/store/_cart_item.html.a2 +16 -0
  32. data/sample/depot/app/views/store/_cart_item.html.erb +14 -0
  33. data/sample/depot/app/views/store/add_to_cart.rjs +11 -0
  34. data/sample/depot/app/views/store/checkout.html.a2 +45 -0
  35. data/sample/depot/app/views/store/checkout.html.a2.using_macro +32 -0
  36. data/sample/depot/app/views/store/checkout.html.a2.without_label +37 -0
  37. data/sample/depot/app/views/store/checkout.html.erb +41 -0
  38. data/sample/depot/app/views/store/index.html.a2 +19 -0
  39. data/sample/depot/app/views/store/index.html.erb +22 -0
  40. data/sample/depot/config/database.yml +24 -0
  41. data/sample/depot/db/create_database.sql +14 -0
  42. data/sample/depot/doc/README_FOR_APP +35 -0
  43. data/sample/depot/lib/tasks/db_schema_version.rake +6 -0
  44. data/sample/depot/log/development.log +116 -0
  45. data/sample/depot/log/test.log +347 -0
  46. data/sample/depot/public/404.html +13 -0
  47. data/sample/depot/public/500.html +13 -0
  48. data/sample/depot/public/dispatch.cgi +10 -0
  49. data/sample/depot/public/dispatch.fcgi +24 -0
  50. data/sample/depot/public/favicon.ico +0 -0
  51. data/sample/depot/public/images/auto.jpg +0 -0
  52. data/sample/depot/public/images/logo.png +0 -0
  53. data/sample/depot/public/images/rails.png +0 -0
  54. data/sample/depot/public/images/svn.jpg +0 -0
  55. data/sample/depot/public/images/utc.jpg +0 -0
  56. data/sample/depot/public/index.html +282 -0
  57. data/sample/depot/public/javascripts/application.js +2 -0
  58. data/sample/depot/public/javascripts/controls.js +832 -0
  59. data/sample/depot/public/javascripts/dragdrop.js +942 -0
  60. data/sample/depot/public/javascripts/effects.js +954 -0
  61. data/sample/depot/public/javascripts/prototype.js +2347 -0
  62. data/sample/depot/public/robots.txt +1 -0
  63. data/sample/depot/public/stylesheets/depot.css +227 -0
  64. data/sample/depot/public/stylesheets/scaffold.css +74 -0
  65. data/sample/depot/script/about +3 -0
  66. data/sample/depot/script/breakpointer +3 -0
  67. data/sample/depot/script/console +3 -0
  68. data/sample/depot/script/destroy +3 -0
  69. data/sample/depot/script/generate +3 -0
  70. data/sample/depot/script/performance/benchmarker +3 -0
  71. data/sample/depot/script/performance/profiler +3 -0
  72. data/sample/depot/script/plugin +3 -0
  73. data/sample/depot/script/process/inspector +3 -0
  74. data/sample/depot/script/process/reaper +3 -0
  75. data/sample/depot/script/process/spawner +3 -0
  76. data/sample/depot/script/runner +3 -0
  77. data/sample/depot/script/server +3 -0
  78. data/sample/depot/test/fixtures/line_items.yml +16 -0
  79. data/sample/depot/test/fixtures/orders.yml +4 -0
  80. data/sample/depot/test/fixtures/performance/products.yml +8 -0
  81. data/sample/depot/test/fixtures/products.yml +16 -0
  82. data/sample/depot/test/fixtures/users.yml +7 -0
  83. data/sample/depot/vendor/plugins/will_paginate/LICENSE +18 -0
  84. data/sample/depot/vendor/plugins/will_paginate/README +171 -0
  85. data/sample/depot/vendor/plugins/will_paginate/Rakefile +27 -0
  86. data/sample/depot/vendor/plugins/will_paginate/test/console +9 -0
  87. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/companies.yml +24 -0
  88. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +13 -0
  89. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/projects.yml +7 -0
  90. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/replies.yml +34 -0
  91. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/schema.sql +44 -0
  92. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/topics.yml +30 -0
  93. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/users.yml +35 -0
  94. data/sample/login_engine/README +182 -0
  95. data/sample/login_engine/Rakefile +27 -0
  96. data/sample/login_engine/app/views/layouts/user.a2html +20 -0
  97. data/sample/login_engine/app/views/layouts/user.rhtml +16 -0
  98. data/sample/login_engine/app/views/user/_edit.a2html +16 -0
  99. data/sample/login_engine/app/views/user/_edit.rhtml +11 -0
  100. data/sample/login_engine/app/views/user/_password.a2html +18 -0
  101. data/sample/login_engine/app/views/user/_password.rhtml +9 -0
  102. data/sample/login_engine/app/views/user/change_password.a2html +17 -0
  103. data/sample/login_engine/app/views/user/change_password.rhtml +17 -0
  104. data/sample/login_engine/app/views/user/edit.a2html +22 -0
  105. data/sample/login_engine/app/views/user/edit.rhtml +23 -0
  106. data/sample/login_engine/app/views/user/forgot_password.rhtml +18 -0
  107. data/sample/login_engine/app/views/user/home.a2html +12 -0
  108. data/sample/login_engine/app/views/user/home.rhtml +7 -0
  109. data/sample/login_engine/app/views/user/login.a2html +16 -0
  110. data/sample/login_engine/app/views/user/login.rhtml +17 -0
  111. data/sample/login_engine/app/views/user/logout.rhtml +8 -0
  112. data/sample/login_engine/app/views/user/signup.a2html +14 -0
  113. data/sample/login_engine/app/views/user/signup.rhtml +17 -0
  114. data/sample/login_engine/app/views/user_notify/change_password.rhtml +10 -0
  115. data/sample/login_engine/app/views/user_notify/delete.rhtml +5 -0
  116. data/sample/login_engine/app/views/user_notify/forgot_password.rhtml +11 -0
  117. data/sample/login_engine/app/views/user_notify/pending_delete.rhtml +9 -0
  118. data/sample/login_engine/app/views/user_notify/signup.rhtml +12 -0
  119. data/sample/login_engine/config/database.yml +18 -0
  120. data/sample/login_engine/db/create_database.sql +14 -0
  121. data/sample/login_engine/db/dev.sqlite3 +0 -0
  122. data/sample/login_engine/db/test.sqlite3 +0 -0
  123. data/sample/login_engine/doc/README_FOR_APP +2 -0
  124. data/sample/login_engine/locale/ja/LC_MESSAGES/login_engine.mo +0 -0
  125. data/sample/login_engine/log/development.log +330 -0
  126. data/sample/login_engine/log/test.log +19026 -0
  127. data/sample/login_engine/po/ja/login_engine.po +248 -0
  128. data/sample/login_engine/po/login_engine.pot +245 -0
  129. data/sample/login_engine/public/404.html +30 -0
  130. data/sample/login_engine/public/500.html +30 -0
  131. data/sample/login_engine/public/dispatch.cgi +10 -0
  132. data/sample/login_engine/public/dispatch.fcgi +24 -0
  133. data/sample/login_engine/public/favicon.ico +0 -0
  134. data/sample/login_engine/public/images/rails.png +0 -0
  135. data/sample/login_engine/public/index.html +277 -0
  136. data/sample/login_engine/public/javascripts/application.js +2 -0
  137. data/sample/login_engine/public/javascripts/controls.js +833 -0
  138. data/sample/login_engine/public/javascripts/dragdrop.js +942 -0
  139. data/sample/login_engine/public/javascripts/effects.js +1088 -0
  140. data/sample/login_engine/public/javascripts/prototype.js +2385 -0
  141. data/sample/login_engine/public/robots.txt +1 -0
  142. data/sample/login_engine/public/stylesheets/login_engine.css +81 -0
  143. data/sample/login_engine/script/about +3 -0
  144. data/sample/login_engine/script/breakpointer +3 -0
  145. data/sample/login_engine/script/console +3 -0
  146. data/sample/login_engine/script/destroy +3 -0
  147. data/sample/login_engine/script/generate +3 -0
  148. data/sample/login_engine/script/performance/benchmarker +3 -0
  149. data/sample/login_engine/script/performance/profiler +3 -0
  150. data/sample/login_engine/script/plugin +3 -0
  151. data/sample/login_engine/script/process/inspector +3 -0
  152. data/sample/login_engine/script/process/reaper +3 -0
  153. data/sample/login_engine/script/process/spawner +3 -0
  154. data/sample/login_engine/script/runner +3 -0
  155. data/sample/login_engine/script/server +3 -0
  156. data/sample/login_engine/test/fixtures/users.yml +41 -0
  157. data/specs/erb_cdata.rb +11 -0
  158. data/specs/filters.rb +5 -4
  159. data/specs/gettext/static_text.rb +30 -13
  160. data/specs/impl/preprocess.rb +58 -54
  161. metadata +375 -120
  162. data/sample/hello/test1.rb +0 -23
@@ -0,0 +1,26 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <div class="depot-form">
7
+ <fieldset>
8
+ <legend>Please Log In</legend>
9
+
10
+ <% form_tag do %>
11
+ <p>
12
+ <label for="name">Name:</label>
13
+ <%= text_field_tag :name, params[:name] %>
14
+ </p>
15
+
16
+ <p>
17
+ <label for="password">Password:</label>
18
+ <%= password_field_tag :password, params[:password] %>
19
+ </p>
20
+
21
+ <p>
22
+ <%= submit_tag "Login" %>
23
+ </p>
24
+ <% end %>
25
+ </fieldset>
26
+ </div>
@@ -0,0 +1,18 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <<div.cart-title<
7
+ Your Cart
8
+
9
+ <<table :cart | CartHelper <
10
+ %= render(:partial => "cart_item", :collection => $_.items)
11
+ <<tr class="total-line"<------------------------------
12
+ | colspan || 2 | |
13
+ | class || | total-cell |
14
+ | || Total | <<:total_price_currency>> |
15
+ ----------------------------------------------------
16
+
17
+ %= button_to "Checkout", :action => :checkout
18
+ %= button_to "Empty cart", :action => :empty_cart
@@ -0,0 +1,17 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <div class="cart-title">Your Cart</div>
7
+
8
+ <table>
9
+ <%= render(:partial => "cart_item", :collection => cart.items) %>
10
+ <tr class="total-line">
11
+ <td colspan="2">Total</td>
12
+ <td class="total-cell"><%= number_to_currency(cart.total_price) %></td>
13
+ </tr>
14
+ </table>
15
+
16
+ <%= button_to "Checkout", :action => :checkout %>
17
+ <%= button_to "Empty cart", :action => :empty_cart %>
@@ -0,0 +1,16 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ << :cart_item {
7
+ :current => ($_ == @current_item),
8
+ :price => number_to_currency($_.price),
9
+ } <
10
+ <<tr id="current_item" :
11
+ | Attr[:id=>:current]
12
+ <------------------------------------------------
13
+ |class|| | | item-price |
14
+ | ||<<:quantity>> X |<<:title>>| <<:price>> |
15
+ -------------------------------------------------
16
+
@@ -0,0 +1,14 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <% if cart_item == @current_item %>
7
+ <tr id="current_item">
8
+ <% else %>
9
+ <tr>
10
+ <% end %>
11
+ <td><%= cart_item.quantity %> X </td>
12
+ <td><%= h(cart_item.title) %></td>
13
+ <td class="item-price"><%= number_to_currency(cart_item.price) %></td>
14
+ </tr>
@@ -0,0 +1,11 @@
1
+ #START_HIGHLIGHT
2
+ page.select("div#notice").each { |div| div.hide }
3
+ #END_HIGHLIGHT
4
+
5
+ page.replace_html("cart", :partial => "cart", :object => @cart)
6
+
7
+ page[:cart].visual_effect :blind_down if @cart.total_items == 1
8
+
9
+ page[:current_item].visual_effect :highlight,
10
+ :startcolor => "#88ff88",
11
+ :endcolor => "#114411"
@@ -0,0 +1,45 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <<div.depot-form<
7
+
8
+ %= error_messages_for 'order'
9
+
10
+ <<fieldset<
11
+ <legend>Please Enter Your Details</legend>
12
+
13
+ <%
14
+ form = amrita_define_form(
15
+ :order,
16
+ :url => { :action => :save_order },
17
+ :amrita_format => :as_label_field_hash) do |f|
18
+ f.text_field :name, :size => 40
19
+ f.text_area :address, :rows => 3, :cols => 40
20
+ f.text_field :email, :size => 40
21
+ f.select :pay_type,
22
+ Order::PAYMENT_TYPES,
23
+ :prompt => "Select a payment method"
24
+ end
25
+ %>
26
+
27
+ <<:form | AcceptData[:hook] <
28
+ <<p :name<
29
+ <<label :label | Attr[:for] <
30
+ <<:text | :capitalize >>:
31
+ <<:field>>
32
+ <<p :address<
33
+ <<label :label | Attr[:for] <
34
+ <<:text | :capitalize >>:
35
+ <<:field>>
36
+ <<p :email<
37
+ <<label :label | Attr[:for] <
38
+ E-Mail:
39
+ <<:field>>
40
+ <<p :pay_type<
41
+ <<label :label | Attr[:for] <
42
+ Pay with:
43
+ <<:field>>
44
+
45
+ %= submit_tag "Place Order", :class => "submit"
@@ -0,0 +1,32 @@
1
+ <%(BeforeCompile)
2
+ use_macro(StandardForm)
3
+ %>
4
+
5
+ <!--
6
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
7
+ ! We make no guarantees that this code is fit for any purpose.
8
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
9
+ -->
10
+ <div class="depot-form">
11
+
12
+ %= error_messages_for 'order'
13
+
14
+ << standard_form record="order" <
15
+ <form_title>Please Enter Your Detailsa</form_title>
16
+ <url action = "save_order" />
17
+ <<header<
18
+ % pay_select = select "order", :pay_type,
19
+ % Order::PAYMENT_TYPES, :prompt => "Select a payment method"
20
+ <<<--------------------------------------------------------------
21
+ ||| Name || <text id="name" size="40" /> |
22
+ <<<--------------------------------------------------------------
23
+ ||| Address || <text_area id="address" rows="3" cols="40" /> |
24
+ <<<--------------------------------------------------------------
25
+ ||| E-Mail || <text id="email" size="40" /> |
26
+ <<<--------------------------------------------------------------
27
+ ||| Pay with || <<field id="pay_type"< |
28
+ ||| || <<:pay_select\|NoSanitize>> |
29
+ ---------------------------------------------------------------
30
+ <<fotter<
31
+ %= submit_tag "Place Order", :class => "submit"
32
+
@@ -0,0 +1,37 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <<div.depot-form<
7
+
8
+ %= error_messages_for 'order'
9
+
10
+ <<fieldset<
11
+ <legend>Please Enter Your Details</legend>
12
+
13
+ <%
14
+ form = amrita_define_form(:form_for, :order, :url => { :action => :save_order }) do |f|
15
+ f.text_field :name, :size => 40
16
+ f.text_area :address, :rows => 3, :cols => 40
17
+ f.text_field :email, :size => 40
18
+ f.select :pay_type,
19
+ Order::PAYMENT_TYPES,
20
+ :prompt => "Select a payment method"
21
+ end
22
+ %>
23
+ <<:form | AcceptData[:hook] <
24
+ <<p<
25
+ <label for="order_name">Name:</label>
26
+ <<:name>>
27
+ <<p<
28
+ <label for="order_address">Address:</label>
29
+ <<:address>>
30
+ <<p<
31
+ <label for="order_email">E-Mail:</label>
32
+ <<:email>>
33
+ <<p<
34
+ <label for="order_pay_type">Pay with:</label>
35
+ <<:pay_type>>
36
+
37
+ %= submit_tag "Place Order", :class => "submit"
@@ -0,0 +1,41 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <div class="depot-form">
7
+
8
+ <%= error_messages_for 'order' %>
9
+
10
+ <fieldset>
11
+ <legend>Please Enter Your Details</legend>
12
+
13
+ <% form_for :order, :url => { :action => :save_order } do |form| %>
14
+ <p>
15
+ <label for="order_name">Name:</label>
16
+ <%= form.text_field :name, :size => 40 %>
17
+ </p>
18
+
19
+ <p>
20
+ <label for="order_address">Address:</label>
21
+ <%= form.text_area :address, :rows => 3, :cols => 40 %>
22
+ </p>
23
+
24
+ <p>
25
+ <label for="order_email">E-Mail:</label>
26
+ <%= form.text_field :email, :size => 40 %>
27
+ </p>
28
+
29
+ <p>
30
+ <label for="order_pay_type">Pay with:</label>
31
+ <%=
32
+ form.select :pay_type,
33
+ Order::PAYMENT_TYPES,
34
+ :prompt => "Select a payment method"
35
+ %>
36
+ </p>
37
+
38
+ <%= submit_tag "Place Order", :class => "submit" %>
39
+ <% end %>
40
+ </fieldset>
41
+ </div>
@@ -0,0 +1,19 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <h1>Your Pragmatic Catalog</h1>
7
+
8
+ <<div.entry :products <
9
+ %= image_tag($_.image_url)
10
+ <<h3 :title>>
11
+ <<:description>>
12
+ <<div.price-line<
13
+ <<span.price :price | ModuleExtendFilter[PriceHelper] | :to_currency >>
14
+
15
+ % form_remote_tag :url => { :action => :add_to_cart, :id => $_ } do
16
+ %= submit_tag "Add to Cart"
17
+ % end
18
+
19
+
@@ -0,0 +1,22 @@
1
+ <!--
2
+ ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
3
+ ! We make no guarantees that this code is fit for any purpose.
4
+ ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
5
+ -->
6
+ <h1>Your Pragmatic Catalog</h1>
7
+
8
+ <% for product in @products -%>
9
+ <div class="entry">
10
+ <%= image_tag(product.image_url) %>
11
+ <h3><%= h(product.title) %></h3>
12
+ <%= product.description %>
13
+ <div class="price-line">
14
+ <span class="price"><%= number_to_currency(product.price) %></span>
15
+
16
+ <% form_remote_tag :url => { :action => :add_to_cart, :id => product } do %>
17
+ <%= submit_tag "Add to Cart" %>
18
+ <% end %>
19
+
20
+ </div>
21
+ </div>
22
+ <% end %>
@@ -0,0 +1,24 @@
1
+ development:
2
+ adapter: mysql
3
+ database: depot_dev
4
+ username: depot
5
+ password: depot
6
+ host: localhost
7
+ socket: /var/run/mysqld/mysqld.sock
8
+
9
+ test:
10
+ adapter: mysql
11
+ database: depot_test
12
+ username: depot
13
+ password: depot
14
+ host: localhost
15
+ socket: /var/run/mysqld/mysqld.sock
16
+
17
+ production:
18
+ adapter: mysql
19
+ database: depot_production
20
+ username: depot
21
+ password: depot
22
+ host: localhost
23
+ socket: /var/run/mysqld/mysqld.sock
24
+
@@ -0,0 +1,14 @@
1
+
2
+ drop database if exists depot_dev ;
3
+ create database depot_dev ;
4
+ grant all on depot_dev.* to depot@localhost identified by 'depot' ;
5
+
6
+ drop database if exists depot_test ;
7
+ create database depot_test ;
8
+ grant all on depot_test.* to depot@localhost identified by 'depot' ;
9
+
10
+ drop database if exists depot ;
11
+ create database depot ;
12
+ grant all on depot.* to depot@localhost identified by 'depot' ;
13
+
14
+
@@ -0,0 +1,35 @@
1
+ = The Depot Online Store
2
+
3
+ This application implements an online store, with a catalog, cart, and orders.
4
+
5
+ It is divided into three main sections:
6
+
7
+ * The buyer's side of the application manages the catalog, cart, and
8
+ checkout. It is implemented in StoreController and the associated
9
+ views.
10
+
11
+ * Only administrators can access stuff in the AdminController.
12
+ This is implemented by the LoginController, and is enforced by the
13
+ ApplicationController#authorize method.
14
+
15
+ * There's also a simple web service accessible via the InfoController.
16
+
17
+ This code was produced as an example for the book {Agile Web
18
+ Development with
19
+ Rails}[http://pragmaticprogrammer.com/titles/rails2]. It should not be
20
+ run as a real online store.
21
+
22
+ === Author
23
+
24
+ Dave Thomas, The Pragmatic Programmers, LLC
25
+
26
+ === Warranty
27
+
28
+ This code is provided for educational purposes only, and comes with
29
+ absolutely no warranty. It should not be used in live applications.
30
+
31
+ == Copyright
32
+
33
+ This code is Copyright (c) 2006 The Pragmatic Programmers, LLC.
34
+
35
+ It is released under the same license as Ruby.
@@ -0,0 +1,6 @@
1
+ namespace :db do
2
+ desc "Prints the migration version"
3
+ task :schema_version => :environment do
4
+ puts ActiveRecord::Base.connection.select_value('select version from schema_info')
5
+ end
6
+ end
@@ -0,0 +1,116 @@
1
+ # Logfile created on Mon Mar 03 17:32:49 +0900 2008 SQL (0.013002) SET SQL_AUTO_IS_NULL=0
2
+ SQL (0.060364) CREATE TABLE `schema_info` (version int(11))
3
+ SQL (0.042630) INSERT INTO `schema_info` (version) VALUES(0)
4
+ SQL (0.000000) Mysql::Error: Table 'schema_info' already exists: CREATE TABLE `schema_info` (version int(11))
5
+ SQL (0.022310) SELECT version FROM schema_info
6
+ Migrating to CreateProducts (1)
7
+ SQL (0.251951) CREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255) DEFAULT NULL, `description` text DEFAULT NULL, `image_url` varchar(255) DEFAULT NULL) ENGINE=InnoDB
8
+ SQL (0.015268) UPDATE schema_info SET version = 1
9
+ SQL (0.000153) SELECT version FROM schema_info
10
+ Migrating to AddPrice (2)
11
+ SQL (0.138196) ALTER TABLE `products` ADD `price` decimal(8,2) DEFAULT 0
12
+ SQL (0.000350) UPDATE schema_info SET version = 2
13
+ SQL (0.000110) SELECT version FROM schema_info
14
+ Migrating to AddTestData (3)
15
+ Product Delete all (0.000202) DELETE FROM `products` 
16
+ Product Columns (0.000633) SHOW FIELDS FROM `products`
17
+ SQL (0.000134) BEGIN
18
+ Product Load (0.000205) SELECT * FROM `products` WHERE (products.title = 'Pragmatic Project Automation') LIMIT 1
19
+ Product Create (0.000169) INSERT INTO `products` (`image_url`, `price`, `title`, `description`) VALUES('/images/auto.jpg', '29.95', 'Pragmatic Project Automation', '<p>\n <em>Pragmatic Project Automation</em> shows you how to improve the \n consistency and repeatability of your project\'s procedures using \n automation to reduce risk and errors.\n </p>\n <p>\n Simply put, we\'re going to put this thing called a computer to work \n for you doing the mundane (but important) project stuff. That means \n you\'ll have more time and energy to do the really \n exciting---and difficult---stuff, like writing quality code.\n </p>')
20
+ SQL (0.000615) COMMIT
21
+ SQL (0.000043) BEGIN
22
+ Product Load (0.000179) SELECT * FROM `products` WHERE (products.title = 'Pragmatic Version Control') LIMIT 1
23
+ Product Create (0.000126) INSERT INTO `products` (`image_url`, `price`, `title`, `description`) VALUES('/images/svn.jpg', '28.5', 'Pragmatic Version Control', '<p>\n This book is a recipe-based approach to using Subversion that will \n get you up and \n running quickly---and correctly. All projects need version control: \n it\'s a foundational piece of any project\'s infrastructure. Yet half \n of all project teams in the U.S. don\'t use any version control at all. \n Many others don\'t use it well, and end up experiencing time-consuming problems.\n </p>')
24
+ SQL (0.007396) COMMIT
25
+ SQL (0.000039) BEGIN
26
+ Product Load (0.000150) SELECT * FROM `products` WHERE (products.title = 'Pragmatic Unit Testing (C#)') LIMIT 1
27
+ Product Create (0.000134) INSERT INTO `products` (`image_url`, `price`, `title`, `description`) VALUES('/images/utc.jpg', '27.75', 'Pragmatic Unit Testing (C#)', '<p>\n Pragmatic programmers use feedback to drive their development and \n personal processes. The most valuable feedback you can get while \n coding comes from unit testing.\n </p>\n <p>\n Without good tests in place, coding can become a frustrating game of \n \"whack-a-mole.\" That\'s the carnival game where the player strikes at a \n mechanical mole; it retreats and another mole pops up on the opposite side \n of the field. The moles pop up and down so fast that you end up flailing \n your mallet helplessly as the moles continue to pop up where you least \n expect them.\n </p>')
28
+ SQL (0.000149) COMMIT
29
+ SQL (0.000274) UPDATE schema_info SET version = 3
30
+ SQL (0.000113) SELECT version FROM schema_info
31
+ Migrating to AddSessions (4)
32
+ SQL (0.000842) CREATE TABLE `sessions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `session_id` varchar(255) DEFAULT NULL, `data` text DEFAULT NULL, `updated_at` datetime DEFAULT NULL) ENGINE=InnoDB
33
+ SQL (0.025951) CREATE INDEX `index_sessions_on_session_id` ON `sessions` (`session_id`)
34
+ SQL (0.000253) UPDATE schema_info SET version = 4
35
+ SQL (0.000139) SELECT version FROM schema_info
36
+ Migrating to CreateOrders (5)
37
+ SQL (0.000905) CREATE TABLE `orders` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `address` text DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `pay_type` varchar(10) DEFAULT NULL) ENGINE=InnoDB
38
+ SQL (0.000168) UPDATE schema_info SET version = 5
39
+ SQL (0.000114) SELECT version FROM schema_info
40
+ Migrating to CreateLineItems (6)
41
+ SQL (0.004357) CREATE TABLE `line_items` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `product_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `quantity` int(11) NOT NULL, `total_price` decimal(8,2) NOT NULL) ENGINE=InnoDB
42
+ SQL (0.002167) alter table line_items
43
+ add constraint fk_line_item_products
44
+ foreign key (product_id) references products(id)
45
+ SQL (0.009577) alter table line_items
46
+ add constraint fk_line_item_orders
47
+ foreign key (order_id) references orders(id)
48
+ SQL (0.000225) UPDATE schema_info SET version = 6
49
+ SQL (0.000152) SELECT version FROM schema_info
50
+ Migrating to CreateUsers (7)
51
+ SQL (0.000770) CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `hashed_password` varchar(255) DEFAULT NULL, `salt` varchar(255) DEFAULT NULL) ENGINE=InnoDB
52
+ SQL (0.000164) UPDATE schema_info SET version = 7
53
+ SQL (0.000163) SELECT * FROM schema_info
54
+ SQL (0.000197) SHOW TABLES
55
+ SQL (0.030424) SHOW FIELDS FROM `line_items`
56
+ SQL (0.000380) describe `line_items`
57
+ SQL (0.007629) SHOW KEYS FROM `line_items`
58
+ SQL (0.000376) SHOW FIELDS FROM `orders`
59
+ SQL (0.000344) describe `orders`
60
+ SQL (0.000204) SHOW KEYS FROM `orders`
61
+ SQL (0.000294) SHOW FIELDS FROM `products`
62
+ SQL (0.000337) describe `products`
63
+ SQL (0.000207) SHOW KEYS FROM `products`
64
+ SQL (0.000313) SHOW FIELDS FROM `sessions`
65
+ SQL (0.000310) describe `sessions`
66
+ SQL (0.000216) SHOW KEYS FROM `sessions`
67
+ SQL (0.000319) SHOW FIELDS FROM `users`
68
+ SQL (0.000310) describe `users`
69
+ SQL (0.000194) SHOW KEYS FROM `users`
70
+ SQL (0.000114) SET SQL_AUTO_IS_NULL=0
71
+ SQL (0.000000) Mysql::Error: Table 'schema_info' already exists: CREATE TABLE `schema_info` (version int(11))
72
+ SQL (0.000213) SELECT version FROM schema_info
73
+ SQL (0.000046) SELECT version FROM schema_info
74
+ SQL (0.000043) SELECT version FROM schema_info
75
+ SQL (0.000042) SELECT version FROM schema_info
76
+ SQL (0.000042) SELECT version FROM schema_info
77
+ SQL (0.000042) SELECT version FROM schema_info
78
+ SQL (0.000043) SELECT version FROM schema_info
79
+ SQL (0.000052) SELECT * FROM schema_info
80
+ SQL (0.000187) SHOW TABLES
81
+ SQL (0.000449) SHOW FIELDS FROM `line_items`
82
+ SQL (0.000340) describe `line_items`
83
+ SQL (0.000194) SHOW KEYS FROM `line_items`
84
+ SQL (0.000346) SHOW FIELDS FROM `orders`
85
+ SQL (0.000340) describe `orders`
86
+ SQL (0.000143) SHOW KEYS FROM `orders`
87
+ SQL (0.000355) SHOW FIELDS FROM `products`
88
+ SQL (0.000342) describe `products`
89
+ SQL (0.000157) SHOW KEYS FROM `products`
90
+ SQL (0.000322) SHOW FIELDS FROM `sessions`
91
+ SQL (0.000314) describe `sessions`
92
+ SQL (0.000159) SHOW KEYS FROM `sessions`
93
+ SQL (0.000320) SHOW FIELDS FROM `users`
94
+ SQL (0.000312) describe `users`
95
+ SQL (0.000140) SHOW KEYS FROM `users`
96
+ SQL (0.000063) SET SQL_AUTO_IS_NULL=0
97
+ SQL (0.003709) DROP DATABASE IF EXISTS `depot_test`
98
+ SQL (0.000157) CREATE DATABASE `depot_test` DEFAULT CHARACTER SET `utf8`
99
+ SQL (0.000075) SET SQL_AUTO_IS_NULL=0
100
+ SQL (0.000000) Mysql::Error: Unknown table 'line_items': DROP TABLE `line_items`
101
+ SQL (0.002265) CREATE TABLE `line_items` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `product_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `quantity` int(11) NOT NULL, `total_price` decimal(8,2) NOT NULL) ENGINE=InnoDB
102
+ SQL (0.015063) CREATE INDEX `fk_line_item_products` ON `line_items` (`product_id`)
103
+ SQL (0.026515) CREATE INDEX `fk_line_item_orders` ON `line_items` (`order_id`)
104
+ SQL (0.000000) Mysql::Error: Unknown table 'orders': DROP TABLE `orders`
105
+ SQL (0.000621) CREATE TABLE `orders` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `address` text DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `pay_type` varchar(10) DEFAULT NULL) ENGINE=InnoDB
106
+ SQL (0.000000) Mysql::Error: Unknown table 'products': DROP TABLE `products`
107
+ SQL (0.000611) CREATE TABLE `products` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `title` varchar(255) DEFAULT NULL, `description` text DEFAULT NULL, `image_url` varchar(255) DEFAULT NULL, `price` decimal(8,2) DEFAULT 0.0) ENGINE=InnoDB
108
+ SQL (0.000000) Mysql::Error: Unknown table 'sessions': DROP TABLE `sessions`
109
+ SQL (0.000586) CREATE TABLE `sessions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `session_id` varchar(255) DEFAULT NULL, `data` text DEFAULT NULL, `updated_at` datetime DEFAULT NULL) ENGINE=InnoDB
110
+ SQL (0.010056) CREATE INDEX `index_sessions_on_session_id` ON `sessions` (`session_id`)
111
+ SQL (0.000000) Mysql::Error: Unknown table 'users': DROP TABLE `users`
112
+ SQL (0.000614) CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT NULL, `hashed_password` varchar(255) DEFAULT NULL, `salt` varchar(255) DEFAULT NULL) ENGINE=InnoDB
113
+ SQL (0.000401) CREATE TABLE `schema_info` (version int(11))
114
+ SQL (0.000149) INSERT INTO `schema_info` (version) VALUES(0)
115
+ SQL (0.000262) SHOW FIELDS FROM `schema_info`
116
+ SQL (0.000170) UPDATE schema_info SET version = 7