hatio-core 0.0.6
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +28 -0
- data/Rakefile +6 -0
- data/lib/generators/hatio/bundle/USAGE +68 -0
- data/lib/generators/hatio/bundle/bundle_generator.rb +100 -0
- data/lib/generators/hatio/bundle/templates/04_seed_entities.rb +9 -0
- data/lib/generators/hatio/bundle/templates/05_seed_common_codes.rb +8 -0
- data/lib/generators/hatio/bundle/templates/06_seed_menus.rb +6 -0
- data/lib/generators/hatio/bundle/templates/Controller.js +24 -0
- data/lib/generators/hatio/bundle/templates/Gemfile +4 -0
- data/lib/generators/hatio/bundle/templates/LICENSE.txt +22 -0
- data/lib/generators/hatio/bundle/templates/README.md +29 -0
- data/lib/generators/hatio/bundle/templates/Rakefile +1 -0
- data/lib/generators/hatio/bundle/templates/engine.rb +7 -0
- data/lib/generators/hatio/bundle/templates/gemspec +19 -0
- data/lib/generators/hatio/bundle/templates/index.js +14 -0
- data/lib/generators/hatio/bundle/templates/init.rb +1 -0
- data/lib/generators/hatio/bundle/templates/lib_bundle.rb +12 -0
- data/lib/generators/hatio/bundle/templates/locale.js +13 -0
- data/lib/generators/hatio/bundle/templates/locales.yml +27 -0
- data/lib/generators/hatio/bundle/templates/pluggable_spot.rb +3 -0
- data/lib/generators/hatio/bundle/templates/routes.rb +3 -0
- data/lib/generators/hatio/bundle/templates/seeds.rb +4 -0
- data/lib/generators/hatio/bundle/templates/task.rake +4 -0
- data/lib/generators/hatio/bundle/templates/test.rb +8 -0
- data/lib/generators/hatio/bundle/templates/test_helper.rb +3 -0
- data/lib/generators/hatio/bundle/templates/version.rb +3 -0
- data/lib/generators/hatio/resource_api/resource_api_generator.rb +92 -0
- data/lib/generators/hatio/resource_api/templates/controller.rb +7 -0
- data/lib/generators/hatio/resource_api/templates/create.json.jbuilder +1 -0
- data/lib/generators/hatio/resource_api/templates/destroy.json.jbuilder +1 -0
- data/lib/generators/hatio/resource_api/templates/index.json.jbuilder +1 -0
- data/lib/generators/hatio/resource_api/templates/migration.rb +1 -0
- data/lib/generators/hatio/resource_api/templates/model.rb +3 -0
- data/lib/generators/hatio/resource_api/templates/show.json.jbuilder +3 -0
- data/lib/generators/hatio/resource_api/templates/update.json.jbuilder +2 -0
- data/lib/generators/hatio/resource_model/resource_model_generator.rb +52 -0
- data/lib/generators/hatio/resource_model/templates/migration.rb +1 -0
- data/lib/generators/hatio/resource_model/templates/model.rb +3 -0
- data/lib/generators/hatio/resource_view/USAGE +16 -0
- data/lib/generators/hatio/resource_view/resource_view_generator.rb +154 -0
- data/lib/generators/hatio/resource_view/templates/Model.js +19 -0
- data/lib/generators/hatio/resource_view/templates/Store.js +34 -0
- data/lib/generators/hatio/resource_view/templates/detail/Controller.js +81 -0
- data/lib/generators/hatio/resource_view/templates/detail/DetailForm.js +17 -0
- data/lib/generators/hatio/resource_view/templates/detail/DetailMain.js +26 -0
- data/lib/generators/hatio/resource_view/templates/detail/DetailPopup.js +25 -0
- data/lib/generators/hatio/resource_view/templates/detail/PopupController.js +90 -0
- data/lib/generators/hatio/resource_view/templates/detail/ViewController.js +78 -0
- data/lib/generators/hatio/resource_view/templates/item/Controller.js +81 -0
- data/lib/generators/hatio/resource_view/templates/item/ItemForm.js +19 -0
- data/lib/generators/hatio/resource_view/templates/item/ItemMain.js +18 -0
- data/lib/generators/hatio/resource_view/templates/item/ItemPopup.js +25 -0
- data/lib/generators/hatio/resource_view/templates/item/PopupController.js +90 -0
- data/lib/generators/hatio/resource_view/templates/item/ViewController.js +47 -0
- data/lib/generators/hatio/resource_view/templates/list/Controller.js +36 -0
- data/lib/generators/hatio/resource_view/templates/list/ListGrid.js +10 -0
- data/lib/generators/hatio/resource_view/templates/list/ListMain.js +20 -0
- data/lib/generators/hatio/resource_view/templates/list/ListSearch.js +9 -0
- data/lib/generators/hatio/resource_view/templates/report/Controller.js +53 -0
- data/lib/generators/hatio/resource_view/templates/report/ReportList.js +27 -0
- data/lib/generators/hatio/resource_view/templates/report/ReportMain.js +18 -0
- data/lib/generators/hatio/resource_view/templates/report/ReportSearch.js +9 -0
- data/lib/generators/hatio/util/api_util.rb +97 -0
- data/lib/generators/hatio/util/migration_util.rb +178 -0
- data/lib/generators/hatio/util/model_util.rb +77 -0
- data/lib/generators/hatio/util/report_view_util.rb +32 -0
- data/lib/generators/hatio/util/resource_view_util.rb +383 -0
- data/lib/generators/hatio/util/view_util.rb +214 -0
- data/lib/hatio-core.rb +33 -0
- data/lib/hatio-core/action_controller/search_helper.rb +332 -0
- data/lib/hatio-core/active_record/extension_logic.rb +36 -0
- data/lib/hatio-core/active_record/rem_tracker.rb +35 -0
- data/lib/hatio-core/active_record/stringified_id.rb +75 -0
- data/lib/hatio-core/active_record/stripper.rb +37 -0
- data/lib/hatio-core/active_record/userstamp.rb +48 -0
- data/lib/hatio-core/birt/birt_report.rb +42 -0
- data/lib/hatio-core/bundle/hatio_bundle.rb +37 -0
- data/lib/hatio-core/engine.rb +5 -0
- data/lib/hatio-core/exception/exceptions.rb +33 -0
- data/lib/hatio-core/patch/actionpack_hatio_patch.rb +28 -0
- data/lib/hatio-core/patch/date.rb +11 -0
- data/lib/hatio-core/patch/string_key.rb +56 -0
- data/lib/hatio-core/pluggable/pluggable_spot.rb +22 -0
- data/lib/hatio-core/util/hatio_util.rb +106 -0
- data/lib/hatio-core/version.rb +3 -0
- data/lib/tasks/hatiocore_tasks.rake +75 -0
- data/lib/utils/detect_invalid_js_format.rb +0 -0
- data/lib/utils/detect_mismatch_tags.rb +57 -0
- data/lib/utils/update_license.rb +5 -0
- data/lib/utils/upload_locale.rb +67 -0
- metadata +148 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
module Hatio
|
2
|
+
module ExtensionLogic
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
super
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.class_eval do
|
8
|
+
include InstanceMethods
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def run_class_logic(logic_name, params)
|
14
|
+
entity = Entity.find_by_name(self.name)
|
15
|
+
raise Hatio::Exception::MisConfigured, (I18n.translate 'errors.messages.x_not_found', :x => "Entity (#{self.name})") unless entity
|
16
|
+
logic = entity.entity_logics.where("level = ? and name = ?", :class.to_s, logic_name).first
|
17
|
+
raise Hatio::Exception::MisConfigured, (I18n.translate 'errors.messages.x_not_found', :x => "EntityLogic (#{logic_name}) of Entity (#{self.name})") unless logic
|
18
|
+
raise Hatio::Exception::MisConfigured, (I18n.translate 'errors.messages.empty_x_not_allowed', :x => "EntityLogic (#{logic_name}) of Entity (#{self.name})") if (logic.logic.nil? || logic.logic.empty?)
|
19
|
+
return self.instance_eval logic.logic
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module InstanceMethods
|
24
|
+
public
|
25
|
+
def run_instance_logic(logic_name, params)
|
26
|
+
entity = Entity.find_by_name(self.class.name)
|
27
|
+
raise Hatio::Exception::MisConfigured, (I18n.translate 'errors.messages.x_not_found', :x => "Entity (#{self.class.name})") unless entity
|
28
|
+
logic = entity.entity_logics.where("level = ? and name = ?", :instance.to_s, logic_name).first
|
29
|
+
raise Hatio::Exception::MisConfigured, (I18n.translate 'errors.messages.x_not_found', :x => "EntityLogic (#{logic_name}) of Entity (#{self.class.name})") unless logic
|
30
|
+
raise Hatio::Exception::MisConfigured, (I18n.translate 'errors.messages.empty_x_not_allowed', :x => "EntityLogic (#{logic_name}) of Entity (#{self.class.name})") if (logic.logic.nil? || logic.logic.empty?)
|
31
|
+
return self.instance_eval logic.logic
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Hatio
|
2
|
+
module RemTracker
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
super
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.class_eval do
|
8
|
+
include InstanceMethods
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def removing_trackable
|
14
|
+
class_eval do
|
15
|
+
after_destroy :trace_removing
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module InstanceMethods
|
21
|
+
private
|
22
|
+
def trace_removing
|
23
|
+
# self 정보를 모두 REM_TRACES 테이블에 추가
|
24
|
+
rem_trace = RemTrace.new
|
25
|
+
rem_trace.name = self.name if(self.respond_to?(:name))
|
26
|
+
rem_trace.entity_type = self.class.name
|
27
|
+
rem_trace.entity_id = self.id
|
28
|
+
rem_trace.content = self.to_json
|
29
|
+
rem_trace.domain_id = self.domain_id
|
30
|
+
rem_trace.save!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'uuidtools'
|
2
|
+
|
3
|
+
module Hatio
|
4
|
+
module StringfiedID
|
5
|
+
def self.included(base) #:nodoc:
|
6
|
+
super
|
7
|
+
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
base.class_eval do
|
10
|
+
include InstanceMethods
|
11
|
+
class_attribute :meaningful_composite_key
|
12
|
+
class_attribute :meaningful_id_separator
|
13
|
+
class_attribute :self_sequence_length
|
14
|
+
class_attribute :self_sequence_block
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
|
20
|
+
def meaningful_id(composite = [:domain_id, :name], separator = nil, options = {})
|
21
|
+
self.meaningful_composite_key = composite.clone
|
22
|
+
self.meaningful_id_separator = separator
|
23
|
+
|
24
|
+
composite.each do |field|
|
25
|
+
validates_presence_of field
|
26
|
+
end
|
27
|
+
|
28
|
+
# Soft Delete 지원으로 이 부분은 수동으로 추가하는 것으로 변경
|
29
|
+
# validates_uniqueness_of composite.pop, :scope => composite
|
30
|
+
|
31
|
+
before_create :set_meaningful_id
|
32
|
+
end
|
33
|
+
|
34
|
+
def universal_unique_id
|
35
|
+
before_create :set_uuid_as_id
|
36
|
+
end
|
37
|
+
|
38
|
+
def self_sequence_id(seqlen = 16, composite = [:domain_id, ''], separator = nil, &block)
|
39
|
+
self.meaningful_composite_key = composite.clone
|
40
|
+
self.meaningful_id_separator = separator
|
41
|
+
|
42
|
+
self.self_sequence_block = block
|
43
|
+
self.self_sequence_length = seqlen
|
44
|
+
|
45
|
+
before_create :set_self_sequence_as_id
|
46
|
+
end
|
47
|
+
|
48
|
+
def next_self_sequence(field, seqlen = 6, key = nil)
|
49
|
+
key = yield if block_given?
|
50
|
+
maxrec = self.find(:first, :select => "max(substr(#{field.to_s}, #{key.length + 1}, #{key.length + seqlen})) + 1 #{field.to_s}", :conditions => ["#{field.to_s} like ?", "#{key}%"])
|
51
|
+
key + sprintf("%0#{seqlen}d", maxrec[field.to_sym].nil? ? 1 : maxrec[field.to_sym])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
module InstanceMethods #:nodoc:
|
56
|
+
private
|
57
|
+
def set_uuid_as_id
|
58
|
+
self.id = generateUUID
|
59
|
+
#self.id = Digest::SHA1.hexdigest(Time.now.to_s.split(//).sort_by {rand}.join).to_s
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_meaningful_id
|
63
|
+
self.id ||= self.meaningful(meaningful_composite_key, meaningful_id_separator)
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_self_sequence_as_id
|
67
|
+
self.id ||= if self_sequence_block.nil?
|
68
|
+
self.class.next_self_sequence 'id', self_sequence_length, self.meaningful(meaningful_composite_key, meaningful_id_separator)
|
69
|
+
else
|
70
|
+
self.class.next_self_sequence 'id', self_sequence_length, &self_sequence_block
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Hatio
|
2
|
+
module Stripper
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
super
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.class_eval do
|
8
|
+
include InstanceMethods
|
9
|
+
class_attribute :strip_fields
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def strip_cols(cols)
|
15
|
+
class_eval do
|
16
|
+
self.strip_fields = cols
|
17
|
+
before_validation :strip_vals
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module InstanceMethods
|
23
|
+
private
|
24
|
+
def strip_vals
|
25
|
+
assign_attrs = {}
|
26
|
+
self.strip_fields.each do |col|
|
27
|
+
val = self.attributes[col.to_s]
|
28
|
+
val = val.strip if(val && val.respond_to?(:strip))
|
29
|
+
assign_attrs[col.to_s] = val
|
30
|
+
end
|
31
|
+
|
32
|
+
self.assign_attributes(assign_attrs) unless(assign_attrs.empty?)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Hatio
|
2
|
+
module Userstamp
|
3
|
+
|
4
|
+
def self.included(base) #:nodoc:
|
5
|
+
super
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.class_eval do
|
8
|
+
include InstanceMethods
|
9
|
+
class_attribute :creator_attribute
|
10
|
+
class_attribute :updater_attribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def stampable(options = {:creator_id => :creator_id, :updater_id => :updater_id})
|
16
|
+
self.creator_attribute = options[:creator_id]
|
17
|
+
self.updater_attribute = options[:updater_id]
|
18
|
+
|
19
|
+
class_eval do
|
20
|
+
belongs_to :creator, :class_name => "User", :foreign_key => self.creator_attribute
|
21
|
+
belongs_to :updater, :class_name => "User", :foreign_key => self.updater_attribute
|
22
|
+
before_save :set_updater_attribute
|
23
|
+
before_create :set_creator_attribute
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module InstanceMethods #:nodoc:
|
29
|
+
public
|
30
|
+
def creator_name
|
31
|
+
self.creator ? self.creator.name : nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def updater_name
|
35
|
+
self.updater ? self.updater.name : nil
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def set_creator_attribute
|
40
|
+
self.creator_id = User.current_user.id if User.current_user && !self.creator_id
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_updater_attribute
|
44
|
+
self.updater_id = User.current_user.id if User.current_user && !self.updater_id
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
# require 'birt_report'
|
4
|
+
# obj = GeneratorReport.new
|
5
|
+
# obj.create_report(2057,'pdf','reporte',:consulta_id=>"237")
|
6
|
+
#
|
7
|
+
|
8
|
+
class GeneratorReport
|
9
|
+
|
10
|
+
REPORT_TEMPLATE_PATH = File.join(RAILS_ROOT,'app','reports')
|
11
|
+
REPORT_REPOSITORY_VPATH = File.join(RAILS_ROOT,'public','reports')
|
12
|
+
BIRT_GENERATOR = File.join(ENV['BIRT_HOME'], 'ReportEngine','genReport.sh')
|
13
|
+
|
14
|
+
|
15
|
+
def create_report(user_id , format , name_report, option={})
|
16
|
+
|
17
|
+
report_path = File.join(REPORT_TEMPLATE_PATH,"#{name_report}.rptdesign")
|
18
|
+
report_repository_path = File.join(REPORT_REPOSITORY_VPATH,user_id.to_s,format.to_s)
|
19
|
+
name_out_report = "#{name_report}_#{Time.now.strftime('%Y%m%d%H%M%S')}.#{format}"
|
20
|
+
report_out_path = File.join(report_repository_path,name_out_report)
|
21
|
+
commands = "sh #{BIRT_GENERATOR}"
|
22
|
+
FileUtils.mkpath(report_repository_path) unless File.directory?(report_repository_path)
|
23
|
+
parameters = option.inject("") do |r,e|
|
24
|
+
%Q(#{r} -p #{e[0]}=#{e[1]})
|
25
|
+
end
|
26
|
+
|
27
|
+
commands << " #{parameters} "
|
28
|
+
commands << " -l es"
|
29
|
+
commands << " -f #{format} "
|
30
|
+
commands << " -o #{report_out_path}"
|
31
|
+
commands << " #{report_path}"
|
32
|
+
|
33
|
+
RAILS_DEFAULT_LOGGER.info("BIRT: #{commands}")
|
34
|
+
|
35
|
+
result = %x(#{commands})
|
36
|
+
result = report_out_path if $?.exitstatus == 0
|
37
|
+
|
38
|
+
"[#{$?.exitstatus}] #{result}"
|
39
|
+
return name_out_report
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Hatio
|
2
|
+
$HATIO_BUNDLES = [] unless defined? $HATIO_BUNDLES
|
3
|
+
|
4
|
+
class Bundle
|
5
|
+
attr_accessor :name, :module, :version, :summary, :author, :email, :url, :description, :changes, :entities, :dependencies, :bootstrap_controllers
|
6
|
+
|
7
|
+
def initialize(name, version)
|
8
|
+
self.name = name
|
9
|
+
self.version = version
|
10
|
+
self.module = Kernel.const_get(name.gsub('-', '_').classify)
|
11
|
+
self.entities = []
|
12
|
+
self.dependencies = []
|
13
|
+
self.bootstrap_controllers = []
|
14
|
+
|
15
|
+
yield self if block_given?
|
16
|
+
|
17
|
+
$HATIO_BUNDLES << self
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.ordered_bundle_list
|
21
|
+
ordered_list = []
|
22
|
+
$HATIO_BUNDLES.each do |bundle|
|
23
|
+
ordering_bundles bundle, ordered_list
|
24
|
+
end
|
25
|
+
ordered_list
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.ordering_bundles bundle, ordered_list
|
29
|
+
return if ordered_list.include? bundle
|
30
|
+
bundle.dependencies.each do |dep|
|
31
|
+
dep_bundle = $HATIO_BUNDLES.detect{|b| b.name == dep}
|
32
|
+
ordering_bundles dep_bundle, ordered_list if dep_bundle
|
33
|
+
end
|
34
|
+
ordered_list << bundle unless ordered_list.include? bundle
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Hatio
|
2
|
+
module Exception
|
3
|
+
class HatioError < StandardError; end
|
4
|
+
|
5
|
+
class InsufficientParameter < HatioError; end
|
6
|
+
|
7
|
+
class MisConfigured < HatioError; end
|
8
|
+
|
9
|
+
class ResourceNotFound < HatioError; end
|
10
|
+
|
11
|
+
class ServerError < HatioError; end
|
12
|
+
|
13
|
+
class InvalidRequest < HatioError; end
|
14
|
+
|
15
|
+
class ValidationWarning < HatioError; end
|
16
|
+
|
17
|
+
@status_code_map = {
|
18
|
+
'ActiveRecord::RecordNotUnique' => :internal_server_error,
|
19
|
+
'ActiveRecord::RecordNotFound' => :not_found,
|
20
|
+
'ActiveRecord::StatementInvalid' => :internal_server_error,
|
21
|
+
'Hatio::Exception::ResourceNotFound' => :not_found,
|
22
|
+
'Hatio::Exception::InsufficientParameter' => :bad_request,
|
23
|
+
'Hatio::Exception::MisConfigured' => :internal_server_error,
|
24
|
+
'Hatio::Exception::ServerError' => :internal_server_error,
|
25
|
+
'Hatio::Exception::InvalidRequest' => :bad_request,
|
26
|
+
'Hatio::Exception::ValidationWarning' => :bad_request
|
27
|
+
}
|
28
|
+
|
29
|
+
def self.get_status_code e
|
30
|
+
@status_code_map[e.class.name] || :internal_server_error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# TODO 무엇을 위한 설정인가 ?
|
2
|
+
# module ActionDispatch::Session::Compatibility
|
3
|
+
# def initialize(app, options = {})
|
4
|
+
# options[:key] ||= '_session_id'
|
5
|
+
# options[:secret] ||= Rails.application.config.secret_token
|
6
|
+
# super
|
7
|
+
# end
|
8
|
+
# end
|
9
|
+
|
10
|
+
# Development mode시에 public/assets 스태틱 라우팅을 Disable 시킨다.
|
11
|
+
# 이렇게 하지 않으면, development 모드에서 이중으로 스크립트들이 로드되는 문제가 발생한다.
|
12
|
+
# class ActionDispatch::Static
|
13
|
+
# def call(env)
|
14
|
+
# case env['REQUEST_METHOD']
|
15
|
+
# when 'GET', 'HEAD'
|
16
|
+
# path = env['PATH_INFO'].chomp('/')
|
17
|
+
#
|
18
|
+
# unless Rails.application.config.consider_all_requests_local && path.starts_with?('/assets/')
|
19
|
+
# if match = @file_handler.match?(path)
|
20
|
+
# env["PATH_INFO"] = match
|
21
|
+
# return @file_handler.call(env)
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# @app.call(env)
|
27
|
+
# end
|
28
|
+
# end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# migration id type 바꾸기. integer => string
|
2
|
+
Object.class_eval do
|
3
|
+
def meaningful keys, separator = '-'
|
4
|
+
keys.collect{|key| key.class == Symbol ? self.send(key) : key}.join(separator || '-')
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
# userstamp 명세 변경하기.
|
9
|
+
module Hatio
|
10
|
+
module MigrationHelper
|
11
|
+
module Userstamp
|
12
|
+
def self.included(base) # :nodoc:
|
13
|
+
base.send(:include, InstanceMethods)
|
14
|
+
end
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
def userstamps(include_deleted_by = false)
|
18
|
+
# column(:creator_id, :string, :limit => 16)
|
19
|
+
# column(:updater_id, :string, :limit => 16)
|
20
|
+
# column(:deleter_id, :string, :limit => 16) if include_deleted_by
|
21
|
+
column(:creator_id, :integer)
|
22
|
+
column(:updater_id, :integer)
|
23
|
+
column(:deleter_id, :integer) if include_deleted_by
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Hatio::MigrationHelper::Userstamp)
|
31
|
+
|
32
|
+
# oracle default primary key number --> varchar2(64)
|
33
|
+
if RUBY_PLATFORM =~ /java/
|
34
|
+
module ::ArJdbc
|
35
|
+
module Oracle
|
36
|
+
def create_table(table_name, options = {})
|
37
|
+
puts "oracel patch"
|
38
|
+
table_definition = TableDefinition.new(self)
|
39
|
+
table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false || options[:id] == :meaningful || options[:id] == :uuid
|
40
|
+
|
41
|
+
yield table_definition
|
42
|
+
|
43
|
+
if options[:force] && table_exists?(table_name)
|
44
|
+
drop_table(table_name, options)
|
45
|
+
end
|
46
|
+
|
47
|
+
create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "
|
48
|
+
create_sql << "#{quote_table_name(table_name)} ("
|
49
|
+
create_sql << "id varchar(#{options[:id_limit] || 64}) NOT NULL PRIMARY KEY, " if options[:id] == :meaningful || options[:id] == :uuid
|
50
|
+
create_sql << table_definition.to_sql
|
51
|
+
create_sql << ") #{options[:options]}"
|
52
|
+
execute create_sql
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|