ctrl 0.0.2
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 +14 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/ctrl +5 -0
- data/ctrl-0.0.1.gem +0 -0
- data/ctrl.gemspec +23 -0
- data/lib/ctrl.rb +14 -0
- data/lib/ctrl/api.rb +83 -0
- data/lib/ctrl/board.rb +42 -0
- data/lib/ctrl/card.rb +74 -0
- data/lib/ctrl/checklist.rb +13 -0
- data/lib/ctrl/cli.rb +26 -0
- data/lib/ctrl/config.rb +6 -0
- data/lib/ctrl/list.rb +55 -0
- data/lib/ctrl/print.rb +12 -0
- data/lib/ctrl/version.rb +3 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: caea91c4c6d31277d97489372241f8e5ded087fc
|
4
|
+
data.tar.gz: 4a64effe36a39f46fed5016ae31790b026a20162
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77a45ee34a63f571542eb8c13461bc362d9502e473d4c6f0f7d0aca5e89c13a782d6823adcb29233d50d8dc2a7a304e4294008fdd4ed4302db959eb75a06ae2b
|
7
|
+
data.tar.gz: 9591bc967a90da746afa0eb4f7adf2aaf1ab71aecd3bf3df33c2b30ca089e60b90ec2d332dd657e096bb1a97cb4357181bdd9619f49241ad3a8b4bd8e939a7ca
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Mike Beasley
|
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,31 @@
|
|
1
|
+
# Ctrl
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ctrl'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ctrl
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/ctrl/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/ctrl
ADDED
data/ctrl-0.0.1.gem
ADDED
Binary file
|
data/ctrl.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ctrl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ctrl"
|
8
|
+
spec.version = Ctrl::VERSION
|
9
|
+
spec.authors = ["Mike Beasley"]
|
10
|
+
spec.email = ["mike.beasley@gmail.com"]
|
11
|
+
spec.summary = %q{Command-line Trello}
|
12
|
+
spec.description = %q{Trello API, command line client and webhook watcher}
|
13
|
+
spec.homepage = "http://github.com/mbeasley/ctrl"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["ctrl"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/lib/ctrl.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "pry"
|
2
|
+
require "thor"
|
3
|
+
require "fuzzy_match"
|
4
|
+
require "rainbow"
|
5
|
+
require "rainbow/ext/string"
|
6
|
+
require "yaml"
|
7
|
+
require "httparty"
|
8
|
+
|
9
|
+
ctrl_lib = File.expand_path(File.dirname(__FILE__))
|
10
|
+
Dir.glob("#{ctrl_lib}/ctrl/*.rb").each { |p| require p }
|
11
|
+
|
12
|
+
module Ctrl
|
13
|
+
binding.pry
|
14
|
+
end
|
data/lib/ctrl/api.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
module Ctrl
|
2
|
+
class Trello
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'https://api.trello.com/1/'
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@key = ::CONFIG["key"]
|
8
|
+
@token = ::CONFIG["token"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(path, data, options = {})
|
12
|
+
options.merge!({query: data, key: @key, token: @token})
|
13
|
+
self.class.get(path + "?key=#{@key}&token=#{@token}", options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def post(path, data, options = {})
|
17
|
+
options.merge!({query: data, key: @key, token: @token})
|
18
|
+
self.class.post(path, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def put(path, data, options = {})
|
22
|
+
options.merge!({query: data, key: @key, token: @token})
|
23
|
+
self.class.put(path, options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(path, options = {})
|
27
|
+
options.merge!({key: @key, token: @token})
|
28
|
+
self.class.delete(path, options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module API
|
33
|
+
def self.get_boards
|
34
|
+
get("/members/me/boards", {filter: "open", lists: "open"})
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.get_board(id)
|
38
|
+
get("/boards/#{id}", {cards: "open", lists: "open"})
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.get_lists_for_board(id)
|
42
|
+
get("/boards/#{id}/lists", {filter: "open", cards: "open"})
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.get_cards_for_board(id)
|
46
|
+
get("/boards/#{id}/cards", {filter: "open"})
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.get_list(id)
|
50
|
+
get("/lists/#{id}", {cards: "open", board: true})
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.get_cards_for_list(id)
|
54
|
+
get("/lists/#{id}/cards", {filter: "open", board: true, list: true})
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.get_card(id)
|
58
|
+
get("/cards/#{id}")
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def self.get(path, data = nil, options = {})
|
64
|
+
@@trello ||= Ctrl::Trello.new()
|
65
|
+
@@trello.get(path, data, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.post(path, data = nil, options = {})
|
69
|
+
@@trello ||= Ctrl::Trello.new()
|
70
|
+
@@trello.post(path, data, options)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.put(path, data = nil, options = {})
|
74
|
+
@@trello ||= Ctrl::Trello.new()
|
75
|
+
@@trello.put(path, data, options)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.delete(path, options = {})
|
79
|
+
@@trello ||= Ctrl::Trello.new()
|
80
|
+
@@trello.delete(path, options)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/ctrl/board.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Ctrl
|
2
|
+
class Board
|
3
|
+
attr_accessor :id, :name, :labels, :closed, :url
|
4
|
+
|
5
|
+
def initialize(opts);
|
6
|
+
@id = opts["id"]
|
7
|
+
@name = opts["name"]
|
8
|
+
@url = opts["shortUrl"] || opts["url"]
|
9
|
+
@labels = opts["labelNames"] || opts["labels"]
|
10
|
+
@closed = opts["closed"]
|
11
|
+
@lists = opts["lists"].map { |list| List.new(list) } if opts["lists"]
|
12
|
+
@cards = opts["cards"].map { |card| Card.new(card) } if opts["cards"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def save; end
|
16
|
+
|
17
|
+
def self.create(opts); end
|
18
|
+
|
19
|
+
def self.find_by_id(id)
|
20
|
+
Board.new(API.get_board(id))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.find_by_name(name)
|
24
|
+
fuzzy = FuzzyMatch.new(find_all, read: :name)
|
25
|
+
fuzzy.find(name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find_all;
|
29
|
+
API.get_boards.map { |board| Board.new(board) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def lists
|
33
|
+
return @lists if @lists
|
34
|
+
API.get_lists_for_board(id).map { |list| List.new(list) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def cards;
|
38
|
+
return @cards if @cards
|
39
|
+
API.get_cards_for_board(id).map { |card| Card.new(card) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/ctrl/card.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
module Ctrl
|
2
|
+
class Card
|
3
|
+
attr_accessor :id, :name, :description, :due, :labels, :position, :closed, :url
|
4
|
+
|
5
|
+
def initialize(opts)
|
6
|
+
@id = opts["id"]
|
7
|
+
@name = opts["name"]
|
8
|
+
@description = opts["description"]
|
9
|
+
@due = opts["due"]
|
10
|
+
@labels = opts["labels"]
|
11
|
+
@position = opts["pos"]
|
12
|
+
@closed = opts["closed"]
|
13
|
+
@url = opts["shortUrl"] || opts["url"]
|
14
|
+
@board = Board.new(opts["board"]) if opts["board"]
|
15
|
+
@list = List.new(opts["list"]) if opts["list"]
|
16
|
+
@board_id = opts["idBoard"]
|
17
|
+
@list_id = opts["idList"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def save; end
|
21
|
+
|
22
|
+
def self.create(opts); end
|
23
|
+
|
24
|
+
def self.find_by_id(id)
|
25
|
+
Card.new(API.get_card(id))
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find_by_name(name, obj)
|
29
|
+
if obj.is_a? List
|
30
|
+
fuzzy = FuzzyMatch.new(find_all_by_list(obj.id), read: :name)
|
31
|
+
elsif obj.is_a? Board
|
32
|
+
fuzzy = FuzzyMatch.new(find_all_by_board(obj.id), read: :name)
|
33
|
+
else
|
34
|
+
fail "Object must be a card or a board"
|
35
|
+
end
|
36
|
+
fuzzy.find(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.find_by_position(pos, list)
|
40
|
+
pos = 0 if pos == "first" || pos == "top"
|
41
|
+
pos = -1 if pos == "last" || pos == "bottom"
|
42
|
+
|
43
|
+
unless pos.is_a? Integer
|
44
|
+
fail "Position must by integer, 'top', 'first', 'bottom', or 'last'"
|
45
|
+
end
|
46
|
+
|
47
|
+
find_all_by_list(list.id).sort_by(&:position)[pos]
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.find_all_by_list(list_id);
|
51
|
+
API.get_cards_for_list(list_id).map { |card| Card.new(card) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.find_all_by_board(board_id)
|
55
|
+
API.get_cards_for_board(board_id).map { |card| Card.new(card) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def board
|
59
|
+
@board ||= Board.find_by_id(@board_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
def list
|
63
|
+
@list ||= List.find_by_id(@list_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
# TODO
|
67
|
+
#def checklists; end
|
68
|
+
#def position=(pos); end
|
69
|
+
#def move(list, pos=nil); end
|
70
|
+
#def print; end
|
71
|
+
#def archive; end
|
72
|
+
#def delete; end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ctrl
|
2
|
+
class Checklist
|
3
|
+
attr_reader :card, :list, :board, :data
|
4
|
+
attr_accessor :name
|
5
|
+
|
6
|
+
def initialize; end
|
7
|
+
def save; end
|
8
|
+
def self.find_by_id(id); end
|
9
|
+
def self.find_by_name(name, card=nil, list=nil, board=nil); end
|
10
|
+
def self.all(card=nil); end
|
11
|
+
def self.create(opts); end
|
12
|
+
end
|
13
|
+
end
|
data/lib/ctrl/cli.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ctrl
|
2
|
+
class CLI < Thor
|
3
|
+
attr_accessor :ctrl
|
4
|
+
def initialize(*args)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "show", "show a card"
|
9
|
+
def show; binding.pry; end
|
10
|
+
|
11
|
+
desc "list", "show a list and its cards"
|
12
|
+
def list; end
|
13
|
+
|
14
|
+
desc "board", "show a board and its cards, by list"
|
15
|
+
def board; end
|
16
|
+
|
17
|
+
desc "new", "create a new card"
|
18
|
+
def new; end
|
19
|
+
|
20
|
+
desc "view", "show a configured view"
|
21
|
+
def view; end
|
22
|
+
|
23
|
+
desc "move", "move a card or list"
|
24
|
+
def move; end
|
25
|
+
end
|
26
|
+
end
|
data/lib/ctrl/config.rb
ADDED
data/lib/ctrl/list.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Ctrl
|
2
|
+
class List
|
3
|
+
attr_accessor :id, :name, :position, :closed
|
4
|
+
|
5
|
+
def initialize(opts)
|
6
|
+
@id = opts["id"]
|
7
|
+
@name = opts["name"]
|
8
|
+
@position = opts["pos"]
|
9
|
+
@closed = opts["closed"]
|
10
|
+
@cards = opts["cards"].map { |card| Card.new(card) } if opts["cards"]
|
11
|
+
@board = Board.new(opts["board"]) if opts["board"]
|
12
|
+
@board_id = opts["idBoard"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def save; end
|
16
|
+
|
17
|
+
def self.create(opts); end
|
18
|
+
|
19
|
+
def self.find_by_id(id)
|
20
|
+
List.new(API.get_list(id))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.find_by_name(name, board)
|
24
|
+
fuzzy = FuzzyMatch.new(find_all_by_board(board.id), read: :name)
|
25
|
+
fuzzy.find(name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find_by_position(pos, board)
|
29
|
+
pos = 0 if pos == "first" || pos == "top"
|
30
|
+
pos = -1 if pos == "last" || pos == "bottom"
|
31
|
+
|
32
|
+
unless pos.is_a? Integer
|
33
|
+
fail "Position must by integer, 'top', 'first', 'bottom', or 'last'"
|
34
|
+
end
|
35
|
+
|
36
|
+
find_all_by_board(board.id).sort_by(&:position)[pos]
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.find_all_by_board(board_id)
|
40
|
+
API.get_lists_for_board(board_id).map{ |list| List.new(list) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def board
|
44
|
+
@board ||= Board.find_by_id(@board_id)
|
45
|
+
end
|
46
|
+
|
47
|
+
def cards
|
48
|
+
return @cards if @cards
|
49
|
+
API.get_cards_for_list(id).map { |card| Card.new(card) }
|
50
|
+
end
|
51
|
+
|
52
|
+
# TODO
|
53
|
+
#def count; end
|
54
|
+
end
|
55
|
+
end
|
data/lib/ctrl/print.rb
ADDED
data/lib/ctrl/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ctrl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Beasley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Trello API, command line client and webhook watcher
|
42
|
+
email:
|
43
|
+
- mike.beasley@gmail.com
|
44
|
+
executables:
|
45
|
+
- ctrl
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/ctrl
|
55
|
+
- ctrl-0.0.1.gem
|
56
|
+
- ctrl.gemspec
|
57
|
+
- lib/ctrl.rb
|
58
|
+
- lib/ctrl/api.rb
|
59
|
+
- lib/ctrl/board.rb
|
60
|
+
- lib/ctrl/card.rb
|
61
|
+
- lib/ctrl/checklist.rb
|
62
|
+
- lib/ctrl/cli.rb
|
63
|
+
- lib/ctrl/config.rb
|
64
|
+
- lib/ctrl/list.rb
|
65
|
+
- lib/ctrl/print.rb
|
66
|
+
- lib/ctrl/version.rb
|
67
|
+
homepage: http://github.com/mbeasley/ctrl
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.4.2
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Command-line Trello
|
91
|
+
test_files: []
|