infopark_reactor_migrations 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +165 -0
  4. data/README +64 -0
  5. data/Rakefile +19 -0
  6. data/infopark_reactor_migrations.gemspec +27 -0
  7. data/lib/generators/cm/migration/USAGE +8 -0
  8. data/lib/generators/cm/migration/migration_generator.rb +15 -0
  9. data/lib/generators/cm/migration/templates/template.rb +7 -0
  10. data/lib/infopark_reactor_migrations.rb +29 -0
  11. data/lib/reactor/cm/attribute.rb +84 -0
  12. data/lib/reactor/cm/bridge.rb +49 -0
  13. data/lib/reactor/cm/editorial_group.rb +22 -0
  14. data/lib/reactor/cm/group.rb +270 -0
  15. data/lib/reactor/cm/language.rb +56 -0
  16. data/lib/reactor/cm/link.rb +132 -0
  17. data/lib/reactor/cm/live_group.rb +22 -0
  18. data/lib/reactor/cm/missing_credentials.rb +7 -0
  19. data/lib/reactor/cm/obj.rb +402 -0
  20. data/lib/reactor/cm/obj_class.rb +186 -0
  21. data/lib/reactor/cm/object_base.rb +164 -0
  22. data/lib/reactor/cm/user.rb +100 -0
  23. data/lib/reactor/cm/workflow.rb +40 -0
  24. data/lib/reactor/cm/xml_attribute.rb +35 -0
  25. data/lib/reactor/cm/xml_markup.rb +85 -0
  26. data/lib/reactor/cm/xml_request.rb +82 -0
  27. data/lib/reactor/cm/xml_request_error.rb +16 -0
  28. data/lib/reactor/cm/xml_response.rb +41 -0
  29. data/lib/reactor/configuration.rb +7 -0
  30. data/lib/reactor/migration.rb +82 -0
  31. data/lib/reactor/migrations/railtie.rb +10 -0
  32. data/lib/reactor/migrations/version.rb +5 -0
  33. data/lib/reactor/plans/common_attribute.rb +32 -0
  34. data/lib/reactor/plans/common_group.rb +44 -0
  35. data/lib/reactor/plans/common_obj_class.rb +69 -0
  36. data/lib/reactor/plans/create_attribute.rb +32 -0
  37. data/lib/reactor/plans/create_group.rb +34 -0
  38. data/lib/reactor/plans/create_obj.rb +48 -0
  39. data/lib/reactor/plans/create_obj_class.rb +28 -0
  40. data/lib/reactor/plans/delete_attribute.rb +23 -0
  41. data/lib/reactor/plans/delete_group.rb +28 -0
  42. data/lib/reactor/plans/delete_obj.rb +22 -0
  43. data/lib/reactor/plans/delete_obj_class.rb +22 -0
  44. data/lib/reactor/plans/prepared.rb +15 -0
  45. data/lib/reactor/plans/rename_group.rb +32 -0
  46. data/lib/reactor/plans/rename_obj_class.rb +24 -0
  47. data/lib/reactor/plans/update_attribute.rb +23 -0
  48. data/lib/reactor/plans/update_group.rb +30 -0
  49. data/lib/reactor/plans/update_obj.rb +30 -0
  50. data/lib/reactor/plans/update_obj_class.rb +26 -0
  51. data/lib/reactor/tools/migrator.rb +135 -0
  52. data/lib/reactor/tools/response_handler/base.rb +22 -0
  53. data/lib/reactor/tools/response_handler/string.rb +19 -0
  54. data/lib/reactor/tools/response_handler/xml_attribute.rb +52 -0
  55. data/lib/reactor/tools/smart_xml_logger.rb +69 -0
  56. data/lib/reactor/tools/sower.rb +89 -0
  57. data/lib/reactor/tools/uploader.rb +131 -0
  58. data/lib/reactor/tools/versioner.rb +120 -0
  59. data/lib/reactor/tools/xml_attributes.rb +70 -0
  60. data/lib/tasks/cm_migrate.rake +8 -0
  61. data/lib/tasks/cm_seeds.rake +41 -0
  62. metadata +193 -0
