totrello 0.2.03 → 0.3.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTNjOGEzMzY1NTg4ZDE3Y2VhNWVhM2RhMmY3ZjIyMWNmOTc3YTU4NA==
4
+ MjNlMjZiY2FhN2JhNjliYzJkMjM2MDc3YTA4ZDM4ZDNlMWNmOTIwOQ==
5
5
  data.tar.gz: !binary |-
6
- MGE2NGJhZjIyMjc4YjlkNGUwMjhmYmFlYTk0ODE4ZDNhNGMxYzhiNQ==
6
+ MjZmNmM5YmUzZTc2OTI2MWRkZmI0YzBmYjdmNjUwYjc2YTU1YTY2OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTc0NDVkOTJlNzdhMDRkZmZiZWEwYTQwZmM5MTEzNzFiNjRjMDgwNTc4ZGM5
10
- NTZhNDMzNjdkMjQyZWQxMjc0ZDQ0MGU0Y2IyYmQzM2RlYzg1NmY4YjdmMGNk
11
- Y2FkOGUxNTA0YmNiNWM2MWE0NDMyODcyNTBlN2EyOGE2YjJjZjE=
9
+ Y2M5MGU3OThmOWI0ZGUxNjFlNjJjZDA4ZTczZmU5YmZhYWYyODc4YzkzZjNh
10
+ NjJhYzg3ZGJjZTU1ZGU0YTcwNTYyOTJiYmZlODI0ODViY2M1MGExN2FlOGZj
11
+ NDNmNDU0ZmE1MmUwNmFjZWFjZjIwODhlN2Q5NTA4MzVhMDJkZjY=
12
12
  data.tar.gz: !binary |-
13
- N2RlYzBjM2I0ZDQ5NGMzMmQ5Y2EzOTE3NDYwYjk2YjM4MjA5NWVjZTg4MGMx
14
- ZmUwYzAzMjgyNGIyN2VmMDg1YjYyNTYyNTNmYWExOTZlN2IxNGQ4NGQ2OTZk
15
- MGVkODdhOTViYzkzM2M4YjQ5YzRhZjg5N2JmMWJhMGZmMjE3Mzg=
13
+ OWJiYTk4YjE1ZDMyYTFhYzZkM2FhYWZjMWM2ZGE0OTkxMDI4MmYzZTlmMDdk
14
+ MTM2MDRmMGU2NmQzODhlODcyYThlM2Q0MTAyN2NhYmFhNzc4ZmMwMWZjNjRi
15
+ NzQ0OTZmNDllMmQ0OTc3OTFhNGUzODU1NDNkZTI1MWFjYjVjY2Y=
data/.totrello.yml CHANGED
@@ -2,7 +2,10 @@ totrello:
2
2
  project_name: 'ToTrello'
3
3
  board_name: 'ToTrello'
4
4
  default_list: 'To Do'
5
+ todo_types: ['TODO', '#TODO', '#TODO:', 'TODO:', 'FIXME', '#FIXME', '#FIXME:', 'FIXME:']
6
+ comment_style: ['#','//']
7
+ file_types: ['.rb','.yml']
5
8
  excludes: [
6
9
  'pkg/',
7
10
  'bin/',
8
- ]
11
+ ]
data/README.md CHANGED
@@ -30,13 +30,16 @@ Generate your TRELLO_MEMBER_TOKEN at: https://trello.com/1/authorize?key=[TRELLO
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:
33
+ ### Creating a .totrello.yml file (Must be in root directory):
34
34
 
35
35
  The ToTrello yml file allows you to customize the way ToTrello functions:
36
36
  + Project_name : The name of the project (i.e. ToTrello)
37
- + board_name : The Trello board you want to post to
37
+ + board_name : The Trello board you want to post to
38
38
  + default_list : The list you want your new todo items to post to
39
- + excludes : The files or directories you want to exclude
39
+ + todo_types : The types of todo items you want to capture
40
+ + comment_style: How comments appear in your file types
41
+ + file_types : Types of files you want to include in the search
42
+ + excludes : The files or directories you want to exclude
40
43
 
