infopark_reactor_migrations 1.9.1 → 1.10.0.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a79422bdeff7f67cd50cfa57de204d9c0a88ce52
4
- data.tar.gz: 920130097cd74911b52b2d52d48b6b080c3a73d8
3
+ metadata.gz: dd4d687fb9d13c8c3908e18c01355239178fc463
4
+ data.tar.gz: c8a1925bb6476696a2d813c52ebba7db17e6d99e
5
5
  SHA512:
6
- metadata.gz: 7ce8837352a635b9621460169c71d1be0c3c1d1f536d383f89cfdb4b7f669b78e2f5c5f22281b272fe4601fb6e5b5b68ed9422a99b59d4bc6106344a0fcf4d8c
7
- data.tar.gz: c8b0dc9d2627c00afe41ce0f289e730789a5f318113dc0d6e362b096efb284ffec7d212ab6db7b99bb608e5b32b13d1f979424d3405fea4f49e256282ba146d5
6
+ metadata.gz: 9e1317ce8a6af0e7ed4dedda994e2eca04dcd2920bb19fe8233f3ed07e336e150a827b4209eb3996ed7cf13d46cc5eaea1fd03bafcbd77aeacd4d0d83828d26e
7
+ data.tar.gz: 8eac7fa4e2b24be975206d700e337148215053f04a82da25a1c0b3e411a2b50d18a9c708da64a6132bef2df2e47ad0d8d75c3c3f2b99364ff7c52a5bef17c0e0
@@ -5,6 +5,8 @@ require 'reactor/cm/xml_request_error'
5
5
  require 'reactor/tools/xml_attributes'
6
6
  require 'reactor/tools/response_handler/string'
7
7
 
8
+ require 'reactor/cm/permissions'
9
+
8
10
  module Reactor
9
11
 
10
12
  module Cm
@@ -69,48 +71,16 @@ module Reactor
69
71
 
70
72
  end
71
73
 
74
+ include Permissions
75
+
72
76
  attribute :name, :except => [:set]
73
77
  attribute :display_title, :name => :displayTitle, :only => [:get]
74
78
  attribute :real_name, :name => :realName
75
79
  attribute :owner
76
80
  attribute :users, :type => :list
77
- attribute :global_permissions, :name => :globalPermissions, :type => :list
78
81
 
79
82
  primary_key :name
80
83
 
81
- # Returns true, if a global permission with the given +name+ exists, false otherwise.
82
- def global_permission?(name)
83
- self.global_permissions.include?(name.to_s)
84
- end
85
-
86
- # Add the given +permissions+ to the current set of group permissions.
87
- def grant_global_permissions!(permissions)
88
- permissions = permissions.kind_of?(Array) ? permissions : [permissions]
89
- permissions = self.global_permissions | permissions
90
-
91
- set_global_permissions!(permissions)
92
- end
93
-
94
- # Take away the given +permissions+ from the current set of group permissions.
95
- def revoke_global_permissions!(permissions)
96
- permissions = permissions.kind_of?(Array) ? permissions : [permissions]
97
- permissions = self.global_permissions - permissions
98
-
99
- set_global_permissions(permissions)
100
- end
101
-
102
- # Set the group permissions to the given +permissions+.
103
- def set_global_permissions!(permissions)
104
- request = XmlRequest.prepare do |xml|
105
- xml.where_key_tag!(base_name, self.class.primary_key, self.name)
106
- xml.set_key_tag!(base_name, self.class.xml_attribute(:global_permissions).name, permissions)
107
- end
108
-
109
- request.execute!
110
-
111
- self.global_permissions = permissions
112
- end
113
-
114
84
  # Returns true, if an user with the given +name+ exists, false otherwise.
115
85
  def user?(name)
116
86
  users.include?(name)
@@ -0,0 +1,44 @@
1
+ module Reactor
2
+ module Cm
3
+ module Permissions
4
+ def self.included(base)
5
+ base.instance_eval do
6
+ attribute :global_permissions, :name => :globalPermissions, :type => :list
7
+ end
8
+ end
9
+
10
+ # Returns true, if a global permission with the given +name+ exists, false otherwise.
11
+ def global_permission?(name)
12
+ self.global_permissions.include?(name.to_s)
13
+ end
14
+
15
+ # Add the given +permissions+ to the current set of group permissions.
16
+ def grant_global_permissions!(permissions)
17
+ permissions = permissions.kind_of?(Array) ? permissions : [permissions]
18
+ permissions = self.global_permissions | permissions
19
+
20
+ set_global_permissions!(permissions)
21
+ end
22
+
23
+ # Take away the given +permissions+ from the current set of group permissions.
24
+ def revoke_global_permissions!(permissions)
25
+ permissions = permissions.kind_of?(Array) ? permissions : [permissions]
26
+ permissions = self.global_permissions - permissions
27
+
28
+ set_global_permissions(permissions)
29
+ end
30
+
31
+ # Set the group permissions to the given +permissions+.
32
+ def set_global_permissions!(permissions)
33
+ request = XmlRequest.prepare do |xml|
34
+ xml.where_key_tag!(base_name, self.class.primary_key, self.name)
35
+ xml.set_key_tag!(base_name, self.class.xml_attribute(:global_permissions).name, permissions)
36
+ end
37
+
38
+ request.execute!
39
+
40
+ self.global_permissions = permissions
41
+ end
42
+ end
43
+ end
44
+ end
@@ -4,6 +4,8 @@ require 'reactor/configuration'
4
4
  require 'reactor/cm/language'
