totrello 0.1.18 → 0.2.01

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDdlNmQ0YTYwNzljZDhmODFmM2EzODUxMTE1Njg1NDJhMWIzOTA0MQ==
4
+ NDJiZWVhNWI5NDUxYjBlMzE3Yzc1MGU3MGM1ZmFiZGZjMGU0NDIzNw==
5
5
  data.tar.gz: !binary |-
6
- ZDhjNWYyNDAxNDA0MjA3YTZkZDQ2YmQxMGYxNDk3YTdjYTMxZDRjZA==
6
+ YTllOGExY2E3N2I0YjNkM2ZmZjZkN2FhMTBlZjhjZjE0YTQzOGQ4Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzEzMzc5MjYxYjQ2YTRjZjJkYjFlZjQ2MzZmN2VlYWNmYzNmNjllYTZkNDZk
10
- MTJkNmRmOGNkYjk4YzlkOWRlZDMzZGEwNmY4NmZmMjdkOTQ4Nzg0NjFiNWIy
11
- ODRhYTM5YWQ0ZGNjNTg4MzY0ZjZmYTc0NGRmNWI1YzdhZjhhYmM=
9
+ MWI4ODY4MDQ2ZTQxOGUwYjRlNDBmM2ZiM2E2ZmFmMGI4Yjk1NWViOGFiYzU3
10
+ NjgxNGYwMjBhNzk3NWQwYjRhZDYwMjExNmQ3NDU2NmZkMDEzNzlhNzMwZWM1
11
+ YjUzN2FjODMwZTY4Zjg5NGIzOGIxYzRiMzQ3YzI1NzYxOWRiODk=
12
12
  data.tar.gz: !binary |-
13
- YmM0YzMxYTE2NzY5YWRlMmMzNzk2NmE5Y2RmYTYxMTg3YWE3YWNjMDhjYWZl
14
- MDJkZmRjZjE4NTk3MWE0NmFhNWY4MTFmZjYxOGZiM2IyZTk1NWI0NTdkZmNl
15
- MDk4YTc5MWFmOGE1MGViNjE0ZjVhYjJkOGVlNGNlZTAwNTI1ZWE=
13
+ YzhhMzBlMGE0MTZkZmRjMjM1YTRhZGQyZjk5OGY4NTQzNzI0ZmNhNDkwMDAw
14
+ YzU1YjM5OTJiODZmMjEyOGY1ZTU0NDMyOTc0NDY5ODhjZWUzMThhNWI0YTIz
15
+ Y2Y3ZWEwYzE4MTY3N2Q2ODZmOGRmYmIwYjE5NWEzM2IzZWJmYmE=
data/.totrello.yml ADDED
@@ -0,0 +1,8 @@
1
+ totrello:
2
+ project_name: 'ToTrello'
3
+ board_name: 'ToTrello'
4
+ default_list: 'To Do'
5
+ excludes: [
6
+ 'pkg/',
7
+ 'bin/',
8
+ ]
data/.travis.yml CHANGED
@@ -4,7 +4,7 @@ rvm:
4
4
  - 2.1.1
5
5
  - 2.0.0-p247
6
6
  - 1.9.3-p194
