leankitkanban 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :rubygems
2
+
3
+ gem "echoe"
4
+ gem "httparty"
5
+ gem "json"
6
+
7
+ group :test do
8
+ gem 'rspec', '~> 2.7.0'
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ allison (2.0.3)
5
+ diff-lcs (1.1.3)
6
+ echoe (4.6.3)
7
+ allison (>= 2.0.3)
8
+ gemcutter (>= 0.7.0)
9
+ rake (>= 0.9.2)
10
+ rdoc (>= 3.6.1)
11
+ rubyforge (>= 2.0.4)
12
+ gemcutter (0.7.0)
13
+ httparty (0.8.1)
14
+ multi_json
15
+ multi_xml
16
+ json (1.6.1)
17
+ json_pure (1.6.1)
18
+ multi_json (1.0.3)
19
+ multi_xml (0.4.1)
20
+ rake (0.9.2.2)
21
+ rdoc (3.11)
22
+ json (~> 1.4)
23
+ rspec (2.7.0)
24
+ rspec-core (~> 2.7.0)
25
+ rspec-expectations (~> 2.7.0)
26
+ rspec-mocks (~> 2.7.0)
27
+ rspec-core (2.7.1)
28
+ rspec-expectations (2.7.0)
29
+ diff-lcs (~> 1.1.2)
30
+ rspec-mocks (2.7.0)
31
+ rubyforge (2.0.4)
32
+ json_pure (>= 1.1.7)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ echoe
39
+ httparty
40
+ json
41
+ rspec (~> 2.7.0)
data/Manifest ADDED
@@ -0,0 +1,12 @@
1
+ Gemfile
2
+ Gemfile.lock
3
+ README
4
+ Rakefile
5
+ lib/leankitkanban.rb
6
+ lib/leankitkanban/board.rb
7
+ lib/leankitkanban/config.rb
8
+ spec/leankitkanban/board_spec.rb
9
+ spec/leankitkanban/config_spec.rb
10
+ spec/spec_helper.rb
11
+ spec/support/config_helper.rb
12
+ Manifest
data/README ADDED
@@ -0,0 +1,8 @@
1
+ Usage
2
+
3
+ LeanKitKanban::Config.email = "mytestemail@test.com"
4
+ LeanKitKanban::Config.password = "mypassword"
5
+ LeanKitKanban::Config.account = "myaccount"
6
+
7
+ LeanKitKanban::Board.all #gets all boards and returns an array of hashes
8
+ LeanKitKanban::Board.find(board_id) #gets the specified board
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('leankitkanban', '0.0.1') do |p|
6
+ p.description = "Ruby Wrapper around LeanKitKanban Api"
7
+ p.url = "http://github.com/mlainez/leankitkanban"
8
+ p.author = "Marc Lainez"
9
+ p.email = "ml@theotherguys.be"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{leankitkanban}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = [%q{Marc Lainez}]
9
+ s.date = %q{2011-10-27}
10
+ s.description = %q{Ruby Wrapper around LeanKitKanban Api}
11
+ s.email = %q{ml@theotherguys.be}
12
+ s.extra_rdoc_files = [%q{README}, %q{lib/leankitkanban.rb}, %q{lib/leankitkanban/board.rb}, %q{lib/leankitkanban/config.rb}]
13
+ s.files = [%q{Gemfile}, %q{Gemfile.lock}, %q{README}, %q{Rakefile}, %q{lib/leankitkanban.rb}, %q{lib/leankitkanban/board.rb}, %q{lib/leankitkanban/config.rb}, %q{spec/leankitkanban/board_spec.rb}, %q{spec/leankitkanban/config_spec.rb}, %q{spec/spec_helper.rb}, %q{spec/support/config_helper.rb}, %q{Manifest}, %q{leankitkanban.gemspec}]
14
+ s.homepage = %q{http://github.com/mlainez/leankitkanban}
15
+ s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Leankitkanban}, %q{--main}, %q{README}]
16
+ s.require_paths = [%q{lib}]
17
+ s.rubyforge_project = %q{leankitkanban}
18
+ s.rubygems_version = %q{1.8.4}
19
+ s.summary = %q{Ruby Wrapper around LeanKitKanban Api}
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ require "uri"
2
+ require "httparty"
3
+ require "json"
4
+
5
+ require File.join(File.dirname(__FILE__), 'leankitkanban', 'config')
6
+ require File.join(File.dirname(__FILE__), 'leankitkanban', 'board')
7
+
8
+ module LeanKitKanban
9
+ end
@@ -0,0 +1,27 @@
1
+ module LeanKitKanban
2
+ module Board
3
+ include HTTParty
4
+
5
+ ALL_BOARDS = "/Boards"
6
+ ONE_BOARD = "/Boards/{boardID}"
7
+
8
+ def self.all
9
+ url = "#{LeanKitKanban::Config.uri}#{ALL_BOARDS}"
10
+ response = get(url, LeanKitKanban::Config.basic_auth_hash)
11
+ parse_body(response.body)
12
+ end
13
+
14
+ def self.find(board_id)
15
+ api_call = ONE_BOARD.gsub("{boardID}", board_id.to_s)
16
+ url = "#{LeanKitKanban::Config.uri}#{api_call}"
17
+ response = get(url, LeanKitKanban::Config.basic_auth_hash)
18
+ parse_body(response.body)
19
+ end
20
+
21
+ private
22
+ def self.parse_body(body)
23
+ json_data = JSON.parse body
24
+ json_data["ReplyData"]
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module LeanKitKanban
2
+ module Config
3
+ class NoCredentials < StandardError; end
4
+ class NoAccount < StandardError; end
5
+
6
+ class << self
7
+ attr_accessor :email, :password, :account
8
+
9
+ LKK_DOMAIN = "leankitkanban.com"
10
+
11
+ def validate
12
+ raise NoCredentials if email.nil? || password.nil?
13
+ raise NoAccount if account.nil?
14
+ end
15
+
16
+ def uri
17
+ validate
18
+ "http://#{account}.#{LKK_DOMAIN}/Kanban/API"
19
+ end
20
+
21
+ def basic_auth_hash
22
+ validate
23
+ {:basic_auth => {:username => email, :password => password}}
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,76 @@
1
+ require "spec_helper"
2
+
3
+ describe LeanKitKanban::Board do
4
+ before :all do
5
+ ConfigHelper.set_test_config
6
+ end
7
+
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
+ 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)
38
+ LeanKitKanban::Board.all
39
+ end
40
+ end
41
+
42
+ describe :find do
43
+ 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)
63
+ end
64
+
65
+ 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)
73
+ LeanKitKanban::Board.find(@board_id)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,59 @@
1
+ require "spec_helper"
2
+
3
+ describe LeanKitKanban::Config do
4
+ describe :validate do
5
+ before :each do
6
+ ConfigHelper.set_test_config
7
+ end
8
+
9
+ context "when the config is not set" do
10
+ it "raises a no credentials error when no email" do
11
+ LeanKitKanban::Config.email = nil
12
+ lambda{ LeanKitKanban::Config.validate }.should raise_error(LeanKitKanban::Config::NoCredentials)
13
+ end
14
+
15
+ it "raises a no credentials error when no password" do
16
+ LeanKitKanban::Config.password = nil
17
+ lambda{ LeanKitKanban::Config.validate }.should raise_error(LeanKitKanban::Config::NoCredentials)
18
+ end
19
+
20
+ it "raises a no account error when no account" do
21
+ LeanKitKanban::Config.account = nil
22
+ lambda{ LeanKitKanban::Config.validate }.should raise_error(LeanKitKanban::Config::NoAccount)
23
+ end
24
+ end
25
+
26
+ context "when the config is set" do
27
+ it "doesn't raise a no credentials error" do
28
+ lambda{ LeanKitKanban::Config.validate }.should_not raise_error(LeanKitKanban::Config::NoCredentials)
29
+ end
30
+
31
+ it "doesn't raise a no account error" do
32
+ lambda{ LeanKitKanban::Config.validate }.should_not raise_error(LeanKitKanban::Config::NoAccount)
33
+ end
34
+ end
35
+ end
36
+
37
+ describe :uri do
38
+ it "validates the config" do
39
+ LeanKitKanban::Config.should_receive(:validate)
40
+ LeanKitKanban::Config.uri
41
+ end
42
+
43
+ it "returns the domain including the account name" do
44
+ LeanKitKanban::Config.uri.should eql "http://#{TEST_ACCOUNT}.leankitkanban.com/Kanban/API"
45
+ end
46
+ end
47
+
48
+ describe :basic_auth_hash do
49
+ it "validates the config" do
50
+ LeanKitKanban::Config.should_receive(:validate)
51
+ LeanKitKanban::Config.basic_auth_hash
52
+ end
53
+
54
+ it "returns a hash with the credentials" do
55
+ expected_hash = {:basic_auth => {:username => EMAIL, :password => PASSWORD}}
56
+ LeanKitKanban::Config.basic_auth_hash.should eql expected_hash
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'support/config_helper'
3
+ require 'leankitkanban'
4
+
5
+ EMAIL = "test@test.com"
6
+ PASSWORD = "mysecret"
7
+ TEST_ACCOUNT = "test"
@@ -0,0 +1,7 @@
1
+ module ConfigHelper
2
+ def self.set_test_config
3
+ LeanKitKanban::Config.email = EMAIL
4
+ LeanKitKanban::Config.password = PASSWORD
5
+ LeanKitKanban::Config.account = TEST_ACCOUNT
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: leankitkanban
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Marc Lainez
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-10-27 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Ruby Wrapper around LeanKitKanban Api
17
+ email: ml@theotherguys.be
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - lib/leankitkanban.rb
25
+ - lib/leankitkanban/board.rb
26
+ - lib/leankitkanban/config.rb
27
+ files:
28
+ - Gemfile
29
+ - Gemfile.lock
30
+ - README
31
+ - Rakefile
32
+ - lib/leankitkanban.rb
33
+ - lib/leankitkanban/board.rb
34
+ - lib/leankitkanban/config.rb
35
+ - spec/leankitkanban/board_spec.rb
36
+ - spec/leankitkanban/config_spec.rb
37
+ - spec/spec_helper.rb
38
+ - spec/support/config_helper.rb
39
+ - Manifest
40
+ - leankitkanban.gemspec
41
+ homepage: http://github.com/mlainez/leankitkanban
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --line-numbers
47
+ - --inline-source
48
+ - --title
49
+ - Leankitkanban
50
+ - --main
51
+ - README
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "1.2"
66
+ requirements: []
67
+
68
+ rubyforge_project: leankitkanban
69
+ rubygems_version: 1.8.4
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Ruby Wrapper around LeanKitKanban Api
73
+ test_files: []
74
+