yello 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +6 -0
- data/bin/yello +15 -0
- data/lib/yello/auth.rb +26 -0
- data/lib/yello/base.rb +13 -0
- data/lib/yello/card.rb +20 -0
- data/lib/yello/checklist.rb +14 -0
- data/lib/yello/cli/export.rb +48 -0
- data/lib/yello/cli/import.rb +24 -0
- data/lib/yello/cli/login.rb +52 -0
- data/lib/yello/cli.rb +3 -0
- data/lib/yello/from_trello.rb +35 -0
- data/lib/yello/from_yaml.rb +39 -0
- data/lib/yello/import.rb +36 -0
- data/lib/yello/list.rb +14 -0
- data/lib/yello/to_yaml.rb +49 -0
- data/lib/yello/trello.rb +16 -0
- data/lib/yello/version.rb +3 -0
- data/lib/yello.rb +3 -0
- data/spec/auth_spec.rb +24 -0
- data/spec/create.yml +8 -0
- data/spec/from_trello_spec.rb +36 -0
- data/spec/from_yaml_spec.rb +32 -0
- data/spec/import_spec.rb +47 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/test.yml +16 -0
- data/spec/to_yaml_spec.rb +32 -0
- data/yello.gemspec +31 -0
- metadata +224 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1051e51b5c7018f72f7cb092742a3f9209f34a72
|
4
|
+
data.tar.gz: bf719bb53b70f785ce1601d60ed589e846cb6b61
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9017cb714d9f1dc14879c6975e4a9b177f623e4154cc6c0b8d89d19dd7eb5213729110acaecd6916b22cc9983f5ef59e96b9f15a0d1a8133320cbfa0ed7d3ef9
|
7
|
+
data.tar.gz: ebec2bf06456e6203e1b9730ef487b191aaec3766538b3351a9201e5198c87b62e27221fff981356a714ffdc74c1a4e06809182fea4162197a4a9235223cda66
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
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,71 @@
|
|
1
|
+
# Yello
|
2
|
+
|
3
|
+
This CLI enables the import/export of Trello boards to and from YAML files.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem install yello
|
9
|
+
```
|
10
|
+
|
11
|
+
## Configuration
|
12
|
+
You will need to obtain a Trello API key and token. The CLI will
|
13
|
+
walk you through this process if you run this:
|
14
|
+
```bash
|
15
|
+
yello login
|
16
|
+
```
|
17
|
+
Credentials will be stored in your [netrc file](http://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-File.html).
|
18
|
+
If you encrypt this file with GPG, your Trello credentials will also be encrypted.
|
19
|
+
This functionality is brought to you courtesy of the [netrc gem](https://github.com/heroku/netrc)
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Here is an example of the file format:
|
24
|
+
```yaml
|
25
|
+
Not Started:
|
26
|
+
cards:
|
27
|
+
- Get an email account
|
28
|
+
- Have lunch with your manager
|
29
|
+
- Get a key card
|
30
|
+
- Attend the noob-101 workshop
|
31
|
+
- Submit your first bugfix:
|
32
|
+
desc: You must fix a bug to prove your worth.
|
33
|
+
checklists:
|
34
|
+
- Process:
|
35
|
+
- Write tests
|
36
|
+
- Write code
|
37
|
+
- Get it reviewed
|
38
|
+
- Merge it
|
39
|
+
In Progress: {}
|
40
|
+
Completed: {}
|
41
|
+
```
|
42
|
+
|
43
|
+
### Importing a file
|
44
|
+
Importing a file will create a new board in Trello with the name you specify..
|
45
|
+
```bash
|
46
|
+
# this ...
|
47
|
+
yello import "my awesome board" --file /path/to/file.yml
|
48
|
+
|
49
|
+
# or this ...
|
50
|
+
cat /path/to/file.yml | yello import "my awesome board"
|
51
|
+
```
|
52
|
+
|
53
|
+
### Exporting a file
|
54
|
+
Exporting a board will generate yaml based on the given board from Trello.
|
55
|
+
At present, only board IDs are supported when exporting.
|
56
|
+
|
57
|
+
```bash
|
58
|
+
# this ...
|
59
|
+
yello export --id TE7Kl7ua --file /path/to/file.yml
|
60
|
+
|
61
|
+
# or this ...
|
62
|
+
yello export --id TE7Kl7ua > /path/to/file.yml
|
63
|
+
```
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
1. Fork it ( https://github.com/[my-github-username]/yello/fork )
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/yello
ADDED
data/lib/yello/auth.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'netrc'
|
2
|
+
|
3
|
+
module Yello
|
4
|
+
|
5
|
+
Auth = Struct.new(:key, :token)
|
6
|
+
|
7
|
+
class Auth
|
8
|
+
class << self
|
9
|
+
def get
|
10
|
+
Auth.new(*(netrc['yello']))
|
11
|
+
end
|
12
|
+
|
13
|
+
def set(key, token)
|
14
|
+
netrc.tap do |n|
|
15
|
+
n['yello'] = key, token
|
16
|
+
n.save
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def netrc
|
21
|
+
Netrc.read
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/lib/yello/base.rb
ADDED
data/lib/yello/card.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'yello/base'
|
2
|
+
require 'yello/checklist'
|
3
|
+
|
4
|
+
module Yello
|
5
|
+
class Card < Base
|
6
|
+
attr_accessor :checklists, :desc
|
7
|
+
|
8
|
+
def initialize(name, desc, checklists)
|
9
|
+
super(name)
|
10
|
+
@desc = desc
|
11
|
+
@checklists = checklists
|
12
|
+
end
|
13
|
+
|
14
|
+
def attributes
|
15
|
+
super.merge('desc'=>desc)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'yello/from_trello'
|
3
|
+
require 'yello/trello'
|
4
|
+
require 'yello/to_yaml'
|
5
|
+
|
6
|
+
module Yello
|
7
|
+
class CLI < Thor
|
8
|
+
desc 'export', 'Export a board.'
|
9
|
+
option :id, aliases: :i, banner: "<id>", required: true
|
10
|
+
option :file, aliases: :f, banner: "<file>", type: :boolean
|
11
|
+
def export
|
12
|
+
Yello.from_trello(board).tap do |result|
|
13
|
+
output {|f|
|
14
|
+
f.write(Yello.to_yaml(result))
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
no_tasks do
|
20
|
+
|
21
|
+
def board
|
22
|
+
client.find(:boards, id) || (fail "No such board: #{id}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def output(&block)
|
26
|
+
if file
|
27
|
+
File.open(file){|f| yield f}
|
28
|
+
else
|
29
|
+
yield STDOUT
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def name
|
34
|
+
options[:name]
|
35
|
+
end
|
36
|
+
|
37
|
+
def id
|
38
|
+
options[:id]
|
39
|
+
end
|
40
|
+
|
41
|
+
def file
|
42
|
+
options[:file]
|
43
|
+
end
|
44
|
+
|
45
|
+
include Trello
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'yello/from_yaml'
|
3
|
+
require 'yello/import'
|
4
|
+
|
5
|
+
module Yello
|
6
|
+
class CLI < Thor
|
7
|
+
desc 'import', 'Import a board.'
|
8
|
+
option :file, aliases: :f, banner: "<file>"
|
9
|
+
def import(board)
|
10
|
+
Yello.import(board, Yello.from_yaml(input))
|
11
|
+
end
|
12
|
+
|
13
|
+
no_tasks do
|
14
|
+
def input
|
15
|
+
file ? File.read(file) : STDIN.read
|
16
|
+
end
|
17
|
+
|
18
|
+
def file
|
19
|
+
options[:file]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'os'
|
3
|
+
require 'thor'
|
4
|
+
require 'yello/auth'
|
5
|
+
|
6
|
+
module Yello
|
7
|
+
class CLI < Thor
|
8
|
+
|
9
|
+
desc 'login', 'Login to Trello'
|
10
|
+
def login
|
11
|
+
get_key
|
12
|
+
key = ask('Enter Trello API key:')
|
13
|
+
|
14
|
+
get_token(key)
|
15
|
+
token = ask('Enter Trello member token:')
|
16
|
+
|
17
|
+
Yello::Auth.set(key, token)
|
18
|
+
end
|
19
|
+
|
20
|
+
no_tasks do
|
21
|
+
def api_url
|
22
|
+
'https://trello.com/1/appKey/generate'
|
23
|
+
end
|
24
|
+
|
25
|
+
def token_url(key)
|
26
|
+
"https://trello.com/1/authorize?key=#{key}&name=yello&expiration=never&response_type=token&scope=read,write"
|
27
|
+
end
|
28
|
+
|
29
|
+
if OS.osx?
|
30
|
+
def get_key
|
31
|
+
ask "Press Enter to open a browser window to get your API key."
|
32
|
+
`open "#{api_url}"`
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_token(key)
|
36
|
+
ask "Press Enter to open a browser window to get your member token."
|
37
|
+
`open "#{token_url(key)}"`
|
38
|
+
end
|
39
|
+
else
|
40
|
+
def get_key
|
41
|
+
puts "Get your trello API key here: #{api_url}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_token(key)
|
45
|
+
puts "Get your member token here: #{token_url}\n"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
data/lib/yello/cli.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'yello/trello'
|
2
|
+
require 'yello/list'
|
3
|
+
|
4
|
+
module Yello
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def from_trello(board)
|
8
|
+
Yello::FromTrello.convert(board)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module FromTrello
|
13
|
+
class << self
|
14
|
+
def convert(board)
|
15
|
+
board.lists.map{|l|
|
16
|
+
Yello::List.new(l.name, cards(l.cards))
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def cards(array)
|
21
|
+
# Sort by position
|
22
|
+
array.sort_by{|c|c.pos}.map{|c|
|
23
|
+
Yello::Card.new(c.name, c.desc, checklists(c.checklists))
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def checklists(array)
|
28
|
+
array.map{|cl|
|
29
|
+
Yello::Checklist.new(cl.name, cl.items.map(&:name))
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'yello/list'
|
3
|
+
|
4
|
+
module Yello
|
5
|
+
class << self
|
6
|
+
def from_yaml(string)
|
7
|
+
Yello::FromYaml.convert(string)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module FromYaml
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def convert(string)
|
15
|
+
YAML.load(string).map{|k,v|
|
16
|
+
Yello::List.new(k, cards(v))
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def cards(hash)
|
23
|
+
(hash['cards'] || []).map{|c|
|
24
|
+
if c.is_a? Hash
|
25
|
+
Card.new(c.keys[0], c['desc'], checklists(c))
|
26
|
+
else
|
27
|
+
Card.new(c, nil, [])
|
28
|
+
end
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def checklists(hash)
|
33
|
+
(hash['checklists'] || []).map{|h|
|
34
|
+
Checklist.new(h.keys[0], h.values[0] || [])
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/yello/import.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'yello/trello'
|
3
|
+
module Yello
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def import(name, lists)
|
7
|
+
Yello::Import.new.run(name, lists)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Import
|
12
|
+
include Trello
|
13
|
+
|
14
|
+
def run(name, lists)
|
15
|
+
board = client.create(:boards, 'name'=>name)
|
16
|
+
board.lists.each do |l|
|
17
|
+
l.closed = true
|
18
|
+
l.save
|
19
|
+
end
|
20
|
+
|
21
|
+
lists.reverse.each do |l|
|
22
|
+
list = client.create(:list, l.attributes.merge('idBoard'=>board.id))
|
23
|
+
l.cards.reverse.each do |c|
|
24
|
+
card = client.create(:card, c.attributes.merge('idList'=>list.id))
|
25
|
+
c.checklists.each do |cl|
|
26
|
+
checklist = client.find(:checklist, JSON.parse(card.create_new_checklist(cl.name))['id'])
|
27
|
+
cl.items.each do |i|
|
28
|
+
checklist.add_item(i)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/yello/list.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
module Yello
|
3
|
+
class << self
|
4
|
+
def to_yaml(lists)
|
5
|
+
Yello::ToYaml.convert(lists)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module ToYaml
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
def convert(lists)
|
14
|
+
{}.tap{|h|
|
15
|
+
lists.each{|l|
|
16
|
+
h[l.name] = list(l)
|
17
|
+
}
|
18
|
+
}.to_yaml
|
19
|
+
end
|
20
|
+
|
21
|
+
def list(l)
|
22
|
+
{}.tap{|h|
|
23
|
+
h['cards'] = l.cards.map{|c|
|
24
|
+
card(c)
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def card(c)
|
30
|
+
if c.checklists && !c.checklists.empty?
|
31
|
+
{
|
32
|
+
c.name=>nil,
|
33
|
+
'desc'=>c.desc,
|
34
|
+
'checklists'=>c.checklists.map{|cl|checklist(cl)}
|
35
|
+
}
|
36
|
+
else
|
37
|
+
c.name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def checklist(cl)
|
42
|
+
{
|
43
|
+
cl.name => cl.items
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/yello/trello.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'yello/auth'
|
2
|
+
require 'trello'
|
3
|
+
|
4
|
+
module Yello
|
5
|
+
module Trello
|
6
|
+
def client
|
7
|
+
@client ||= ::Trello::Client.new(
|
8
|
+
developer_public_key: auth.key,
|
9
|
+
member_token: auth.token)
|
10
|
+
end
|
11
|
+
|
12
|
+
def auth
|
13
|
+
@auth ||= Yello::Auth.get
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/yello.rb
ADDED
data/spec/auth_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yello/auth'
|
3
|
+
|
4
|
+
module Yello
|
5
|
+
describe Auth do
|
6
|
+
|
7
|
+
let(:netrc) {{'yello'=>['KEY', 'TOKEN']}}
|
8
|
+
|
9
|
+
it 'should get auth' do
|
10
|
+
expect(Netrc).to receive(:read){ netrc }
|
11
|
+
Yello::Auth.get.tap{|auth|
|
12
|
+
expect(auth.key).to eq "KEY"
|
13
|
+
expect(auth.token).to eq "TOKEN"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set auth' do
|
18
|
+
expect(Netrc).to receive(:read){ netrc }
|
19
|
+
expect(netrc).to receive(:[]=).with('yello', ['KEY', 'TOKEN'])
|
20
|
+
expect(netrc).to receive(:save)
|
21
|
+
Yello::Auth.set('KEY', 'TOKEN')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/create.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yello/from_trello'
|
3
|
+
|
4
|
+
module Yello
|
5
|
+
describe self do
|
6
|
+
|
7
|
+
let(:board){ double('board', name: 'BOARD', lists: [list]) }
|
8
|
+
let(:list){ double('list', name: 'LIST', cards:[card])}
|
9
|
+
let(:card){ double('card', name: 'CARD', pos: 1, desc: 'DESCRIPTION', checklists: [checklist])}
|
10
|
+
let(:checklist){ double('checklist', name: 'CHECKLIST', items: [item])}
|
11
|
+
let(:item){ double('item', name: 'ITEM') }
|
12
|
+
|
13
|
+
it 'should convert trello objects to model objects' do
|
14
|
+
Yello.from_trello(board).tap do |lists|
|
15
|
+
expect(lists.size).to eq 1
|
16
|
+
lists[0].tap do |list|
|
17
|
+
expect(list.name).to eq 'LIST'
|
18
|
+
list.cards.tap do |cards|
|
19
|
+
expect(cards.size).to eq 1
|
20
|
+
cards[0].tap do |card|
|
21
|
+
expect(card.name).to eq 'CARD'
|
22
|
+
card.checklists.tap do |checklists|
|
23
|
+
expect(checklists.size).to eq 1
|
24
|
+
checklists[0].tap do |checklist|
|
25
|
+
expect(checklist.name).to eq 'CHECKLIST'
|
26
|
+
expect(checklist.items).to eq(["ITEM"])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec/expectations'
|
3
|
+
require 'yello/from_yaml'
|
4
|
+
|
5
|
+
describe Yello do
|
6
|
+
RSpec.configure do |c|
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:lists) { Yello.from_yaml(File.read("#{__dir__}/test.yml")) }
|
10
|
+
let(:cards) { lists[0].cards }
|
11
|
+
let(:checklists) { cards[4].checklists }
|
12
|
+
|
13
|
+
it 'should have lists' do
|
14
|
+
expect(lists.size).to eq 3
|
15
|
+
expect(lists[0].name).to eq("Not Started")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have cards' do
|
19
|
+
expect(cards.size).to eq 5
|
20
|
+
expect(cards[0].name).to eq 'Get an email account'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have checklists' do
|
24
|
+
expect(checklists.size).to eq 1
|
25
|
+
expect(checklists[0].name).to eq 'Process'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have items in a checklist' do
|
29
|
+
expect(checklists[0].items.size).to eq 4
|
30
|
+
expect(checklists[0].items[0]).to eq 'Write tests'
|
31
|
+
end
|
32
|
+
end
|
data/spec/import_spec.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yello/from_yaml'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'yello/import'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Yello
|
7
|
+
describe self do
|
8
|
+
let(:auth){ double('auth', :key=>'KEY', :token=>'TOKEN') }
|
9
|
+
let(:client) { double('client') }
|
10
|
+
let(:board) { double('board', id: 'BOARD-ID') }
|
11
|
+
let(:existing_lists){ [existing_list] }
|
12
|
+
let(:existing_list){ double('existing-list') }
|
13
|
+
let(:list) { double('list', id: 'LIST-ID') }
|
14
|
+
let(:card){ double('card') }
|
15
|
+
let(:checklist_json){ {'id'=>'CHECKLIST-ID'}.to_json }
|
16
|
+
let(:checklist){double('checklist')}
|
17
|
+
let(:input){
|
18
|
+
Yello.from_yaml(File.read("#{__dir__}/create.yml"))
|
19
|
+
}
|
20
|
+
|
21
|
+
it 'should import a board' do
|
22
|
+
expect(Yello::Auth).to receive(:get){ auth }
|
23
|
+
expect(::Trello::Client).to receive(:new).with(
|
24
|
+
developer_public_key: 'KEY',
|
25
|
+
member_token: 'TOKEN'){
|
26
|
+
client
|
27
|
+
}
|
28
|
+
expect(client).to receive(:create).with(:boards, 'name'=>'BOARD'){board}
|
29
|
+
expect(board).to receive(:lists){existing_lists}
|
30
|
+
expect(existing_list).to receive(:closed=).with(true)
|
31
|
+
expect(existing_list).to receive(:save)
|
32
|
+
expect(client).to receive(:create).with(:list, 'name'=>'LIST', 'idBoard'=> 'BOARD-ID'){ list }
|
33
|
+
expect(client).to receive(:create).with(:card, 'name'=>'CARD', 'idList'=>'LIST-ID', 'desc'=>nil){ card }
|
34
|
+
expect(card).to receive(:create_new_checklist).with('CHECKLIST'){checklist_json}
|
35
|
+
expect(client).to receive(:find).with(:checklist, 'CHECKLIST-ID'){checklist}
|
36
|
+
expect(checklist).to receive(:add_item).with('ITEM')
|
37
|
+
|
38
|
+
Yello.import('BOARD', input)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should export a board' do
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/spec/spec_helper.rb
ADDED
data/spec/test.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Not Started:
|
2
|
+
cards:
|
3
|
+
- Get an email account
|
4
|
+
- Have lunch with your manager
|
5
|
+
- Get a key card
|
6
|
+
- Attend the noob-101 workshop
|
7
|
+
- Submit your first bugfix:
|
8
|
+
desc: You must fix a bug to prove your worth.
|
9
|
+
checklists:
|
10
|
+
- Process:
|
11
|
+
- Write tests
|
12
|
+
- Write code
|
13
|
+
- Get it reviewed
|
14
|
+
- Merge it
|
15
|
+
In Progress: {}
|
16
|
+
Completed: {}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yello/to_yaml'
|
3
|
+
|
4
|
+
module Yello
|
5
|
+
describe self do
|
6
|
+
let(:lists){[list]}
|
7
|
+
let(:list){double('list', name: 'LIST', cards: [card1, card2])}
|
8
|
+
let(:card1){double('card1', name: 'CARD1', desc: 'DESCRIPTION', checklists: [checklist])}
|
9
|
+
let(:card2){double('card2', name: 'CARD2', desc: nil, checklists:nil)}
|
10
|
+
let(:checklist){double('checklist', name: 'CHECKLIST', items:['ITEM'])}
|
11
|
+
|
12
|
+
it 'should convert model objects to yaml' do
|
13
|
+
expect(YAML.load(Yello.to_yaml(lists))).to eq (
|
14
|
+
{
|
15
|
+
'LIST'=>{
|
16
|
+
'cards'=>[
|
17
|
+
{
|
18
|
+
'CARD1'=>nil,
|
19
|
+
'checklists'=>[
|
20
|
+
{'CHECKLIST'=>[
|
21
|
+
'ITEM']
|
22
|
+
}
|
23
|
+
],
|
24
|
+
'desc'=>'DESCRIPTION'
|
25
|
+
},
|
26
|
+
'CARD2'
|
27
|
+
]
|
28
|
+
}
|
29
|
+
})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/yello.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'yello/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'yello'
|
8
|
+
spec.version = Yello::VERSION
|
9
|
+
spec.authors = ['Mike Shea']
|
10
|
+
spec.email = ['mike.shea@gmail.com']
|
11
|
+
spec.summary = %q{Yaml to trello}
|
12
|
+
spec.homepage = "http://github.com/sheax0r/yello"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
+
spec.add_development_dependency 'rspec', '~>3.0'
|
23
|
+
spec.add_development_dependency 'simplecov', '~> 0.9'
|
24
|
+
|
25
|
+
spec.add_dependency 'highline', '~> 1.6'
|
26
|
+
spec.add_dependency 'os', '~> 0.9'
|
27
|
+
spec.add_dependency 'rest-client', '~> 1.7'
|
28
|
+
spec.add_dependency 'ruby-trello', '~> 1.1'
|
29
|
+
spec.add_dependency 'thor', '~> 0.19'
|
30
|
+
spec.add_dependency 'netrc', '~> 0.8'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yello
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Shea
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: highline
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: os
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.9'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.9'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rest-client
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.7'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.7'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: ruby-trello
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.1'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.1'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: thor
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.19'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.19'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: netrc
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.8'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.8'
|
153
|
+
description:
|
154
|
+
email:
|
155
|
+
- mike.shea@gmail.com
|
156
|
+
executables:
|
157
|
+
- yello
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- ".gitignore"
|
162
|
+
- Gemfile
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.md
|
165
|
+
- Rakefile
|
166
|
+
- bin/yello
|
167
|
+
- lib/yello.rb
|
168
|
+
- lib/yello/auth.rb
|
169
|
+
- lib/yello/base.rb
|
170
|
+
- lib/yello/card.rb
|
171
|
+
- lib/yello/checklist.rb
|
172
|
+
- lib/yello/cli.rb
|
173
|
+
- lib/yello/cli/export.rb
|
174
|
+
- lib/yello/cli/import.rb
|
175
|
+
- lib/yello/cli/login.rb
|
176
|
+
- lib/yello/from_trello.rb
|
177
|
+
- lib/yello/from_yaml.rb
|
178
|
+
- lib/yello/import.rb
|
179
|
+
- lib/yello/list.rb
|
180
|
+
- lib/yello/to_yaml.rb
|
181
|
+
- lib/yello/trello.rb
|
182
|
+
- lib/yello/version.rb
|
183
|
+
- spec/auth_spec.rb
|
184
|
+
- spec/create.yml
|
185
|
+
- spec/from_trello_spec.rb
|
186
|
+
- spec/from_yaml_spec.rb
|
187
|
+
- spec/import_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
- spec/test.yml
|
190
|
+
- spec/to_yaml_spec.rb
|
191
|
+
- yello.gemspec
|
192
|
+
homepage: http://github.com/sheax0r/yello
|
193
|
+
licenses:
|
194
|
+
- MIT
|
195
|
+
metadata: {}
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
require_paths:
|
199
|
+
- lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
requirements: []
|
211
|
+
rubyforge_project:
|
212
|
+
rubygems_version: 2.2.2
|
213
|
+
signing_key:
|
214
|
+
specification_version: 4
|
215
|
+
summary: Yaml to trello
|
216
|
+
test_files:
|
217
|
+
- spec/auth_spec.rb
|
218
|
+
- spec/create.yml
|
219
|
+
- spec/from_trello_spec.rb
|
220
|
+
- spec/from_yaml_spec.rb
|
221
|
+
- spec/import_spec.rb
|
222
|
+
- spec/spec_helper.rb
|
223
|
+
- spec/test.yml
|
224
|
+
- spec/to_yaml_spec.rb
|