7
- script: gem install bundler && bundle exec rspec test/totrello_spec.rb
7
+ script: gem install bundler && bundle exec rspec test/*
8
8
  deploy:
9
9
  provider: rubygems
10
10
  api_key:
data/README.md CHANGED
@@ -8,8 +8,8 @@ TODO: Turns Todo items into Trello cards
8
8
 
9
9
  ## Notes
10
10
 
11
- This is very early in development and makes several assumptions.
12
- + As it stands you cannot specify the board you want todo items posted to. They are always posted to a board with the projects name
11
+ If you do not specify a .totrello.yml file somewhere in your project ToTrello will assume:
12
+ + The board will be called by the directory name ToTrello was run in
13
13
  + Todo items are placed into the To Do list by default
14
14
 
15
15
 
@@ -29,7 +29,25 @@ Generate your TRELLO_MEMBER_TOKEN at: https://trello.com/1/authorize?key=[TRELLO
29
29
 
30
30
  $ export TRELLO_DEVELOPER_PUBLIC_KEY='[Your key here]'
31
31
  $ export TRELLO_MEMBER_TOKEN='[Your key here]'
32
-
32
+
33
+ ### Creating a .totrello.yml file:
34
+
35
+ The ToTrello yml file allows you to customize the way ToTrello functions:
36
+ + Project_name : The name of the project (i.e. ToTrello)
37
+ + board_name : The Trello board you want to post to
38
+ + default_list : The list you want your new todo items to post to
39
+ + excludes : The files or directories you want to exclude
40
+
41
+ #### Sample file:
42
+
43
+ totrello:
44
+ project_name: 'ToTrello'
45
+ board_name: 'ToTrello'
46
+ default_list: 'To Do'
47
+ excludes: [
48
+ 'pkg/',
49
+ 'bin/',
50
+ ]
33
51
 
34
52
  ### To Index the current working folder and create trello cards for it
35
53
 
data/lib/to_do_find.rb CHANGED
@@ -4,23 +4,24 @@ class ToDoFind
4
4
 
5
5
  # This will search a given directory
6
6
  #
7
- def search(directory)
7
+ def search(directory, excludes_dirs)
8
+ files_to_search = []
8
9
 
9
- dir = directory
10
- dir ||= Dir.pwd
10
+ directory ||= Dir.pwd
11
11
 
12
- todos= {directory: dir.split('/').last, :todo_list=>[] }
12
+ todos= {directory: directory.split('/').last, :todo_list=>[] }
13
13
 
14
- rbfiles = File.join("#{dir}/**", "*.*rb")
14
+ files_to_search = exclude_folders(get_folders(directory), Array(excludes_dirs))
15
15
 
16
- Dir.glob(rbfiles) do |my_text_file|
16
+
17
+ files_to_search.each do |my_text_file|
17
18
 
18
19
  found_todo = find_todo(my_text_file)
19
20
 
20
21
 
21
22
  if found_todo
22
23
  todos[:todo_list].append(
23
- {:file=> my_text_file.gsub(dir,''),
24
+ {:file=> my_text_file.gsub(directory,''),
24
25
  :todos => found_todo}
25
26
  )
26
27
  end
@@ -29,6 +30,19 @@ class ToDoFind
29
30
  todos
30
31
  end
31
32
 
33
+ def get_folders(directory)
34
+ directory ||= Dir.pwd
35
+ rbfiles = File.join("#{directory}/**", "*.*rb")
36
+ Dir.glob(rbfiles)
37
+ end
38
+
39
+ def exclude_folders(file_array, excludes_array)
40
+ excludes_array.each do |excludes_dir|
41
+ file_array.reject! { |i| i.include? excludes_dir }
42
+ end
43
+ file_array
44
+ end
45
+
32
46
  def find_todo(file)
33
47
  todo_styles = ['TODO', '#TODO', '#TODO:', 'TODO:']
34
48
  @out = []
@@ -1,3 +1,3 @@
1
1
  module Totrello
2
- VERSION = "0.1.18"
2
+ VERSION = "0.2.01"
3
3
  end
data/lib/totrello.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "totrello/version"
2
2
  require 'trello_creator'
3
3
  require 'to_do_find'
4
+ require 'totrello_config'
4
5
 
5
6
 
6
7
  module Totrello
@@ -8,11 +9,14 @@ module Totrello
8
9
  class Trelloize
9
10
  @trello
10
11
  @directory
12
+ @config
11
13
 
12
14
  def initialize(directory)
13
15
  begin
14
16
  @trello = TrelloCreator.new
15
17
  @directory = directory
18
+ totrello_config = TotrelloConfig.new(directory)
19
+ @config = totrello_config.build_hash
16
20
  rescue
17
21
  error_data = "It looks like you're missing some details:\n\n\n"
18
22
  error_data += " You must define TRELLO_DEVELOPER_PUBLIC_KEY & TRELLO_MEMBER_TOKEN\n"
@@ -20,58 +24,81 @@ module Totrello
20
24
  error_data += " \nhttps://trello.com/1/appKey/generate\n"
21
25
  error_data += " \nYou can generate the TRELLO_MEMBER_TOKEN at:\n "
22
26
  error_data += "\nhttps://trello.com/1/authorize?key=[TRELLO_DEVELOPER_PUBLIC_KEY]&name=ToTrelloGem&expiration=never&response_type=token&scope=read,write\n"
23
- #raise CustomException.new(error: error_data)
27
+ puts error_data
24
28
  end
25
-
26
- #find_todo_items
27
29
  end
28
30
 
29
31
  def find_todo_items
30
- puts 'Finding your todo items... This should take a minute...'
31
- todo = ToDoFind.new
32
- todos = todo.search(@directory)
33
- puts "Woot! We've got'em"
34
32
 
35
33
  puts 'Generating your board'
36
34
 
37
- board_name = todos[:directory].nil? ? todos[:directory] : @directory.split('/').last
38
- puts "Creating the board: #{board_name}"
39
-
35
+ puts "Creating the board: #{@config[:board_name].to_s}"
40
36
 
41
- board = create_or_gen_board(board_name)
37
+ board = create_or_gen_board(@config[:board_name].to_s)
42
38
 
43
39
  return -1 if board.nil?
44
40
 
45
41
  puts "Created or found a board with the ID: #{board.name}"
46
42
 
43
+
44
+ create_cards(board)
45
+ puts "And you're ready to go!"
46
+
47
+ end
48
+
49
+ def create_or_gen_board(board_name)
50
+ board = @trello.find_board(board_name)
51
+ board ||= @trello.create_board(board_name, 'Auto Generated by ToTrello Gem')
52
+ end
53
+
54
+ def create_trello_card(board, list, todo, filename)
55
+ @trello.create_card(board, todo, gen_description(filename,todo, @config[:project_name].to_s),list)
56
+ end
57
+
58
+ private
59
+ def create_cards(board)
60
+
61
+
62
+ processes = []
63
+ todos = get_todos
64
+
47
65
  puts 'Talking to Trello, this is the longest part...'
66
+
48
67
  todos[:todo_list].each do |tdl|
49
68
  tdl[:todos].each do |td|
50
- puts gen_description(tdl[:file], td)
51
- #@trello.create_card(board,td, gen_description(tdl[:file],td),'To Do') unless td == ''
52
69
  unless td == ''
53
- create_trello_card(board, 'To Do', td, tdl[:file])
70
+ processes.append(fork {create_trello_card(board, @config[:default_list].to_s, td, tdl[:file])})
54
71
  end
55
72
  end
56
73
  end
57
- puts "And you're ready to go!"
74
+
75
+ process_manager(processes)
58
76
  end
59
77
 
60
- def create_or_gen_board(board_name)
61
- board = @trello.find_board(board_name)
62
- board ||= @trello.create_board(board_name, 'Auto Generated by ToTrello Gem')
78
+ private
79
+ def process_manager(processes)
80
+ processes.each {|pro| Process.waitpid(pro)}
63
81
  end
64
82
 
65
- def create_trello_card(board, list, todo, filename)
66
- @trello.create_card(board, todo, gen_description(filename,todo),list)
83
+ private
84
+ def get_todos
85
+ puts 'Finding your todo items... '
86
+ todo = ToDoFind.new
87
+ todos = todo.search(@directory,Array( @config[:excludes]))
88
+ puts "Woot! We've got'em"
89
+ todos
67
90
  end
68
91
 
69
92
 
70
- def gen_description(file, todo)
93
+
94
+ private
95
+ def gen_description(file, todo, project_name)
71
96
  out = "TODO item found by ToTrello\n"
72
- out += "Filename: #{file}\n"
73
- out += "Action item: #{todo[:todo]}\n"
74
- out += "Location (at or near) line: #{todo[:location]}\n"
97
+ out += "===========================\n"
98
+ out += "**Project name:** #{project_name}\n"
99
+ out += "**Filename**: #{file}\n"
100
+ out += "**Action item**: #{todo[:todo]}\n"
101
+ out += "**Location (at or near) line**: #{todo[:location]}\n"
75
102
  end
76
103
 
77
104
 
@@ -0,0 +1,44 @@
1
+ require 'yaml'
2
+
3
+ class TotrelloConfig
4
+ @project_name
5
+ @board_name
6
+ @default_list
7
+ @excludes
8
+
9
+ def initialize(directory)
10
+ read_config(directory)
11
+ defaults(directory)
12
+ end
13
+
14
+ def build_hash
15
+ {
16
+ :project_name => @project_name,
17
+ :board_name => @board_name,
18
+ :default_list => @default_list,
19
+ :excludes => @excludes
20
+ }
21
+ end
22
+
23
+ private
24
+ def read_config(directory)
25
+
26
+ rbfiles = File.join("#{directory}/**", ".totrello.yml")
27
+ trello_yml = Dir.glob(rbfiles)[0]
28
+
29
+ unless trello_yml.nil?
30
+ config = YAML.load_file(trello_yml )
31
+ config['totrello'].each { |key, value| instance_variable_set("@#{key}", value) }
32
+ end
33
+
34
+ end
35
+
36
+ private
37
+ def defaults(directory)
38
+ @project_name ||= directory.split('/').last
39
+ @board_name ||= directory.split('/').last
40
+ @default_list ||= 'To Do'
41
+ @excludes ||= Array(nil)
42
+ end
43
+
44
+ end
@@ -0,0 +1,8 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
4
+ require 'totrello'
5
+ require 'digest/sha1'
6
+
7
+ TRELLO_DEVELOPER_PUBLIC_KEY ||= ENV['TRELLO_DEVELOPER_PUBLIC_KEY']
8
+ TRELLO_MEMBER_TOKEN ||= ENV['TRELLO_MEMBER_TOKEN']
@@ -0,0 +1,52 @@
1
+ require 'totrello'
2
+ require 'digest/sha1'
3
+
4
+ describe 'ToDoFind' do
5
+
6
+ describe 'find_todo_items' do
7
+ it 'returns a hash of todo items from a directory'do
8
+ todo = ToDoFind.new
9
+ todos = todo.search("#{Dir.pwd}/test/test_data",nil)
10
+ expected = {:directory => "test_data", :todo_list => [{:file => "/testing.rb", :todos => [{:todo => "test1", :location => 1}, {:todo => "test2", :location => 2}, {:todo => "test3", :location => 3}, {:todo => "test4}", :location => 4}, {:todo => "test5", :location => 5}, {:todo => "test6", :location => 6}]}]}
11
+ expect(todos).to include(expected)
12
+ end
13
+
14
+ end
15
+
16
+ describe 'formatted_data' do
17
+ it "Should have a string for the todo and an Int for the locaion" do
18
+ todo = ToDoFind.new
19
+ todos = todo.search("#{Dir.pwd}/test/test_data", nil)
20
+
21
+ todos[:todo_list].each do |tdl|
22
+ tdl[:todos].each do |td|
23
+ expect(td[:todo]).to be_a_kind_of(String)
24
+ expect(td[:location]).to be_a_kind_of(Integer)
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ describe 'get_folders' do
33
+ it "Should return an array of files and folders" do
34
+ todo = ToDoFind.new
35
+ files = todo.get_folders("#{Dir.pwd}/test/test_data")
36
+ expect(files).to be_a(Array)
37
+ end
38
+
39
+ end
40
+
41
+ describe 'exclude_folders' do
42
+ it "Should return an array an empty array" do
43
+ todo = ToDoFind.new
44
+ files = todo.get_folders("#{Dir.pwd}/test/test_data")
45
+ files = todo.exclude_folders(files, Array(['test']))
46
+ expect(files).to be_a(Array)
47
+ expect(files).to match_array([])
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require 'totrello_config'
3
+
4
+ describe 'defaults' do
5
+
6
+ it 'should produce a hash of the defaulted settings file' do
7
+
8
+
9
+ sample_config = TotrelloConfig.new("#{Dir.pwd}/test/test_data/noymlfile")
10
+ test_settings = {
11
+ :project_name => 'noymlfile',
12
+ :board_name => 'noymlfile',
13
+ :default_list => 'To Do',
14
+ :excludes => Array(nil)
15
+ }
16
+ expect(sample_config.build_hash).to include(test_settings)
17
+
18
+
19
+
20
+
21
+ end
22
+ end
@@ -1,9 +1,6 @@
1
1
  require 'totrello'
2
2
  require 'digest/sha1'
3
3
 
4
- TRELLO_DEVELOPER_PUBLIC_KEY = ENV['TRELLO_DEVELOPER_PUBLIC_KEY']
5
- TRELLO_MEMBER_TOKEN = ENV['TRELLO_MEMBER_TOKEN']
6
-
7
4
  describe 'Totrello' do
8
5
 
9
6
  describe 'initialize' do
@@ -42,70 +39,5 @@ describe 'Totrello' do
42
39
 
43
40
  end
44
41
 
45
- describe 'ToDoFind' do
46
-
47
- describe 'find_todo_items' do
48
- it 'returns a hash of todo items from a directory'do
49
- todo = ToDoFind.new
50
- todos = todo.search("#{Dir.pwd}/test/test_data")
51
- expected = {:directory => "test_data", :todo_list => [{:file => "/testing.rb", :todos => [{:todo => "test1", :location => 1}, {:todo => "test2", :location => 2}, {:todo => "test3", :location => 3}, {:todo => "test4}", :location => 4}, {:todo => "test5", :location => 5}, {:todo => "test6", :location => 6}]}]}
52
- expect(todos).to include(expected)
53
- end
54
-
55
- end
56
-
57
- describe 'formatted_data' do
58
- it "Should have a string for the todo and an Int for the locaion" do
59
- todo = ToDoFind.new
60
- todos = todo.search("#{Dir.pwd}/test/test_data")
61
-
62
- todos[:todo_list].each do |tdl|
63
- tdl[:todos].each do |td|
64
- expect(td[:todo]).to be_a_kind_of(String)
65
- expect(td[:location]).to be_a_kind_of(Integer)
66
- end
67
- end
68
-
69
- end
70
-
71
- end
72
-
73
-
74
- end
75
-
76
- describe 'TrelloCreator' do
77
-
78
- describe 'initialize' do
79
- it 'should become an instance of itself' do
80
- t = TrelloCreator.new
81
- expect(t).to be_an_instance_of(TrelloCreator)
82
- end
83
-
84
- end
85
-
86
- describe 'create_card' do
87
-
88
- it 'should create a card' do
89
-
90
- directory = "#{Dir.pwd}/test/test_data"
91
- board_name = directory.split('/').last
92
-
93
-
94
- t = TrelloCreator.new
95
-
96
- board = t.find_board(board_name)
97
- board ||= t.create_board(board_name, 'Auto Generated by ToTrello Gem')
98
-
99
- card_name = {:todo => (Digest::SHA1.hexdigest Time.now.to_s)}
100
- card = t.create_card(board, card_name, card_name[:todo].reverse,'To Do')
101
- expect(card).to include(card_name[:todo])
102
-
103
- end
104
-
105
- end
106
-
107
-
108
- end
109
-
110
42
 
111
43
 
@@ -0,0 +1,60 @@
1
+ require 'totrello'
2
+ require 'digest/sha1'
3
+
4
+ describe 'TrelloCreator' do
5
+
6
+ describe 'initialize' do
7
+ it 'should become an instance of itself' do
8
+ t = TrelloCreator.new
9
+ expect(t).to be_an_instance_of(TrelloCreator)
10
+ end
11
+
12
+ end
13
+
14
+ describe 'create_card' do
15
+
16
+ it 'should create a card' do
17
+
18
+ directory = "#{Dir.pwd}/test/test_data"
19
+ board_name = directory.split('/').last
20
+
21
+
22
+ t = TrelloCreator.new
23
+
24
+ board = t.find_board(board_name)
25
+ board ||= t.create_board(board_name, 'Auto Generated by ToTrello Gem')
26
+
27
+ card_name = {:todo => (Digest::SHA1.hexdigest Time.now.to_s)}
28
+ card = t.create_card(board, card_name, card_name[:todo].reverse,'To Do')
29
+ expect(card).to include(card_name[:todo])
30
+
31
+ end
32
+
33
+ end
34
+
35
+ describe 'find_cards' do
36
+
37
+ it 'should find cards' do
38
+
39
+ directory = "#{Dir.pwd}/test/test_data"
40
+ board_name = directory.split('/').last
41
+
42
+
43
+ t = TrelloCreator.new
44
+
45
+ board = t.find_board(board_name)
46
+ board ||= t.create_board(board_name, 'Auto Generated by ToTrello Gem')
47
+ list = t.find_list(board, 'To Do')
48
+
49
+ cards = t.find_cards(board,list)
50
+ expect(cards).to be_a(Array)
51
+
52
+ end
53
+
54
+ end
55
+
56
+
57
+ end
58
+
59
+
60
+
data/totrello.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency 'rspec', '~> 3.0.0'
24
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.0'
24
25
 
25
26
  spec.add_dependency 'ruby-trello', '~> 1.1.1'
26
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totrello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.2.01
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Teeter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-07 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: ruby-trello
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +89,7 @@ extensions: []
75
89
  extra_rdoc_files: []
76
90
  files:
77
91
  - .gitignore
92
+ - .totrello.yml
78
93
  - .travis.yml
79
94
  - Gemfile
80
95
  - LICENSE.txt
@@ -84,9 +99,14 @@ files:
84
99
  - lib/to_do_find.rb
85
100
  - lib/totrello.rb
86
101
  - lib/totrello/version.rb
102
+ - lib/totrello_config.rb
87
103
  - lib/trello_creator.rb
104
+ - test/spec_helper.rb
88
105
  - test/test_data/testing.rb
106
+ - test/to_do_find_spec.rb
107
+ - test/totrello_config_spec.rb
89
108
  - test/totrello_spec.rb
109
+ - test/trello_creator_spec.rb
90
110
  - totrello.gemspec
91
111
  homepage: https://github.com/whatisinternet/ToTrello
92
112
  licenses:
@@ -113,5 +133,9 @@ signing_key:
113
133
  specification_version: 4
114
134
  summary: Turns todo items into trello cards.
115
135
  test_files:
136
+ - test/spec_helper.rb
116
137
  - test/test_data/testing.rb
138
+ - test/to_do_find_spec.rb
139
+ - test/totrello_config_spec.rb
117
140
  - test/totrello_spec.rb
141
+ - test/trello_creator_spec.rb