plutus 0.4.2 → 0.5.1

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 (81) hide show
  1. data/README.markdown +12 -9
  2. data/VERSION.yml +2 -2
  3. data/config/backtrace_silencers.rb +7 -0
  4. data/config/inflections.rb +10 -0
  5. data/config/mime_types.rb +5 -0
  6. data/config/secret_token.rb +7 -0
  7. data/config/session_store.rb +8 -0
  8. data/doc/Account.html +1 -1
  9. data/doc/AccountsController.html +1 -1
  10. data/doc/Asset.html +1 -1
  11. data/doc/CreatePlutusTables.html +265 -0
  12. data/doc/Equity.html +1 -1
  13. data/doc/Expense.html +1 -1
  14. data/doc/Liability.html +1 -1
  15. data/doc/Plutus.html +91 -0
  16. data/doc/Plutus/Engine.html +100 -0
  17. data/doc/PlutusGenerator.html +312 -0
  18. data/doc/Revenue.html +1 -1
  19. data/doc/Transaction.html +1 -1
  20. data/doc/TransactionsController.html +1 -1
  21. data/doc/_index.html +39 -1
  22. data/doc/class_list.html +1 -1
  23. data/doc/file.README.html +11 -11
  24. data/doc/index.html +11 -11
  25. data/doc/method_list.html +76 -36
  26. data/doc/top-level-namespace.html +4 -2
  27. data/fixture_rails_root/.gitignore +4 -0
  28. data/fixture_rails_root/Gemfile +38 -0
  29. data/fixture_rails_root/Gemfile.lock +98 -0
  30. data/fixture_rails_root/README +256 -0
  31. data/fixture_rails_root/Rakefile +7 -0
  32. data/fixture_rails_root/app/controllers/application_controller.rb +3 -0
  33. data/fixture_rails_root/app/helpers/application_helper.rb +2 -0
  34. data/fixture_rails_root/app/views/layouts/application.html.erb +14 -0
  35. data/fixture_rails_root/config.ru +4 -0
  36. data/fixture_rails_root/config/application.rb +42 -0
  37. data/fixture_rails_root/config/boot.rb +13 -0
  38. data/fixture_rails_root/config/database.yml +22 -0
  39. data/fixture_rails_root/config/environment.rb +5 -0
  40. data/fixture_rails_root/config/environments/development.rb +26 -0
  41. data/fixture_rails_root/config/environments/production.rb +49 -0
  42. data/fixture_rails_root/config/environments/test.rb +35 -0
  43. data/fixture_rails_root/config/initializers/backtrace_silencers.rb +7 -0
  44. data/fixture_rails_root/config/initializers/inflections.rb +10 -0
  45. data/fixture_rails_root/config/initializers/mime_types.rb +5 -0
  46. data/fixture_rails_root/config/initializers/secret_token.rb +7 -0
  47. data/fixture_rails_root/config/initializers/session_store.rb +8 -0
  48. data/fixture_rails_root/config/locales/en.yml +5 -0
  49. data/fixture_rails_root/config/routes.rb +58 -0
  50. data/{generators/plutus/templates/plutus.rb → fixture_rails_root/db/migrate/20101203193439_create_plutus_tables.rb} +1 -1
  51. data/fixture_rails_root/db/schema.rb +40 -0
  52. data/fixture_rails_root/db/seeds.rb +7 -0
  53. data/fixture_rails_root/doc/README_FOR_APP +2 -0
  54. data/fixture_rails_root/lib/tasks/.gitkeep +0 -0
  55. data/fixture_rails_root/public/404.html +26 -0
  56. data/fixture_rails_root/public/422.html +26 -0
  57. data/fixture_rails_root/public/500.html +26 -0
  58. data/fixture_rails_root/public/favicon.ico +0 -0
  59. data/fixture_rails_root/public/images/rails.png +0 -0
  60. data/fixture_rails_root/public/index.html +239 -0
  61. data/fixture_rails_root/public/javascripts/application.js +2 -0
  62. data/fixture_rails_root/public/javascripts/controls.js +965 -0
  63. data/fixture_rails_root/public/javascripts/dragdrop.js +974 -0
  64. data/fixture_rails_root/public/javascripts/effects.js +1123 -0
  65. data/fixture_rails_root/public/javascripts/prototype.js +6001 -0
  66. data/fixture_rails_root/public/javascripts/rails.js +175 -0
  67. data/fixture_rails_root/public/robots.txt +5 -0
  68. data/fixture_rails_root/public/stylesheets/.gitkeep +0 -0
  69. data/fixture_rails_root/script/rails +6 -0
  70. data/fixture_rails_root/test/performance/browsing_test.rb +9 -0
  71. data/fixture_rails_root/test/test_helper.rb +13 -0
  72. data/fixture_rails_root/vendor/plugins/.gitkeep +0 -0
  73. data/{generators → lib/generators}/plutus/USAGE +1 -1
  74. data/lib/generators/plutus/plutus_generator.rb +26 -0
  75. data/lib/generators/plutus/templates/migration.rb +33 -0
  76. data/lib/plutus.rb +6 -0
  77. data/plutus.gemspec +60 -6
  78. data/spec/spec_helper.rb +6 -50
  79. metadata +63 -9
  80. data/generators/plutus/plutus_generator.rb +0 -9
  81. data/rails/init.rb +0 -1
