leankitkanban 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,8 +12,12 @@ Usage
12
12
  LeanKitKanban::Config.password = "mypassword"
13
13
  LeanKitKanban::Config.account = "myaccount"
14
14
 
15
- @boards = LeanKitKanban::Board.all # gets all boards and returns an array of hashes
16
- @board = LeanKitKanban::Board.find(board_id) # gets the board with specified id as a hash
15
+ # get all boards and returns an array of hashes
16
+ @boards = LeanKitKanban::Board.all
17
+ # get the board with specified id as a hash
18
+ @board = LeanKitKanban::Board.find(board_id)
19
+ # get all the identifiers for a board
20
+ @identifiers = LeanKitKanban::Board.get_identifiers(board_id)
17
21
 
18
22
  Board ID
19
23
  --------
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('leankitkanban', '0.0.2') do |p|
5
+ Echoe.new('leankitkanban', '0.0.3') do |p|
6
6
  p.description = "Ruby Wrapper around LeanKitKanban Api"
7
7
  p.url = "http://github.com/mlainez/leankitkanban"
8
8
  p.author = "Marc Lainez"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{leankitkanban}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Marc Lainez}]
@@ -2,34 +2,35 @@ module LeanKitKanban
2
2
  module Board
3
3
  include HTTParty
4
4
 
5
- ALL_BOARDS = "/Boards"
6
- ONE_BOARD = "/Boards/{boardID}"
7
- IDENTIFIERS = "/Board/{boardID}/GetBoardIdentifiers"
5
+ ALL_BOARDS = "/Boards"
6
+ ONE_BOARD = "/Boards/{boardID}"
7
+ IDENTIFIERS = "/Board/{boardID}/GetBoardIdentifiers"
8
+ REPLY_DATA_KEY = "ReplyData"
8
9
 
9
10
  def self.all
10
- url = "#{LeanKitKanban::Config.uri}#{ALL_BOARDS}"
11
- response = get(url, LeanKitKanban::Config.basic_auth_hash)
12
- parse_body(response.body)
11
+ get(ALL_BOARDS)
13
12
  end
14
13
 
15
14
  def self.find(board_id)
16
15
  api_call = ONE_BOARD.gsub("{boardID}", board_id.to_s)
17
- url = "#{LeanKitKanban::Config.uri}#{api_call}"
18
- response = get(url, LeanKitKanban::Config.basic_auth_hash)
19
- parse_body(response.body)
16
+ get(api_call)
20
17
  end
21
18
 
22
19
  def self.get_identifiers(board_id)
23
20
  api_call = IDENTIFIERS.gsub("{boardID}", board_id.to_s)
21
+ get(api_call)
22
+ end
23
+
24
+ private
25
+ def self.get(api_call)
24
26
  url = "#{LeanKitKanban::Config.uri}#{api_call}"
25
- response = get(url, LeanKitKanban::Config.basic_auth_hash)
27
+ response = super(url, LeanKitKanban::Config.basic_auth_hash)
26
28
  parse_body(response.body)
27
29
  end
28
30
 
29
- private
30
31
  def self.parse_body(body)
31
- json_data = JSON.parse body
32
- json_data["ReplyData"]
32
+ json_data = JSON.parse body
33
+ json_data[REPLY_DATA_KEY]
33
34
  end
34
35
  end
35
36
  end
@@ -7,6 +7,7 @@ module LeanKitKanban
7
7
  attr_accessor :email, :password, :account
8
8
 
9
9
  LKK_DOMAIN = "leankitkanban.com"
10
+ API_SUFFIX = "/Kanban/API"
10
11
 
11
12
  def validate
12
13
  raise NoCredentials if email.nil? || password.nil?
@@ -15,7 +16,7 @@ module LeanKitKanban
15
16
 
16
17
  def uri
17
18
  validate
18
- "http://#{account}.#{LKK_DOMAIN}/Kanban/API"
19
+ "http://#{account}.#{LKK_DOMAIN}#{API_SUFFIX}"
19
20
  end
20
21
 
21
22
  def basic_auth_hash
@@ -6,105 +6,33 @@ describe LeanKitKanban::Board do
6
6
  end
7
7
 
8
8
  describe :all do