41
44
  #### Sample file:
42
45
 
@@ -44,6 +47,9 @@ The ToTrello yml file allows you to customize the way ToTrello functions:
44
47
  project_name: 'ToTrello'
45
48
  board_name: 'ToTrello'
46
49
  default_list: 'To Do'
50
+ todo_types: ['TODO', '#TODO', '#TODO:', 'TODO:', 'FIXME', '#FIXME', '#FIXME:', 'FIXME:']
51
+ comment_style: ['#','//']
52
+ file_types: ['.rb','.yml']
47
53
  excludes: [
48
54
  'pkg/',
49
55
  'bin/',
data/lib/to_do_find.rb CHANGED
@@ -4,19 +4,19 @@ class ToDoFind
4
4
 
5
5
  # This will search a given directory
6
6
  #
7
- def search(directory, excludes_dirs)
7
+ def search(directory, excludes_dirs, todo_styles, file_types, comment_styles)
8
8
  files_to_search = []
9
9
 
10
10
  directory ||= Dir.pwd
11
11
 
12
12
  todos= {directory: directory.split('/').last, :todo_list=>[] }
13
13
 
14
- files_to_search = exclude_folders(get_folders(directory), Array(excludes_dirs))
14
+ files_to_search = exclude_folders(get_folders(directory, file_types), Array(excludes_dirs))
15
15
 
16
16
 
17
17
  files_to_search.each do |my_text_file|
18
18
 
19
- found_todo = find_todo(my_text_file)
19
+ found_todo = find_todo(my_text_file, todo_styles, comment_styles)
20
20
 
21
21
 
22
22
  if found_todo
@@ -30,10 +30,16 @@ class ToDoFind
30
30
  todos
31
31
  end
32
32
 
33
- def get_folders(directory)
33
+ def get_folders(directory, file_types)
34
+
35
+ files = []
34
36
  directory ||= Dir.pwd
35
- rbfiles = File.join("#{directory}/**", "*.*rb")
36
- Dir.glob(rbfiles)
37
+
38
+ file_types.each do |ft|
39
+ file = File.join("#{directory}/**", "*#{ft.to_s}")
40
+ files.concat(Dir.glob(file))
41
+ end
42
+ files
37
43
  end
38
44
 
39
45
  def exclude_folders(file_array, excludes_array)
@@ -43,47 +49,46 @@ class ToDoFind
43
49
  file_array
44
50
  end
45
51
 
46
- def find_todo(file)
47
- todo_styles = ['TODO', '#TODO', '#TODO:', 'TODO:']
52
+ def find_todo(file, todo_styles, comment_styles)
48
53
  @out = []
49
54
  code_lines = File.readlines(file)
50
-
51
- return @out unless code_lines.grep('/TODO/' || '/todo/')
52
-
53
55
  code_lines= code_lines.map.with_index { |x,i| {:todo => x, :location => i + 1}}
54
56
 
55
57
  todo_styles.each do |tds|
56
58
  @out.concat((code_lines.find_all { |i| is_todo?(i[:todo], (tds))}))
57
59
  end
58
60
 
59
- clean_todos(@out).sort_by { |hsh| hsh[:todo] }
61
+ clean_todos(@out, todo_styles, comment_styles).sort_by { |hsh| hsh[:todo] }
60
62
  end
61
63
 
62
64
  private
63
- def clean_todos(todo_array)
64
- todo_array.each do |found_todos|
65
- found_todos[:todo].gsub!('TODO:', '')
66
- found_todos[:todo].gsub!('TODO', '')
67
- found_todos[:todo].gsub!('#', '')
68
- found_todos[:todo].chomp!
69
- found_todos[:todo].lstrip!
65
+ def clean_todos(todo_array, todo_styles, comment_styles)
66
+ todo_array.each do |found_todos|
67
+ todo_styles.each do |tds|
68
+ found_todos[:todo].gsub!(tds,'')
69
+ end
70
+ comment_styles.each do |cms|
71
+ found_todos[:todo].gsub!(cms,'')
72
+ end
73
+ found_todos[:todo].gsub!(':','')
74
+ found_todos[:todo].chomp!
75
+ found_todos[:todo].lstrip!
76
+ end
77
+
70
78
  end
71
79
 
72
- end
80
+ def is_todo?( string, test_string )
81
+ begin
82
+ location = string.split(' ').index test_string
83
+ if location.nil?
84
+ return false
85
+ else
86
+ return true
87
+ end
88
+ rescue
89
+ false
90
+ end
73
91
 
74
- private
75
- def is_todo?( string, test_string )
76
- begin
77
- location = string.split(' ').index test_string
78
- if location.nil?
79
- return false
80
- else
81
- return true
82
92
  end
83
- rescue
84
- false
85
- end
86
-
87
- end
88
93
 
89
94
  end
@@ -1,3 +1,3 @@
1
1
  module Totrello
2
- VERSION = "0.2.03"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/totrello.rb CHANGED
@@ -56,45 +56,43 @@ module Totrello
56
56
  end
57
57
 
58
58
  private
59
- def create_cards(board)
59
+ def create_cards(board)
60
60
 
61
61
 
62
- processes = []
63
- todos = get_todos
62
+ processes = []
63
+ todos = get_todos
64
64
 
65
- puts 'Talking to Trello, this is the longest part...'
65
+ puts 'Talking to Trello, this is the longest part...'
66
66
 
67
- todos[:todo_list].each do |tdl|
68
- tdl[:todos].each do |td|
69
- unless td == ''
70
- processes.append(fork {create_trello_card(board, @config[:default_list], td, tdl[:file])})
67
+ todos[:todo_list].each do |tdl|
68
+ tdl[:todos].each do |td|
69
+ unless td == ''
70
+ processes.append(fork {create_trello_card(board, @config[:default_list], td, tdl[:file])})
71
71
 
72
+ end
72
73
  end
73
74
  end
74
- end
75
-
76
- process_manager(processes)
77
- end
78
-
79
- private
80
- def process_manager(processes)
81
- processes.each {|pro| Process.waitpid(pro)}
82
- end
83
-
84
- private
85
- def get_todos
86
- puts 'Finding your todo items... '
87
- todo = ToDoFind.new
88
- todos = todo.search(@directory,Array( @config[:excludes]))
89
- puts "Woot! We've got'em"
90
- todos
91
- end
92
-
93
75
 
76
+ process_manager(processes)
77
+ end
94
78
 
79
+ def process_manager(processes)
80
+ processes.each {|pro| Process.waitpid(pro)}
81
+ end
95
82
 
83
+ def get_todos
84
+ puts 'Finding your todo items... '
85
+ todo = ToDoFind.new
86
+ todos = todo.search(@directory,
87
+ Array( @config[:excludes]),
88
+ Array( @config[:todo_types]),
89
+ Array( @config[:file_types]),
90
+ Array( @config[:comment_styles]))
91
+ puts "Woot! We've got'em"
92
+ todos
93
+ end
96
94
 
97
- end
98
95
 
96
+ end
99
97
 
100
98
  end
@@ -5,6 +5,9 @@ class TotrelloConfig
5
5
  @board_name
6
6
  @default_list
7
7
  @excludes
8
+ @todo_types
9
+ @file_types
10
+ @comment_style
8
11
 
9
12
  def initialize(directory)
10
13
  read_config(directory)
@@ -16,29 +19,35 @@ class TotrelloConfig
16
19
  :project_name => @project_name,
17
20
  :board_name => @board_name,
18
21
  :default_list => @default_list,
19
- :excludes => @excludes
22
+ :excludes => @excludes,
23
+ :todo_types => @todo_types,
24
+ :file_types => @file_types,
25
+ :comment_style => @comment_style
20
26
  }
