simple_crowd 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,26 +1,28 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- doc
20
- pkg
21
- .idea
22
- .yardoc
23
- .bundle
24
-
25
- ## PROJECT::SPECIFIC
26
- test/crowd_config.yml
1
+ Gemfile.lock
2
+ ## MAC OS
3
+ .DS_Store
4
+
5
+ ## TEXTMATE
6
+ *.tmproj
7
+ tmtags
8
+
9
+ ## EMACS
10
+ *~
11
+ \#*
12
+ .\#*
13
+
14
+ ## VIM
15
+ *.swp
16
+
17
+ ## PROJECT::GENERAL
18
+ coverage
19
+ rdoc
20
+ doc
21
+ pkg
22
+ .idea
23
+ .yardoc
24
+ .bundle
25
+ .rvmrc
26
+
27
+ ## PROJECT::SPECIFIC
28
+ test/crowd_config.yml
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in simple_crowd.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem 'i18n'
8
+ end
data/Rakefile CHANGED
@@ -4,16 +4,17 @@ require 'rake/rdoctask'
4
4
  require 'bundler'
5
5
  Bundler::GemHelper.install_tasks
6
6
 
7
- desc 'Run tests for InheritedResources.'
7
+ desc 'Run tests for simple_crowd.'
8
8
  Rake::TestTask.new(:test) do |t|
9
- t.pattern = 'test/**/*_test.rb'
9
+ t.libs << 'test'
10
+ t.pattern = 'test/**/test_*.rb'
10
11
  t.verbose = true
11
12
  end
12
13
 
13
- desc 'Generate documentation for InheritedResources.'
14
+ desc 'Generate documentation for simple_crowd.'
14
15
  Rake::RDocTask.new(:rdoc) do |rdoc|
15
16
  rdoc.rdoc_dir = 'rdoc'
16
- rdoc.title = 'InheritedResources'
17
+ rdoc.title = 'SimpleCrowd'
17
18
  rdoc.options << '--line-numbers' << '--inline-source'
18
19
  rdoc.rdoc_files.include('README.rdoc')
19
20
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -1,7 +1,10 @@
1
1
  module SimpleCrowd
2
2
  class Client
3
+
4
+ attr_reader :options
5
+
3
6
  def initialize options = {}
4
- @options = SimpleCrowd.soap_options SimpleCrowd.options.merge(options)
7
+ @options = SimpleCrowd.options options
5
8
 
6
9
  # TODO: Fix error handling
7
10
  # Errors do not contained Exception info so we'll handle the errors ourselves
@@ -231,7 +234,7 @@ module SimpleCrowd
231
234
  raise CrowdError.new(response.soap_fault, response.to_hash[:fault]) if response.soap_fault?
232
235
  return response
233
236
  rescue CrowdError => e
234
- if retries && e.type?(:invalid_authorization_token_exception)
237
+ if retries > 0 && e.type?(:invalid_authorization_token_exception)
235
238
  # Clear token to force a refresh
236
239
  self.app_token = nil
237
240
  retries -= 1
@@ -1,3 +1,3 @@
1
1
  module SimpleCrowd
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.4"
3
3
  end
data/lib/simple_crowd.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'savon'
2
2
  require 'hashie'
3
+ require 'yaml'
3
4
  require 'forwardable'
4
5
  require 'simple_crowd/crowd_entity'
5
6
  require 'simple_crowd/crowd_error'
@@ -14,16 +15,13 @@ module SimpleCrowd
14
15
  def config &config_block
15
16
  config_block.call(options)
16
17
  end
17
- # SimpleCrowd default options
18
- def options
19
- @options ||= {
20
- :service_url => "http://localhost:8095/crowd/",
21
- :app_name => "crowd",
22
- :app_password => ""
23
- }
18
+
19
+ def options app_options = {}
20
+ c = soap_options.merge(default_crowd_options).merge(app_options) and
21
+ c.merge(:service_url => c[:service_url] + 'services/SecurityServer')
24
22
  end
25
- def soap_options base_options = self.options
26
- @soap_options ||= base_options.merge({
23
+ def soap_options
24
+ @soap_options ||= {
27
25
  :service_ns => "urn:SecurityServer",
28
26
  :service_namespaces => {
29
27
  'xmlns:auth' => 'http://authentication.integration.crowd.atlassian.com',
@@ -32,10 +30,22 @@ module SimpleCrowd
32
30
  'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
33
31
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
34
32
  }
35
- })
36
- @soap_options.merge!({:service_url => base_options[:service_url] + 'services/SecurityServer'})
33
+ }
34
+ end
35
+ def default_crowd_options
36
+ @default_crowd_options ||= {
37
+ :service_url => "http://localhost:8095/crowd/",
38
+ :app_name => "crowd",
39
+ :app_password => ""
40
+ }
41
+ defined?(IRB) ? @default_crowd_options.merge(config_file_options) : @default_crowd_options
42
+ end
43
+ def config_file_options
44
+ @config_file_options ||= begin
45
+ (File.exists?('config/crowd.yml') &&
46
+ yml = (YAML.load_file('config/crowd.yml')[ENV["RAILS_ENV"] || "development"] || {}) and
47
+ yml.symbolize_keys!) || {}
48
+ end
37
49
  end