5
5
  require 'reactor/tools/xml_attributes'
6
6
 
7
+ require 'reactor/cm/permissions'
8
+
7
9
  module Reactor
8
10
 
9
11
  module Cm
@@ -20,6 +22,12 @@ module Reactor
20
22
  attribute :groups, :type => :list
21
23
  attribute :real_name, :name => :realName
22
24
 
25
+ include Permissions
26
+
27
+ def name
28
+ self.login
29
+ end
30
+
23
31
  def change_password(new_password)
24
32
  request = XmlRequest.prepare do |xml|
25
33
  xml.where_key_tag!(base_name, primary_key, primary_key_value)
@@ -35,6 +43,10 @@ module Reactor
35
43
  response.ok?
36
44
  end
37
45
 
46
+ def has_password?(password)
47
+ ::Reactor::Cm::User.new(self.login).has_password?(password)
48
+ end
49
+
38
50
  primary_key :login
39
51
 
40
52
  # Returns true if user is root, false otherwise
@@ -44,7 +56,7 @@ module Reactor
44
56
 
45
57
  # Creates a user with given login and sets its default group
46
58
  # Returns instance of the class for user with given login
47
- def self.create(login, default_group)
59
+ def self.create(login, default_group)
48
60
  super(login, {:login => login, :defaultGroup => default_group})
49
61
  end
50
62
 
@@ -54,6 +66,8 @@ module Reactor
54
66
 
55
67
  attribute :name
56
68
  attribute :groups, :type => :list
69
+ attribute :global_permissions, :name => :globalPermissions, :type => :list
70
+
57
71
 
58
72
  primary_key 'login'
59
73
 
@@ -61,6 +75,17 @@ module Reactor
61
75
  @name = name
62
76
  end
63
77
 
78
+ def has_password?(password)
79
+ request = XmlRequest.prepare do |xml|
80
+ xml.where_key_tag!(base_name, self.class.primary_key, self.name)
81
+ xml.get_tag!(base_name) do |xml3|
82
+ xml3.tag!('hasPassword', :password => password)
83
+ end
84
+ end
85
+ response = request.execute!
86
+ response.xpath('//hasPassword/text()') == '1'
87
+ end
88
+
64
89
  def is_root?
65
90
  request = XmlRequest.prepare do |xml|
66
91
  xml.where_key_tag!(base_name, self.class.primary_key, self.name)
@@ -76,6 +101,19 @@ module Reactor
76
101
  Reactor::Cm::Language.get(self.name)
77
102
  end
78
103
 
104
+ def global_permissions
105
+ xml_attribute = self.class.xml_attribute(:global_permissions)
106
+
107
+ request = XmlRequest.prepare do |xml|
108
+ xml.where_key_tag!(base_name, self.class.primary_key, self.name)
109
+ xml.get_key_tag!(base_name, xml_attribute.name)
110
+ end
111
+
112
+ response = request.execute!
113
+
114
+ self.class.response_handler.get(response, xml_attribute)
115
+ end
116
+
79
117
  def groups
80
118
  xml_attribute = self.class.xml_attribute(:groups)
81
119
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
3
  module Migrations
4
- VERSION = "1.9.1"
4
+ VERSION = "1.10.0.beta"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_reactor_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.10.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Przedmojski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -104,6 +104,7 @@ files:
104
104
  - lib/reactor/cm/obj.rb
105
105
  - lib/reactor/cm/obj_class.rb
106
106
  - lib/reactor/cm/object_base.rb
107
+ - lib/reactor/cm/permissions.rb
107
108
  - lib/reactor/cm/user.rb
108
109
  - lib/reactor/cm/workflow.rb
109
110
  - lib/reactor/cm/xml_attribute.rb
@@ -164,9 +165,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
165
  version: '0'
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
- - - '>='
168
+ - - '>'
168
169
  - !ruby/object:Gem::Version
169
- version: '0'
170
+ version: 1.3.1
170
171
  requirements: []
171
172
  rubyforge_project:
172
173
  rubygems_version: 2.0.14