21
27
  end
22
28
 
23
29
  private
24
- def read_config(directory)
30
+ def read_config(directory)
25
31
 
26
- rbfiles = File.join("#{directory}/**", ".totrello.yml")
27
- trello_yml = Dir.glob(rbfiles)[0]
32
+ totrello_config_file = File.join("#{directory}/", ".totrello.yml")
33
+ trello_yml = Dir.glob(totrello_config_file)[0]
28
34
 
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
35
+ unless trello_yml.nil?
36
+ puts "Found yml file file: #{trello_yml}"
37
+ config = YAML.load_file(trello_yml )
38
+ config['totrello'].each { |key, value| instance_variable_set("@#{key}", value) }
39
+ end
33
40
 
34
- end
41
+ end
35
42
 
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
+ def defaults(directory)
44
+ @project_name ||= directory.split('/').last
45
+ @board_name ||= directory.split('/').last
46
+ @default_list ||= 'To Do'
47
+ @excludes ||= Array(nil)
48
+ @todo_types ||= Array(['TODO', '#TODO', '#TODO:', 'TODO:'])
49
+ @file_types ||= Array(['.rb','.erb'])
50
+ @comment_style ||= Array(['#'])
51
+ end
43
52
 
44
53
  end
@@ -9,7 +9,6 @@ class TrelloCreator
9
9
  end
