infopark_reactor 1.10.0.beta → 1.11.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/rails_connector/abstract_model.rb +7 -0
- data/app/models/rails_connector/abstract_obj.rb +31 -0
- data/app/models/rails_connector/attribute.rb +94 -0
- data/app/models/rails_connector/blob_mapping.rb +12 -0
- data/app/models/rails_connector/channel.rb +41 -0
- data/app/models/rails_connector/content.rb +12 -0
- data/app/models/rails_connector/meta/eager_loader.rb +41 -0
- data/app/models/rails_connector/obj_class.rb +143 -0
- data/app/models/rails_connector/object_with_meta_data.rb +18 -0
- data/infopark_reactor.gemspec +4 -4
- data/lib/generators/cm/migration/USAGE +8 -0
- data/lib/generators/cm/migration/migration_generator.rb +16 -0
- data/lib/generators/cm/migration/templates/template.rb +8 -0
- data/lib/infopark_reactor.rb +35 -1
- data/lib/reactor/attributes.rb +2 -4
- data/lib/reactor/cm/attribute.rb +91 -0
- data/lib/reactor/cm/bridge.rb +50 -0
- data/lib/reactor/cm/channel.rb +18 -0
- data/lib/reactor/cm/editorial_group.rb +23 -0
- data/lib/reactor/cm/group.rb +241 -0
- data/lib/reactor/cm/language.rb +57 -0
- data/lib/reactor/cm/link.rb +136 -0
- data/lib/reactor/cm/live_group.rb +23 -0
- data/lib/reactor/cm/log_entry.rb +64 -0
- data/lib/reactor/cm/missing_credentials.rb +8 -0
- data/lib/reactor/cm/multi_xml_request.rb +102 -0
- data/lib/reactor/cm/obj.rb +544 -0
- data/lib/reactor/cm/obj_class.rb +187 -0
- data/lib/reactor/cm/object_base.rb +165 -0
- data/lib/reactor/cm/permissions.rb +44 -0
- data/lib/reactor/cm/user.rb +139 -0
- data/lib/reactor/cm/workflow.rb +41 -0
- data/lib/reactor/cm/xml_attribute.rb +36 -0
- data/lib/reactor/cm/xml_markup.rb +86 -0
- data/lib/reactor/cm/xml_multi_request_error.rb +10 -0
- data/lib/reactor/cm/xml_request.rb +83 -0
- data/lib/reactor/cm/xml_request_error.rb +11 -0
- data/lib/reactor/cm/xml_response.rb +43 -0
- data/lib/reactor/cm/xml_single_request_error.rb +21 -0
- data/lib/reactor/configuration.rb +8 -0
- data/lib/{engine.rb → reactor/engine.rb} +16 -1
- data/lib/reactor/legacy.rb +3 -3
- data/lib/reactor/link/temporary_link.rb +8 -4
- data/lib/reactor/migration.rb +87 -0
- data/lib/reactor/permission.rb +2 -2
- data/lib/reactor/persistence.rb +14 -12
- data/lib/reactor/plans/common_attribute.rb +33 -0
- data/lib/reactor/plans/common_channel.rb +32 -0
- data/lib/reactor/plans/common_group.rb +45 -0
- data/lib/reactor/plans/common_obj_class.rb +70 -0
- data/lib/reactor/plans/create_attribute.rb +33 -0
- data/lib/reactor/plans/create_channel.rb +24 -0
- data/lib/reactor/plans/create_group.rb +35 -0
- data/lib/reactor/plans/create_obj.rb +49 -0
- data/lib/reactor/plans/create_obj_class.rb +29 -0
- data/lib/reactor/plans/delete_attribute.rb +24 -0
- data/lib/reactor/plans/delete_channel.rb +22 -0
- data/lib/reactor/plans/delete_group.rb +29 -0
- data/lib/reactor/plans/delete_obj.rb +23 -0
- data/lib/reactor/plans/delete_obj_class.rb +23 -0
- data/lib/reactor/plans/prepared.rb +16 -0
- data/lib/reactor/plans/rename_group.rb +33 -0
- data/lib/reactor/plans/rename_obj_class.rb +25 -0
- data/lib/reactor/plans/update_attribute.rb +24 -0
- data/lib/reactor/plans/update_group.rb +31 -0
- data/lib/reactor/plans/update_obj.rb +31 -0
- data/lib/reactor/plans/update_obj_class.rb +27 -0
- data/lib/reactor/rails_connector_meta.rb +144 -0
- data/lib/reactor/tools/migrator.rb +136 -0
- data/lib/reactor/tools/response_handler/base.rb +23 -0
- data/lib/reactor/tools/response_handler/string.rb +20 -0
- data/lib/reactor/tools/response_handler/xml_attribute.rb +53 -0
- data/lib/reactor/tools/smart_xml_logger.rb +70 -0
- data/lib/reactor/tools/sower.rb +90 -0
- data/lib/reactor/tools/uploader.rb +134 -0
- data/lib/reactor/tools/versioner.rb +121 -0
- data/lib/reactor/tools/workflow_generator.rb +1 -1
- data/lib/reactor/tools/xml_attributes.rb +71 -0
- data/lib/reactor/version.rb +1 -1
- data/lib/tasks/cm_migrate.rake +8 -0
- data/lib/tasks/cm_seeds.rake +41 -0
- metadata +82 -13
- data/README.md +0 -186
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2649a34240ebf7ba0254b206e929f8d80be1f4ad
|
4
|
+
data.tar.gz: 31b0f374168394beb5f1de509a0e201ce8b64f33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c119f9285fa51ff038cb37d40628bdc606d57022d0d4d91c6b0e4d3195ca1342b31ea6f89014b8f9710a7fc25cb03ccf04fd7fa9581ba1e80b24be448120801
|
7
|
+
data.tar.gz: 13d83fbc668a9b4d211b5f339a7bafe9ef658e7fcb06a892c0f17a3f96c5e0443cc00b7d15bfd1ec23959f45dd40560df9c39c06a8cb2cd430835a7e2b5deb30
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# This trick is a workaround to provide compatiblity with both
|
3
|
+
# ObjExtensions-enabled versions (older versions) and ObjExtensions-deprecated
|
4
|
+
# versions (newest versions) of RailsConnector
|
5
|
+
#
|
6
|
+
# It first tries to use user-defined Obj class in the newest RailsConnector,
|
7
|
+
# which is also an alias for RailsConnector::Obj in the older RailsConnector.
|
8
|
+
# If that fails it falls back to ::RailsConnector::BasicObj (new)
|
9
|
+
# or ::RailsConnector::Obj (old).
|
10
|
+
# The last case shouldn't really ever happen.
|
11
|
+
root_class = begin
|
12
|
+
::RailsConnector::BasicObj
|
13
|
+
rescue NameError
|
14
|
+
::RailsConnector::Obj
|
15
|
+
end
|
16
|
+
AbstractObj = begin
|
17
|
+
if ::Obj < root_class
|
18
|
+
::Obj
|
19
|
+
else
|
20
|
+
root_class
|
21
|
+
end
|
22
|
+
rescue NameError
|
23
|
+
root_class
|
24
|
+
end
|
25
|
+
|
26
|
+
class AbstractObj
|
27
|
+
def self.compute_type(type_name)
|
28
|
+
try_type { type_name.constantize } || self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module RailsConnector
|
3
|
+
|
4
|
+
# The methods date?, enum?, html?, linklist?, markdown?, multienum?, string? and
|
5
|
+
# text? are created by meta programming have no documentation of their own.
|
6
|
+
# Warning: Dependent on the setup of your DB replication, most tables
|
7
|
+
# with meta information will not be available on your live system!
|
8
|
+
class Attribute < RailsConnector::AbstractModel
|
9
|
+
|
10
|
+
# The possible types of an attribute.
|
11
|
+
TYPES = %w{date enum html linklist markdown multienum string text}
|
12
|
+
|
13
|
+
self.primary_key = :attribute_id
|
14
|
+
|
15
|
+
has_and_belongs_to_many :obj_class_definitions, :class_name => '::RailsConnector::ObjClass',
|
16
|
+
:join_table => "#{table_name_prefix}obj_class_attrs"
|
17
|
+
|
18
|
+
alias_method :obj_class_defs, :obj_class_definitions
|
19
|
+
alias_attribute :name, :attribute_name
|
20
|
+
|
21
|
+
# The (human readable) title.
|
22
|
+
def title(language = :de)
|
23
|
+
load_blob_data
|
24
|
+
@blob_data['titles'].presence && @blob_data['titles'][language.to_s]
|
25
|
+
end
|
26
|
+
|
27
|
+
# The description of the attribute.
|
28
|
+
def help_text(language = :de)
|
29
|
+
load_blob_data
|
30
|
+
@blob_data['helpTexts'].presence && @blob_data['helpTexts'][language.to_s]
|
31
|
+
end
|
32
|
+
|
33
|
+
# Searchable in Content Manager.
|
34
|
+
def searchable_in_cm?
|
35
|
+
load_blob_data
|
36
|
+
@blob_data['isSearchableInCM'].to_i != 0
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the possible values if attribute is of type `enum' or `multienum'.
|
40
|
+
def values
|
41
|
+
load_blob_data
|
42
|
+
@blob_data['values']
|
43
|
+
end
|
44
|
+
|
45
|
+
def max_size
|
46
|
+
load_blob_data
|
47
|
+
@blob_data["maxSize"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def min_size
|
51
|
+
load_blob_data
|
52
|
+
@blob_data["minSize"]
|
53
|
+
end
|
54
|
+
|
55
|
+
TYPES.each do |type|
|
56
|
+
self.class_eval <<EOM, __FILE__, __LINE__ + 1
|
57
|
+
def #{type}?
|
58
|
+
self.attribute_type == "#{type}"
|
59
|
+
end
|
60
|
+
EOM
|
61
|
+
end
|
62
|
+
|
63
|
+
# Convenience method for find_by_attribute_name
|
64
|
+
def self.find_by_name(*args)
|
65
|
+
self.find_by_attribute_name(*args)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns the blob as a JSON object.
|
69
|
+
def self.read_blob_data(name) #:nodoc:
|
70
|
+
blob = RailsConnector::Meta.hello_im_rails_and_im_retarted_so_please_be_patient do # these queries really pollute our logs!
|
71
|
+
blob_name = if RailsConnector::BlobMapping.exists?
|
72
|
+
RailsConnector::BlobMapping.get_fingerprint("#{name}.jsonAttributeDict")
|
73
|
+
else
|
74
|
+
"#{name}.jsonAttributeDict"
|
75
|
+
end
|
76
|
+
|
77
|
+
RailsConnector::Blob.find_without_excluded_blob_data(blob_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
return {} unless blob && blob.blob_data?
|
81
|
+
|
82
|
+
JSON.parse(blob.blob_data)
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
# load attribute details from blob
|
88
|
+
def load_blob_data #:nodoc:
|
89
|
+
@blob_data ||= self.class.read_blob_data(self.attribute_name)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# @author Anton Mezin
|
3
|
+
module RailsConnector
|
4
|
+
class Channel < AbstractModel
|
5
|
+
self.primary_key = "channel_name"
|
6
|
+
|
7
|
+
def self.table_name
|
8
|
+
"#{table_name_prefix}" "channels"
|
9
|
+
end
|
10
|
+
|
11
|
+
has_many :news, :class_name => 'News', :foreign_key => 'channel_name'
|
12
|
+
|
13
|
+
if ::Rails::VERSION::MAJOR == 4
|
14
|
+
|
15
|
+
has_many :active_news,
|
16
|
+
lambda { where(['valid_from <= :now AND valid_until >= :now', {:now => Time.now.to_s(:number)}]) },
|
17
|
+
:class_name => 'News', :foreign_key => 'channel_name'
|
18
|
+
|
19
|
+
if ::Rails::VERSION::MINOR >= 1
|
20
|
+
|
21
|
+
def self.scoped
|
22
|
+
self.where(nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
elsif ::Rails::VERSION::MAJOR == 3
|
28
|
+
|
29
|
+
has_many :active_news, :class_name => 'News', :foreign_key => 'channel_name',
|
30
|
+
:conditions => ['valid_from <= :now AND valid_until >= :now', {:now => Time.now.to_s(:number)}]
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
has_many :objects, :through => :news
|
35
|
+
|
36
|
+
def self.with_prefix(prefix)
|
37
|
+
scoped.where(["channel_name LIKE ?", "#{prefix}%"])
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module RailsConnector
|
5
|
+
module Meta
|
6
|
+
class EagerLoader
|
7
|
+
include Singleton
|
8
|
+
def initialize
|
9
|
+
# Rails.logger.debug "EagerLoader: I am eager to start working"
|
10
|
+
@obj_classes = {}
|
11
|
+
# Rails 3.1 contains a bug that screws attribute loading
|
12
|
+
# attributes are set to assigned classes
|
13
|
+
if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 1
|
14
|
+
RailsConnector::ObjClass.all.each do |obj_class|
|
15
|
+
obj_class.custom_attributes
|
16
|
+
@obj_classes[obj_class.name] = obj_class
|
17
|
+
end
|
18
|
+
else
|
19
|
+
RailsConnector::ObjClass.includes(:custom_attributes_raw).all.each do |obj_class|
|
20
|
+
@obj_classes[obj_class.name] = obj_class
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def obj_class(name)
|
26
|
+
name = name.to_s
|
27
|
+
if !@obj_classes.fetch(name, nil).nil?
|
28
|
+
# puts "EagerLoader: I've already loaded it: #{name}"
|
29
|
+
@obj_classes[name]
|
30
|
+
else
|
31
|
+
# puts "EagerLoader: NO HAVE: #{name}"
|
32
|
+
@obj_classes[name] ||= RailsConnector::ObjClass.find_by_obj_class_name(name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def forget_obj_class(name)
|
37
|
+
@obj_classes.delete(name.to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module RailsConnector
|
3
|
+
|
4
|
+
# This class is used to read out the custom attributes,
|
5
|
+
# mandatory attributes and titles of an Obj.
|
6
|
+
# Warning: Dependent on the setup of your DB replication, most tables
|
7
|
+
# with meta information will not be available on your live system!
|
8
|
+
class ObjClass < RailsConnector::AbstractModel
|
9
|
+
|
10
|
+
self.primary_key = :obj_class_id
|
11
|
+
|
12
|
+
has_and_belongs_to_many :custom_attributes_raw, :class_name => '::RailsConnector::Attribute',
|
13
|
+
:join_table => "#{table_name_prefix}obj_class_attrs"
|
14
|
+
|
15
|
+
alias_attribute :name, :obj_class_name
|
16
|
+
|
17
|
+
# Returns the title of the file format or nil, if it was not set.
|
18
|
+
def title(language)
|
19
|
+
self.titles[language.to_s].presence
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns all titles as a Hash.
|
23
|
+
def titles
|
24
|
+
load_blob_data
|
25
|
+
@blob_data['titles'] || {}
|
26
|
+
end
|
27
|
+
|
28
|
+
# returns channel feature is_activate?
|
29
|
+
def can_create_news_items?
|
30
|
+
load_blob_data
|
31
|
+
@blob_data['canCreateNewsItems'].to_i != 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def enabled?
|
35
|
+
is_enabled == 1
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the custom Ruby class or RailsConnector::AbstractObj.
|
39
|
+
def ruby_class
|
40
|
+
# this must be the same algorithm that the rest of the RailsConnector uses!
|
41
|
+
RailsConnector::AbstractObj.compute_type(self.name)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns true, if a custom Ruby class exists.
|
45
|
+
def has_custom_ruby_class?
|
46
|
+
self.ruby_class.present? && self.ruby_class != RailsConnector::AbstractObj &&
|
47
|
+
self.ruby_class.ancestors.include?(RailsConnector::AbstractObj)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns the custom attributes in the form of a Hash.
|
51
|
+
def custom_attributes
|
52
|
+
# return the cached data
|
53
|
+
return @custom_attributes if @custom_attributes
|
54
|
+
|
55
|
+
# create a Hash (with indifferent access) out of an Array of ActiveRecord objects
|
56
|
+
@custom_attributes = self.custom_attributes_raw.map do |attr|
|
57
|
+
{attr.attribute_name => attr}
|
58
|
+
end.reduce(HashWithIndifferentAccess.new, &:merge)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns true, if the Obj Class has an attribute of the given name.
|
62
|
+
def custom_attribute?(attr)
|
63
|
+
self.custom_attributes.key?(attr)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns an Array of String of all mandatory attributes found for this ObjClass,
|
67
|
+
# no matter if it is a custom or built-in attribute. Built-in attributes
|
68
|
+
# are underscored (valid_from, not validFrom).
|
69
|
+
# Possible +options+ are:
|
70
|
+
# <tt>:only_custom_attributes</tt>:: Return only custom attributes, omit
|
71
|
+
# built-in attributes like content_type or valid_from.
|
72
|
+
def mandatory_attribute_names(options = {})
|
73
|
+
only_custom_attributes ||= options[:only_custom_attributes] || false
|
74
|
+
build_mandatory_attribute_arrays
|
75
|
+
return @mandatory_custom_attributes if only_custom_attributes
|
76
|
+
@mandatory_attributes
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns true, if the file format has an mandatory attribute of the given name.
|
80
|
+
def mandatory_attribute?(attr)
|
81
|
+
self.mandatory_attribute_names.include?(attr.to_s)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Convenience method for find_by_obj_class_name
|
85
|
+
def self.find_by_name(*args)
|
86
|
+
self.find_by_obj_class_name(*args)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Reads a whole bunch of data, where only some of it is useful
|
90
|
+
# in a Rails application:
|
91
|
+
# attributeGroups, availableBlobEditors, bodyTemplateName,
|
92
|
+
# canCreateNewsItems, completionCheck, mandatoryAttributes,
|
93
|
+
# presetAttributes, recordSetCallback, titles, validSubObjClassCheck,
|
94
|
+
# workflowModification
|
95
|
+
def self.read_blob_data(name) #:nodoc:
|
96
|
+
blob = RailsConnector::Meta.hello_im_rails_and_im_retarted_so_please_be_patient do # these queries really pollute our logs!
|
97
|
+
blob_name = if RailsConnector::BlobMapping.exists?
|
98
|
+
RailsConnector::BlobMapping.get_fingerprint("#{name}.jsonObjClassDict")
|
99
|
+
else
|
100
|
+
"#{name}.jsonObjClassDict"
|
101
|
+
end
|
102
|
+
|
103
|
+
RailsConnector::Blob.find_without_excluded_blob_data(blob_name)
|
104
|
+
end
|
105
|
+
|
106
|
+
return {} unless blob && blob.blob_data?
|
107
|
+
|
108
|
+
JSON.parse(blob.blob_data)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def load_blob_data #:nodoc:
|
114
|
+
return if @blob_data
|
115
|
+
|
116
|
+
@blob_data = self.class.read_blob_data(self.name)
|
117
|
+
|
118
|
+
# reset depending instance variables
|
119
|
+
@mandatory_custom_attributes = @mandatory_attributes = nil
|
120
|
+
end
|
121
|
+
|
122
|
+
def build_mandatory_attribute_arrays #:nodoc:
|
123
|
+
return if @mandatory_attributes
|
124
|
+
|
125
|
+
load_blob_data
|
126
|
+
|
127
|
+
@mandatory_custom_attributes = []
|
128
|
+
@mandatory_attributes = []
|
129
|
+
(@blob_data['mandatoryAttributes'] || []).each do |attr|
|
130
|
+
attr_name = attr.to_s
|
131
|
+
if self.custom_attribute?(attr_name)
|
132
|
+
@mandatory_custom_attributes << attr_name
|
133
|
+
else
|
134
|
+
# only modify built-in attributes; i.e. `validFrom` will become `valid_from`
|
135
|
+
attr_name = attr_name.underscore
|
136
|
+
end
|
137
|
+
@mandatory_attributes << attr_name
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module RailsConnector
|
3
|
+
|
4
|
+
# This class allows us to read out the version and
|
5
|
+
# the reminder information of an Obj
|
6
|
+
class ObjectWithMetaData < RailsConnector::AbstractModel #:nodoc:
|
7
|
+
|
8
|
+
# If we name the class Object, conflicts with the plain Ruby
|
9
|
+
# objects inside the RailsConnector will occur.
|
10
|
+
def self.table_name
|
11
|
+
"#{table_name_prefix}" "objects"
|
12
|
+
end
|
13
|
+
|
14
|
+
self.primary_key = :object_id
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/infopark_reactor.gemspec
CHANGED
@@ -18,12 +18,12 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
-
s.require_paths = ["lib"
|
21
|
+
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency 'rails', '>= 3.0.10', '<= 4.
|
24
|
-
s.add_dependency 'infopark_reactor_migrations', '>= 1.7.2'
|
23
|
+
s.add_dependency 'rails', '>= 3.0.10', '<= 4.2.0'
|
25
24
|
#s.add_dependency 'infopark_rails_connector'
|
26
|
-
s.add_dependency '
|
25
|
+
s.add_dependency 'nokogiri'
|
26
|
+
s.add_dependency 'term-ansicolor'
|
27
27
|
|
28
28
|
s.add_development_dependency 'rspec'
|
29
29
|
s.add_development_dependency 'yard'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Cm
|
3
|
+
module Generators
|
4
|
+
class MigrationGenerator < Rails::Generators::NamedBase
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
def self.next_migration_number(dirname)
|
7
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
8
|
+
end
|
9
|
+
|
10
|
+
source_root File.expand_path('../templates', __FILE__)
|
11
|
+
def create_migration_file
|
12
|
+
migration_template "template.rb", "cm/migrate/#{file_name}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/infopark_reactor.rb
CHANGED
@@ -17,10 +17,43 @@ module Reactor
|
|
17
17
|
::Rails::VERSION::MAJOR == 4 && ::Rails::VERSION::MINOR == 0
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.rails4_1?
|
21
|
+
::Rails::VERSION::MAJOR == 4 && ::Rails::VERSION::MINOR == 1
|
22
|
+
end
|
23
|
+
|
20
24
|
def self.rails4_0_ge6?
|
21
25
|
::Rails::VERSION::MAJOR == 4 && ::Rails::VERSION::MINOR == 0 && ::Rails::VERSION::TINY >= 6
|
22
26
|
end
|
23
27
|
end
|
28
|
+
# require config
|
29
|
+
require 'reactor/configuration'
|
30
|
+
|
31
|
+
|
32
|
+
# require components
|
33
|
+
require 'reactor/cm/bridge'
|
34
|
+
require 'reactor/cm/language'
|
35
|
+
require 'reactor/cm/object_base'
|
36
|
+
require 'reactor/cm/user'
|
37
|
+
require 'reactor/cm/attribute'
|
38
|
+
require 'reactor/cm/obj'
|
39
|
+
require 'reactor/cm/obj_class'
|
40
|
+
require 'reactor/cm/link'
|
41
|
+
require 'reactor/cm/group'
|
42
|
+
require 'reactor/cm/editorial_group'
|
43
|
+
require 'reactor/cm/live_group'
|
44
|
+
require 'reactor/cm/workflow'
|
45
|
+
require 'reactor/cm/log_entry'
|
46
|
+
require 'reactor/cm/channel'
|
47
|
+
|
48
|
+
# require main class
|
49
|
+
require 'reactor/migration'
|
50
|
+
|
51
|
+
# require misc
|
52
|
+
require 'reactor/cm/xml_request_error'
|
53
|
+
require 'reactor/cm/missing_credentials'
|
54
|
+
|
55
|
+
# require public tools
|
56
|
+
require 'reactor/tools/uploader'
|
24
57
|
|
25
58
|
# require exceptions
|
26
59
|
require 'reactor/already_released'
|
@@ -37,10 +70,11 @@ require 'reactor/rc_independent'
|
|
37
70
|
require 'reactor/sudo'
|
38
71
|
require 'reactor/workflow'
|
39
72
|
require 'reactor/streaming_upload'
|
73
|
+
require 'reactor/rails_connector_meta'
|
40
74
|
|
41
75
|
# require rails integration
|
42
76
|
require 'reactor/session'
|
43
77
|
require 'reactor/session/user'
|
44
78
|
|
45
79
|
# require engine
|
46
|
-
require File.expand_path('../engine', __FILE__) if defined?(Rails)
|
80
|
+
require File.expand_path('../reactor/engine', __FILE__) if defined?(Rails)
|
data/lib/reactor/attributes.rb
CHANGED
@@ -105,7 +105,7 @@ module Reactor
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
[:
|
108
|
+
[:contentType].each do |attribute|
|
109
109
|
writers << attribute.to_sym
|
110
110
|
writers << attribute.to_s.underscore.to_sym
|
111
111
|
end
|
@@ -268,13 +268,11 @@ module Reactor
|
|
268
268
|
end
|
269
269
|
|
270
270
|
def resolve_attribute_alias(key)
|
271
|
-
key = :body if key == :main_content
|
272
271
|
key
|
273
272
|
end
|
274
273
|
|
275
274
|
def key_to_attr(key)
|
276
275
|
@__attribute_map ||= {
|
277
|
-
:main_content => :blob,
|
278
276
|
:body => :blob,
|
279
277
|
:valid_until => :validUntil,
|
280
278
|
:valid_from => :validFrom,
|
@@ -337,7 +335,7 @@ module Reactor
|
|
337
335
|
def path=(*args) ; super ; end
|
338
336
|
|
339
337
|
def attribute_type(attr)
|
340
|
-
return :html if [:body, :blob
|
338
|
+
return :html if [:body, :blob].include?(attr.to_sym)
|
341
339
|
return :date if [:valid_from, :valid_until, :last_changed].include?(attr.to_sym)
|
342
340
|
return :string if [:name, :title, :obj_class, :permalink].include?(attr.to_sym)
|
343
341
|
return :multienum if [:channels].include?(attr.to_sym)
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Reactor
|
3
|
+
module Cm
|
4
|
+
class Attribute
|
5
|
+
def self.exists?(name)
|
6
|
+
begin
|
7
|
+
return Attribute.new.send(:get,name).ok?
|
8
|
+
rescue
|
9
|
+
return false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.instance(name)
|
14
|
+
attr = Attribute.new
|
15
|
+
attr.instance_variable_set('@name', name)
|
16
|
+
attr
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.get(name)
|
20
|
+
attr = Attribute.new
|
21
|
+
attr.send(:get,name)
|
22
|
+
attr
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.create(name, type)
|
26
|
+
attr = Attribute.new
|
27
|
+
attr.send(:create,name,type)
|
28
|
+
attr
|
29
|
+
end
|
30
|
+
|
31
|
+
def set(key, value)
|
32
|
+
@params[key.to_sym] = value
|
33
|
+
end
|
34
|
+
|
35
|
+
def save!
|
36
|
+
request = XmlRequest.prepare do |xml|
|
37
|
+
xml.where_key_tag!(base_name, 'name', @name)
|
38
|
+
xml.set_tag!(base_name) do
|
39
|
+
@params.each do |key, value|
|
40
|
+
xml.value_tag!(key.to_s, value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
response = request.execute!
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete!
|
48
|
+
request = XmlRequest.prepare do |xml|
|
49
|
+
xml.where_key_tag!(base_name, 'name', @name)
|
50
|
+
xml.tag!("#{base_name}-delete")
|
51
|
+
end
|
52
|
+
response = request.execute!
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
def base_name
|
57
|
+
'attribute'
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize
|
61
|
+
@params = {}
|
62
|
+
end
|
63
|
+
|
64
|
+
def get(name)
|
65
|
+
request = XmlRequest.prepare do |xml|
|
66
|
+
xml.where_key_tag!(base_name, 'name', name)
|
67
|
+
xml.get_key_tag!(base_name, 'name')
|
68
|
+
end
|
69
|
+
response = request.execute!
|
70
|
+
@name = name
|
71
|
+
response
|
72
|
+
end
|
73
|
+
|
74
|
+
def create(name, type)
|
75
|
+
request = XmlRequest.prepare do |xml|
|
76
|
+
xml.create_tag!(base_name) do
|
77
|
+
xml.tag!('name') do
|
78
|
+
xml.text!(name)
|
79
|
+
end
|
80
|
+
xml.tag!('type') do
|
81
|
+
xml.text!(type)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
response = request.execute!
|
86
|
+
@name = name
|
87
|
+
response
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|