kobra_client 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.MD CHANGED
@@ -1,4 +1,48 @@
1
- KOBRA Client
1
+ KOBRA Ruby Client [![Tested with Travis-CI](https://secure.travis-ci.org/LinTek/kobra_client.png)](http://travis-ci.org/#!/LinTek/kobra_client)
2
2
  ============
3
3
 
4
- Simple client for KOBRA.
4
+ Simple client for KOBRA.
5
+
6
+ ## Requirments
7
+
8
+ * Ruby 1.9.2: kobra_client is only tested with Ruby 1.9.2, no garantees for other versions of Ruby.
9
+
10
+ ## Install
11
+
12
+ Install via RubyGems
13
+
14
+ gem install kobra_client
15
+
16
+ ## Source
17
+
18
+ The source for kobra_client is available on Github:
19
+
20
+ https://github.com/LinTek/kobra_client
21
+
22
+ ### Development
23
+
24
+ kobra_client uses rspec and webmock for testing, do a `bundle install` for all the development requirements.
25
+
26
+ ## Usage
27
+
28
+ kobra_client is a client to the KOBRA service at LiU (Linköpings Universitet).
29
+ A KOBRA account is needed to use this client.
30
+
31
+ ### Initiate and authenticate
32
+
33
+ Get the username and API-key from your KOBRA account and use to authenticate the client.
34
+
35
+ require 'kobra/client'
36
+ kobra = Kobra::Client.new(:username => 'jage', :api_key => 'a9b8c7')
37
+ # => #<Kobra::Client:0x00000101175898 @base_url="https://jage:a9b8c7@kobra.ks.liu.se/">
38
+
39
+ When we have the `kobra` instance, we can use the API.
40
+
41
+ ### Lookup a LiU student
42
+
43
+ kobra.get_student(:liu_id => 'johdoXXX')
44
+ => {:blocked=>nil, :last_name=>"DOE", :email=>"johdoXXX@student.liu.se", :first_name=>"JOHN", :personal_number=>"887711-0011", :rfid_number=>"9999999999", :barcode_number=>"888888888888888", :union=>"LinTek", :liu_id=>"johdoXXX"}
45
+
46
+ ## Copyright
47
+
48
+ Copyright (c) 2011 Johan Eckerström. See LICENSE for details.
data/lib/kobra/client.rb CHANGED
@@ -13,7 +13,7 @@ module Kobra
13
13
  # Kobra::Client.new(:domain => "kobra.ks.liu.se", :username => "john", :api_key => "a3h93hu393")
14
14
  def initialize(settings = {})
15
15
  settings[:domain] ||= 'kobra.ks.liu.se'
16
- @base_url = "http://#{settings[:username]}:#{settings[:api_key]}@#{settings[:domain]}/"
16
+ @base_url = "https://#{settings[:username]}:#{settings[:api_key]}@#{settings[:domain]}/"
17
17
  end
18
18
 
19
19
  # get_student(:liu_id => 'johec890')
@@ -4,7 +4,7 @@ require 'kobra/client'
4
4
  describe Kobra::Client do
5
5
  describe '#get_student' do
6
6
  it 'obtains student information by email' do
7
- stub_request(:post, "http://john:a9b8c7@kobra.ks.liu.se/students/api.json").
7
+ stub_request(:post, "https://john:a9b8c7@kobra.ks.liu.se/students/api.json").
8
8
  with(:body => "email=johdoXXX%40student.liu.se").
9
9
  to_return(fixture('student_found.txt'))
10
10
 
@@ -23,7 +23,7 @@ describe Kobra::Client do
23
23
  end
24
24
 
25
25
  it 'fails to obtain student information by email' do
26
- stub_request(:post, "http://john:a9b8c7@kobra.ks.liu.se/students/api.json").
26
+ stub_request(:post, "https://john:a9b8c7@kobra.ks.liu.se/students/api.json").
27
27
  with(:body => "email=johdoXXX%40student.liu.se").
28
28
  to_return(fixture('student_not_found.txt'))
29
29
 
@@ -32,7 +32,7 @@ describe Kobra::Client do
32
32
  end
33
33
 
34
34
  it 'fails to authorize' do
35
- stub_request(:post, "http://john:wrong@kobra.ks.liu.se/students/api.json").
35
+ stub_request(:post, "https://john:wrong@kobra.ks.liu.se/students/api.json").
36
36
  with(:body => "email=johdoXXX%40student.liu.se").
37
37
  to_return(fixture('auth_failure.txt'))
38
38
 
@@ -41,7 +41,7 @@ describe Kobra::Client do
41
41
  end
42
42
 
43
43
  it 'gets garbage' do
44
- stub_request(:post, "http://john:a9b8c7@kobra.ks.liu.se/students/api.json").
44
+ stub_request(:post, "https://john:a9b8c7@kobra.ks.liu.se/students/api.json").
45
45
  with(:body => "email=johdoXXX%40student.liu.se").
46
46
  to_return(fixture('garbage.txt'))
47
47
 
@@ -50,7 +50,7 @@ describe Kobra::Client do
50
50
  end
51
51
 
52
52
  it 'gets server error' do
53
- stub_request(:post, "http://john:a9b8c7@kobra.ks.liu.se/students/api.json").
53
+ stub_request(:post, "https://john:a9b8c7@kobra.ks.liu.se/students/api.json").
54
54
  with(:body => "email=johdoXXX%40student.liu.se").
55
55
  to_return(fixture('server_error.txt'))
56
56
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kobra_client
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Johan Eckerstroem
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-21 00:00:00 +02:00
14
- default_executable:
13
+ date: 2011-09-09 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: json_pure
@@ -86,8 +85,7 @@ files:
86
85
  - spec/kobra_client_spec.rb
87
86
  - spec/spec_helper.rb
88
87
  - README.MD
89
- has_rdoc: true
90
- homepage: http://kobra.ks.liu.se/
88
+ homepage: https://kobra.ks.liu.se/
91
89
  licenses: []
92
90
 
93
91
  post_install_message:
@@ -110,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
108
  requirements: []
111
109
 
112
110
  rubyforge_project:
113
- rubygems_version: 1.6.2
111
+ rubygems_version: 1.8.5
114
112
  signing_key:
115
113
  specification_version: 3
116
114
  summary: Client library for KOBRA.