cas_rest_client 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,4 +2,5 @@ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__))
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rest_client'
5
+ require 'yaml'
5
6
  require 'cas_rest_client/cas_rest_client.rb'
@@ -1,11 +1,13 @@
1
1
  class CasRestClient
2
+
2
3
  @cas_opts = nil
3
4
  @tgt = nil
4
5
  @cookies = nil
5
6
  DEFAULT_OPTIONS = {:use_cookies => true}
6
7
 
7
- def initialize(cas_opts)
8
- @cas_opts = DEFAULT_OPTIONS.merge(cas_opts)
8
+ def initialize(cas_opts = {})
9
+ @cas_opts = DEFAULT_OPTIONS.merge(get_cas_config).merge(cas_opts)
10
+
9
11
  begin
10
12
  get_tgt
11
13
  rescue RestClient::BadRequest => e
@@ -76,4 +78,20 @@ class CasRestClient
76
78
  @tgt = RestClient.post(opts.delete(:uri), opts).headers[:location]
77
79
  end
78
80
 
81
+ def get_cas_config
82
+ begin
83
+ cas_config = YAML.load_file("config/cas_rest_client.yml")
84
+ cas_config = cas_config[Rails.env] if defined?(Rails) and Rails.env
85
+
86
+ cas_config = cas_config.inject({}) do |options, (key, value)|
87
+ options[(key.to_sym rescue key) || key] = value
88
+ options
89
+ end
90
+ rescue Exception
91
+ cas_config = {}
92
+ end
93
+ cas_config
94
+ end
79
95
  end
96
+
97
+
metadata CHANGED
@@ -1,11 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cas_rest_client
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
- - 2
8
- version: "1.2"
8
+ - 3
9
+ version: "1.3"
9
10
  platform: ruby
10
11
  authors:
11
12
  - Antonio Marques, Roberto Klein
@@ -13,16 +14,18 @@ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-08-17 00:00:00 -03:00
17
+ date: 2010-09-21 00:00:00 -03:00
17
18
  default_executable:
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
20
21
  name: rest-client
21
22
  prerelease: false
22
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
23
25
  requirements:
24
26
  - - ">="
25
27
  - !ruby/object:Gem::Version
28
+ hash: 3
26
29
  segments:
27
30
  - 1
28
31
  - 4
@@ -53,23 +56,27 @@ rdoc_options: []
53
56
  require_paths:
54
57
  - lib
55
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
56
60
  requirements:
57
61
  - - ">="
58
62
  - !ruby/object:Gem::Version
63
+ hash: 3
59
64
  segments:
60
65
  - 0
61
66
  version: "0"
62
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
63
69
  requirements:
64
70
  - - ">="
65
71
  - !ruby/object:Gem::Version
72
+ hash: 3
66
73
  segments:
67
74
  - 0
68
75
  version: "0"
69
76
  requirements: []
70
77
 
71
78
  rubyforge_project:
72
- rubygems_version: 1.3.6
79
+ rubygems_version: 1.3.7
73
80
  signing_key:
74
81
  specification_version: 3
75
82
  summary: Rest client for services using CAS authentication.