@@ -0,0 +1,175 @@
1
+ (function() {
2
+ // Technique from Juriy Zaytsev
3
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
4
+ function isEventSupported(eventName) {
5
+ var el = document.createElement('div');
6
+ eventName = 'on' + eventName;
7
+ var isSupported = (eventName in el);
8
+ if (!isSupported) {
9
+ el.setAttribute(eventName, 'return;');
10
+ isSupported = typeof el[eventName] == 'function';
11
+ }
12
+ el = null;
13
+ return isSupported;
14
+ }
15
+
16
+ function isForm(element) {
17
+ return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
18
+ }
19
+
20
+ function isInput(element) {
21
+ if (Object.isElement(element)) {
22
+ var name = element.nodeName.toUpperCase()
23
+ return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
24
+ }
25
+ else return false
26
+ }
27
+
28
+ var submitBubbles = isEventSupported('submit'),
29
+ changeBubbles = isEventSupported('change')
30
+
31
+ if (!submitBubbles || !changeBubbles) {
32
+ // augment the Event.Handler class to observe custom events when needed
33
+ Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
34
+ function(init, element, eventName, selector, callback) {
35
+ init(element, eventName, selector, callback)
36
+ // is the handler being attached to an element that doesn't support this event?
37
+ if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
38
+ (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
39
+ // "submit" => "emulated:submit"
40
+ this.eventName = 'emulated:' + this.eventName
41
+ }
42
+ }
43
+ )
44
+ }
45
+
46
+ if (!submitBubbles) {
47
+ // discover forms on the page by observing focus events which always bubble
48
+ document.on('focusin', 'form', function(focusEvent, form) {
49
+ // special handler for the real "submit" event (one-time operation)
50
+ if (!form.retrieve('emulated:submit')) {
51
+ form.on('submit', function(submitEvent) {
52
+ var emulated = form.fire('emulated:submit', submitEvent, true)
53
+ // if custom event received preventDefault, cancel the real one too
54
+ if (emulated.returnValue === false) submitEvent.preventDefault()
55
+ })
56
+ form.store('emulated:submit', true)
57
+ }
58
+ })
59
+ }
60
+
61
+ if (!changeBubbles) {
62
+ // discover form inputs on the page
63
+ document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
64
+ // special handler for real "change" events
65
+ if (!input.retrieve('emulated:change')) {
66
+ input.on('change', function(changeEvent) {
67
+ input.fire('emulated:change', changeEvent, true)
68
+ })
69
+ input.store('emulated:change', true)
70
+ }
71
+ })
72
+ }
73
+
74
+ function handleRemote(element) {
75
+ var method, url, params;
76
+
77
+ var event = element.fire("ajax:before");
78
+ if (event.stopped) return false;
79
+
80
+ if (element.tagName.toLowerCase() === 'form') {
81
+ method = element.readAttribute('method') || 'post';
82
+ url = element.readAttribute('action');
83
+ params = element.serialize();
84
+ } else {
85
+ method = element.readAttribute('data-method') || 'get';
86
+ url = element.readAttribute('href');
87
+ params = {};
88
+ }
89
+
90
+ new Ajax.Request(url, {
91
+ method: method,
92
+ parameters: params,
93
+ evalScripts: true,
94
+
95
+ onComplete: function(request) { element.fire("ajax:complete", request); },
96
+ onSuccess: function(request) { element.fire("ajax:success", request); },
97
+ onFailure: function(request) { element.fire("ajax:failure", request); }
98
+ });
99
+
100
+ element.fire("ajax:after");
101
+ }
102
+
103
+ function handleMethod(element) {
104
+ var method = element.readAttribute('data-method'),
105
+ url = element.readAttribute('href'),
106
+ csrf_param = $$('meta[name=csrf-param]')[0],
107
+ csrf_token = $$('meta[name=csrf-token]')[0];
108
+
109
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
110
+ element.parentNode.insert(form);
111
+
112
+ if (method !== 'post') {
113
+ var field = new Element('input', { type: 'hidden', name: '_method', value: method });
114
+ form.insert(field);
115
+ }
116
+
117
+ if (csrf_param) {
118
+ var param = csrf_param.readAttribute('content'),
119
+ token = csrf_token.readAttribute('content'),
120
+ field = new Element('input', { type: 'hidden', name: param, value: token });
121
+ form.insert(field);
122
+ }
123
+
124
+ form.submit();
125
+ }
126
+
127
+
128
+ document.on("click", "*[data-confirm]", function(event, element) {
129
+ var message = element.readAttribute('data-confirm');
130
+ if (!confirm(message)) event.stop();
131
+ });
132
+
133
+ document.on("click", "a[data-remote]", function(event, element) {
134
+ if (event.stopped) return;
135
+ handleRemote(element);
136
+ event.stop();
137
+ });
138
+
139
+ document.on("click", "a[data-method]", function(event, element) {
140
+ if (event.stopped) return;
141
+ handleMethod(element);
142
+ event.stop();
143
+ });
144
+
145
+ document.on("submit", function(event) {
146
+ var element = event.findElement(),
147
+ message = element.readAttribute('data-confirm');
148
+ if (message && !confirm(message)) {
149
+ event.stop();
150
+ return false;
151
+ }
152
+
153
+ var inputs = element.select("input[type=submit][data-disable-with]");
154
+ inputs.each(function(input) {
155
+ input.disabled = true;
156
+ input.writeAttribute('data-original-value', input.value);
157
+ input.value = input.readAttribute('data-disable-with');
158
+ });
159
+
160
+ var element = event.findElement("form[data-remote]");
161
+ if (element) {
162
+ handleRemote(element);
163
+ event.stop();
164
+ }
165
+ });
166
+
167
+ document.on("ajax:after", "form", function(event, element) {
168
+ var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
169
+ inputs.each(function(input) {
170
+ input.value = input.readAttribute('data-original-value');
171
+ input.removeAttribute('data-original-value');
172
+ input.disabled = false;
173
+ });
174
+ });
175
+ })();
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionDispatch::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
File without changes
@@ -2,7 +2,7 @@ Description:
2
2
  Generator for Plutus Plugin
