moneyrail 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/.gitignore +5 -0
  2. data/.gitmodules +6 -0
  3. data/Changelog +21 -0
  4. data/README +1 -0
  5. data/Rakefile +32 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/accounts_controller.rb +99 -0
  8. data/app/controllers/application_controller.rb +10 -0
  9. data/app/controllers/categories_controller.rb +99 -0
  10. data/app/controllers/home_controller.rb +31 -0
  11. data/app/controllers/items_controller.rb +105 -0
  12. data/app/controllers/logs_controller.rb +20 -0
  13. data/app/helpers/accounts_helper.rb +2 -0
  14. data/app/helpers/application_helper.rb +3 -0
  15. data/app/helpers/categories_helper.rb +2 -0
  16. data/app/helpers/home_helper.rb +2 -0
  17. data/app/helpers/items_helper.rb +2 -0
  18. data/app/helpers/logs_helper.rb +42 -0
  19. data/app/models/account.rb +12 -0
  20. data/app/models/category.rb +26 -0
  21. data/app/models/expense.rb +2 -0
  22. data/app/models/income.rb +2 -0
  23. data/app/models/item.rb +31 -0
  24. data/app/models/move.rb +37 -0
  25. data/app/models/simple_item.rb +27 -0
  26. data/app/views/accounts/edit.html.erb +16 -0
  27. data/app/views/accounts/index.html.erb +24 -0
  28. data/app/views/accounts/new.html.erb +15 -0
  29. data/app/views/accounts/show.html.erb +8 -0
  30. data/app/views/categories/edit.html.erb +20 -0
  31. data/app/views/categories/index.html.erb +26 -0
  32. data/app/views/categories/new.html.erb +19 -0
  33. data/app/views/categories/show.html.erb +13 -0
  34. data/app/views/home/index.html.erb +15 -0
  35. data/app/views/items/edit.html.erb +45 -0
  36. data/app/views/items/index.html.erb +38 -0
  37. data/app/views/items/new.html.erb +40 -0
  38. data/app/views/items/show.html.erb +3 -0
  39. data/app/views/layouts/application.html.erb +37 -0
  40. data/app/views/logs/view.html.erb +120 -0
  41. data/config/boot.rb +110 -0
  42. data/config/database.yml +25 -0
  43. data/config/environment.rb +41 -0
  44. data/config/environments/cucumber.rb +21 -0
  45. data/config/environments/development.rb +17 -0
  46. data/config/environments/production.rb +28 -0
  47. data/config/environments/test.rb +28 -0
  48. data/config/initializers/backtrace_silencers.rb +7 -0
  49. data/config/initializers/inflections.rb +10 -0
  50. data/config/initializers/mime_types.rb +5 -0
  51. data/config/initializers/new_rails_defaults.rb +19 -0
  52. data/config/initializers/session_store.rb +15 -0
  53. data/config/locales/en.yml +5 -0
  54. data/config/routes.rb +80 -0
  55. data/db/migrate/20090802070406_create_accounts.rb +14 -0
  56. data/db/migrate/20090802073601_create_categories.rb +15 -0
  57. data/db/migrate/20090804065900_create_items.rb +26 -0
  58. data/db/production.sqlite3 +0 -0
  59. data/doc/README_FOR_APP +2 -0
  60. data/features/step_definitions/webrat_steps.rb +129 -0
  61. data/features/support/env.rb +37 -0
  62. data/features/support/paths.rb +27 -0
  63. data/lib/tasks/cucumber.rake +20 -0
  64. data/lib/tasks/rspec.rake +182 -0
  65. data/main.rb +5 -0
  66. data/moneyrail.gemspec +170 -0
  67. data/public/404.html +30 -0
  68. data/public/422.html +30 -0
  69. data/public/500.html +30 -0
  70. data/public/favicon.ico +0 -0
  71. data/public/images/rails.png +0 -0
  72. data/public/javascripts/application.js +2 -0
  73. data/public/javascripts/controls.js +963 -0
  74. data/public/javascripts/dragdrop.js +973 -0
  75. data/public/javascripts/editor.js +188 -0
  76. data/public/javascripts/effects.js +1128 -0
  77. data/public/javascripts/jquery-ui.js +160 -0
  78. data/public/javascripts/jquery.js +32 -0
  79. data/public/javascripts/prototype.js +4320 -0
  80. data/public/robots.txt +5 -0
  81. data/public/stylesheets/editor.less +67 -0
  82. data/public/stylesheets/scaffold.css +54 -0
  83. data/script/about +4 -0
  84. data/script/autospec +6 -0
  85. data/script/console +3 -0
  86. data/script/cucumber +8 -0
  87. data/script/dbconsole +3 -0
  88. data/script/destroy +3 -0
  89. data/script/generate +3 -0
  90. data/script/performance/benchmarker +3 -0
  91. data/script/performance/profiler +3 -0
  92. data/script/plugin +3 -0
  93. data/script/runner +3 -0
  94. data/script/server +3 -0
  95. data/script/spec +10 -0
  96. data/script/spec_server +9 -0
  97. data/spec/_fixtures/accounts.yml +5 -0
  98. data/spec/_fixtures/categories.yml +19 -0
  99. data/spec/_fixtures/incomes.yml +7 -0
  100. data/spec/_fixtures/items.yml +7 -0
  101. data/spec/fixtures/accounts.yml +11 -0
  102. data/spec/fixtures/categories.yml +24 -0
  103. data/spec/fixtures/items.yml +82 -0
  104. data/spec/helpers/accounts_helper_spec.rb +11 -0
  105. data/spec/helpers/categories_helper_spec.rb +11 -0
  106. data/spec/helpers/items_helper_spec.rb +11 -0
  107. data/spec/models/account_spec.rb +13 -0
  108. data/spec/models/category_spec.rb +9 -0
  109. data/spec/models/income_spec.rb +9 -0
  110. data/spec/models/item_spec.rb +13 -0
  111. data/spec/rcov.opts +2 -0
  112. data/spec/spec.opts +4 -0
  113. data/spec/spec_helper.rb +51 -0
  114. data/vendor/plugins/acts_as_list/README +23 -0
  115. data/vendor/plugins/acts_as_list/init.rb +3 -0
  116. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  117. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  118. data/vendor/plugins/less/LICENCE +20 -0
  119. data/vendor/plugins/less/README +52 -0
  120. data/vendor/plugins/less/init.rb +19 -0
  121. data/vendor/plugins/less/lib/less_for_rails.rb +37 -0
  122. data/vendor/plugins/less/test/less_for_rails_test.rb +15 -0
  123. metadata +202 -0
