totrello 0.3.04 → 1.0.0
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 +8 -8
- data/.gitignore +3 -83
- data/.hound.yml +1 -0
- data/.totrello.yml +3 -0
- data/.travis.yml +3 -7
- data/Gemfile +0 -1
- data/Guardfile +37 -0
- data/README.md +3 -1
- data/bin/ToTrello +31 -39
- data/lib/totrello.rb +3 -59
- data/lib/totrello/todos.rb +65 -0
- data/lib/totrello/trello_builder.rb +59 -0
- data/lib/totrello/trello_config.rb +31 -0
- data/lib/totrello/trelloize.rb +32 -0
- data/lib/totrello/version.rb +1 -1
- data/spec/fixtures/.totrello.yml +11 -0
- data/spec/fixtures/fixture.rb +19 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/todos_spec.rb +183 -0
- data/spec/totrello_spec.rb +7 -0
- data/spec/trello_builder_spec.rb +166 -0
- data/spec/trello_config_spec.rb +105 -0
- data/spec/trelloize_spec.rb +49 -0
- data/totrello.gemspec +10 -0
- metadata +165 -18
- data/lib/to_do_find.rb +0 -101
- data/lib/totrello_config.rb +0 -52
- data/lib/trello_creator.rb +0 -63
- data/test/spec_helper.rb +0 -8
- data/test/test_data/testing.rb +0 -19
- data/test/to_do_find_spec.rb +0 -67
- data/test/totrello_config_spec.rb +0 -23
- data/test/totrello_spec.rb +0 -67
- data/test/trello_creator_spec.rb +0 -60
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
# TrelloConfig
|
4
|
+
class TrelloConfig
|
5
|
+
attr_accessor :project_name, :board_name, :default_list,
|
6
|
+
:excludes, :todo_types, :file_types, :comment_style
|
7
|
+
|
8
|
+
def initialize(directory = Dir.pwd.to_s)
|
9
|
+
load_config("#{directory}/.totrello.yml")
|
10
|
+
default_config(directory)
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_config(directory = Dir.pwd.to_s)
|
14
|
+
@project_name ||= directory.split('/').last
|
15
|
+
@board_name ||= directory.split('/').last
|
16
|
+
@default_list ||= 'To Do'
|
17
|
+
@excludes ||= Array(nil)
|
18
|
+
@todo_types ||= Array(['TODO', '#TODO', '#TODO:', 'TODO:'])
|
19
|
+
@file_types ||= Array(['.rb', '.erb'])
|
20
|
+
@comment_style ||= Array(['#'])
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_config(config_file)
|
24
|
+
return if config_file == ''
|
25
|
+
config_yaml = YAML.load_file(config_file)
|
26
|
+
|
27
|
+
config_yaml['totrello'].each do |key, value|
|
28
|
+
instance_variable_set("@#{key}", value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'totrello/trello_builder'
|
2
|
+
require 'totrello/trelloize'
|
3
|
+
require 'totrello/trello_config'
|
4
|
+
require 'totrello/todos'
|
5
|
+
|
6
|
+
# Trelloize
|
7
|
+
class Trelloize
|
8
|
+
attr_accessor :trello, :directory, :config
|
9
|
+
|
10
|
+
def initialize(directory = Dir.pwd.to_s)
|
11
|
+
@trello = TrelloBuilder.new
|
12
|
+
@directory = directory
|
13
|
+
@config = TrelloConfig.new(directory)
|
14
|
+
end
|
15
|
+
|
16
|
+
def description(todo, config)
|
17
|
+
return '' if todo.nil?
|
18
|
+
out = 'TODO item found by the '
|
19
|
+
out += "[ToTrello](https://rubygems.org/gems/totrello) gem\n"
|
20
|
+
out += "**Project name:** #{config.project_name}\n"
|
21
|
+
out += "**Filename**: #{todo[:file]}\n"
|
22
|
+
out += "**Action item**: #{todo[:todo]}\n"
|
23
|
+
out + "**Location (at or near) line**: #{todo[:line_number]}\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_and_create_cards_from_todos(todos, board)
|
27
|
+
todos.each do |todo|
|
28
|
+
description = description(todo, @config)
|
29
|
+
@trello.create_card(board, todo[:todo], description, @config.default_list)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/totrello/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
totrello:
|
2
|
+
project_name: 'ToTrello'
|
3
|
+
board_name: 'ToTrello'
|
4
|
+
default_list: 'To Do'
|
5
|
+
todo_types: ['TODO', '#TODO', '#TODO:', 'TODO:', 'FIXME', '#FIXME', '#FIXME:', 'FIXME:']
|
6
|
+
comment_style: ['#','//']
|
7
|
+
file_types: ['.rb','.yml']
|
8
|
+
excludes: [
|
9
|
+
'pkg/',
|
10
|
+
'bin/',
|
11
|
+
]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#TODO: test1
|
2
|
+
## TODO: test2
|
3
|
+
## TODO test3
|
4
|
+
## TODO: test4}
|
5
|
+
# #TODO test5
|
6
|
+
# #TODO: test6
|
7
|
+
todo
|
8
|
+
todo.test
|
9
|
+
TODO.tst #sdfasdfasdf
|
10
|
+
def clean_todos(todo_array)
|
11
|
+
todo_array.each do |found_todos|
|
12
|
+
found_todos[:todo].gsub!('TODO:', '')
|
13
|
+
found_todos[:todo].gsub!('TODO', '')
|
14
|
+
found_todos[:todo].gsub!('#', '')
|
15
|
+
found_todos[:todo].chomp!
|
16
|
+
found_todos[:todo].lstrip!
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'codeclimate-test-reporter'
|
2
|
+
require 'pry'
|
3
|
+
require 'dotenv'
|
4
|
+
require 'vcr'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
require 'bundler/setup'
|
7
|
+
CodeClimate::TestReporter.start
|
8
|
+
|
9
|
+
Bundler.setup
|
10
|
+
Dotenv.load
|
11
|
+
|
12
|
+
TRELLO_DEVELOPER_PUBLIC_KEY ||= ENV['TRELLO_DEVELOPER_PUBLIC_KEY']
|
13
|
+
TRELLO_MEMBER_TOKEN ||= ENV['TRELLO_MEMBER_TOKEN']
|
14
|
+
|
15
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
16
|
+
|
17
|
+
VCR.configure do |c|
|
18
|
+
c.cassette_library_dir = 'spec/cassettes'
|
19
|
+
c.hook_into :webmock
|
20
|
+
c.configure_rspec_metadata!
|
21
|
+
c.allow_http_connections_when_no_cassette = true
|
22
|
+
end
|
23
|
+
|
24
|
+
# require 'totrello/totrello'
|
25
|
+
require 'totrello'
|
26
|
+
|
27
|
+
RSpec.configure do |c|
|
28
|
+
# c.profile_examples = true
|
29
|
+
# c.fail_fast = 1
|
30
|
+
end
|
data/spec/todos_spec.rb
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'totrello/todos'
|
3
|
+
require 'totrello/trello_config'
|
4
|
+
|
5
|
+
describe Todos do
|
6
|
+
before(:all) do
|
7
|
+
@test_dir = "#{Dir.pwd}/spec/fixtures"
|
8
|
+
@test_file = 'fixture.rb'
|
9
|
+
@config = TrelloConfig.new
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'load_files' do
|
13
|
+
before(:each) do
|
14
|
+
@todos = Todos.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'responds to load_files' do
|
18
|
+
expect(@todos).to respond_to(:load_files)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'responds to load_files with a directory path and config' do
|
22
|
+
expect(@todos).to respond_to(:load_files).with(2).arguments
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns an array of file strings' do
|
26
|
+
expect(@todos.load_files(@test_dir, @config)).to be_a(Array)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'each item must be a string' do
|
30
|
+
files = @todos.load_files(@test_dir, @config)
|
31
|
+
files.each do |f|
|
32
|
+
expect(f).to be_a(String)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'lines_with_index_for_file' do
|
38
|
+
before(:each) do
|
39
|
+
@todos = Todos.new
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'responds to lines_with_index_for_file' do
|
43
|
+
expect(@todos).to respond_to(:lines_with_index_for_file)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'responds to lines_with_index_for_file for one argument' do
|
47
|
+
expect(@todos).to respond_to(:lines_with_index_for_file).with(1).arguments
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns an array' do
|
51
|
+
expect(@todos.lines_with_index_for_file(
|
52
|
+
"#{@test_dir}/#{@test_file}"
|
53
|
+
)).to be_a(Array)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'returns an array of todo objects' do
|
57
|
+
files = @todos.lines_with_index_for_file("#{@test_dir}/#{@test_file}")
|
58
|
+
files.each do |f|
|
59
|
+
expect(f).to be_a(Object)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'todo?' do
|
65
|
+
before(:each) do
|
66
|
+
@todos = Todos.new
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'responds to todo?' do
|
70
|
+
expect(@todos).to respond_to(:todo?)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'responds to lines_with_index_for_file for two arguments' do
|
74
|
+
expect(@todos).to respond_to(:todo?).with(2).arguments
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns a bool' do
|
78
|
+
expect([true, false]).to include @todos.todo?('', @config)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'returns true if a valid todo is passed' do
|
82
|
+
expect(@todos.todo?('#TODO: Something', @config)).to be true
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'returns false if a comment that\'s not a todo todo is passed' do
|
86
|
+
expect(@todos.todo?('#NODO: Something', @config)).to be(false)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'returns false if a a line doesn\'t start with a comment' do
|
90
|
+
expect(@todos.todo?('TODO: Something', @config)).to be(false)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns false if a a line is actually code for a hash todo' do
|
94
|
+
expect(@todos.todo?('todo: Something', @config)).to be(false)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'returns false if an assignment of variable todo' do
|
98
|
+
expect(@todos.todo?('todo = @something', @config)).to be(false)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'returns false if a a line is actually code with the word todo in it' do
|
102
|
+
expect(
|
103
|
+
@todos.todo?("found_todos[todo].gsub!('', '')", @config)
|
104
|
+
).to be(false)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'todos_for_file' do
|
109
|
+
before(:each) do
|
110
|
+
@todos = Todos.new
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'responds to todos_for_file' do
|
114
|
+
expect(@todos).to respond_to(:todos_for_file)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'responds to todos_for_file for three arguments' do
|
118
|
+
expect(@todos).to respond_to(:todos_for_file).with(2).arguments
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'returns an array' do
|
122
|
+
expect(
|
123
|
+
@todos.todos_for_file("#{@test_dir}/#{@test_file}", @config)
|
124
|
+
).to be_a(Array)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'returns an array of todo objects' do
|
128
|
+
files = @todos.todos_for_file("#{@test_dir}/#{@test_file}", @config)
|
129
|
+
files.each do |f|
|
130
|
+
expect(f).to be_a(Object)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'all_todos' do
|
136
|
+
before(:each) do
|
137
|
+
@todos = Todos.new
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'responds to all_todos' do
|
141
|
+
expect(@todos).to respond_to(:all_todos)
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'responds to todos_for_file for two arguments' do
|
145
|
+
expect(@todos).to respond_to(:all_todos).with(2).arguments
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'returns an array' do
|
149
|
+
expect(@todos.all_todos(@test_dir, @config)).to be_a(Array)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'returns an array of todo objects' do
|
153
|
+
files = @todos.all_todos(@test_dir, @config)
|
154
|
+
files.each do |f|
|
155
|
+
expect(f).to be_a(Object)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe 'clean_todo' do
|
161
|
+
before(:each) do
|
162
|
+
@todos = Todos.new
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'responds to clean_todo' do
|
166
|
+
expect(@todos).to respond_to(:clean_todo)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'responds to clean_todo for two arguments' do
|
170
|
+
expect(@todos).to respond_to(:clean_todo).with(2).arguments
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'returns a string' do
|
174
|
+
expect(@todos.clean_todo('#TODO: FOO BAR', @config)).to be_a(String)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'returns a string without #TODO' do
|
178
|
+
expect(
|
179
|
+
@todos.clean_todo('#TODO: Something awesome', @config)
|
180
|
+
).to be_a(String)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'totrello/trello_builder'
|
3
|
+
require 'totrello/trello_config'
|
4
|
+
require 'digest/sha1'
|
5
|
+
|
6
|
+
describe TrelloBuilder do
|
7
|
+
before(:all) do
|
8
|
+
@test_dir = "#{Dir.pwd}/spec/fixtures"
|
9
|
+
@test_file = 'fixture.rb'
|
10
|
+
@config = TrelloConfig.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'find_board' do
|
14
|
+
before(:each) do
|
15
|
+
@trello = TrelloBuilder.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'responds to find_board' do
|
19
|
+
expect(@trello).to respond_to(:find_board)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'responds to find_board with config' do
|
23
|
+
expect(@trello).to respond_to(:find_board).with(1).argument
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'responds with a board if the board exists' do
|
27
|
+
VCR.use_cassette 'find_board' do
|
28
|
+
expect(@trello.find_board(@config)).not_to be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'create_board' do
|
34
|
+
before(:each) do
|
35
|
+
@trello = TrelloBuilder.new
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'responds to create_board' do
|
39
|
+
expect(@trello).to respond_to(:create_board)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'responds to create_board with config' do
|
43
|
+
expect(@trello).to respond_to(:create_board).with(1).argument
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'creates a board' do
|
47
|
+
VCR.use_cassette 'create_board' do
|
48
|
+
expect(@trello.create_board(@config)).to be_a(Trello::Board)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'find_or_create_board' do
|
54
|
+
before(:each) do
|
55
|
+
@trello = TrelloBuilder.new
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'responds to find_or_create_board' do
|
59
|
+
expect(@trello).to respond_to(:find_or_create_board)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'responds to find_or_create_board with config' do
|
63
|
+
expect(@trello).to respond_to(:find_or_create_board).with(1).argument
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'finds or creates a board' do
|
67
|
+
VCR.use_cassette 'finds_or_creates_a_board' do
|
68
|
+
expect(@trello.find_or_create_board(@config)).to be_a(Trello::Board)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'find_list' do
|
74
|
+
before(:each) do
|
75
|
+
@trello = TrelloBuilder.new
|
76
|
+
@board = @trello.find_board(@config)
|
77
|
+
@list_name = 'To Do'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'responds to find_list' do
|
81
|
+
expect(@trello).to respond_to(:find_list)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'responds to find_list with board and list_name' do
|
85
|
+
expect(@trello).to respond_to(:find_list).with(2).arguments
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'returns the id of the list' do
|
89
|
+
VCR.use_cassette 'gets list id' do
|
90
|
+
expect(@trello.find_list(@board, @list_name)).to be_a(String)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'cards' do
|
96
|
+
before(:each) do
|
97
|
+
@trello = TrelloBuilder.new
|
98
|
+
@board = @trello.find_board(@config)
|
99
|
+
@list_name = 'To Do'
|
100
|
+
@list_id = @trello.find_list(@board, @list_name)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'responds to cards' do
|
104
|
+
expect(@trello).to respond_to(:cards)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'responds to cards with board and list_id' do
|
108
|
+
expect(@trello).to respond_to(:cards).with(2).arguments
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'returns a collection of cards' do
|
112
|
+
VCR.use_cassette 'list of cards' do
|
113
|
+
expect(@trello.cards(@board, @list_id)).to be_a(Array)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'card_exists?' do
|
119
|
+
before(:each) do
|
120
|
+
@trello = TrelloBuilder.new
|
121
|
+
@board = @trello.find_board(@config)
|
122
|
+
@list_name = 'To Do'
|
123
|
+
@list_id = @trello.find_list(@board, @list_name)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'responds to card_exists?' do
|
127
|
+
expect(@trello).to respond_to(:card_exists?)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'responds to card_exists? with board, list_names and card_name' do
|
131
|
+
expect(@trello).to respond_to(:card_exists?).with(3).arguments
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'returns false if the card doesn\'t exist' do
|
135
|
+
VCR.use_cassette 'doesn\'t find a card' do
|
136
|
+
expect(@trello.card_exists?(@board, ['To Do'], srand.to_s)).to be_falsey
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe 'create_card' do
|
142
|
+
before(:each) do
|
143
|
+
@trello = TrelloBuilder.new
|
144
|
+
@board = @trello.find_board(@config)
|
145
|
+
@list_name = 'To Do'
|
146
|
+
@list_id = @trello.find_list(@board, @list_name)
|
147
|
+
@card_name = (Digest::SHA1.hexdigest Time.now.to_s)
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'responds to create_card' do
|
151
|
+
expect(@trello).to respond_to(:create_card)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'responds to create_card with a board, name, description, and list' do
|
155
|
+
expect(@trello).to respond_to(:create_card).with(4).arguments
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'returns a string of json if the card is created' do
|
159
|
+
VCR.use_cassette 'card created' do
|
160
|
+
expect(@trello.create_card(
|
161
|
+
@board, @card_name, 'bar', @list_name
|
162
|
+
)).to be_a(String)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|