3
3
 
4
4
  Example:
5
- ./script/generate plutus plutus
5
+ rails g plutus
6
6
 
7
7
  This will create:
8
8
  Create a migration in the application for the "Account" and Transaction" tables.
@@ -0,0 +1,26 @@
1
+ # lib/generators/plutus/plutus_generator.rb
2
+ require 'rails/generators'
3
+ require 'rails/generators/migration'
4
+
5
+ class PlutusGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ def self.source_root
9
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
10
+ end
11
+
12
+ # Implement the required interface for Rails::Generators::Migration.
13
+ # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
14
+ def self.next_migration_number(dirname)
15
+ if ActiveRecord::Base.timestamped_migrations
16
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
17
+ else
18
+ "%.3d" % (current_migration_number(dirname) + 1)
19
+ end
20
+ end
21
+
22
+ def create_migration_file
23
+ migration_template 'migration.rb', 'db/migrate/create_plutus_tables.rb'
24
+ end
25
+
26
+ end
@@ -0,0 +1,33 @@
1
+ class CreatePlutusTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :accounts do |t|
4
+ t.string :name
5
+ t.string :type
6
+ t.boolean :contra
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :accounts, [:name, :type]
12
+
13
+ create_table :transactions do |t|
14
+ t.string :description
15
+ t.integer :credit_account_id
16
+ t.integer :debit_account_id
17
+ t.decimal :amount, :precision => 20, :scale => 10
18
+ t.integer :commercial_document_id
19
+ t.string :commercial_document_type
20
+
21
+ t.timestamps
22
+ end
23
+
24
+ add_index :transactions, :credit_account_id
25
+ add_index :transactions, :debit_account_id
26
+ add_index :transactions, [:commercial_document_id, :commercial_document_type], :name => "index_transactions_on_commercial_doc"
27
+ end
28
+
29
+ def self.down
30
+ drop_table :accounts
31
+ drop_table :transactions
32
+ end
33
+ end
data/lib/plutus.rb CHANGED
@@ -1 +1,7 @@
1
1
  # Plutus