9
- before :each do
10
- @response = mock("Response")
11
- @body = mock("Body")
12
- @auth_hash = mock("Auth hash")
13
- LeanKitKanban::Config.stub(:uri)
14
- LeanKitKanban::Config.stub(:basic_auth_hash => @auth_hash)
15
- LeanKitKanban::Board.stub(:get => @response)
16
- @response.stub(:body => @body)
17
- LeanKitKanban::Board.stub(:parse_body)
18
- end
19
-
20
- it "gets the base uri" do
21
- LeanKitKanban::Config.should_receive(:uri)
22
- LeanKitKanban::Board.all
23
- end
24
-
25
- it "gets the basic authentication hash" do
26
- LeanKitKanban::Config.should_receive(:basic_auth_hash)
27
- LeanKitKanban::Board.all
28
- end
29
-
30
9
  it "gets all boards for that account" do
31
- url = "/Boards"
32
- LeanKitKanban::Board.should_receive(:get).with(url, @auth_hash).and_return(@response)
33
- LeanKitKanban::Board.all
34
- end
35
-
36
- it "gets the body from the response" do
37
- @response.should_receive(:body).and_return(@body)
10
+ api_call = "/Boards"
11
+ LeanKitKanban::Board.should_receive(:get).with(api_call)
38
12
  LeanKitKanban::Board.all
39
13
  end
40
14
  end
41
15
 
42
16
  describe :find do
43
17
  before :each do
44
- @board_id = 123
45
- @response = mock("Response")
46
- @body = mock("Body")
47
- @auth_hash = mock("Auth hash")
48
- LeanKitKanban::Config.stub(:uri)
49
- LeanKitKanban::Config.stub(:basic_auth_hash => @auth_hash)
50
- LeanKitKanban::Board.stub(:get => @response)
51
- @response.stub(:body => @body)
52
- LeanKitKanban::Board.stub(:parse_body)
53
- end
54
-
55
- it "gets the base uri" do
56
- LeanKitKanban::Config.should_receive(:uri)
57
- LeanKitKanban::Board.find(@board_id)
58
- end
59
-
60
- it "gets the basic authentication hash" do
61
- LeanKitKanban::Config.should_receive(:basic_auth_hash)
62
- LeanKitKanban::Board.find(@board_id)
18
+ @board_id = mock("boardID")
63
19
  end
64
20
 
65
21
  it "gets the board whose id is passed as parameter" do
66
- url = "/Boards/#{@board_id}"
67
- LeanKitKanban::Board.should_receive(:get).with(url, @auth_hash).and_return(@response)
68
- LeanKitKanban::Board.find(@board_id)
69
- end
70
-
71
- it "gets the body from the response" do
72
- @response.should_receive(:body).and_return(@body)
22
+ api_call = "/Boards/#{@board_id}"
23
+ LeanKitKanban::Board.should_receive(:get).with(api_call)
73
24
  LeanKitKanban::Board.find(@board_id)
74
25
  end
75
26
  end
76
27
 
77
28
  describe :get_identifiers do
78
29
  before :each do
79
- @board_id = 123
80
- @response = mock("Response")
81
- @body = mock("Body")
82
- @auth_hash = mock("Auth hash")
83
- LeanKitKanban::Config.stub(:uri)
84
- LeanKitKanban::Config.stub(:basic_auth_hash => @auth_hash)
85
- LeanKitKanban::Board.stub(:get => @response)
86
- @response.stub(:body => @body)
87
- LeanKitKanban::Board.stub(:parse_body)
88
- end
89
-
90
- it "gets the base uri" do
91
- LeanKitKanban::Config.should_receive(:uri)
92
- LeanKitKanban::Board.get_identifiers(@board_id)
93
- end
94
-
95
- it "gets the basic authentication hash" do
96
- LeanKitKanban::Config.should_receive(:basic_auth_hash)
97
- LeanKitKanban::Board.get_identifiers(@board_id)
98
- end
99
-
100
- it "gets the board whose id is passed as parameter" do
101
- url = "/Board/#{@board_id}/GetBoardIdentifiers"
102
- LeanKitKanban::Board.should_receive(:get).with(url, @auth_hash).and_return(@response)
103
- LeanKitKanban::Board.get_identifiers(@board_id)
30
+ @board_id = mock("boardID")
104
31
  end
105
32
 
106
- it "gets the body from the response" do
107
- @response.should_receive(:body).and_return(@body)
33
+ it "gets the identifiers of the board whose id is passed as parameter" do
34
+ api_call = "/Board/#{@board_id}/GetBoardIdentifiers"
35
+ LeanKitKanban::Board.should_receive(:get).with(api_call)
108
36
  LeanKitKanban::Board.get_identifiers(@board_id)
109
37
  end
110
38
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: leankitkanban
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Marc Lainez