yhara-moneyrail 0.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 (121) 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/doc/README_FOR_APP +2 -0
  59. data/features/step_definitions/webrat_steps.rb +129 -0
  60. data/features/support/env.rb +37 -0
  61. data/features/support/paths.rb +27 -0
  62. data/lib/tasks/cucumber.rake +20 -0
  63. data/lib/tasks/rspec.rake +182 -0
  64. data/main.rb +5 -0
  65. data/moneyrail.gemspec +170 -0
  66. data/public/404.html +30 -0
  67. data/public/422.html +30 -0
  68. data/public/500.html +30 -0
  69. data/public/favicon.ico +0 -0
  70. data/public/images/rails.png +0 -0
  71. data/public/javascripts/application.js +2 -0
  72. data/public/javascripts/controls.js +963 -0
  73. data/public/javascripts/dragdrop.js +973 -0
  74. data/public/javascripts/editor.js +188 -0
  75. data/public/javascripts/effects.js +1128 -0
  76. data/public/javascripts/jquery-ui.js +160 -0
  77. data/public/javascripts/jquery.js +32 -0
  78. data/public/javascripts/prototype.js +4320 -0
  79. data/public/robots.txt +5 -0
  80. data/public/stylesheets/editor.less +67 -0
  81. data/script/about +4 -0
  82. data/script/autospec +6 -0
  83. data/script/console +3 -0
  84. data/script/cucumber +8 -0
  85. data/script/dbconsole +3 -0
  86. data/script/destroy +3 -0
  87. data/script/generate +3 -0
  88. data/script/performance/benchmarker +3 -0
  89. data/script/performance/profiler +3 -0
  90. data/script/plugin +3 -0
  91. data/script/runner +3 -0
  92. data/script/server +3 -0
  93. data/script/spec +10 -0
  94. data/script/spec_server +9 -0
  95. data/spec/_fixtures/accounts.yml +5 -0
  96. data/spec/_fixtures/categories.yml +19 -0
  97. data/spec/_fixtures/incomes.yml +7 -0
  98. data/spec/_fixtures/items.yml +7 -0
  99. data/spec/fixtures/accounts.yml +11 -0
  100. data/spec/fixtures/categories.yml +24 -0
  101. data/spec/fixtures/items.yml +82 -0
  102. data/spec/helpers/accounts_helper_spec.rb +11 -0
  103. data/spec/helpers/categories_helper_spec.rb +11 -0
  104. data/spec/helpers/items_helper_spec.rb +11 -0
  105. data/spec/models/account_spec.rb +13 -0
  106. data/spec/models/category_spec.rb +9 -0
  107. data/spec/models/income_spec.rb +9 -0
  108. data/spec/models/item_spec.rb +13 -0
  109. data/spec/rcov.opts +2 -0
  110. data/spec/spec.opts +4 -0
  111. data/spec/spec_helper.rb +51 -0
  112. data/vendor/plugins/acts_as_list/README +23 -0
  113. data/vendor/plugins/acts_as_list/init.rb +3 -0
  114. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  115. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  116. data/vendor/plugins/less/LICENCE +20 -0
  117. data/vendor/plugins/less/README +52 -0
  118. data/vendor/plugins/less/init.rb +19 -0
  119. data/vendor/plugins/less/lib/less_for_rails.rb +37 -0
  120. data/vendor/plugins/less/test/less_for_rails_test.rb +15 -0
  121. metadata +201 -0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ db/*.sqlite3
2
+ db/schema.rb
3
+ log
4
+ tmp
5
+ public/stylesheets/*.css
data/.gitmodules ADDED
@@ -0,0 +1,6 @@
1
+ [submodule "vendor/plugins/less"]
2
+ path = vendor/plugins/less
3
+ url = git://github.com/augustl/less-for-rails.git
4
+ [submodule "vendor/plugins/acts_as_list"]
5
+ path = vendor/plugins/acts_as_list
6
+ url = git://github.com/rails/acts_as_list.git
data/Changelog ADDED
@@ -0,0 +1,21 @@
1
+ 2009-08-19 Yutaka HARA <yhara(at)kmc.gr.jp>
2
+
3
+ * Released 0.0.1
4
+
5
+ * new: delete an item when title and amount are both empty
6
+
7
+ * fix: item deletion raises an error
8
+
9
+ * fix: fails to update cells whose position > 0
10
+
11
+ 2009-08-17 Yutaka HARA <yhara(at)kmc.gr.jp>
12
+
13
+ * new: show logs
14
+
15
+ 2009-08-16 Yutaka HARA <yhara(at)kmc.gr.jp>
16
+
17
+ * Released 0.0.0
18
+
19
+
20
+
21
+
data/README ADDED
@@ -0,0 +1 @@
1
+ see http://wiki.github.com/yhara/moneyrail
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ require 'tasks/rails'
11
+
12
+ # -- gem creation
13
+
14
+ PROJECT_NAME = "moneyrail"
15
+
16
+ begin
17
+ require 'jeweler'
18
+ rescue LoadError
19
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
20
+ end
21
+
22
+ Jeweler::Tasks.new do |gemspec|
23
+ gemspec.name = "#{PROJECT_NAME}"
24
+ gemspec.summary = "Household account book, written in Rails"
25
+ gemspec.email = "yutaka.hara/at/gmail.com"
26
+ gemspec.homepage = "http://github.com/yhara/#{PROJECT_NAME}"
27
+ gemspec.description = gemspec.summary
28
+ gemspec.authors = ["Yutaka HARA"]
29
+ gemspec.add_dependency('rails', '= 2.3.3')
30
+ gemspec.add_dependency('ruby-station-runtime', '>= 0.0.2')
31
+ gemspec.files.concat Dir["vendor/plugins/**/*"]
32
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,99 @@
1
+ class AccountsController < ApplicationController
2
+ # GET /accounts
3
+ # GET /accounts.xml
4
+ def index
5
+ @accounts = Account.all(:order => "position")
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @accounts }
10
+ end
11
+ end
12
+
13
+ # GET /accounts/1
14
+ # GET /accounts/1.xml
15
+ def show
16
+ @account = Account.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @account }
21
+ end
22
+ end
23
+
24
+ # GET /accounts/new
25
+ # GET /accounts/new.xml
26
+ def new
27
+ @account = Account.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @account }
32
+ end
33
+ end
34
+
35
+ # GET /accounts/1/edit
36
+ def edit
37
+ @account = Account.find(params[:id])
38
+ end
39
+
40
+ # POST /accounts
41
+ # POST /accounts.xml
42
+ def create
43
+ @account = Account.new(params[:account])
44
+
45
+ respond_to do |format|
46
+ if @account.save
47
+ flash[:notice] = 'Account was successfully created.'
48
+ format.html { redirect_to(@account) }
49
+ format.xml { render :xml => @account, :status => :created, :location => @account }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @account.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /accounts/1
58
+ # PUT /accounts/1.xml
59
+ def update
60
+ @account = Account.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @account.update_attributes(params[:account])
64
+ flash[:notice] = 'Account was successfully updated.'
65
+ format.html { redirect_to(@account) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @account.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /accounts/1
75
+ # DELETE /accounts/1.xml
76
+ def destroy
77
+ @account = Account.find(params[:id])
78
+ @account.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(accounts_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+
86
+ def move_up
87
+ @account = Account.find(params[:id])
88
+ @account.move_higher
89
+
90
+ redirect_to :back
91
+ end
92
+
93
+ def move_down
94
+ @account = Account.find(params[:id])
95
+ @account.move_lower
96
+
97
+ redirect_to :back
98
+ end
99
+ end
@@ -0,0 +1,10 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # Scrub sensitive parameters from your log
9
+ # filter_parameter_logging :password
10
+ end
@@ -0,0 +1,99 @@
1
+ class CategoriesController < ApplicationController
2
+ # GET /categories
3
+ # GET /categories.xml
4
+ def index
5
+ @categories = Category.all(:order => "kind, position")
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @categories }
10
+ end
11
+ end
12
+
13
+ # GET /categories/1
14
+ # GET /categories/1.xml
15
+ def show
16
+ @category = Category.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @category }
21
+ end
22
+ end
23
+
24
+ # GET /categories/new
25
+ # GET /categories/new.xml
26
+ def new
27
+ @category = Category.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @category }
32
+ end
33
+ end
34
+
35
+ # GET /categories/1/edit
36
+ def edit
37
+ @category = Category.find(params[:id])
38
+ end
39
+
40
+ # POST /categories
41
+ # POST /categories.xml
42
+ def create
43
+ @category = Category.new(params[:category])
44
+
45
+ respond_to do |format|
46
+ if @category.save
47
+ flash[:notice] = 'Category was successfully created.'
48
+ format.html { redirect_to(@category) }
49
+ format.xml { render :xml => @category, :status => :created, :location => @category }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /categories/1
58
+ # PUT /categories/1.xml
59
+ def update
60
+ @category = Category.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @category.update_attributes(params[:category])
64
+ flash[:notice] = 'Category was successfully updated.'
65
+ format.html { redirect_to(@category) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /categories/1
75
+ # DELETE /categories/1.xml
76
+ def destroy
77
+ @category = Category.find(params[:id])
78
+ @category.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(categories_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+
86
+ def move_up
87
+ @account = Category.find(params[:id])
88
+ @account.move_higher
89
+
90
+ redirect_to :action => :index
91
+ end
92
+
93
+ def move_down
94
+ @account = Category.find(params[:id])
95
+ @account.move_lower
96
+
97
+ redirect_to :action => :index
98
+ end
99
+ end
@@ -0,0 +1,31 @@
1
+ class HomeController < ApplicationController
2
+
3
+ def index
4
+ @months = []
5
+ collect_months(@months)
6
+ append_current_month(@months)
7
+ end
8
+
9
+ private
10
+
11
+ def collect_months(months)
12
+ oldest = Item.minimum("date")
13
+ newest = Item.maximum("date")
14
+
15
+ if oldest and newest
16
+ m = newest.beginning_of_month
17
+ while m >= oldest.beginning_of_month
18
+ months.push m
19
+ m <<= 1
20
+ end
21
+ end
22
+ end
23
+
24
+ def append_current_month(months)
25
+ current = Time.now.to_date.beginning_of_month
26
+ unless months.include?(current)
27
+ months.push current
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,105 @@
1
+ class ItemsController < ApplicationController
2
+ # GET /items
3
+ # GET /items.xml
4
+ def index
5
+ @items = Item.all(:order => "updated_at DESC")
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @items }
10
+ end
11
+ end
12
+
13
+ # GET /items/1
14
+ # GET /items/1.xml
15
+ def show
16
+ @item = Item.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @item }
21
+ end
22
+ end
23
+
24
+ # GET /items/new
25
+ # GET /items/new.xml
26
+ def new
27
+ @item = Item.new
28
+ @accounts = Account.all
29
+ @categories = Category.all
30
+
31
+ respond_to do |format|
32
+ format.html # new.html.erb
33
+ format.xml { render :xml => @item }
34
+ end
35
+ end
36
+
37
+ # GET /items/1/edit
38
+ def edit
39
+ @item = Item.find(params[:id])
40
+ @accounts = Account.all
41
+ @categories = Category.all
42
+ end
43
+
44
+ # POST /items
45
+ # POST /items.xml
46
+ def create
47
+ @item = Item.new(params[:item])
48
+ @item.type = @item.category.kind
49
+ @accounts = Account.all
50
+ @categories = Category.all
51
+
52
+ respond_to do |format|
53
+ if @item.save
54
+ format.html {
55
+ flash[:notice] = 'Item was successfully created.'
56
+ redirect_to(@item)
57
+ }
58
+ format.xml { render :xml => @item, :status => :created, :location => @item }
59
+ format.json { render :text => "['ok', #{@item.id}]" }
60
+ else
61
+ logger.debug @item.errors.inspect
62
+ format.html { render :action => "new" }
63
+ format.xml { render :xml => @item.errors, :status => :unprocessable_entity }
64
+ format.json { render :text => "['error']" }
65
+ end
66
+ end
67
+ end
68
+
69
+ # PUT /items/1
70
+ # PUT /items/1.xml
71
+ def update
72
+ @item = Item.find(params[:id])
73
+ @accounts = Account.all
74
+ @categories = Category.all
75
+
76
+ respond_to do |format|
77
+ if @item.update_attributes(params[:item])
78
+ format.html {
79
+ flash[:notice] = 'Item was successfully updated.'
80
+ redirect_to(@item)
81
+ }
82
+ format.xml { head :ok }
83
+ format.json { render :text => "['ok']" }
84
+ else
85
+ logger.debug @item.errors.inspect
86
+ format.html { render :action => "edit" }
87
+ format.xml { render :xml => @item.errors, :status => :unprocessable_entity }
88
+ format.json { render :text => "['error']" }
89
+ end
90
+ end
91
+ end
92
+
93
+ # DELETE /items/1
94
+ # DELETE /items/1.xml
95
+ def destroy
96
+ @item = Item.find(params[:id])
97
+ @item.destroy
98
+
99
+ respond_to do |format|
100
+ format.html { redirect_to(items_url) }
101
+ format.xml { head :ok }
102
+ format.json { render :text => "['ok']" }
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,20 @@
1
+ class LogsController < ApplicationController
2
+
3
+ def view
4
+ @mode = params[:mode]
5
+ @year, @month = params[:year].to_i, params[:month].to_i
6
+
7
+ first_day = Date.new(@year, @month)
8
+ @month_range = first_day .. ((first_day >> 1) - 1)
9
+
10
+ @accounts = Account.all(:order => "position")
11
+ @categories = Category.hashed
12
+ @cat_all = [
13
+ @categories[:expense],
14
+ @categories[:income],
15
+ @categories[:move],
16
+ ].flatten(1)
17
+ end
18
+ attr_reader :mode
19
+
20
+ end