2
+ require "rails"
3
+ module Plutus
4
+ class Engine < Rails::Engine
5
+ engine_name :plutus
6
+ end
7
+ end
data/plutus.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{plutus}
8
- s.version = "0.4.2"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Bulat"]
12
- s.date = %q{2010-11-19}
12
+ s.date = %q{2010-12-03}
13
13
  s.description = %q{The plutus plugin provides a complete double entry accounting system for use in any Ruby on Rails application. The plugin follows general Double Entry Bookkeeping practices. All calculations are done using BigDecimal in order to prevent floating point rounding errors. The plugin requires a decimal type on your database as well.}
14
14
  s.email = %q{mbulat@crazydogsoftware.com}
15
15
  s.extra_rdoc_files = [
@@ -37,12 +37,21 @@ Gem::Specification.new do |s|
37
37
  "app/views/layouts/transactions.html.erb",
38
38
  "app/views/transactions/index.html.erb",
39
39
  "app/views/transactions/show.html.erb",
40
+ "config/backtrace_silencers.rb",
41
+ "config/inflections.rb",
42
+ "config/mime_types.rb",
43
+ "config/secret_token.rb",
44
+ "config/session_store.rb",
40
45
  "doc/Account.html",
41
46
  "doc/AccountsController.html",
42
47
  "doc/Asset.html",
48
+ "doc/CreatePlutusTables.html",
43
49
  "doc/Equity.html",
44
50
  "doc/Expense.html",
45
51
  "doc/Liability.html",
52
+ "doc/Plutus.html",
53
+ "doc/Plutus/Engine.html",
54
+ "doc/PlutusGenerator.html",
46
55
  "doc/Revenue.html",
47
56
  "doc/Transaction.html",
48
57
  "doc/TransactionsController.html",
@@ -60,12 +69,57 @@ Gem::Specification.new do |s|
60
69
  "doc/js/jquery.js",
61
70
  "doc/method_list.html",
62
71
  "doc/top-level-namespace.html",
63
- "generators/plutus/USAGE",
64
- "generators/plutus/plutus_generator.rb",
65
- "generators/plutus/templates/plutus.rb",
72
+ "fixture_rails_root/.gitignore",
73
+ "fixture_rails_root/Gemfile",
74
+ "fixture_rails_root/Gemfile.lock",
75
+ "fixture_rails_root/README",
76
+ "fixture_rails_root/Rakefile",
77
+ "fixture_rails_root/app/controllers/application_controller.rb",
78
+ "fixture_rails_root/app/helpers/application_helper.rb",
79
+ "fixture_rails_root/app/views/layouts/application.html.erb",
80
+ "fixture_rails_root/config.ru",
81
+ "fixture_rails_root/config/application.rb",
82
+ "fixture_rails_root/config/boot.rb",
83
+ "fixture_rails_root/config/database.yml",
84
+ "fixture_rails_root/config/environment.rb",
85
+ "fixture_rails_root/config/environments/development.rb",
86
+ "fixture_rails_root/config/environments/production.rb",
87
+ "fixture_rails_root/config/environments/test.rb",
88
+ "fixture_rails_root/config/initializers/backtrace_silencers.rb",
89
+ "fixture_rails_root/config/initializers/inflections.rb",
90
+ "fixture_rails_root/config/initializers/mime_types.rb",
91
+ "fixture_rails_root/config/initializers/secret_token.rb",
92
+ "fixture_rails_root/config/initializers/session_store.rb",
93
+ "fixture_rails_root/config/locales/en.yml",
94
+ "fixture_rails_root/config/routes.rb",
95
+ "fixture_rails_root/db/migrate/20101203193439_create_plutus_tables.rb",
96
+ "fixture_rails_root/db/schema.rb",
97
+ "fixture_rails_root/db/seeds.rb",
98
+ "fixture_rails_root/doc/README_FOR_APP",
99
+ "fixture_rails_root/lib/tasks/.gitkeep",
100
+ "fixture_rails_root/public/404.html",
101
+ "fixture_rails_root/public/422.html",
102
+ "fixture_rails_root/public/500.html",
103
+ "fixture_rails_root/public/favicon.ico",
104
+ "fixture_rails_root/public/images/rails.png",
105
+ "fixture_rails_root/public/index.html",
106
+ "fixture_rails_root/public/javascripts/application.js",
107
+ "fixture_rails_root/public/javascripts/controls.js",
108
+ "fixture_rails_root/public/javascripts/dragdrop.js",
109
+ "fixture_rails_root/public/javascripts/effects.js",
110
+ "fixture_rails_root/public/javascripts/prototype.js",
111
+ "fixture_rails_root/public/javascripts/rails.js",
112
+ "fixture_rails_root/public/robots.txt",
113
+ "fixture_rails_root/public/stylesheets/.gitkeep",
114
+ "fixture_rails_root/script/rails",
115
+ "fixture_rails_root/test/performance/browsing_test.rb",
116
+ "fixture_rails_root/test/test_helper.rb",
117
+ "fixture_rails_root/vendor/plugins/.gitkeep",
118
+ "lib/generators/plutus/USAGE",
119
+ "lib/generators/plutus/plutus_generator.rb",
120
+ "lib/generators/plutus/templates/migration.rb",
66
121
  "lib/plutus.rb",
67
122
  "plutus.gemspec",
68
- "rails/init.rb",
69
123
  "spec/controllers/accounts_controller_spec.rb",
70
124
  "spec/controllers/transactions_controller_spec.rb",
71
125
  "spec/factories/account_factory.rb",
data/spec/spec_helper.rb CHANGED
@@ -1,57 +1,13 @@
1
- # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
- # from the project root directory.
3
1
  ENV["RAILS_ENV"] ||= 'test'
4
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..','..','config','environment'))
5
- require 'spec/autorun'
6
- require 'spec/rails'
2
+ require File.expand_path(File.dirname(__FILE__) + "/../fixture_rails_root/config/environment")
3
+ require 'rspec/rails'
7
4
 
8
- # Uncomment the next line to use webrat's matchers
9
- #require 'webrat/integrations/rspec-rails'
5
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib/')
6
+ require 'plutus'
10
7
 
11
- # Requires supporting files with custom matchers and macros, etc,
12
- # in ./support/ and its subdirectories.
13
- Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
14
-
15
- # Require in factories
16
8
  Dir[File.expand_path(File.join(File.dirname(__FILE__),'factories','**','*.rb'))].each {|f| require f}
17
9
 
18
- Spec::Runner.configure do |config|
19
- # If you're not using ActiveRecord you should remove these
20
- # lines, delete config/database.yml and disable :active_record
21
- # in your config/boot.rb
10
+ RSpec.configure do |config|
11
+ config.mock_with :mocha
22
12
  config.use_transactional_fixtures = true
23
- config.use_instantiated_fixtures = false
24
- config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
25
-
26
- # == Fixtures
27
- #
28
- # You can declare fixtures for each example_group like this:
29
- # describe "...." do
30
- # fixtures :table_a, :table_b
31
- #
32
- # Alternatively, if you prefer to declare them only once, you can
33
- # do so right here. Just uncomment the next line and replace the fixture
34
- # names with your fixtures.
35
- #
36
- # config.global_fixtures = :table_a, :table_b
37
- #
38
- # If you declare global fixtures, be aware that they will be declared
39
- # for all of your examples, even those that don't use them.
40
- #
41
- # You can also declare which fixtures to use (for example fixtures for test/fixtures):
42
- #
43
- # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
44
- #
45
- # == Mock Framework
46
- #
47
- # RSpec uses its own mocking framework by default. If you prefer to
48
- # use mocha, flexmock or RR, uncomment the appropriate line:
49
- #
50
- # config.mock_with :mocha
51
- # config.mock_with :flexmock
52
- # config.mock_with :rr
53
- #
54
- # == Notes
55
- #
56
- # For more information take a look at Spec::Runner::Configuration and Spec::Runner
57
13
  end