trell 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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +96 -0
- data/Rakefile +1 -0
- data/lib/trell.rb +24 -0
- data/lib/trell/authentication.rb +50 -0
- data/lib/trell/client.rb +125 -0
- data/lib/trell/client/boards.rb +29 -0
- data/lib/trell/client/cards.rb +25 -0
- data/lib/trell/client/labels.rb +26 -0
- data/lib/trell/client/lists.rb +25 -0
- data/lib/trell/client/members.rb +17 -0
- data/lib/trell/client/tokens.rb +9 -0
- data/lib/trell/configurable.rb +47 -0
- data/lib/trell/version.rb +3 -0
- data/spec/helper.rb +78 -0
- data/trell.gemspec +25 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3601d4f9ca2ab5fd25aed1943ab321a6d5709d54
|
4
|
+
data.tar.gz: 072bcd28f5f0dae310d7adcf2a8bd5ecf13d962b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d8b06012dacd50a03d10c570bfa91abea1feb3e74cd05a0b562d7bd113518c277a5bf666d197c3511413ddd5cef794a8df0b3c003f7f6ae0fc1622c6e3cef0ec
|
7
|
+
data.tar.gz: a7ba3b14741afe45e36048a116876294ec19cbb6643878629801b9dba6667ff04be4af2a315150dcd3a917f7cc443eb4153bdb8ba343109270897566d231a575
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in trell.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'pry'
|
8
|
+
gem 'awesome_print', require: 'ap'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem 'coveralls', require: false
|
13
|
+
gem 'simplecov', require: false
|
14
|
+
gem 'rspec', '~> 3.0.0.beta2'
|
15
|
+
gem 'vcr', '~> 2.8'
|
16
|
+
gem 'webmock', '~> 1.17'
|
17
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 linyows
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
Trell
|
2
|
+
=====
|
3
|
+
|
4
|
+
[][gem]
|
5
|
+
[][travis]
|
6
|
+
[][gemnasium]
|
7
|
+
[][codeclimate]
|
8
|
+
[][coveralls]
|
9
|
+
|
10
|
+
[gem]: https://rubygems.org/gems/trell
|
11
|
+
[travis]: http://travis-ci.org/linyows/trell
|
12
|
+
[gemnasium]: https://gemnasium.com/linyows/trell
|
13
|
+
[codeclimate]: https://codeclimate.com/github/linyows/trell
|
14
|
+
[coveralls]: https://coveralls.io/r/linyows/trell
|
15
|
+
|
16
|
+
Simple Ruby wrapper for <img src="https://d2k1ftgv7pobq7.cloudfront.net/images/bd87ee916375920ae72dffadbb10d412/logo-blue-lg.png" width="70">API. API documentation: https://trello.com/docs/api
|
17
|
+
|
18
|
+
Installation
|
19
|
+
------------
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'trell'
|
25
|
+
```
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
$ gem install trell
|
31
|
+
```
|
32
|
+
|
33
|
+
Usage
|
34
|
+
-----
|
35
|
+
|
36
|
+
Reading public data
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
member = Trell.member 'foo'
|
40
|
+
member.fullName
|
41
|
+
=> #<Sawyer::Resource:0x007f971230f538
|
42
|
+
```
|
43
|
+
|
44
|
+
Authentication
|
45
|
+
--------------
|
46
|
+
|
47
|
+
Generate a application key and application token
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
`open #{Trell.key_generator}` #=> get application key
|
51
|
+
`open #{Trell.token_generator}` #=> get application token
|
52
|
+
|
53
|
+
Trell.configure do |c|
|
54
|
+
c.application_key = '429452e37b7eb23182ec12**********'
|
55
|
+
c.application_token = '1cf2e7a22edf6ad8e967aa31a60947dc9ad2e0bf90d5********************'
|
56
|
+
end
|
57
|
+
```
|
58
|
+
Reading private data
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
member = Trell.member 'me'
|
62
|
+
=> "invalid token\n"
|
63
|
+
member = Trell.member 'me'
|
64
|
+
=> #<Sawyer::Resource:0x007fdf537f07d0
|
65
|
+
member.fullName
|
66
|
+
=> "my full name"
|
67
|
+
member.bio
|
68
|
+
=> ""
|
69
|
+
member.idBoards
|
70
|
+
=> ["4e79823242c330ede8*****",
|
71
|
+
"518b1a7f47e4c61d310*****",
|
72
|
+
"5313d1b1239bbeb31a1*****"]
|
73
|
+
member = Trell.update_member 'me', bio: 'hi'
|
74
|
+
=> #<Sawyer::Resource:0x007fcca26189f8
|
75
|
+
member.bio
|
76
|
+
=> "hi"
|
77
|
+
```
|
78
|
+
|
79
|
+
Contributing
|
80
|
+
------------
|
81
|
+
|
82
|
+
1. Fork it ( http://github.com/linyows/trell/fork )
|
83
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. Create new Pull Request
|
87
|
+
|
88
|
+
Authors
|
89
|
+
-------
|
90
|
+
|
91
|
+
- [linyows](https://github.com/linyows)
|
92
|
+
|
93
|
+
License
|
94
|
+
-------
|
95
|
+
|
96
|
+
The MIT License (MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/trell.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'trell/version'
|
2
|
+
require 'trell/client'
|
3
|
+
|
4
|
+
module Trell
|
5
|
+
class << self
|
6
|
+
include Trell::Configurable
|
7
|
+
|
8
|
+
def client
|
9
|
+
unless defined?(@client) && @client.same_options?(options)
|
10
|
+
@client = Trell::Client.new(options)
|
11
|
+
end
|
12
|
+
@client
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def method_missing(method_name, *args, &block)
|
18
|
+
return super unless client.respond_to?(method_name)
|
19
|
+
client.send(method_name, *args, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Trell.setup
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Trell
|
2
|
+
module Authentication
|
3
|
+
def generation_endpoint
|
4
|
+
@api_endpoint.gsub('api.', '')
|
5
|
+
end
|
6
|
+
|
7
|
+
def key_generetor
|
8
|
+
"#{generation_endpoint}appKey/generate"
|
9
|
+
end
|
10
|
+
|
11
|
+
def token_generator(expiration = 'never', scope = 'read,write,account')
|
12
|
+
query = [
|
13
|
+
"response_type=token",
|
14
|
+
"key=#{@application_key}",
|
15
|
+
"scope=#{scope}",
|
16
|
+
"expiration=#{expiration}",
|
17
|
+
"name=Trell"
|
18
|
+
].join('&')
|
19
|
+
|
20
|
+
"#{generation_endpoint}authorize?#{query}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def basic_authenticated?
|
24
|
+
!!(@login && @password)
|
25
|
+
end
|
26
|
+
|
27
|
+
def token_authenticated?
|
28
|
+
!!@access_token
|
29
|
+
end
|
30
|
+
|
31
|
+
def user_authenticated?
|
32
|
+
basic_authenticated? || token_authenticated?
|
33
|
+
end
|
34
|
+
|
35
|
+
def application_authenticated?
|
36
|
+
!!application_authentication
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def application_authentication
|
42
|
+
if @application_key && @application_token
|
43
|
+
{
|
44
|
+
key: @application_key,
|
45
|
+
token: @application_token
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/trell/client.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'sawyer'
|
2
|
+
require 'trell/configurable'
|
3
|
+
require 'trell/authentication'
|
4
|
+
require 'trell/client/members'
|
5
|
+
require 'trell/client/boards'
|
6
|
+
require 'trell/client/cards'
|
7
|
+
require 'trell/client/lists'
|
8
|
+
require 'trell/client/labels'
|
9
|
+
require 'trell/client/tokens'
|
10
|
+
|
11
|
+
module Trell
|
12
|
+
class Client
|
13
|
+
include Trell::Authentication
|
14
|
+
include Trell::Configurable
|
15
|
+
include Trell::Client::Members
|
16
|
+
include Trell::Client::Boards
|
17
|
+
include Trell::Client::Cards
|
18
|
+
include Trell::Client::Lists
|
19
|
+
include Trell::Client::Labels
|
20
|
+
include Trell::Client::Tokens
|
21
|
+
|
22
|
+
CONVENIENCE_HEADERS = Set.new(%i(accept content_type))
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
Trell::Configurable.keys.each do |key|
|
26
|
+
instance_variable_set(:"@#{key}", options[key] || Trell.instance_variable_get(:"@#{key}"))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def same_options?(opts)
|
31
|
+
opts.hash == options.hash
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(url, options = {})
|
35
|
+
request :get, url, parse_query_and_convenience_headers(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def post(url, options = {})
|
39
|
+
request :post, url, options
|
40
|
+
end
|
41
|
+
|
42
|
+
def put(url, options = {})
|
43
|
+
request :put, url, options
|
44
|
+
end
|
45
|
+
|
46
|
+
def patch(url, options = {})
|
47
|
+
request :patch, url, options
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete(url, options = {})
|
51
|
+
request :delete, url, options
|
52
|
+
end
|
53
|
+
|
54
|
+
def head(url, options = {})
|
55
|
+
request :head, url, parse_query_and_convenience_headers(options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def agent
|
59
|
+
@agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
|
60
|
+
http.headers[:accept] = media_type
|
61
|
+
http.headers[:content_type] = media_type
|
62
|
+
http.headers[:user_agent] = user_agent
|
63
|
+
|
64
|
+
if basic_authenticated?
|
65
|
+
http.basic_auth(@login, @password)
|
66
|
+
elsif token_authenticated?
|
67
|
+
http.authorization 'token', @access_token
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def request(method, path, data, options = {})
|
75
|
+
if data.is_a?(Hash)
|
76
|
+
options[:query] = data.delete(:query) || {}
|
77
|
+
options[:headers] = data.delete(:headers) || {}
|
78
|
+
if accept = data.delete(:accept)
|
79
|
+
options[:headers][:accept] = accept
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
if application_authenticated?
|
84
|
+
options[:query].merge! application_authentication
|
85
|
+
end
|
86
|
+
|
87
|
+
@last_response = response = agent.call(method, URI::Parser.new.escape(path.to_s), data, options)
|
88
|
+
response.data
|
89
|
+
end
|
90
|
+
|
91
|
+
def boolean_from_response(method, path, options = {})
|
92
|
+
request(method, path, options)
|
93
|
+
@last_response.status == 204
|
94
|
+
rescue Trell::NotFound
|
95
|
+
false
|
96
|
+
end
|
97
|
+
|
98
|
+
def sawyer_options
|
99
|
+
opts = {
|
100
|
+
:links_parser => Sawyer::LinkParsers::Simple.new
|
101
|
+
}
|
102
|
+
conn_opts = @connection_options
|
103
|
+
conn_opts[:builder] = @middleware if @middleware
|
104
|
+
conn_opts[:proxy] = @proxy if @proxy
|
105
|
+
opts[:faraday] = Faraday.new(conn_opts)
|
106
|
+
|
107
|
+
opts
|
108
|
+
end
|
109
|
+
|
110
|
+
def parse_query_and_convenience_headers(options)
|
111
|
+
headers = options.fetch(:headers, {})
|
112
|
+
CONVENIENCE_HEADERS.each do |h|
|
113
|
+
if header = options.delete(h)
|
114
|
+
headers[h] = header
|
115
|
+
end
|
116
|
+
end
|
117
|
+
query = options.delete(:query)
|
118
|
+
opts = {:query => options}
|
119
|
+
opts[:query].merge!(query) if query && query.is_a?(Hash)
|
120
|
+
opts[:headers] = headers unless headers.empty?
|
121
|
+
|
122
|
+
opts
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Trell
|
2
|
+
class Client
|
3
|
+
module Boards
|
4
|
+
def all_boards(options = {})
|
5
|
+
get 'boards', options
|
6
|
+
end
|
7
|
+
|
8
|
+
def boards(username, options = {})
|
9
|
+
get "members/#{username}/boards", options
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_board(options = {})
|
13
|
+
post 'boards', options
|
14
|
+
end
|
15
|
+
|
16
|
+
def board(id, options = {})
|
17
|
+
get "boards/#{id}", options
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_board(id, options = {})
|
21
|
+
put "boards/#{id}", options
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_board(id, options = {})
|
25
|
+
delete "boards/#{id}", options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Trell
|
2
|
+
class Client
|
3
|
+
module Cards
|
4
|
+
def cards(board_id, options = {})
|
5
|
+
get "boards/#{board_id}/cards", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_card(options = {})
|
9
|
+
post 'cards', options
|
10
|
+
end
|
11
|
+
|
12
|
+
def card(id, options = {})
|
13
|
+
get "cards/#{id}", options
|
14
|
+
end
|
15
|
+
|
16
|
+
def update_card(id, options = {})
|
17
|
+
put "cards/#{id}", options
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_card(id, options = {})
|
21
|
+
delete "cards/#{id}", options
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Trell
|
2
|
+
class Client
|
3
|
+
module Labels
|
4
|
+
class << self
|
5
|
+
def colors
|
6
|
+
%i(
|
7
|
+
blue
|
8
|
+
green
|
9
|
+
orange
|
10
|
+
purple
|
11
|
+
red
|
12
|
+
yellow
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
self.colors.each do |color|
|
18
|
+
class_eval <<-RUBY
|
19
|
+
def change_board_#{color}_label(board_id, options = {})
|
20
|
+
put "boards/\#{board_id}/labelNames/#{color}", options
|
21
|
+
end
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Trell
|
2
|
+
class Client
|
3
|
+
module Lists
|
4
|
+
def lists(board_id, options = {})
|
5
|
+
get "boards/#{board_id}/lists", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_list(options = {})
|
9
|
+
post 'lists', options
|
10
|
+
end
|
11
|
+
|
12
|
+
def list(id, options = {})
|
13
|
+
get "lists/#{id}", options
|
14
|
+
end
|
15
|
+
|
16
|
+
def update_list(id, options = {})
|
17
|
+
put "lists/#{id}", options
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_list(id, options = {})
|
21
|
+
delete "lists/#{id}", options
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Trell
|
2
|
+
class Client
|
3
|
+
module Members
|
4
|
+
def members(board_id, options = {})
|
5
|
+
get "boards/#{board_id}/members", options
|
6
|
+
end
|
7
|
+
|
8
|
+
def member(member, options = {})
|
9
|
+
get "members/#{member}", options
|
10
|
+
end
|
11
|
+
|
12
|
+
def update_member(member, options = {})
|
13
|
+
put "members/#{member}", options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Trell
|
2
|
+
module Configurable
|
3
|
+
OPTIONS_KEYS = %i(
|
4
|
+
login
|
5
|
+
password
|
6
|
+
application_key
|
7
|
+
application_token
|
8
|
+
api_endpoint
|
9
|
+
web_endpoint
|
10
|
+
user_agent
|
11
|
+
media_type
|
12
|
+
)
|
13
|
+
|
14
|
+
attr_accessor(*OPTIONS_KEYS)
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def keys
|
18
|
+
@keys ||= OPTIONS_KEYS
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure
|
23
|
+
yield self
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset!
|
27
|
+
@login = ENV['TRELL_LOGIN']
|
28
|
+
@password = ENV['TRELL_PASSWORD']
|
29
|
+
@application_key = ENV['TRELL_APPLICATION_TOKEN']
|
30
|
+
@application_secret = ENV['TRELL_APPLICATION_SECRET']
|
31
|
+
@api_endpoint = ENV['TRELL_API_ENDPOINT'] || 'https://api.trello.com/1/'
|
32
|
+
@web_endpoint = ENV['TRELL_WEB_ENDPOINT'] || 'https://trello.com/'
|
33
|
+
@user_agent = "Trell Ruby Gem #{Trell::VERSION}"
|
34
|
+
@media_type = 'application/json'
|
35
|
+
self
|
36
|
+
end
|
37
|
+
alias setup reset!
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def options
|
42
|
+
Hash[Trell::Configurable.keys.map { |key|
|
43
|
+
[key, instance_variable_get(:"@#{key}")]
|
44
|
+
}]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'coveralls'
|
5
|
+
require 'trell'
|
6
|
+
require 'rspec'
|
7
|
+
require 'ap'
|
8
|
+
require 'vcr'
|
9
|
+
require 'webmock/rspec'
|
10
|
+
|
11
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
12
|
+
SimpleCov::Formatter::HTMLFormatter,
|
13
|
+
Coveralls::SimpleCov::Formatter
|
14
|
+
]
|
15
|
+
SimpleCov.start
|
16
|
+
|
17
|
+
WebMock.disable_net_connect!(allow: 'coveralls.io')
|
18
|
+
RSpec.configure { |c| c.include WebMock::API }
|
19
|
+
|
20
|
+
VCR.configure do |c|
|
21
|
+
c.configure_rspec_metadata!
|
22
|
+
c.cassette_library_dir = 'spec/cassettes'
|
23
|
+
c.hook_into :webmock
|
24
|
+
c.default_cassette_options = {
|
25
|
+
serialize_with: :json,
|
26
|
+
preserve_exact_body_bytes: true,
|
27
|
+
decode_compressed_response: true,
|
28
|
+
record: :once
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
class String
|
33
|
+
def strip_heredoc
|
34
|
+
indent = scan(/^[ \t]*(?=\S)/).min.size || 0
|
35
|
+
gsub(/^[ \t]{#{indent}}/, '')
|
36
|
+
end
|
37
|
+
|
38
|
+
def no_lf
|
39
|
+
gsub(/\n|\r\n/, ' ')
|
40
|
+
end
|
41
|
+
|
42
|
+
def pretty_heredoc
|
43
|
+
strip_heredoc.no_lf.strip
|
44
|
+
end
|
45
|
+
|
46
|
+
def escaping
|
47
|
+
gsub(/https?:\/\//, '').gsub(/\/|\./, '_')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def fixture_path
|
52
|
+
File.expand_path('../fixtures', __FILE__)
|
53
|
+
end
|
54
|
+
|
55
|
+
def fixture(file)
|
56
|
+
File.read(fixture_path + '/' + file)
|
57
|
+
end
|
58
|
+
|
59
|
+
def decode(file)
|
60
|
+
JSON.parse(fixture file)
|
61
|
+
end
|
62
|
+
|
63
|
+
def json_response(file)
|
64
|
+
{
|
65
|
+
body: fixture(file),
|
66
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
def method_missing(method, *args, &block)
|
71
|
+
if method =~ /^a_(get|post|put|delete)$/
|
72
|
+
a_request(Regexp.last_match[1].to_sym, *args, &block)
|
73
|
+
elsif method =~ /^stub_(get|post|put|delete|head|patch)$/
|
74
|
+
stub_request(Regexp.last_match[1].to_sym, *args, &block)
|
75
|
+
else
|
76
|
+
super
|
77
|
+
end
|
78
|
+
end
|
data/trell.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'trell/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'trell'
|
8
|
+
spec.version = Trell::VERSION
|
9
|
+
spec.authors = ['linyows']
|
10
|
+
spec.email = ['linyows@gmail.com']
|
11
|
+
spec.summary = %q{Simple Ruby wrapper for the Trello API.}
|
12
|
+
spec.description = %q{Simple Ruby wrapper for the Trello API.}
|
13
|
+
spec.homepage = 'https://github.com/linyows/trell'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'sawyer', '~> 0.5.3'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- linyows
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sawyer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Simple Ruby wrapper for the Trello API.
|
56
|
+
email:
|
57
|
+
- linyows@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- lib/trell.rb
|
70
|
+
- lib/trell/authentication.rb
|
71
|
+
- lib/trell/client.rb
|
72
|
+
- lib/trell/client/boards.rb
|
73
|
+
- lib/trell/client/cards.rb
|
74
|
+
- lib/trell/client/labels.rb
|
75
|
+
- lib/trell/client/lists.rb
|
76
|
+
- lib/trell/client/members.rb
|
77
|
+
- lib/trell/client/tokens.rb
|
78
|
+
- lib/trell/configurable.rb
|
79
|
+
- lib/trell/version.rb
|
80
|
+
- spec/helper.rb
|
81
|
+
- trell.gemspec
|
82
|
+
homepage: https://github.com/linyows/trell
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.2.2
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Simple Ruby wrapper for the Trello API.
|
106
|
+
test_files:
|
107
|
+
- spec/helper.rb
|