Class: SafetyPin::JCR
- Inherits:
-
Object
- Object
- SafetyPin::JCR
- Defined in:
- lib/safety_pin/jcr.rb
Class Method Summary collapse
- .dev_login ⇒ Object
- .logged_in? ⇒ Boolean
- .logged_out? ⇒ Boolean
- .login(opts = {}) ⇒ Object
- .logout ⇒ Object
- .parse_hostname(hostname) ⇒ Object
- .session ⇒ Object
Class Method Details
.dev_login ⇒ Object
38 39 40 |
# File 'lib/safety_pin/jcr.rb', line 38 def self.dev_login login(:hostname => "http://localhost:4502", :username => "admin", :password => "cq4me") end |
.logged_in? ⇒ Boolean
18 19 20 |
# File 'lib/safety_pin/jcr.rb', line 18 def self.logged_in? session.live? end |
.logged_out? ⇒ 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.login(opts = {}) repository = JcrUtils.get_repository(parse_hostname(opts[:hostname])) creds = SimpleCredentials.new(opts[:username], JString.new(opts[:password]).to_char_array) @@session = repository.login(creds) end |
.logout ⇒ Object
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 |
.session ⇒ Object
26 27 28 |
# File 'lib/safety_pin/jcr.rb', line 26 def self.session @@session end |