infopark_reactor 1.26.1 → 1.27.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +25 -0
- data/.rubocop_todo.yml +363 -0
- data/Rakefile +10 -13
- data/app/models/rails_connector/abstract_obj.rb +2 -1
- data/config/routes.rb +0 -1
- data/infopark_reactor.gemspec +16 -15
- data/lib/generators/cm/migration/migration_generator.rb +4 -8
- data/lib/infopark_reactor.rb +43 -69
- data/lib/reactor/already_released.rb +1 -2
- data/lib/reactor/attributes.rb +92 -268
- data/lib/reactor/attributes/date_serializer.rb +20 -16
- data/lib/reactor/attributes/html_serializer.rb +6 -5
- data/lib/reactor/attributes/link_list_extender.rb +10 -8
- data/lib/reactor/attributes/link_list_from_accessor.rb +2 -1
- data/lib/reactor/attributes/link_list_from_attr_values.rb +2 -1
- data/lib/reactor/attributes/link_list_serializer.rb +8 -7
- data/lib/reactor/attributes_handlers.rb +164 -0
- data/lib/reactor/cache/permission.rb +6 -9
- data/lib/reactor/cache/user.rb +3 -6
- data/lib/reactor/cm/attribute.rb +16 -16
- data/lib/reactor/cm/attribute_group.rb +18 -21
- data/lib/reactor/cm/blob_too_small_error.rb +2 -2
- data/lib/reactor/cm/bridge.rb +6 -9
- data/lib/reactor/cm/channel.rb +3 -4
- data/lib/reactor/cm/editorial_group.rb +2 -9
- data/lib/reactor/cm/group.rb +30 -43
- data/lib/reactor/cm/job.rb +23 -25
- data/lib/reactor/cm/language.rb +21 -22
- data/lib/reactor/cm/link.rb +38 -40
- data/lib/reactor/cm/live_group.rb +2 -9
- data/lib/reactor/cm/log_entry.rb +22 -21
- data/lib/reactor/cm/missing_credentials.rb +3 -2
- data/lib/reactor/cm/multi_xml_request.rb +22 -25
- data/lib/reactor/cm/obj.rb +159 -154
- data/lib/reactor/cm/obj_class.rb +52 -51
- data/lib/reactor/cm/object_base.rb +26 -21
- data/lib/reactor/cm/permissions.rb +7 -7
- data/lib/reactor/cm/user.rb +43 -51
- data/lib/reactor/cm/workflow.rb +11 -12
- data/lib/reactor/cm/xml_attribute.rb +10 -19
- data/lib/reactor/cm/xml_markup.rb +7 -10
- data/lib/reactor/cm/xml_multi_request_error.rb +1 -3
- data/lib/reactor/cm/xml_request.rb +21 -29
- data/lib/reactor/cm/xml_request_error.rb +1 -3
- data/lib/reactor/cm/xml_response.rb +8 -16
- data/lib/reactor/cm/xml_single_request_error.rb +3 -5
- data/lib/reactor/configuration.rb +1 -3
- data/lib/reactor/engine.rb +5 -10
- data/lib/reactor/legacy.rb +6 -7
- data/lib/reactor/link/external.rb +8 -5
- data/lib/reactor/link/internal.rb +8 -5
- data/lib/reactor/link/temporary_link.rb +16 -17
- data/lib/reactor/main.rb +11 -15
- data/lib/reactor/migration.rb +52 -53
- data/lib/reactor/no_working_version.rb +1 -2
- data/lib/reactor/not_permitted.rb +1 -2
- data/lib/reactor/permission.rb +36 -38
- data/lib/reactor/persistence.rb +104 -178
- data/lib/reactor/plans/common_attribute.rb +7 -7
- data/lib/reactor/plans/common_attribute_group.rb +6 -6
- data/lib/reactor/plans/common_channel.rb +6 -6
- data/lib/reactor/plans/common_group.rb +7 -14
- data/lib/reactor/plans/common_job.rb +6 -6
- data/lib/reactor/plans/common_obj_class.rb +11 -11
- data/lib/reactor/plans/create_attribute.rb +1 -3
- data/lib/reactor/plans/create_attribute_group.rb +1 -3
- data/lib/reactor/plans/create_channel.rb +2 -3
- data/lib/reactor/plans/create_group.rb +3 -10
- data/lib/reactor/plans/create_job.rb +3 -4
- data/lib/reactor/plans/create_obj.rb +12 -14
- data/lib/reactor/plans/create_obj_class.rb +1 -2
- data/lib/reactor/plans/delete_attribute.rb +1 -3
- data/lib/reactor/plans/delete_attribute_group.rb +2 -4
- data/lib/reactor/plans/delete_channel.rb +3 -6
- data/lib/reactor/plans/delete_group.rb +2 -9
- data/lib/reactor/plans/delete_job.rb +3 -5
- data/lib/reactor/plans/delete_obj.rb +3 -4
- data/lib/reactor/plans/delete_obj_class.rb +1 -2
- data/lib/reactor/plans/prepared.rb +3 -4
- data/lib/reactor/plans/rename_group.rb +4 -11
- data/lib/reactor/plans/rename_obj_class.rb +1 -2
- data/lib/reactor/plans/update_attribute.rb +1 -3
- data/lib/reactor/plans/update_attribute_group.rb +2 -4
- data/lib/reactor/plans/update_group.rb +2 -9
- data/lib/reactor/plans/update_job.rb +4 -8
- data/lib/reactor/plans/update_obj.rb +6 -7
- data/lib/reactor/plans/update_obj_class.rb +0 -2
- data/lib/reactor/rc_independent.rb +0 -1
- data/lib/reactor/session.rb +27 -31
- data/lib/reactor/session/observers.rb +3 -5
- data/lib/reactor/session/user.rb +6 -7
- data/lib/reactor/session_helper/auth_filter.rb +9 -0
- data/lib/reactor/session_helper/auth_helper.rb +24 -0
- data/lib/reactor/session_helper/rsession_helper.rb +16 -0
- data/lib/reactor/session_helper/session_state.rb +31 -0
- data/lib/reactor/streaming_upload.rb +0 -1
- data/lib/reactor/sudo.rb +2 -3
- data/lib/reactor/support/link_matcher.rb +8 -7
- data/lib/reactor/tools/migrator.rb +30 -35
- data/lib/reactor/tools/response_handler/xml_attribute.rb +27 -33
- data/lib/reactor/tools/smart_xml_logger.rb +20 -22
- data/lib/reactor/tools/sower.rb +22 -23
- data/lib/reactor/tools/uploader.rb +12 -17
- data/lib/reactor/tools/versioner.rb +29 -30
- data/lib/reactor/tools/where_query.rb +11 -14
- data/lib/reactor/tools/workflow_generator.rb +26 -28
- data/lib/reactor/tools/xml_attributes.rb +7 -14
- data/lib/reactor/tools/xpath_extractor.rb +2 -1
- data/lib/reactor/validations.rb +20 -16
- data/lib/reactor/version.rb +1 -2
- data/lib/reactor/workflow.rb +10 -33
- data/lib/reactor/workflow/comment.rb +28 -0
- data/lib/reactor/workflow/empty.rb +0 -1
- data/lib/reactor/workflow/standard.rb +4 -3
- data/lib/tasks/cm_migrate.rake +3 -3
- data/lib/tasks/cm_seeds.rake +9 -16
- metadata +64 -28
- data/app/models/rails_connector/abstract_model.rb +0 -7
- data/app/models/rails_connector/attribute.rb +0 -94
- data/app/models/rails_connector/blob_mapping.rb +0 -16
- data/app/models/rails_connector/channel.rb +0 -41
- data/app/models/rails_connector/content.rb +0 -12
- data/app/models/rails_connector/job.rb +0 -14
- data/app/models/rails_connector/obj_class.rb +0 -158
- data/app/models/rails_connector/obj_class_attr.rb +0 -5
- data/app/models/rails_connector/object_with_meta_data.rb +0 -18
- data/lib/rails_connector/meta/eager_loader.rb +0 -91
- data/lib/reactor/rails_connector_meta.rb +0 -149
- data/lib/reactor/session_helper.rb +0 -72
@@ -1,22 +1,20 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
1
|
module Reactor
|
4
2
|
class Session
|
5
3
|
module Observers
|
6
4
|
class PermissionCacheInvalidator
|
7
|
-
def update(user_name, new_login=false)
|
5
|
+
def update(user_name, new_login = false)
|
8
6
|
Reactor::Cache::Permission.instance.invalidate(user_name) if new_login
|
9
7
|
end
|
10
8
|
end
|
11
9
|
|
12
10
|
class UserCacheInvalidator
|
13
|
-
def update(user_name, new_login=false)
|
11
|
+
def update(user_name, new_login = false)
|
14
12
|
Reactor::Cache::User.instance.invalidate(user_name) if new_login
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
16
|
class CmsAccessDataPropagator
|
19
|
-
def update(user_name,
|
17
|
+
def update(user_name, _new_login = false)
|
20
18
|
Reactor::Configuration.xml_access[:username] = user_name
|
21
19
|
end
|
22
20
|
end
|
data/lib/reactor/session/user.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
|
2
|
-
require 'reactor/cm/user'
|
1
|
+
require "reactor/cm/user"
|
3
2
|
|
4
3
|
module Reactor
|
5
4
|
class Session
|
6
5
|
class User
|
7
6
|
def initialize(user_name)
|
8
7
|
# Rails.logger.debug "Reading user #{user_name} from CM"
|
9
|
-
user
|
10
|
-
@user_name= user_name
|
11
|
-
@groups
|
8
|
+
user = Reactor::Cm::User.new(user_name)
|
9
|
+
@user_name = user_name
|
10
|
+
@groups = user.groups
|
12
11
|
@language = user.language
|
13
|
-
@superuser= user.is_root?
|
14
|
-
@email
|
12
|
+
@superuser = user.is_root?
|
13
|
+
@email = user.email
|
15
14
|
end
|
16
15
|
|
17
16
|
def to_s
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Reactor
|
2
|
+
module SessionHelper
|
3
|
+
module AuthHelper
|
4
|
+
def rsession_auth
|
5
|
+
if RailsConnector::Configuration.mode == :editor && (jsessionid = cookies["JSESSIONID"]).present?
|
6
|
+
# Why the gsub? It's a dirty hack! Reason: JSESSIONIDs are unescaped
|
7
|
+
# when read through Rails and hence all + are converted into spaces.
|
8
|
+
# CM Kernel though stores escaped IDs.
|
9
|
+
# From the possible generated characters only the + seems to be
|
10
|
+
# problematic.
|
11
|
+
# CGI.escape would be the solution, but it's deprecated
|
12
|
+
# URI.escape does too much
|
13
|
+
jsessionid.tr!(" ", "+")
|
14
|
+
|
15
|
+
Rails.logger.info "Trying to log in at #{Reactor::Configuration.xml_access[:host]}:#{Reactor::Configuration.xml_access[:port]} with JSESSIONID=#{jsessionid}."
|
16
|
+
rsession.login(jsessionid)
|
17
|
+
Rails.logger.info %(Logged in as "#{rsession.user_name}".) if rsession.user?
|
18
|
+
else
|
19
|
+
rsession.destroy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Reactor
|
2
|
+
module SessionHelper
|
3
|
+
module RsessionHelper
|
4
|
+
def rsession
|
5
|
+
@__rsession ||= RsessionHelper.from_session(session)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.from_session(session)
|
9
|
+
Reactor::Session.new(
|
10
|
+
# This passes the very powerfull rails session object
|
11
|
+
SessionState.new(session)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Reactor
|
2
|
+
module SessionHelper
|
3
|
+
class SessionState < Reactor::Session::State
|
4
|
+
USER_NAME_KEY = "rsession$user_name".freeze
|
5
|
+
SESSION_ID_KEY = "rsession$session_id".freeze
|
6
|
+
|
7
|
+
def initialize(session)
|
8
|
+
self.session = session
|
9
|
+
super(session[USER_NAME_KEY], session[SESSION_ID_KEY])
|
10
|
+
end
|
11
|
+
|
12
|
+
def user_name=(new_user_name)
|
13
|
+
super
|
14
|
+
# this is a little bit of magic: it will trigger
|
15
|
+
# the the session serialization routine, and will
|
16
|
+
# persist the new information after processing the request
|
17
|
+
session[USER_NAME_KEY] = new_user_name
|
18
|
+
end
|
19
|
+
|
20
|
+
def session_id=(new_session_id)
|
21
|
+
super
|
22
|
+
# see above
|
23
|
+
session[SESSION_ID_KEY] = new_session_id
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
attr_accessor :session
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/reactor/sudo.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
2
|
module Sudo
|
4
|
-
def self.su(other_user_name
|
3
|
+
def self.su(other_user_name)
|
5
4
|
rsession = Reactor::Session.instance
|
6
5
|
current_user_name = rsession.user_name
|
7
6
|
rsession.user_name = other_user_name
|
8
7
|
yield
|
9
8
|
ensure
|
10
|
-
rsession.user_name = current_user_name ||
|
9
|
+
rsession.user_name = current_user_name || "root"
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
2
|
module Support
|
4
3
|
class LinkMatcher
|
@@ -11,27 +10,29 @@ module Reactor
|
|
11
10
|
(match[:action] == "index") &&
|
12
11
|
(match[:controller] == "rails_connector/cms_dispatch") &&
|
13
12
|
((match[:id].present? && RailsConnector::AbstractObj.exists?(match[:id].to_i)) ||
|
14
|
-
(match[:permalink].present? && RailsConnector::AbstractObj.exists?(:
|
13
|
+
(match[:permalink].present? && RailsConnector::AbstractObj.exists?(permalink: match[:permalink])))
|
15
14
|
rescue ActionController::RoutingError
|
16
|
-
|
15
|
+
false
|
17
16
|
end
|
18
17
|
|
19
18
|
def rewrite_url
|
20
19
|
match = match_url
|
21
20
|
|
22
21
|
if match[:permalink].present?
|
23
|
-
append_fragment_and_query RailsConnector::AbstractObj.find_by_permalink(match[:permalink]).path
|
22
|
+
append_fragment_and_query RailsConnector::AbstractObj.find_by_permalink(match[:permalink]).path
|
24
23
|
elsif match[:id].present?
|
25
24
|
append_fragment_and_query RailsConnector::AbstractObj.find(match[:id].to_i).path
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
29
|
+
|
30
30
|
def match_url
|
31
|
-
return {} if
|
32
|
-
|
31
|
+
return {} if /\A[a-z0-9]*:/.match?(@url) # ignore fully qualified urls
|
32
|
+
|
33
|
+
relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
|
33
34
|
url = @url.clone
|
34
|
-
url.gsub!(/^#{Regexp.escape(relative_url_root)}/,
|
35
|
+
url.gsub!(/^#{Regexp.escape(relative_url_root)}/, "") if relative_url_root.present?
|
35
36
|
Rails.application.routes.recognize_path(url)
|
36
37
|
end
|
37
38
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'reactor/tools/versioner'
|
1
|
+
require "reactor/tools/versioner"
|
3
2
|
|
4
3
|
module Reactor
|
5
4
|
# Class responsible for running a single migration, a helper for Migrator
|
@@ -18,47 +17,42 @@ module Reactor
|
|
18
17
|
|
19
18
|
def run
|
20
19
|
return down if @direction.to_sym == :down
|
21
|
-
|
20
|
+
|
21
|
+
up
|
22
22
|
end
|
23
23
|
|
24
24
|
def up
|
25
|
-
if @versioner.applied?(@version)
|
25
|
+
if @versioner.applied?(@version)
|
26
26
|
puts "Migrating up: #{@name} (#{@filename}) already applied, skipping"
|
27
|
-
|
27
|
+
true
|
28
28
|
else
|
29
29
|
result = class_name.send(:up) and @versioner.add(@version)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
if result
|
31
|
+
class_name.contained.each do |version|
|
32
|
+
puts "#{class_name} contains migration #{version}"
|
33
|
+
# @versioner.add(version) # not neccesary!
|
34
|
+
end
|
35
|
+
end
|
34
36
|
result
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
def down
|
39
41
|
result = class_name.send(:down) and @versioner.remove(@version)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
if result
|
43
|
+
class_name.contained.each do |version|
|
44
|
+
puts "#{class_name} contains migration #{version}"
|
45
|
+
@versioner.remove(version)
|
46
|
+
end
|
47
|
+
end
|
44
48
|
result
|
45
49
|
end
|
46
50
|
|
47
51
|
def class_name
|
48
|
-
|
52
|
+
Kernel.const_get(@name)
|
49
53
|
end
|
50
54
|
|
51
|
-
|
52
|
-
@name
|
53
|
-
end
|
54
|
-
|
55
|
-
def version
|
56
|
-
@version
|
57
|
-
end
|
58
|
-
|
59
|
-
def filename
|
60
|
-
@filename
|
61
|
-
end
|
55
|
+
attr_reader :name, :version, :filename
|
62
56
|
end
|
63
57
|
|
64
58
|
# Migrator is responsible for running migrations.
|
@@ -77,10 +71,10 @@ module Reactor
|
|
77
71
|
# and target_version (an integer or nil).
|
78
72
|
#
|
79
73
|
# Used by a rake task.
|
80
|
-
def initialize(migrations_path, target_version=nil)
|
74
|
+
def initialize(migrations_path, target_version = nil)
|
81
75
|
@migrations_path = migrations_path
|
82
76
|
@target_version = target_version.to_i unless target_version.nil?
|
83
|
-
@target_version =
|
77
|
+
@target_version = 99_999_999_999_999 if target_version.nil?
|
84
78
|
@versioner = Versioner.instance
|
85
79
|
end
|
86
80
|
|
@@ -88,25 +82,26 @@ module Reactor
|
|
88
82
|
# Ouputs current version when done
|
89
83
|
def migrate
|
90
84
|
return up if @target_version.to_i > current_version.to_i
|
91
|
-
|
85
|
+
|
86
|
+
down
|
92
87
|
end
|
93
88
|
|
94
89
|
def up
|
95
|
-
rem_migrations = migrations.reject do |version,
|
90
|
+
rem_migrations = migrations.reject do |version, _name, _file|
|
96
91
|
version.to_i > @target_version.to_i or applied?(version)
|
97
92
|
end
|
98
93
|
run(rem_migrations, :up)
|
99
94
|
end
|
100
95
|
|
101
96
|
def down
|
102
|
-
rem_migrations = migrations.reject do |version,
|
103
|
-
version.to_i <= @target_version.to_i or
|
97
|
+
rem_migrations = migrations.reject do |version, _name, _file|
|
98
|
+
version.to_i <= @target_version.to_i or !applied?(version)
|
104
99
|
end
|
105
100
|
run(rem_migrations.reverse, :down)
|
106
101
|
end
|
107
102
|
|
108
103
|
def migrations
|
109
|
-
|
104
|
+
Dir["#{@migrations_path}/[0-9]*_*.rb"].sort.collect do |file|
|
110
105
|
version, name = file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first
|
111
106
|
[version, name, file]
|
112
107
|
end
|
@@ -124,12 +119,12 @@ module Reactor
|
|
124
119
|
begin
|
125
120
|
rem_migrations.each do |version, name, file|
|
126
121
|
migration = MigrationProxy.new(@versioner, name.camelize, version, direction, file)
|
127
|
-
puts "Migrating #{direction
|
128
|
-
migration.load_migration and migration.run or raise "Migrating #{direction
|
122
|
+
puts "Migrating #{direction}: #{migration.name} (#{migration.filename})"
|
123
|
+
migration.load_migration and migration.run or raise "Migrating #{direction}: #{migration.name} (#{migration.filename}) failed"
|
129
124
|
end
|
130
125
|
ensure
|
131
126
|
puts "At version: " + @versioner.current_version.to_s
|
132
|
-
puts "WARNING: Could not store applied migrations!"
|
127
|
+
puts "WARNING: Could not store applied migrations!" unless @versioner.store
|
133
128
|
end
|
134
129
|
end
|
135
130
|
end
|
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'reactor/tools/xpath_extractor'
|
1
|
+
require "reactor/tools/xpath_extractor"
|
3
2
|
module Reactor
|
4
|
-
|
5
3
|
module ResponseHandler
|
6
|
-
|
7
4
|
class XmlAttribute
|
8
|
-
attr_accessor :response
|
9
|
-
|
10
|
-
|
5
|
+
attr_accessor :response, :context
|
6
|
+
|
11
7
|
def get(response, attribute)
|
12
8
|
@response = response
|
13
9
|
@context = context
|
@@ -17,13 +13,13 @@ module Reactor
|
|
17
13
|
|
18
14
|
method_name = "extract_#{type}"
|
19
15
|
|
20
|
-
|
16
|
+
send(method_name, name)
|
21
17
|
end
|
22
18
|
|
23
19
|
def multiple(elem, attributes)
|
24
20
|
values = {}
|
25
21
|
attributes.each do |attribute|
|
26
|
-
values[attribute.name] =
|
22
|
+
values[attribute.name] = get(elem, attribute)
|
27
23
|
end
|
28
24
|
values
|
29
25
|
end
|
@@ -32,18 +28,18 @@ module Reactor
|
|
32
28
|
|
33
29
|
# Extracts a string value with the given +name+ and returns a string.
|
34
30
|
def extract_string(name)
|
35
|
-
result =
|
36
|
-
if result.
|
37
|
-
|
31
|
+
result = xpath(".//#{name}/text()")
|
32
|
+
if result.is_a?(Array)
|
33
|
+
result.first
|
38
34
|
else
|
39
|
-
|
35
|
+
result.to_s
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
43
39
|
# Extracts a list value with the given +name+ and returns an array of strings.
|
44
40
|
def extract_list(name)
|
45
|
-
result =
|
46
|
-
result = result.
|
41
|
+
result = xpath(".//#{name}/listitem/text()")
|
42
|
+
result = result.is_a?(Array) ? result : [result]
|
47
43
|
|
48
44
|
result.map(&:to_s)
|
49
45
|
end
|
@@ -51,38 +47,39 @@ module Reactor
|
|
51
47
|
# This shit will break with the slightest change of the CM.
|
52
48
|
def extract_signaturelist(name)
|
53
49
|
signatures = []
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
xpath(".//#{name}/").each do |potential_signature|
|
51
|
+
next unless potential_signature.name.to_s == "listitem"
|
52
|
+
|
53
|
+
attribute = potential_signature.children.first.text.to_s
|
54
|
+
group = potential_signature.children.last.text.to_s
|
55
|
+
signatures << { attribute: attribute, group: group }
|
60
56
|
end
|
61
57
|
signatures
|
62
58
|
end
|
63
59
|
|
64
60
|
protected
|
61
|
+
|
65
62
|
def node
|
66
63
|
# TODO: clean up this bullshit
|
67
|
-
if
|
68
|
-
|
64
|
+
if response.is_a?(Reactor::Cm::XmlResponse)
|
65
|
+
response.xml
|
69
66
|
else
|
70
|
-
|
67
|
+
response
|
71
68
|
end
|
72
69
|
end
|
73
70
|
|
74
71
|
def xpath(expr)
|
75
|
-
Reactor::XPathExtractor.new(
|
72
|
+
Reactor::XPathExtractor.new(node).match(expr)
|
76
73
|
end
|
77
74
|
|
78
75
|
def extract_schedule(name)
|
79
76
|
schedule_entries = []
|
80
|
-
|
77
|
+
response.xpath("//#{name}/listitem").each do |potential_schedule|
|
81
78
|
entry = {}
|
82
|
-
potential_schedule.children.find_all {|c| c.name == "dictitem" }.each do |item|
|
83
|
-
key = item.children.find {|c| c.name == "key" }.text
|
84
|
-
values_item = item.children.find {|c| c.name == "value" }
|
85
|
-
values = values_item.children.find_all { |c| c.name == "listitem" }.map {|i| i.text.to_s }
|
79
|
+
potential_schedule.children.find_all { |c| c.name == "dictitem" }.each do |item|
|
80
|
+
key = item.children.find { |c| c.name == "key" }.text
|
81
|
+
values_item = item.children.find { |c| c.name == "value" }
|
82
|
+
values = values_item.children.find_all { |c| c.name == "listitem" }.map { |i| i.text.to_s }
|
86
83
|
entry[key.to_sym] = values
|
87
84
|
end
|
88
85
|
schedule_entries << entry
|
@@ -90,9 +87,6 @@ module Reactor
|
|
90
87
|
|
91
88
|
schedule_entries
|
92
89
|
end
|
93
|
-
|
94
90
|
end
|
95
|
-
|
96
91
|
end
|
97
|
-
|
98
92
|
end
|