10
10
 
11
11
  def create_card(board, name, description, list_name)
12
- puts description
13
12
  list_names = ['To Do', 'Doing', 'Done']
14
13
  unless card_exists?(board, list_names, name)
15
14
  card = Trello::Card.create(name: name, list_id: self.find_list(board, list_name), desc: description)
@@ -6,8 +6,19 @@ describe 'ToDoFind' do
6
6
  describe 'find_todo_items' do
7
7
  it 'returns a hash of todo items from a directory'do
8
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}]}]}
9
+ todos = todo.search("#{Dir.pwd}/test/test_data",
10
+ nil,
11
+ Array(['TODO', '#TODO', '#TODO:', 'TODO:']),
12
+ Array(['.rb','.erb']),
13
+ Array(['#']))
14
+ expected = {:directory => "test_data",
15
+ :todo_list => [{:file => "/testing.rb",
16
+ :todos => [{:todo => "test1", :location => 1},
17
+ {:todo => "test2", :location => 2},
18
+ {:todo => "test3", :location => 3},
19
+ {:todo => "test4}", :location => 4},
20
+ {:todo => "test5", :location => 5},
21
+ {:todo => "test6", :location => 6}]}]}
11
22
  expect(todos).to include(expected)
12
23
  end
13
24
 
@@ -16,7 +27,11 @@ describe 'ToDoFind' do
16
27
  describe 'formatted_data' do
17
28
  it "Should have a string for the todo and an Int for the locaion" do
18
29
  todo = ToDoFind.new
19
- todos = todo.search("#{Dir.pwd}/test/test_data", nil)
30
+ todos = todo.search("#{Dir.pwd}/test/test_data",
31
+ nil,
32
+ Array(['TODO', '#TODO', '#TODO:', 'TODO:']),
33
+ Array(['.rb','.erb']),
34
+ Array(['#']))
20
35
 
21
36
  todos[:todo_list].each do |tdl|
22
37
  tdl[:todos].each do |td|
@@ -32,7 +47,7 @@ describe 'ToDoFind' do
32
47
  describe 'get_folders' do
33
48
  it "Should return an array of files and folders" do
34
49
  todo = ToDoFind.new
35
- files = todo.get_folders("#{Dir.pwd}/test/test_data")
50
+ files = todo.get_folders("#{Dir.pwd}/test/test_data",Array(['.rb','.erb']))
36
51
  expect(files).to be_a(Array)
37
52
  end
38
53
 
@@ -41,7 +56,7 @@ describe 'ToDoFind' do
41
56
  describe 'exclude_folders' do
42
57
  it "Should return an array an empty array" do
43
58
  todo = ToDoFind.new
44
- files = todo.get_folders("#{Dir.pwd}/test/test_data")
59
+ files =todo.get_folders("#{Dir.pwd}/test/test_data",Array(['.rb','.erb']))
45
60
  files = todo.exclude_folders(files, Array(['test']))
46
61
  expect(files).to be_a(Array)
47
62
  expect(files).to match_array([])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totrello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.03
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Teeter