erp_base_erp_svcs 3.0.7 → 3.1.0
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.
- data/app/models/category.rb +2 -1
- data/app/models/category_classification.rb +2 -0
- data/app/models/compass_ae_instance.rb +1 -1
- data/app/models/contact.rb +34 -32
- data/app/models/contact_purpose.rb +6 -4
- data/app/models/contact_type.rb +3 -1
- data/app/models/currency.rb +6 -4
- data/app/models/descriptive_asset.rb +2 -0
- data/app/models/email_address.rb +2 -0
- data/app/models/geo_country.rb +2 -0
- data/app/models/geo_zone.rb +2 -0
- data/app/models/individual.rb +2 -0
- data/app/models/iso_country_code.rb +0 -1
- data/app/models/money.rb +1 -0
- data/app/models/note.rb +2 -0
- data/app/models/note_type.rb +2 -0
- data/app/models/organization.rb +2 -0
- data/app/models/party.rb +4 -3
- data/app/models/party_relationship.rb +6 -5
- data/app/models/party_role.rb +7 -5
- data/app/models/phone_number.rb +2 -0
- data/app/models/postal_address.rb +2 -0
- data/app/models/relationship_type.rb +7 -5
- data/app/models/role_type.rb +2 -0
- data/app/models/valid_note_type.rb +2 -0
- data/app/models/view_type.rb +2 -0
- data/db/data_migrations/20110913145838_setup_compass_ae_instance.rb +1 -1
- data/db/migrate/20080805000020_base_erp_services.rb +222 -222
- data/lib/erp_base_erp_svcs/engine.rb +2 -0
- data/lib/erp_base_erp_svcs/extensions/active_record/migration.rb +39 -0
- data/lib/erp_base_erp_svcs/extensions.rb +1 -2
- data/lib/erp_base_erp_svcs/version.rb +2 -2
- data/lib/erp_base_erp_svcs.rb +15 -15
- data/lib/tasks/erp_base_erp_svcs_tasks.rake +58 -23
- data/spec/dummy/config/application.rb +6 -0
- data/spec/dummy/config/environments/spec.rb +3 -0
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/migrate/20130107214414_base_erp_services.erp_base_erp_svcs.rb +461 -0
- data/spec/dummy/db/schema.rb +383 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +17576 -0
- data/spec/models/email_address_spec.rb +1 -1
- data/spec/models/party_spec.rb +19 -19
- data/spec/spec_helper.rb +14 -5
- metadata +70 -149
- data/db/migrate/20110913145329_create_compass_ae_instance.rb +0 -15
- data/db/migrate/upgrade/20110907171257_add_notes.rb +0 -63
- data/lib/erp_base_erp_svcs/extensions/active_record/data_migrator.rb +0 -46
- data/lib/erp_base_erp_svcs/extensions/active_record/migrator.rb +0 -76
@@ -0,0 +1,39 @@
|
|
1
|
+
ActiveRecord::Migration.class_eval do
|
2
|
+
def copy(destination, sources, options = {})
|
3
|
+
copied = []
|
4
|
+
|
5
|
+
FileUtils.mkdir_p(destination) unless File.exists?(destination)
|
6
|
+
|
7
|
+
destination_migrations = ActiveRecord::Migrator.migrations(destination)
|
8
|
+
last = destination_migrations.last
|
9
|
+
sources.each do |scope, path|
|
10
|
+
source_migrations = ActiveRecord::Migrator.migrations(path)
|
11
|
+
|
12
|
+
source_migrations.each do |migration|
|
13
|
+
source = File.read(migration.filename)
|
14
|
+
source = "# This migration comes from #{scope} (originally #{migration.version})\n#{source}"
|
15
|
+
|
16
|
+
if duplicate = destination_migrations.detect { |m| m.name == migration.name }
|
17
|
+
if options[:refresh] && duplicate.scope == scope.to_s
|
18
|
+
Dir.glob(File.join(destination,"*_#{migration.name.underscore}.#{scope.to_s}.rb")).each { |f| puts "Removing old migration #{migration.name}"; File.delete(f) }
|
19
|
+
elsif options[:on_skip] && duplicate.scope != scope.to_s
|
20
|
+
options[:on_skip].call(scope, migration)
|
21
|
+
end
|
22
|
+
next unless options[:refresh]
|
23
|
+
end
|
24
|
+
|
25
|
+
migration.version = next_migration_number(last ? last.version + 1 : 0).to_i unless options[:preserve_timestamp]
|
26
|
+
new_path = File.join(destination, "#{migration.version}_#{migration.name.underscore}.#{scope}.rb")
|
27
|
+
old_path, migration.filename = migration.filename, new_path
|
28
|
+
last = migration
|
29
|
+
|
30
|
+
File.open(migration.filename, "w") { |f| f.write source }
|
31
|
+
copied << migration
|
32
|
+
options[:on_copy].call(scope, migration, old_path) if options[:on_copy]
|
33
|
+
destination_migrations << migration
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
copied
|
38
|
+
end
|
39
|
+
end
|
@@ -11,8 +11,7 @@ require 'erp_base_erp_svcs/extensions/active_record/has_notes'
|
|
11
11
|
require 'erp_base_erp_svcs/extensions/active_record/acts_as_note_type'
|
12
12
|
require 'erp_base_erp_svcs/extensions/active_record/is_describable'
|
13
13
|
require 'erp_base_erp_svcs/extensions/active_record/has_contact'
|
14
|
-
require 'erp_base_erp_svcs/extensions/active_record/migrator'
|
15
|
-
require 'erp_base_erp_svcs/extensions/active_record/data_migrator'
|
16
14
|
require 'erp_base_erp_svcs/extensions/active_record/sti_instantiation'
|
17
15
|
require 'erp_base_erp_svcs/extensions/active_record/to_hash'
|
16
|
+
require 'erp_base_erp_svcs/extensions/active_record/migration'
|
18
17
|
|
data/lib/erp_base_erp_svcs.rb
CHANGED
@@ -6,13 +6,8 @@ require "erp_base_erp_svcs/non_escape_json_string"
|
|
6
6
|
|
7
7
|
module ErpBaseErpSvcs
|
8
8
|
class << self
|
9
|
-
def
|
10
|
-
|
11
|
-
callback = (Rails.application.config.cache_classes ? 'after_initialize' : 'to_prepare')
|
12
|
-
config.send(callback) do
|
13
|
-
block.call(engine)
|
14
|
-
end
|
15
|
-
end
|
9
|
+
def determine_callback
|
10
|
+
(Rails.env == 'development') ? 'to_prepare' : 'after_initialize'
|
16
11
|
end
|
17
12
|
|
18
13
|
def mount_compass_ae_engines(routes)
|
@@ -22,15 +17,15 @@ module ErpBaseErpSvcs
|
|
22
17
|
end
|
23
18
|
|
24
19
|
def register_as_compass_ae_engine(config, engine)
|
25
|
-
|
26
|
-
ErpBaseErpSvcs.load_compass_ae_engine(engine)
|
20
|
+
config.send(ErpBaseErpSvcs.determine_callback) do
|
21
|
+
ErpBaseErpSvcs.load_compass_ae_engine(engine, config)
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
30
|
-
def load_compass_ae_engine(engine)
|
25
|
+
def load_compass_ae_engine(engine, config)
|
31
26
|
Rails.application.config.erp_base_erp_svcs.compass_ae_engines << engine unless Rails.application.config.erp_base_erp_svcs.compass_ae_engines.include?(engine)
|
32
27
|
load_compass_ae_extensions(engine)
|
33
|
-
load_root_compass_ae_framework_extensions
|
28
|
+
load_root_compass_ae_framework_extensions(config)
|
34
29
|
end
|
35
30
|
|
36
31
|
#forces rails to reload model extensions and framework extensions
|
@@ -101,14 +96,19 @@ module ErpBaseErpSvcs
|
|
101
96
|
end
|
102
97
|
end
|
103
98
|
|
104
|
-
def load_root_compass_ae_framework_extensions
|
105
|
-
|
106
|
-
|
99
|
+
def load_root_compass_ae_framework_extensions(config)
|
100
|
+
config.send(ErpBaseErpSvcs.determine_callback) do
|
101
|
+
Dir.glob(File.join(Rails.root,"lib/extensions/compass_ae/**/*.rb")).each do |file|
|
102
|
+
load file
|
103
|
+
end
|
107
104
|
end
|
105
|
+
|
108
106
|
end
|
109
107
|
|
110
108
|
end
|
111
109
|
end
|
112
110
|
|
113
111
|
#load the engine after this module is defined
|
114
|
-
require "erp_base_erp_svcs/engine"
|
112
|
+
require "erp_base_erp_svcs/engine"
|
113
|
+
|
114
|
+
|
@@ -1,36 +1,72 @@
|
|
1
|
-
|
1
|
+
require 'fileutils'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
#redefine copy engine migrations rake task
|
4
|
+
Rake::Task["railties:install:migrations"].clear
|
5
|
+
|
6
|
+
namespace :railties do
|
7
|
+
namespace :install do
|
8
|
+
# desc "Copies missing migrations from Railties (e.g. plugins, engines). You can specify Railties to use with FROM=railtie1,railtie2"
|
9
|
+
task :migrations => :'db:load_config' do
|
10
|
+
to_load = ENV['FROM'].blank? ? :all : ENV['FROM'].split(",").map {|n| n.strip }
|
11
|
+
#added to allow developer to perserve timestamps
|
12
|
+
preserve_timestamp = ENV['PRESERVE_TIMESTAMPS'].blank? ? false : (ENV['PRESERVE_TIMESTAMPS'].to_s.downcase == "true")
|
13
|
+
#refresh will replace migrations from engines
|
14
|
+
refresh = ENV['REFRESH'].blank? ? false : (ENV['REFRESH'].to_s.downcase == "true")
|
15
|
+
railties = ActiveSupport::OrderedHash.new
|
16
|
+
Rails.application.railties.all do |railtie|
|
17
|
+
next unless to_load == :all || to_load.include?(railtie.railtie_name)
|
18
|
+
|
19
|
+
if railtie.respond_to?(:paths) && (path = railtie.paths['db/migrate'].first)
|
20
|
+
railties[railtie.railtie_name] = path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
on_skip = Proc.new do |name, migration|
|
25
|
+
puts "NOTE: Migration #{migration.basename} from #{name} has been skipped. Migration with the same name already exists."
|
26
|
+
end
|
27
|
+
|
28
|
+
on_copy = Proc.new do |name, migration, old_path|
|
29
|
+
puts "Copied migration #{migration.basename} from #{name}"
|
30
|
+
end
|
31
|
+
|
32
|
+
ActiveRecord::Migration.copy(ActiveRecord::Migrator.migrations_paths.first, railties,
|
33
|
+
:on_skip => on_skip, :on_copy => on_copy, :preserve_timestamp => preserve_timestamp, :refresh => refresh)
|
34
|
+
end
|
9
35
|
end
|
36
|
+
end
|
10
37
|
|
38
|
+
namespace :db do
|
11
39
|
namespace :migrate do
|
12
|
-
|
40
|
+
|
13
41
|
desc "list pending migrations"
|
14
42
|
task :list_pending => :environment do
|
15
|
-
ActiveRecord::Migrator.prepare_migrations
|
16
43
|
pending_migrations = ActiveRecord::Migrator.new('up', 'db/migrate/').pending_migrations.collect{|item| File.basename(item.filename)}
|
17
44
|
puts "================Pending Migrations=========="
|
18
45
|
puts pending_migrations
|
19
46
|
puts "============================================"
|
20
|
-
ActiveRecord::Migrator.cleanup_migrations
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "original migrate"
|
24
|
-
task :original_migrate do
|
25
|
-
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
26
|
-
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
27
|
-
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
28
47
|
end
|
29
|
-
|
48
|
+
|
30
49
|
end#migrate
|
31
50
|
end#db
|
32
51
|
|
33
52
|
namespace :compass_ae do
|
53
|
+
namespace :install do
|
54
|
+
desc "Install all CompassAE schema migrations"
|
55
|
+
task :migrations => :environment do
|
56
|
+
compass_ae_railties = Rails.application.config.erp_base_erp_svcs.compass_ae_engines.collect{|e| "#{e.name.split("::").first.underscore}"}.join(',')
|
57
|
+
task = "railties:install:migrations"
|
58
|
+
ENV['FROM'] = compass_ae_railties
|
59
|
+
Rake::Task[task].invoke
|
60
|
+
end #migrations
|
61
|
+
|
62
|
+
desc "Install all CompassAE data migrations"
|
63
|
+
task :data_migrations => :environment do
|
64
|
+
compass_ae_railties = Rails.application.config.erp_base_erp_svcs.compass_ae_engines.collect{|e| "#{e.name.split("::").first.underscore}"}.join(',')
|
65
|
+
task = "railties:install:data_migrations"
|
66
|
+
ENV['FROM'] = compass_ae_railties
|
67
|
+
Rake::Task[task].invoke
|
68
|
+
end #data_migrations
|
69
|
+
end #install
|
34
70
|
|
35
71
|
desc "Upgrade you installation of Compass AE"
|
36
72
|
task :upgrade => :environment do
|
@@ -46,14 +82,13 @@ namespace :compass_ae do
|
|
46
82
|
|
47
83
|
ActiveRecord::Migrator.cleanup_upgrade_migrations
|
48
84
|
RussellEdge::DataMigrator.cleanup_upgrade_migrations
|
49
|
-
rescue Exception=>ex
|
85
|
+
rescue Exception => ex
|
50
86
|
ActiveRecord::Migrator.cleanup_migrations
|
51
87
|
ActiveRecord::Migrator.cleanup_upgrade_migrations
|
52
88
|
RussellEdge::DataMigrator.cleanup_upgrade_migrations
|
53
89
|
|
54
90
|
puts ex.inspect
|
55
91
|
puts ex.backtrace
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
92
|
+
end #handle exceptions
|
93
|
+
end #upgrade
|
94
|
+
end #compass_ae
|
@@ -37,6 +37,12 @@ module Dummy
|
|
37
37
|
|
38
38
|
# Enable the asset pipeline
|
39
39
|
config.assets.enabled = true
|
40
|
+
|
41
|
+
# Enforce whitelist mode for mass assignment.
|
42
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
43
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
44
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
45
|
+
config.active_record.whitelist_attributes = true
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb
|
3
3
|
|
4
|
+
# Raise exception on mass assignment protection for Active Record models
|
5
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
6
|
+
|
4
7
|
# In the development environment your application's code is reloaded on
|
5
8
|
# every request. This slows down response time but is perfect for development
|
6
9
|
# since you don't have to restart the web server when you make code changes.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This migration comes from erp_base_erp_svcs (originally 20110525001935)
|
2
|
+
class AddUsdCurrency
|
3
|
+
|
4
|
+
def self.up
|
5
|
+
Currency.create(:name => 'US Dollar', :internal_identifier => 'USD', :major_unit_symbol => "$")
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.down
|
9
|
+
Currency.usd.destroy
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This migration comes from erp_base_erp_svcs (originally 20110609150135)
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
class AddIsoCodes
|
5
|
+
|
6
|
+
def self.up
|
7
|
+
#find the erp_base_erp_svcs engine
|
8
|
+
engine_path = Rails::Application::Railties.engines.find{|item| item.engine_name == 'erp_base_erp_svcs'}.config.root.to_s
|
9
|
+
|
10
|
+
GeoCountry.load_from_file(File.join(engine_path,'db/data_sets/geo_countries.yml'))
|
11
|
+
GeoZone.load_from_file(File.join(engine_path,'db/data_sets/geo_zones.yml'))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
GeoCountry.delete_all
|
16
|
+
GeoZone.delete_all
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|