38
50
  end
39
- end
40
-
41
-
51
+ end
data/simple_crowd.gemspec CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  test/test_simple_crowd.rb
41
41
  test/test_user.rb
42
42
  )
43
- s.homepage = %q{http://github.com/lapluviosilla/simple_crowd}
43
+ s.homepage = %q{http://github.com/thinkwell/simple_crowd}
44
44
  s.require_paths = ["lib"]
45
45
  s.rubygems_version = %q{1.5.0}
46
46
  s.summary = %q{Simple Atlassian Crowd client using REST and SOAP APIs where needed.}
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
51
51
  s.add_development_dependency(%q<forgery>, [">= 0"])
52
52
  s.add_development_dependency(%q<webmock>, [">= 0"])
53
53
  s.add_development_dependency(%q<rr>, [">= 0"])
54
+ s.add_development_dependency(%q<rake>, [">= 0"])
54
55
  s.add_runtime_dependency(%q<savon>, ["= 0.7.9"])
55
56
  s.add_runtime_dependency(%q<hashie>, ["= 1.0.0"])
56
57
  end
data/test/test_client.rb CHANGED
@@ -7,7 +7,7 @@ class TestClient < Test::Unit::TestCase
7
7
  @client = SimpleCrowd::Client.new({:service_url => CROWD_CONFIG['service_url'],
8
8
  :app_name => CROWD_CONFIG['app_name'],
9
9
  :app_password => CROWD_CONFIG['app_password']})
10
- @service_url = SimpleCrowd.soap_options({:service_url => CROWD_CONFIG['service_url']})[:service_url]
10
+ @service_url = @client.options[:service_url]
11
11
  reset_webmock
12
12
  end
13
13
  should "initialize" do
@@ -6,14 +6,14 @@ class TestSimpleCrowd < Test::Unit::TestCase
6
6
  @default_keys = [:service_url, :service_ns, :service_namespaces, :app_name, :app_password]
7
7
  end
8
8
  should "return options" do
9
- options = SimpleCrowd.soap_options
9
+ options = SimpleCrowd.options
10
10
  options.should_not be nil
11
11
  options.empty?.should be false
12
12
  @default_keys.each {|v| options[v].should_not be nil}
13
13
  end
14
14
 
15
15
  should "only have default options" do
16
- options = SimpleCrowd.soap_options
16
+ options = SimpleCrowd.options
17
17
  options.should_not be nil
18
18
  (options.keys - @default_keys).length.should == 0
19
19
  (@default_keys - options.keys).length.should == 0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_crowd
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 4
10
+ version: 1.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Strong
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-06 00:00:00 -05:00
19
- default_executable:
18
+ date: 2012-03-28 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: shoulda
@@ -103,9 +102,23 @@ dependencies:
103
102
  type: :development
104
103
  version_requirements: *id006
105
104
  - !ruby/object:Gem::Dependency
106
- name: savon
105
+ name: rake
107
106
  prerelease: false
108
107
  requirement: &id007 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ type: :development
117
+ version_requirements: *id007
118
+ - !ruby/object:Gem::Dependency
119
+ name: savon
120
+ prerelease: false
121
+ requirement: &id008 !ruby/object:Gem::Requirement
109
122
  none: false
110
123
  requirements:
111
124
  - - "="
@@ -117,11 +130,11 @@ dependencies:
117
130
  - 9
118
131
  version: 0.7.9
119
132
  type: :runtime
120
- version_requirements: *id007
133
+ version_requirements: *id008
121
134
  - !ruby/object:Gem::Dependency
122
135
  name: hashie
123
136
  prerelease: false
124
- requirement: &id008 !ruby/object:Gem::Requirement
137
+ requirement: &id009 !ruby/object:Gem::Requirement
125
138
  none: false
126
139
  requirements:
127
140
  - - "="
@@ -133,7 +146,7 @@ dependencies:
133
146
  - 0
134
147
  version: 1.0.0
135
148
  type: :runtime
136
- version_requirements: *id008
149
+ version_requirements: *id009
137
150
  description: |-
138
151
  Simple Atlassian Crowd client using REST and SOAP APIs where needed.
139
152
  Doesn't do any fancy object mapping, etc.
@@ -165,8 +178,7 @@ files:
165
178
  - test/test_client.rb
166
179
  - test/test_simple_crowd.rb
167
180
  - test/test_user.rb
168
- has_rdoc: true
169
- homepage: http://github.com/lapluviosilla/simple_crowd
181
+ homepage: http://github.com/thinkwell/simple_crowd
170
182
  licenses: []
171
183
 
172
184
  post_install_message:
@@ -195,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
207
  requirements: []
196
208
 
197
209
  rubyforge_project:
198
- rubygems_version: 1.6.2
210
+ rubygems_version: 1.8.17
199
211
  signing_key:
200
212
  specification_version: 3
201
213
  summary: Simple Atlassian Crowd client using REST and SOAP APIs where needed.