infopark_reactor_migrations 1.5.2 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/infopark_reactor_migrations.rb +1 -0
- data/lib/reactor/cm/channel.rb +17 -0
- data/lib/reactor/cm/obj.rb +2 -2
- data/lib/reactor/cm/xml_request.rb +1 -1
- data/lib/reactor/migration.rb +4 -0
- data/lib/reactor/migrations/version.rb +1 -1
- data/lib/reactor/plans/common_channel.rb +31 -0
- data/lib/reactor/plans/create_channel.rb +23 -0
- data/lib/reactor/plans/delete_channel.rb +21 -0
- metadata +9 -5
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'reactor/cm/object_base'
|
2
|
+
|
3
|
+
module Reactor
|
4
|
+
module Cm
|
5
|
+
class Channel < ObjectBase
|
6
|
+
# Attribute definitions
|
7
|
+
attribute :name, :except => [:set]
|
8
|
+
attribute :title
|
9
|
+
|
10
|
+
primary_key :name
|
11
|
+
|
12
|
+
def self.create(name)
|
13
|
+
super(name, {:name => name})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/reactor/cm/obj.rb
CHANGED
@@ -2,7 +2,7 @@ module Reactor
|
|
2
2
|
module Cm
|
3
3
|
class Obj
|
4
4
|
attr_reader :obj_id
|
5
|
-
OBJ_ATTRS = [:permalink, :objClass, :workflowName, :name, :suppressExport, :parent]
|
5
|
+
OBJ_ATTRS = [:permalink, :objClass, :workflowName, :name, :suppressExport, :parent]
|
6
6
|
ATTR_LENGTH_CONSTRAINT = {:name => 250, :title => 250}
|
7
7
|
|
8
8
|
def self.create(name, parent, objClass)
|
@@ -399,4 +399,4 @@ module Reactor
|
|
399
399
|
end
|
400
400
|
end
|
401
401
|
end
|
402
|
-
end
|
402
|
+
end
|
data/lib/reactor/migration.rb
CHANGED
@@ -12,6 +12,8 @@ require 'reactor/plans/create_group'
|
|
12
12
|
require 'reactor/plans/update_group'
|
13
13
|
require 'reactor/plans/delete_group'
|
14
14
|
require 'reactor/plans/rename_group'
|
15
|
+
require 'reactor/plans/create_channel'
|
16
|
+
require 'reactor/plans/delete_channel'
|
15
17
|
|
16
18
|
module Reactor
|
17
19
|
class Migration
|
@@ -30,6 +32,8 @@ module Reactor
|
|
30
32
|
:delete_group => Plans::DeleteGroup,
|
31
33
|
:update_group => Plans::UpdateGroup,
|
32
34
|
:rename_group => Plans::RenameGroup,
|
35
|
+
:create_channel => Plans::CreateChannel,
|
36
|
+
:delete_channel => Plans::DeleteChannel
|
33
37
|
}
|
34
38
|
|
35
39
|
def self.method_missing(name, *args, &block)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Reactor
|
2
|
+
module Plans
|
3
|
+
class CommonChannel
|
4
|
+
include Prepared
|
5
|
+
|
6
|
+
ALLOWED_PARAMS = [:title]
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@params = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def set(key,value)
|
13
|
+
@params[key.to_sym] = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def migrate!
|
17
|
+
raise "#{self.class.name} did not implement migrate!"
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
def prepare_params!(channel=nil)
|
22
|
+
@params.keys.each{|k| error("unknown parameter: #{k}") unless ALLOWED_PARAMS.include? k}
|
23
|
+
end
|
24
|
+
|
25
|
+
def migrate_params!(channel)
|
26
|
+
@params.each{|k,v|channel.send(:"#{k}=",v)}
|
27
|
+
channel.save!
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'reactor/cm/channel'
|
2
|
+
require 'reactor/plans/common_channel'
|
3
|
+
|
4
|
+
module Reactor
|
5
|
+
module Plans
|
6
|
+
class CreateChannel < CommonChannel
|
7
|
+
def initialize(*args)
|
8
|
+
super()
|
9
|
+
(name, x), options = separate_arguments(*args)
|
10
|
+
@name = name || options[:name]
|
11
|
+
end
|
12
|
+
|
13
|
+
def prepare!
|
14
|
+
error("name is nil") if @name.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def migrate!
|
18
|
+
channel = Reactor::Cm::Channel.create(@name)
|
19
|
+
migrate_params!(channel)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Reactor
|
2
|
+
module Plans
|
3
|
+
class DeleteChannel < CommonAttribute
|
4
|
+
def initialize(*args)
|
5
|
+
super()
|
6
|
+
(name, x), options = separate_arguments(*args)
|
7
|
+
@name = name || options[:name]
|
8
|
+
end
|
9
|
+
|
10
|
+
def prepare!
|
11
|
+
error("name is nil") if @name.nil?
|
12
|
+
error("channel #{@name} does not exist") if not Reactor::Cm::Channel.exists?(@name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def migrate!
|
16
|
+
Reactor::Cm::Channel.get(@name).delete!
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_reactor_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 6
|
9
|
+
- 1
|
10
|
+
version: 1.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tomasz Przedmojski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-01-
|
18
|
+
date: 2013-01-17 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/infopark_reactor_migrations.rb
|
107
107
|
- lib/reactor/cm/attribute.rb
|
108
108
|
- lib/reactor/cm/bridge.rb
|
109
|
+
- lib/reactor/cm/channel.rb
|
109
110
|
- lib/reactor/cm/editorial_group.rb
|
110
111
|
- lib/reactor/cm/group.rb
|
111
112
|
- lib/reactor/cm/language.rb
|
@@ -127,13 +128,16 @@ files:
|
|
127
128
|
- lib/reactor/migrations/railtie.rb
|
128
129
|
- lib/reactor/migrations/version.rb
|
129
130
|
- lib/reactor/plans/common_attribute.rb
|
131
|
+
- lib/reactor/plans/common_channel.rb
|
130
132
|
- lib/reactor/plans/common_group.rb
|
131
133
|
- lib/reactor/plans/common_obj_class.rb
|
132
134
|
- lib/reactor/plans/create_attribute.rb
|
135
|
+
- lib/reactor/plans/create_channel.rb
|
133
136
|
- lib/reactor/plans/create_group.rb
|
134
137
|
- lib/reactor/plans/create_obj.rb
|
135
138
|
- lib/reactor/plans/create_obj_class.rb
|
136
139
|
- lib/reactor/plans/delete_attribute.rb
|
140
|
+
- lib/reactor/plans/delete_channel.rb
|
137
141
|
- lib/reactor/plans/delete_group.rb
|
138
142
|
- lib/reactor/plans/delete_obj.rb
|
139
143
|
- lib/reactor/plans/delete_obj_class.rb
|