trello_client 0.0.0 → 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.
- checksums.yaml +4 -4
- data/lib/trello/board.rb +25 -0
- data/lib/trello/client.rb +25 -0
- data/lib/trello/net_http_client.rb +19 -0
- data/lib/trello_client.rb +2 -2
- data/trello_client.gemspec +3 -2
- metadata +18 -2
- data/lib/trello_client/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5c779e36114f2309f9e980b8d43575b55833a27
|
4
|
+
data.tar.gz: c38c51619feccd92c41acc5f5bdc55f5d827a3f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8a3a827c01cf51635758a0f28b536b46371c925ecb38353fcb80b0ac90fc63f48ada965592ae2aeb0b844a600b5f02a67213ff0e59f1b9bfc5e4fdbe0b1143c
|
7
|
+
data.tar.gz: e1a931da0a13a7317b574fc56ac380ae301a56ac74ab498e6abe98d7dbd31a91f4a38d22e9a3e77b461979fa146b50fcc461fb01312cfe09797656e79142a850
|
data/lib/trello/board.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Trello
|
2
|
+
class Board
|
3
|
+
def initialize(client)
|
4
|
+
@client = client
|
5
|
+
end
|
6
|
+
|
7
|
+
def fetch_all
|
8
|
+
@client.get(boards_url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch(id)
|
12
|
+
@client.get(board_url(id))
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def boards_url
|
18
|
+
"/1/members/me/boards"
|
19
|
+
end
|
20
|
+
|
21
|
+
def board_url(id)
|
22
|
+
"/1/boards/#{id}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "trello/net_http_client"
|
2
|
+
|
3
|
+
module Trello
|
4
|
+
class Client
|
5
|
+
BASE_URL = "https://api.trello.com"
|
6
|
+
VERSION = "0.0.1"
|
7
|
+
|
8
|
+
def initialize(key:, token:)
|
9
|
+
raise unless key && token
|
10
|
+
@key = key
|
11
|
+
@token = token
|
12
|
+
@http_client = NetHttpClient.new(URI.parse(BASE_URL))
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(path)
|
16
|
+
@http_client.perform(:get, with_key_and_token(path))
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def with_key_and_token(path)
|
22
|
+
path + "?key=#{@key}&token=#{@token}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Trello
|
2
|
+
class NetHttpClient
|
3
|
+
def initialize(base_uri)
|
4
|
+
@connection = Net::HTTP.new(base_uri.host, base_uri.port)
|
5
|
+
@connection.use_ssl = true if base_uri.scheme == "https"
|
6
|
+
end
|
7
|
+
|
8
|
+
def perform(method, path, body = nil, headers = {})
|
9
|
+
raise unless [:get, :put, :post, :delete].include?(method)
|
10
|
+
|
11
|
+
req = eval("Net::HTTP::#{method.capitalize}").new(path)
|
12
|
+
req["Content-Type"] = "application/json"
|
13
|
+
req.body = body
|
14
|
+
|
15
|
+
resp = @connection.request(req)
|
16
|
+
JSON.parse(resp.body)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/trello_client.rb
CHANGED
data/trello_client.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
lib = File.expand_path("../lib", __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "
|
3
|
+
require "trello/client"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "trello_client"
|
7
|
-
spec.version =
|
7
|
+
spec.version = Trello::Client::VERSION
|
8
8
|
spec.authors = ["Chen Huang"]
|
9
9
|
spec.email = ["alan.tolearn@gmail.com"]
|
10
10
|
|
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.16"
|
27
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "webmock", "~> 3.3"
|
29
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trello_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chen Huang
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
55
69
|
description: ''
|
56
70
|
email:
|
57
71
|
- alan.tolearn@gmail.com
|
@@ -67,8 +81,10 @@ files:
|
|
67
81
|
- Rakefile
|
68
82
|
- bin/console
|
69
83
|
- bin/setup
|
84
|
+
- lib/trello/board.rb
|
85
|
+
- lib/trello/client.rb
|
86
|
+
- lib/trello/net_http_client.rb
|
70
87
|
- lib/trello_client.rb
|
71
|
-
- lib/trello_client/version.rb
|
72
88
|
- trello_client.gemspec
|
73
89
|
homepage: ''
|
74
90
|
licenses:
|