Class: SafetyPin::JCR

Inherits:
Object
  • Object
show all
Defined in:
lib/safety_pin/jcr.rb

Class Method Summary collapse

Class Method Details

.dev_loginObject



38
39
40
# File 'lib/safety_pin/jcr.rb', line 38

def self.
  (:hostname => "http://localhost:4502", :username => "admin", :password => "cq4me")
end

.logged_in?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/safety_pin/jcr.rb', line 18

def self.logged_in?
  session.live?
end

.logged_out?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/safety_pin/jcr.rb', line 22

def self.logged_out?
  not logged_in?
end

.login(opts = {}) ⇒ Object



7
8
9
10
11
# File 'lib/safety_pin/jcr.rb', line 7

def self.(opts = {})
  repository = JcrUtils.get_repository(parse_hostname(opts[:hostname]))
  creds = SimpleCredentials.new(opts[:username], JString.new(opts[:password]).to_char_array)
  @@session = repository.(creds)
end

.logoutObject



13
14
15
16
# File 'lib/safety_pin/jcr.rb', line 13

def self.logout
  session.logout
  not session.live?
end

.parse_hostname(hostname) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/safety_pin/jcr.rb', line 30

def self.parse_hostname(hostname)
  if hostname.end_with?("/crx/server")
    hostname
  else
    hostname + "/crx/server"
  end
end

.sessionObject



26
27
28
# File 'lib/safety_pin/jcr.rb', line 26

def self.session
  @@session
end