@@ -0,0 +1,24 @@
1
+ <h2>Listing accounts</h2>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ </tr>
7
+
8
+ <% @accounts.each do |account| %>
9
+ <tr>
10
+ <td><%=h account.name %></td>
11
+ <td><%= link_to 'Show', account %></td>
12
+ <td><%= link_to 'Edit', edit_account_path(account) %></td>
13
+ <td><%= link_to 'Destroy', account, :confirm => 'Are you sure?', :method => :delete %></td>
14
+ <td><%= link_to '↑', move_up_account_path(account) %></td>
15
+ <td><%= link_to '↓', move_down_account_path(account) %></td>
16
+ </tr>
17
+ <% end %>
18
+ </table>
19
+
20
+ <br />
21
+
22
+ <%= link_to 'New account', new_account_path %>
23
+
24
+ <%= link_to 'back', root_path %>
@@ -0,0 +1,15 @@
1
+ <h2>New account</h2>
2
+
3
+ <% form_for(@account) do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :name %><br />
8
+ <%= f.text_field :name %>
9
+ </p>
10
+ <p>
11
+ <%= f.submit 'Create' %>
12
+ </p>
13
+ <% end %>
14
+
15
+ <%= link_to 'Back', accounts_path %>
@@ -0,0 +1,8 @@
1
+ <p>
2
+ <b>Name:</b>
3
+ <%=h @account.name %>
4
+ </p>
5
+
6
+
7
+ <%= link_to 'Edit', edit_account_path(@account) %> |
8
+ <%= link_to 'Back', accounts_path %>
@@ -0,0 +1,20 @@
1
+ <h2>Editing category</h2>
2
+
3
+ <% form_for(@category) do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :name %><br />
8
+ <%= f.text_field :name %>
9
+ </p>
10
+ <p>
11
+ <%= f.label :kind %><br />
12
+ <%= f.text_field :kind %>
13
+ </p>
14
+ <p>
15
+ <%= f.submit 'Update' %>
16
+ </p>
17
+ <% end %>
18
+
19
+ <%= link_to 'Show', @category %> |
20
+ <%= link_to 'Back', categories_path %>
@@ -0,0 +1,26 @@
1
+ <h2>Listing categories</h2>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Kind</th>
7
+ </tr>
8
+
9
+ <% @categories.each do |category| %>
10
+ <tr>
11
+ <td><%=h category.name %></td>
12
+ <td><%=h category.kind %></td>
13
+ <td><%= link_to 'Show', category %></td>
14
+ <td><%= link_to 'Edit', edit_category_path(category) %></td>
15
+ <td><%= link_to 'Destroy', category, :confirm => 'Are you sure?', :method => :delete %></td>
16
+ <td><%= link_to '↑', move_up_category_path(category) %></td>
17
+ <td><%= link_to '↓', move_down_category_path(category) %></td>
18
+ </tr>
19
+ <% end %>
20
+ </table>
21
+
22
+ <br />
23
+
24
+ <%= link_to 'New category', new_category_path %>
25
+
26
+ <%= link_to 'back', root_path %>
@@ -0,0 +1,19 @@
1
+ <h2>New category</h2>
2
+
3
+ <% form_for(@category) do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :name %><br />
8
+ <%= f.text_field :name %>
9
+ </p>
10
+ <p>
11
+ <%= f.label :kind %><br />
12
+ <%= f.select :kind, %w(Expense Income Move) %>
13
+ </p>
14
+ <p>
15
+ <%= f.submit 'Create' %>
16
+ </p>
17
+ <% end %>
18
+
19
+ <%= link_to 'Back', categories_path %>
@@ -0,0 +1,13 @@
1
+ <p>
2
+ <b>Name:</b>
3
+ <%=h @category.name %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Kind:</b>
8
+ <%=h @category.kind %>
9
+ </p>
10
+
11
+
12
+ <%= link_to 'Edit', edit_category_path(@category) %> |
13
+ <%= link_to 'Back', categories_path %>
@@ -0,0 +1,15 @@
1
+ <ul>
2
+ <li><%= link_to 'Accounts', accounts_path %></li>
3
+ <li><%= link_to 'Categories', categories_path %></li>
4
+ <li><%= link_to 'Items', items_path %></li>
5
+ </ul>
6
+ <ul>
7
+ <% @months.each do |m| %>
8
+ <li>
9
+ <%= link_to "Logs: #{m.year}-#{m.month}",
10
+ show_logs_path(:year => m.year, :month => m.month) %>
11
+ <%= link_to "(edit)",
12
+ edit_logs_path(:year => m.year, :month => m.month) %>
13
+ </li>
14
+ <% end %>
15
+ </ul>
@@ -0,0 +1,45 @@
1
+ <h2>Editing item</h2>
2
+
3
+ <% form_for :item, @item, :url => item_path(@item), :html => {:method => :put} do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :title %><br />
8
+ <%= f.text_field :title %>
9
+ </p>
10
+ <p>
11
+ <%= f.label :amount %><br />
12
+ <%= f.text_field :amount %>
13
+ </p>
14
+ <p>
15
+ <%= f.label :type %><br />
16
+ <%= f.select :type, %w(Expense Income Move).map{|x| [x, x]} %>
17
+ </p>
18
+ <p>
19
+ <%= f.label :category_id %><br />
20
+ <%= f.select :category_id, @categories.map{|c| [c.name, c.id]} %>
21
+ </p>
22
+ <p>
23
+ <%= f.label :date %><br />
24
+ <%= f.text_field :date %>
25
+ </p>
26
+ <p>
27
+ <%= f.label :position %><br />
28
+ <%= f.text_field :position %>
29
+ </p>
30
+ <p id="one_account">
31
+ <%= f.label :account_id %><br />
32
+ <%= f.select :account_id, @accounts.map{|a| [a.name, a.id]} %>
33
+ </p>
34
+ <p id="two_accounts">
35
+ <%= f.label :account_id_from %><br />
36
+ <%= f.select :account_id_from, @accounts.map{|a| [a.name, a.id]} %>
37
+ → <%= f.select :account_id_to, @accounts.map{|a| [a.name, a.id]} %>
38
+ </p>
39
+ <p>
40
+ <%= f.submit 'Update' %>
41
+ </p>
42
+ <% end %>
43
+
44
+ <%= link_to 'Show', @item %> |
45
+ <%= link_to 'Back', items_path %>
@@ -0,0 +1,38 @@
1
+ <h2>Listing items</h2>
2
+
3
+ <table>
4
+ <tr>
5
+ <td>date</td>
6
+ <td>category</td>
7
+ <td>title</td>
8
+ <td>amount</td>
9
+ <td>account</td>
10
+ </tr>
11
+
12
+ <% @items.each do |item| %>
13
+ <tr>
14
+ <td><%=h item.date %></td>
15
+ <td><%=h item.category.name %></td>
16
+ <td><%=h item.title %></td>
17
+ <td><%=h item.amount %></td>
18
+ <td>
19
+ <% if item.is_a?(Move) %>
20
+ <%=h item.account_from.name %>→<%=h item.account_to.name %>
21
+ <% elsif item.is_a?(Expense) %>
22
+ ←<%=h item.account.name %>
23
+ <% else %>
24
+ →<%=h item.account.name %>
25
+ <% end %>
26
+ </td>
27
+ <!--<td><%= link_to 'Show', item %></td>-->
28
+ <td><%= link_to 'Edit', edit_item_path(item) %></td>
29
+ <td><%= link_to 'Destroy', item, :confirm => 'Are you sure?', :method => :delete %></td>
30
+ </tr>
31
+ <% end %>
32
+ </table>
33
+
34
+ <br />
35
+
36
+ <%= link_to 'New item', new_item_path %>
37
+
38
+ <%= link_to 'back', root_path %>
@@ -0,0 +1,40 @@
1
+ <h2>New item</h2>
2
+
3
+ <% form_for(@item) do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :title %><br />
8
+ <%= f.text_field :title %>
9
+ </p>
10
+ <p>
11
+ <%= f.label :amount %><br />
12
+ <%= f.text_field :amount %>
13
+ </p>
14
+ <p>
15
+ <%= f.label :category_id %><br />
16
+ <%= f.select :category_id, @categories.map{|c| [c.name, c.id]} %>
17
+ </p>
18
+ <p>
19
+ <%= f.label :date %><br />
20
+ <%= f.text_field :date %>
21
+ </p>
22
+ <p>
23
+ <%= f.label :position %><br />
24
+ <%= f.text_field :position %>
25
+ </p>
26
+ <p id="one_account">
27
+ <%= f.label :account_id %><br />
28
+ <%= f.select :account_id, @accounts.map{|a| [a.name, a.id]} %>
29
+ </p>
30
+ <p id="two_accounts">
31
+ <%= f.label :account_id_from %><br />
32
+ <%= f.select :account_id_from, @accounts.map{|a| [a.name, a.id]} %>
33
+ → <%= f.select :account_id_to, @accounts.map{|a| [a.name, a.id]} %>
34
+ </p>
35
+ <p>
36
+ <%= f.submit 'Create' %>
37
+ </p>
38
+ <% end %>
39
+
40
+ <%= link_to 'Back', items_path %>
@@ -0,0 +1,3 @@
1
+
2
+ <%= link_to 'Edit', edit_item_path(@item) %> |
3
+ <%= link_to 'Back', items_path %>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+
10
+ <% if controller.controller_name == "logs" %>
11
+ <title>MoneyRail : Logs: <%=h @year %>/<%=h @month %></title>
12
+ <%= stylesheet_link_tag 'editor' %>
13
+
14
+ <% if controller.mode == :edit %>
15
+ <%= javascript_include_tag 'prototype' %>
16
+ <%= javascript_include_tag 'effects' %>
17
+ <%= javascript_include_tag 'jquery' %>
18
+ <%= javascript_include_tag 'editor' %>
19
+ <% end %>
20
+ <% else %>
21
+ <title>MoneyRail :
22
+ <%=h controller.controller_name.camelcase %>:
23
+ <%= controller.action_name %>
24
+ </title>
25
+ <% end %>
26
+ </head>
27
+ <body>
28
+
29
+ <h1><%= link_to "MoneyRail", :controller => :home %></h1>
30
+
31
+ <p style="color: green"><%= flash[:notice] %></p>
32
+
33
+ <%= yield %>
34
+
35
+ </body>
36
+ </html>
37
+
@@ -0,0 +1,120 @@
1
+ <h2><%=h @year %>/<%=h @month %></h2>
2
+ <% unless @mode == :edit %>
3
+ <%= link_to "(edit)", edit_logs_path(:year => @year, :month => @month) %>
4
+ <% end %>
5
+
6
+ <ul>
7
+ <% @accounts.each_with_index do |account, i| %>
8
+ <li><%= link_to account.name, "#account_#{i}" %></li>
9
+ <% end %>
10
+ </ul>
11
+
12
+ <% @accounts.each_with_index do |account, i| %>
13
+ <%# for each account %>
14
+ <a name="account_<%=h i%>" />
15
+ <h3>
16
+ <%=h account.name %>
17
+ <%= link_to '△', move_up_account_path(account) %>
18
+ <%= link_to '▽', move_down_account_path(account) %>
19
+ </h3>
20
+
21
+ <%# table %>
22
+ <table class="editor" title="<%=h account.id %>">
23
+ <%# first row %>
24
+ <tr>
25
+ <% if @mode == :edit %>
26
+ <th class="inserts" rowspan="2">
27
+ </th>
28
+ <% end %>
29
+ <th class="date" rowspan="2">
30
+ Date
31
+ </th>
32
+ <% [:expense, :income, :move].each do |kind| %>
33
+ <th colspan="<%= @categories[kind].length * 2 %>">
34
+ <%=h kind.to_s.capitalize %>
35
+ </th>
36
+ <% end %>
37
+ </tr>
38
+
39
+ <tr>
40
+ <% @cat_all.each do |cat| %>
41
+ <th class="category" colspan="2">
42
+ <%=h cat.name %>
43
+ </th>
44
+ <% end %>
45
+ </tr>
46
+
47
+ <% make_table_data(account).each_with_index do |(day, i, btn, row), k| %>
48
+ <%# for each row %>
49
+ <% tr_class = (k%2 == 0) ? "even" : "odd" %>
50
+ <tr title="<%=h day.strftime('%Y-%m-%d') %>_<%=h i %>" class="<%=h tr_class %>">
51
+
52
+ <%# first cell %>
53
+ <% if @mode == :edit %>
54
+ <td>
55
+ <% if btn %>
56
+ <span class="pushable">▽</span>
57
+ <% end %>
58
+ </td>
59
+ <% end %>
60
+
61
+ <% row.each do |item| %>
62
+ <%# for each cell %>
63
+
64
+ <% case item
65
+ when Date %>
66
+ <td>
67
+ <%=h item.to_s %>
68
+ </td>
69
+
70
+ <% when :no_date %>
71
+ <td></td>
72
+
73
+ <% when Item %>
74
+ <td class="title" title="<%=h item.id %>">
75
+ <%= cell(item.title) %>
76
+ </td>
77
+ <td class="amount" title="<%=h item.id %>">
78
+ <%= cell(item.amount) %>
79
+ </td>
80
+
81
+ <% else %>
82
+ <td class="title"><%= cell("") %></td>
83
+ <td class="amount"><%= cell("") %></td>
84
+ <% end %>
85
+ <% end %>
86
+ </tr>
87
+ <% end %>
88
+ </table>
89
+ <% end %>
90
+
91
+ <% javascript_tag do %>
92
+ var MoneyRail = MoneyRail || {};
93
+
94
+ MoneyRail.editable = <%=h (@mode == :edit) ? "true" : "false" %>;
95
+
96
+ MoneyRail.authenticity_token = '<%=h form_authenticity_token %>';
97
+
98
+ MoneyRail.category_numbers = [
99
+ <%=h [:expense, :income, :move].map{|kind|
100
+ @categories[kind].length.to_s
101
+ }.join(", ") %>
102
+ ];
103
+
104
+ MoneyRail.category_ids = [
105
+ <%=h @cat_all.map{|c| c.id.to_s}.join(", ") %>
106
+ ];
107
+
108
+ MoneyRail.item_update_path = function(item_id){
109
+ var str = "<%=h update_item_path(9999) %>.json";
110
+ return str.replace(/9999/, item_id);
111
+ };
112
+ MoneyRail.item_destroy_path = function(item_id){
113
+ var str = "<%=h destroy_item_path(9999) %>.json";
114
+ return str.replace(/9999/, item_id);
115
+ };
116
+ MoneyRail.item_create_path = "<%=h create_item_path %>.json";
117
+ <% end %>
118
+
119
+ <%= link_to 'back', root_path %>
120
+ <!-- この文字列は文字化け除けの文章です -->
data/config/boot.rb ADDED
@@ -0,0 +1,110 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion rescue nil
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ require 'rubygems'
86
+ min_version = '1.3.1'
87
+ unless rubygems_version >= min_version
88
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
+ exit 1
95
+ end
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ # All that for this:
110
+ Rails.boot!
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test: &TEST
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
23
+
24
+ cucumber:
25
+ <<: *TEST
@@ -0,0 +1,41 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ Rails::Initializer.run do |config|
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Add additional load paths for your own custom dirs
15
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
16
+
17
+ # Specify gems that this application depends on and have them installed with rake gems:install
18
+ # config.gem "bj"
19
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
20
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
21
+ # config.gem "aws-s3", :lib => "aws/s3"
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+
27
+ # Skip frameworks you're not going to use. To use Rails without a database,
28
+ # you must remove the Active Record framework.
29
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
30
+
31
+ # Activate observers that should always be running
32
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33
+
34
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
35
+ # Run "rake -D time" for a list of tasks for finding time zone names.
36
+ config.time_zone = 'UTC'
37
+
38
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
39
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
40
+ # config.i18n.default_locale = :de
41
+ end
@@ -0,0 +1,21 @@
1
+ config.cache_classes = true # This must be true for Cucumber to operate correctly!
2
+
3
+ # Log error messages when you accidentally call methods on nil.
4
+ config.whiny_nils = true
5
+
6
+ # Show full error reports and disable caching
7
+ config.action_controller.consider_all_requests_local = true
8
+ config.action_controller.perform_caching = false
9
+
10
+ # Disable request forgery protection in test environment
11
+ config.action_controller.allow_forgery_protection = false
12
+
13
+ # Tell Action Mailer not to deliver emails to the real world.
14
+ # The :test delivery method accumulates sent emails in the
15
+ # ActionMailer::Base.deliveries array.
16
+ config.action_mailer.delivery_method = :test
17
+
18
+ config.gem "cucumber", :lib => false, :version => ">=0.3.92" unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber'))
19
+ config.gem "webrat", :lib => false, :version => ">=0.4.4" unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
20
+ config.gem "rspec", :lib => false, :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
21
+ config.gem "rspec-rails", :lib => 'spec/rails', :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false