@@ -0,0 +1,164 @@
1
+ require 'reactor/tools/xml_attributes'
2
+
3
+ module Reactor
4
+ module Cm
5
+ class ObjectBase
6
+ def self.inherited(subclass)
7
+ # dynamic binding is required, otherwise class attributes
8
+ # aren't stored in the correct class
9
+ subclass.send(:include, Reactor::XmlAttributes)
10
+ end
11
+
12
+ # Default base_name is lowercased class name (without namespaces)
13
+ def self.base_name
14
+ self.name.split('::').last.downcase
15
+ end
16
+
17
+ def base_name
18
+ self.class.base_name
19
+ end
20
+
21
+ # Sets the base name for the object. Use it when inheriting the class, for example:
22
+ # class Obj < ObjectBase
23
+ # set_base_name 'obj'
24
+ # end
25
+ def self.set_base_name(base_name_value)
26
+ # we us evaluation of a string in this case, because
27
+ # define_method cannot handle default values
28
+ self.class_eval <<-EOH
29
+ def self.base_name
30
+ '#{base_name_value}'
31
+ end
32
+ EOH
33
+ end
34
+
35
+ private_class_method :new
36
+ # Constructor of this class should never be called directly.
37
+ # Use class methods .get and .create instead (as well as helper method .exists?)
38
+ def initialize(pk_val)
39
+ primary_key_value_set(pk_val)
40
+ end
41
+
42
+ # Reloads the data from CM. Fetches all defined attributes.
43
+ def reload
44
+ request = XmlRequest.prepare do |xml|
45
+ xml.where_key_tag!(base_name, primary_key, primary_key_value)
46
+ xml.get_key_tag!(base_name, self.class.xml_attribute_names)
47
+ end
48
+
49
+ response = request.execute!
50
+
51
+ self.class.attributes.each do |attr_name, attr_def|
52
+ self.send(:"#{attr_name}=", self.class.response_handler.get(response, attr_def))
53
+ end
54
+
55
+ self
56
+ end
57
+
58
+ # Saves all settable instance attributes to the Content Manager.
59
+ def save!
60
+ request = XmlRequest.prepare do |xml|
61
+ xml.where_key_tag!(base_name, primary_key, primary_key_value)
62
+ xml.set_tag!(base_name) do
63
+ self.class.attributes(:set).each do |name, xml_attribute|
64
+ value = self.send(name)
65
+ serialize_attribute_to_xml(xml, xml_attribute, value)
66
+ end
67
+ end
68
+ end
69
+
70
+ response = request.execute!
71
+
72
+ response.ok?
73
+ end
74
+
75
+ # Alias for #save!
76
+ def save ; save! ; end
77
+
78
+ # Proxy method. @see .delete!(login)
79
+ def delete!
80
+ self.class.delete!(self.primary_key_value)
81
+ end
82
+
83
+ def serialize_attribute_to_xml(xml, xml_attribute, value)
84
+ self.class.serialize_attribute_to_xml(xml, xml_attribute, value)
85
+ end
86
+
87
+ def self.serialize_attribute_to_xml(xml, xml_attribute, value)
88
+ xml.value_tag!(xml_attribute.name, value)
89
+ end
90
+
91
+ # Returns true when object with given primary key exists in CM
92
+ # Returns false otherwise
93
+ def self.exists?(pk_val)
94
+ request = XmlRequest.prepare do |xml|
95
+ xml.where_key_tag!(base_name, primary_key, pk_val)
96
+ xml.get_key_tag!(base_name, primary_key)
97
+ end
98
+
99
+ response = request.execute!
100
+
101
+ return response.ok?
102
+
103
+ rescue XmlRequestError => e
104
+ return false
105
+ end
106
+
107
+ # Returns an instance of the class for object with given primary key
108
+ # XmlRequestError will be raised when error occurs (for example
109
+ # when there is no object with given primary key)
110
+ def self.get(pk_val)
111
+ obj = new(pk_val)
112
+ obj.reload
113
+ obj
114
+ end
115
+
116
+ # Removes object with given pk from CM.
117
+ # Returns true on success, raises XmlRequestError on error
118
+ def self.delete!(pk_val)
119
+ request = XmlRequest.prepare do |xml|
120
+ xml.where_key_tag!(base_name, primary_key, pk_val)
121
+ xml.delete_tag!(base_name)
122
+ end
123
+
124
+ return request.execute!.ok?
125
+ end
126
+ # Alias for #delete!
127
+ def delete ; delete! ; end
128
+
129
+ class << self
130
+ # This method should never be called directly. It should always be overriden!
131
+ # pk_value is the value of primary key, it should have its double in attributes hash
132
+ # attributes is a hash of attributes set on creation {:name => 'value'}
133
+ protected
134
+ def create(pk_value, attributes)
135
+ request = XmlRequest.prepare do |xml|
136
+ xml.create_tag!(base_name) do
137
+ attributes.each do |attr_name, attr_value|
138
+ #serialize_attribute_to_xml(xml, xml_attribute, value)
139
+ xml.value_tag!(attr_name, attr_value)
140
+ end
141
+ end
142
+ end
143
+
144
+ response = request.execute!
145
+
146
+ return get(pk_value)
147
+ end
148
+ end
149
+
150
+ protected
151
+ def primary_key
152
+ self.class.primary_key
153
+ end
154
+
155
+ def primary_key_value
156
+ instance_variable_get("@#{self.primary_key}")
157
+ end
158
+
159
+ def primary_key_value_set(value)
160
+ instance_variable_set("@#{self.primary_key}", value)
161
+ end
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,100 @@
1
+ require 'reactor/cm/object_base'
2
+ require 'reactor/configuration'
3
+ require 'reactor/cm/language'
4
+ require 'reactor/tools/xml_attributes'
5
+
6
+ module Reactor
7
+
8
+ module Cm
9
+
10
+ class User
11
+
12
+ class Internal < Reactor::Cm::ObjectBase
13
+ set_base_name 'user'
14
+
15
+ # Attribute definitions
16
+ attribute :login, :except => [:set]
17
+ attribute :super_user, :except => [:set], :name => :isSuperUser
18
+ attribute :default_group, :name => :defaultGroup
19
+ attribute :groups, :type => :list
20
+ attribute :real_name, :name => :realName
21
+
22
+ def change_password(new_password)
23
+ request = XmlRequest.prepare do |xml|
24
+ xml.where_key_tag!(base_name, primary_key, primary_key_value)
25
+ xml.set_tag!(base_name) do
26
+ xml.tag!('password', :verifyNewPassword => new_password) do
27
+ xml.text!(new_password)
28
+ end
29
+ end
30
+ end
31
+
32
+ response = request.execute!
33
+
34
+ response.ok?
35
+ end
36
+
37
+ primary_key :login
38
+
39
+ # Returns true if user is root, false otherwise
40
+ def super_user?
41
+ super_user == '1'
42
+ end
43
+
44
+ # Creates a user with given login and sets its default group
45
+ # Returns instance of the class for user with given login
46
+ def self.create(login, default_group)
47
+ super(login, {:login => login, :defaultGroup => default_group})
48
+ end
49
+
50
+ end
51
+
52
+ include XmlAttributes
53
+
54
+ attribute :name
55
+ attribute :groups, :type => :list
56
+
57
+ primary_key 'login'
58
+
59
+ def initialize(name)
60
+ @name = name
61
+ end
62
+
63
+ def is_root?
64
+ request = XmlRequest.prepare do |xml|
65
+ xml.where_key_tag!(base_name, self.class.primary_key, self.name)
66
+ xml.get_key_tag!(base_name, 'isSuperUser')
67
+ end
68
+
69
+ response = request.execute!
70
+
71
+ response.xpath('//isSuperUser/text()') == '1'
72
+ end
73
+
74
+ def language
75
+ Reactor::Cm::Language.get(self.name)
76
+ end
77
+
78
+ def groups
79
+ xml_attribute = self.class.xml_attribute(:groups)
80
+
81
+ request = XmlRequest.prepare do |xml|
82
+ xml.where_key_tag!(base_name, self.class.primary_key, self.name)
83
+ xml.get_key_tag!(base_name, xml_attribute.name)
84
+ end
85
+
86
+ response = request.execute!
87
+
88
+ self.class.response_handler.get(response, xml_attribute)
89
+ end
90
+
91
+ protected
92
+ def base_name
93
+ 'userProxy'
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,40 @@
1
+ require 'reactor/cm/object_base'
2
+
3
+ module Reactor
4
+ module Cm
5
+ class Workflow < ObjectBase
6
+ # Attribute definitions
7
+ attribute :name, :except => [:set]
8
+ attribute :title
9
+ attribute :is_enabled, :name => :isEnabled
10
+ attribute :edit_groups, :name => :editGroups, :type => :list
11
+ attribute :mutiple_signatures, :name => :allowsMultipleSignatures
12
+ # This attribute should be used as follows:
13
+ # workflow.signatures = [{:attribute => 'mySigAttr', :group => 'myGroup'},{:attribute => 'mySigAttr', :group => 'myOtherGroup'}]
14
+ attribute :signatures, :name => :signatureDefs, :type => :signaturelist
15
+
16
+ primary_key :name
17
+
18
+ # Creates a workflow with given name. A list of edit groups
19
+ # may also be specified - otherwise it defaults to empty list
20
+ def self.create(name, edit_groups = [])
21
+ super(name, {:name => name, :editGroups => edit_groups})
22
+ end
23
+
24
+ def self.serialize_attribute_to_xml(xml, xml_attribute, value)
25
+ if xml_attribute.name.to_sym == :signatureDefs
26
+ xml.tag!('signatureDefs') do
27
+ (value || []).each do |hash|
28
+ xml.tag!('listitem') do
29
+ xml.tag!('listitem', hash[:attribute])
30
+ xml.tag!('listitem', hash[:group])
31
+ end
32
+ end
33
+ end
34
+ else
35
+ super(xml, xml_attribute, value)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ module Reactor
2
+
3
+ module Cm
4
+
5
+ class XmlAttribute
6
+
7
+ AVAILABLE_SCOPES = [:get, :set, :create]
8
+
9
+ attr_accessor :name
10
+ attr_accessor :type
11
+ attr_accessor :scopes
12
+
13
+ def initialize(name, type, options)
14
+ @name = name
15
+ @type = type.presence || :string
16
+
17
+ @scopes =
18
+ if options[:except].present?
19
+ AVAILABLE_SCOPES - options[:except]
20
+ elsif options[:only].present?
21
+ options[:only]
22
+ else
23
+ AVAILABLE_SCOPES
24
+ end
25
+ end
26
+
27
+ def scope?(name)
28
+ self.scopes.include?(name)
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,85 @@
1
+ require 'builder'
2
+
3
+ module Reactor
4
+ module Cm
5
+ class XmlMarkup < Builder::XmlMarkup
6
+
7
+ def where_key_tag!(base_name, key, value)
8
+ where_tag!(base_name) do |xml|
9
+ xml.tag!(key.to_s) do
10
+ xml.text!(value.to_s)
11
+ end
12
+ end
13
+ end
14
+
15
+ def where_tag!(base_name)
16
+ tag!("#{base_name}-where") do |xml|
17
+ yield xml
18
+ end
19
+ end
20
+
21
+ def create_tag!(base_name)
22
+ tag!("#{base_name}-create") do |xml|
23
+ yield xml
24
+ end
25
+ end
26
+
27
+ def delete_tag!(base_name)
28
+ tag!("#{base_name}-delete")
29
+ end
30
+
31
+ def get_key_tag!(base_name, key)
32
+ get_tag!(base_name) do |xml|
33
+ if key.kind_of?(Array)
34
+ key.each {|k| xml.tag!(k.to_s) }
35
+ else
36
+ xml.tag!(key.to_s) ; end
37
+ end
38
+ end
39
+
40
+ def get_tag!(base_name)
41
+ tag!("#{base_name}-get") do |xml|
42
+ yield xml
43
+ end
44
+ end
45
+
46
+ def set_key_tag!(base_name, key, value, options = {})
47
+ set_tag!(base_name) do
48
+ value_tag!(key, value, options)
49
+ end
50
+ end
51
+
52
+ def set_tag!(base_name)
53
+ tag!("#{base_name}-set") do |xml|
54
+ yield xml
55
+ end
56
+ end
57
+
58
+ def value_tag!(key, value, options = {})
59
+ if value.kind_of? Array then array_value_tag!(key, value, options)
60
+ elsif value.kind_of? Hash then hash_value_tag!(key, value)
61
+ else tag!(key.to_s) { text!(value.to_s) }
62
+ end
63
+ end
64
+
65
+ def array_value_tag!(name, values, options = {})
66
+ tag!(name.to_s, options) do
67
+ values.each do |value|
68
+ tag!('listitem') do
69
+ text!(value.to_s)
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ def hash_value_tag!(name, hash)
76
+ hash.each do |value, attr_hash|
77
+ tag!(name.to_s, attr_hash) do
78
+ text!(value.to_s)
79
+ end
80
+ end
81
+ end
82
+
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,82 @@
1
+ require 'net/http'
2
+ require 'reactor/cm/xml_response'
3
+ require 'reactor/cm/xml_request_error'
4
+ require 'reactor/cm/xml_markup'
5
+ require 'reactor/tools/smart_xml_logger'
6
+
7
+ module Reactor
8
+ module Cm
9
+
10
+ if Rails.env.development? && false
11
+ #LOGGER = SmartXmlLogger.new(Rails.logger, :debug)
12
+ LOGGER = SmartXmlLogger.new(Kernel, :puts)
13
+ else
14
+ LOGGER = SmartXmlLogger.new(nil) # turn off logging
15
+ end
16
+ LOGGER.configure(:request, :xpath => 'cm-payload/cm-request/*', :start_indent => 2)
17
+ LOGGER.configure(:response, :xpath => 'cm-payload/cm-response/*', :start_indent => 2)
18
+
19
+ class XmlRequest
20
+
21
+ def self.token(login, instance_secret)
22
+ Digest::MD5.hexdigest(login + instance_secret)
23
+ end
24
+
25
+ def self.prepare
26
+ access = Configuration::xml_access
27
+ sanity_check(access)
28
+ xml = XmlMarkup.new
29
+ ret = nil
30
+ xml.instruct!
31
+ ret = xml.tag!('cm-payload', 'payload-id' =>'abcabc', 'timestamp' => Time.now.getutc.strftime('%Y%m%d%H%M%S'), 'version' => '6.7.3') do
32
+ xml.tag!('cm-header') do
33
+ xml.tag!('cm-sender', 'sender-id' => access[:id], 'name' => "ruby-simple-client")
34
+ xml.tag!('cm-authentication', 'login' => access[:username], 'token' => token(access[:username],access[:secret]))
35
+ end
36
+ id = self.generate_id
37
+ xml.tag!('cm-request', 'request-id' => id) do |xml2|
38
+ yield xml2 if block_given?
39
+ end
40
+ end
41
+ XmlRequest.new(ret)
42
+ end
43
+
44
+ def execute!
45
+ access = Configuration::xml_access
46
+ payload = @xml
47
+
48
+ res = Net::HTTP.new(access[:host], access[:port]).start do |http|
49
+ req = Net::HTTP::Post.new('/xml')
50
+ Reactor::Cm::LOGGER.log('REQUEST:')
51
+ Reactor::Cm::LOGGER.log_xml(:request, payload)
52
+ req.body = payload
53
+ http.request(req)
54
+ end
55
+ Reactor::Cm::LOGGER.log('RESPONSE:')
56
+ Reactor::Cm::LOGGER.log_xml(:response, res.body)
57
+ response = XmlResponse.new(res.body)
58
+ raise XmlRequestError, response unless response.ok?
59
+ response
60
+ end
61
+
62
+ class << self
63
+ protected
64
+
65
+ def generate_id
66
+ rand(10000)
67
+ end
68
+
69
+ def sanity_check(access)
70
+ raise Reactor::Cm::MissingCredentials if access[:username].nil? || access[:username].empty?
71
+ end
72
+ end
73
+
74
+ protected
75
+
76
+ def initialize(xml)
77
+ @xml = xml
78
+ end
79
+
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,16 @@
1
+ module Reactor
2
+ module Cm
3
+ class XmlRequestError < StandardError
4
+ def initialize(response)
5
+ @response = response
6
+ @xml = response.xml
7
+ super(phrase)
8
+ end
9
+
10
+ def phrase
11
+ @response.xpath('//phrase').to_s
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,41 @@
1
+ require 'reactor/tools/response_handler/xml_attribute'
2
+
3
+ module Reactor
4
+
5
+ module Cm
6
+
7
+ class XmlResponse
8
+
9
+ attr_reader :xml
10
+ attr_reader :xml_str
11
+
12
+ def initialize(xml)
13
+ @xml_str = xml
14
+ @xml = REXML::Document.new(xml)
15
+ @handler = Reactor::ResponseHandler::XmlAttribute.new
16
+ end
17
+
18
+ def xpath(expr)
19
+ arr = REXML::XPath.match(@xml, expr)
20
+
21
+ return arr.first if arr.length == 1
22
+ return arr
23
+ end
24
+
25
+ def ok?
26
+ xp = xpath('//cm-code')
27
+
28
+ if xp.is_a?(Array)
29
+ codes = xp.map { |result| result.attribute('numeric').value }.uniq
30
+
31
+ return codes.size == 1 && codes.first == '200'
32
+ end
33
+
34
+ xp.attribute('numeric').value == '200'
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,7 @@
1
+ module Reactor
2
+ class Configuration
3
+ class << self
4
+ attr_accessor :xml_access
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,82 @@
1
+ require 'reactor/plans/create_obj'
2
+ require 'reactor/plans/delete_obj'
3
+ require 'reactor/plans/update_obj'
4
+ require 'reactor/plans/create_obj_class'
5
+ require 'reactor/plans/delete_obj_class'
6
+ require 'reactor/plans/update_obj_class'
7
+ require 'reactor/plans/rename_obj_class'
8
+ require 'reactor/plans/create_attribute'
9
+ require 'reactor/plans/delete_attribute'
10
+ require 'reactor/plans/update_attribute'
11
+ require 'reactor/plans/create_group'
12
+ require 'reactor/plans/update_group'
13
+ require 'reactor/plans/delete_group'
14
+ require 'reactor/plans/rename_group'
15
+
16
+ module Reactor
17
+ class Migration
18
+ METHODS = {
19
+ :create_obj => Plans::CreateObj,
20
+ :delete_obj => Plans::DeleteObj,
21
+ :update_obj => Plans::UpdateObj,
22
+ :create_class => Plans::CreateObjClass,
23
+ :delete_class => Plans::DeleteObjClass,
24
+ :update_class => Plans::UpdateObjClass,
25
+ :rename_class => Plans::RenameObjClass,
26
+ :create_attribute => Plans::CreateAttribute,
27
+ :delete_attribute => Plans::DeleteAttribute,
28
+ :update_attribute => Plans::UpdateAttribute,
29
+ :create_group => Plans::CreateGroup,
30
+ :delete_group => Plans::DeleteGroup,
31
+ :update_group => Plans::UpdateGroup,
32
+ :rename_group => Plans::RenameGroup,
33
+ }
34
+
35
+ def self.method_missing(name, *args, &block)
36
+ if METHODS.key? name.to_sym then
37
+ instance = init(name,*args)
38
+ plan(instance,&block)
39
+ prepare(instance)
40
+ migrate(instance)
41
+ else
42
+ super(name, *args, &block)
43
+ end
44
+ end
45
+
46
+ def self.respond_to?(name)
47
+ METHODS.key?(name.to_sym) || super(name)
48
+ end
49
+
50
+ def self.contains(*args)
51
+ @contained ||= []
52
+ args.flatten.each do |arg|
53
+ migration_num = arg.to_i.to_s
54
+ @contained << migration_num
55
+ end
56
+ end
57
+
58
+ def self.contained
59
+ @contained || []
60
+ end
61
+
62
+ protected
63
+ def self.init(name,*args)
64
+ METHODS[name.to_sym].new(*args)
65
+ end
66
+
67
+ def self.plan(instance,&block)
68
+ instance.instance_eval(&block) if block_given?
69
+ end
70
+
71
+ def self.prepare(instance)
72
+ instance.prepare! if instance.respond_to? :prepare!
73
+ end
74
+
75
+ def self.migrate(instance)
76
+ instance.migrate!
77
+ end
78
+
79
+ private
80
+ def initialize ; end
81
+ end
82
+ end
@@ -0,0 +1,10 @@
1
+ module Reactor
2
+ module Migrations
3
+ class Railtie < Rails::Railtie
4
+ rake_tasks do
5
+ load "tasks/cm_migrate.rake"
6
+ load "tasks/cm_seeds.rake"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Reactor
2
+ module Migrations
3
+ VERSION = "1.5.1"
4
+ end
5
+ end