grouper-rest-client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ .*.swp
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in grouper-rest-client.gemspec
4
+ gemspec
data/HISTORY ADDED
@@ -0,0 +1,4 @@
1
+ 2011-03-17 v0.0.1
2
+ - Initial prototype release.
3
+ - Implements "#groups(subject, [stem_filter])" WS call.
4
+
@@ -0,0 +1,12 @@
1
+ = Grouper::Rest::Client - Minimal REST client for interacting with the Grouper WS API.
2
+
3
+ == Usage
4
+
5
+ Grouper::Rest::Client.new url, :user => user, :password => pass do |grouper|
6
+ # Get all group memberships.
7
+ groups = grouper.groups('blair')
8
+
9
+ # Get group memberships within stem prefix.
10
+ filtered_groups = grouper.groups('blair', 'some:stem:')
11
+ end
12
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "grouper-rest-client/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "grouper-rest-client"
7
+ s.version = Grouper::Rest::Client::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Blair Christensen']
10
+ s.email = ['blair.christensen@gmail.com']
11
+ s.homepage = 'https://github.com/blairc/'
12
+ s.summary = %q{REST client for accessing the Grouper WS API}
13
+ s.description = %q{REST client for accessing the Grouper WS API}
14
+
15
+ s.rubyforge_project = "grouper-rest-client"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency( %q<json>, [ ">=1.5.1" ] )
23
+ s.add_dependency( %q<rest-client>, [ ">=1.6.1" ] )
24
+ end
25
+
@@ -0,0 +1,49 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'rest_client'
4
+
5
+ module Grouper # :nodoc:
6
+ module Rest # :nodoc:
7
+ # = Minimal REST client for interacting with the Grouper WS API.
8
+ #
9
+ # == Usage
10
+ # Grouper::Rest::Client.new url, :user => user, :password => pass do |grouper|
11
+ # # Get all group memberships.
12
+ # groups = grouper.groups('blair')
13
+ #
14
+ # # Get group memberships within stem prefix.
15
+ # filtered_groups = grouper.groups('blair', 'some:stem:')
16
+ # end
17
+ class Client
18
+
19
+ # Response object from last request.
20
+ attr_reader :response
21
+
22
+ # Create Grouper REST client.
23
+ # Params:
24
+ # +url+:: Base URL for Grouper WS API.
25
+ # +:user => user+:: Authenticate to the API as this user.
26
+ # +:password => password+:: Authenticate to the API with this password.
27
+ def initialize( url, options={} )
28
+ @client = RestClient::Resource.new(url, options)
29
+ @response = nil
30
+ yield self if block_given?
31
+ self
32
+ end
33
+
34
+ # Get subject's group memberships.
35
+ # Returns array of hashes of group memberships.
36
+ # Params:
37
+ # +subject+:: Get groups for this subject.
38
+ # +stem_filter+:: Limit groups to those within this stem prefix. (optional)
39
+ def groups(subject, stem_filter=nil)
40
+ @response = @client["subjects/#{subject}/groups"].get :content_type => 'text/x-json'
41
+ result = JSON.parse( @response.body )
42
+ groups = result['WsGetGroupsLiteResult']['wsGroups']
43
+ groups = groups.select { |group| group['name'] =~ /^#{stem_filter}/ } if stem_filter
44
+ groups
45
+ end
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,7 @@
1
+ module Grouper
2
+ module Rest
3
+ module Client
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grouper-rest-client
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Blair Christensen
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-17 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: json
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 1
30
+ segments:
31
+ - 1
32
+ - 5
33
+ - 1
34
+ version: 1.5.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rest-client
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 13
46
+ segments:
47
+ - 1
48
+ - 6
49
+ - 1
50
+ version: 1.6.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: REST client for accessing the Grouper WS API
54
+ email:
55
+ - blair.christensen@gmail.com
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files: []
61
+
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - HISTORY
66
+ - README.rdoc
67
+ - Rakefile
68
+ - grouper-rest-client.gemspec
69
+ - lib/grouper-rest-client.rb
70
+ - lib/grouper-rest-client/version.rb
71
+ has_rdoc: true
72
+ homepage: https://github.com/blairc/
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project: grouper-rest-client
101
+ rubygems_version: 1.6.2
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: REST client for accessing the Grouper WS API
105
+ test_files: []
106
+