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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96f7f9d82ae961f7634a5199e7076965e9120e6e
4
- data.tar.gz: 25f2f57e4a22578864bc1a7cc9526dd3f45d37e0
3
+ metadata.gz: e5c779e36114f2309f9e980b8d43575b55833a27
4
+ data.tar.gz: c38c51619feccd92c41acc5f5bdc55f5d827a3f6
5
5
  SHA512:
6
- metadata.gz: da511c9aae62668a403fec6849902c6fe062daf56a8f6f367b6b47e1a2863018e9887b3d711f0531ec4b2e0aa6c45f069f345b0f274919cb5cd6fd238c2b27bb
7
- data.tar.gz: 3317988c9d0eb9e691b2c40c9d55387f8f8a1ef869a19851ea16e4e826b0ae1925a92a438d2f1d8b08f53ec3f66439a7ed01f4af67f78c9983742d5c87c5669f
6
+ metadata.gz: e8a3a827c01cf51635758a0f28b536b46371c925ecb38353fcb80b0ac90fc63f48ada965592ae2aeb0b844a600b5f02a67213ff0e59f1b9bfc5e4fdbe0b1143c
7
+ data.tar.gz: e1a931da0a13a7317b574fc56ac380ae301a56ac74ab498e6abe98d7dbd31a91f4a38d22e9a3e77b461979fa146b50fcc461fb01312cfe09797656e79142a850
@@ -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
@@ -1,5 +1,5 @@
1
- require "trello_client/version"
1
+ require "trello/client"
2
+ require "trello/board"
2
3
 
3
4
  module TrelloClient
4
- # Your code goes here...
5
5
  end
@@ -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 "trello_client/version"
3
+ require "trello/client"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "trello_client"
7
- spec.version = TrelloClient::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.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:
@@ -1,3 +0,0 @@
1
- module TrelloClient
2
- VERSION = "0.0.0"
3
- end