todos_export 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Export comment TODO's, FIXME's and BUG's from your code.
4
4
 
5
+ [![Build Status](https://travis-ci.org/rcaught/todos_export.png)](https://travis-ci.org/rcaught/todos_export)
6
+ [![Dependency Status](https://gemnasium.com/rcaught/todos_export.png)](https://gemnasium.com/rcaught/todos_export)
7
+ [![Coverage Status](https://coveralls.io/repos/rcaught/todos_export/badge.png)](https://coveralls.io/r/rcaught/todos_export)
8
+ [![Code Climate](https://codeclimate.com/github/rcaught/todos_export.png)](https://codeclimate.com/github/rcaught/todos_export)
9
+
5
10
  Available export locations:
6
11
  - Github Issues
7
12
 
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :default => :spec
5
+ RSpec::Core::RakeTask.new
data/bin/todos_export CHANGED
@@ -1,6 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
+
5
+ # This is to make sure Faraday doesn't warn the user about the `system_timer` gem missing.
6
+ old_warn, $-w = $-w, nil
7
+ begin
8
+ require 'faraday'
9
+ ensure
10
+ $-w = old_warn
11
+ end
12
+
4
13
  require 'todos_export'
5
14
 
6
15
  Signal.trap(:INT, "EXIT")
@@ -53,17 +53,24 @@ module TodosExport
53
53
  say("<%= color('Tags:', :green) %>\n'#{ex[:type].downcase}'")
54
54
  say("\n")
55
55
  create = agree("Create this issue? [y]es, [n]o")
56
- if create
57
- if @client.create_issue(
58
- @repo,
59
- ex[:content],
60
- "#{ex[:content]}\n\nhttps://github.com/#{@repo}/blob/master/#{ex[:file]}#L#{ex[:line]}",
61
- { :labels => ex[:type].downcase })
56
+ if create && @client.create_issue(@repo,
57
+ ex[:content],
58
+ "#{ex[:content]}\n\nhttps://github.com/#{@repo}/blob/master/#{ex[:file]}#L#{ex[:line]}",
59
+ { :labels => ex[:type].downcase }
60
+ )
61
+ say("\n<%= color('Created!', :green) %>\n\n")
62
62
 
63
- say("\n<%= color('Created!', :green) %>\n\n")
64
- else
65
- say("\n<%= color('Not created!', :red) %>\n\n")
63
+ say("Delete the comment and save the file?" \
64
+ "\n\nFile: #{ex[:file]}" \
65
+ "\nLine: #{ex[:line]}" \
66
+ "\nComment: #{ex[:original_content]}\n\n")
67
+ delete = agree("[y]es, [n]")
68
+ if delete
69
+ self.main.delete_exportable(ex[:file], ex[:line])
70
+ say("\n<%= color('Deleted the line', :green) %>\n\n")
66
71
  end
72
+ else
73
+ say("\n<%= color('Not created!', :red) %>\n\n")
67
74
  end
68
75
  end
69
76
  end
@@ -1,3 +1,3 @@
1
1
  module TodosExport
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/todos_export.rb CHANGED
@@ -27,16 +27,19 @@ module TodosExport
27
27
 
28
28
  def find_exportables
29
29
  self.find_files
30
+ @exportables = []
30
31
 
31
32
  self.files.each do |file|
32
33
  File.open(file) do |f|
33
34
  f.each_with_index do |line, number|
34
- search = line.scan(/(?:#)(?:| )(TODO|FIXME|BUG):?(.*)$/i)
35
+ search = line.scan(/((?:#)(?:| )(TODO|FIXME|BUG):?(.*)$)/i)
35
36
  if !search.empty?
36
37
  self.exportables << {
37
- :type => search[0][0].upcase,
38
- :content => search[0][1].strip,
39
- :file => file.gsub(/^(.\/|\/)/, ''),
38
+ :type => search[0][1].upcase,
39
+ :content => search[0][2].strip,
40
+ :original_content => search[0][0],
41
+ :file => file.gsub(/^(.\/)/, ''),
42
+ :original_file => file,
40
43
  :line => number + 1
41
44
  }
42
45
  end
@@ -57,6 +60,24 @@ module TodosExport
57
60
  self.exportables.select { |x| x[:type] == 'BUG' }
58
61
  end
59
62
 
63
+ def delete_exportable(file, line)
64
+ lines = File.readlines(file)
65
+ lines.delete_at(line - 1)
66
+
67
+ File.open(file, "w") do |f|
68
+ lines.each { |l| f.puts(l) }
69
+ end
70
+
71
+ self.find_exportables
72
+ end
73
+
74
+ def delete_exportables
75
+ while !self.exportables.empty? do
76
+ self.delete_exportable(self.exportables[0][:file], self.exportables[0][:line])
77
+ self.find_exportables
78
+ end
79
+ end
80
+
60
81
  def execute
61
82
  self.find_exportables
62
83
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'todos_export/github_issues'
2
3
 
3
4
  describe TodosExport::GithubIssues do
@@ -1,18 +1,74 @@
1
+ require 'spec_helper'
1
2
  require 'todos_export'
3
+ require 'tempfile'
2
4
 
3
5
  describe TodosExport::Main do
4
6
  subject do
5
7
  TodosExport::Main.new('spec/resources')
6
8
  end
7
9
 
8
- it '#find_files' do
9
- subject.find_files
10
- subject.files.size.should == 3
10
+ context '#find_files' do
11
+ it 'finds them' do
12
+ subject.find_files
13
+ subject.files.size.should == 3
14
+ end
15
+
16
+ it 'clears when rerunning' do
17
+ subject.find_files
18
+ subject.files.size.should == 3
19
+ subject.find_files
20
+ subject.files.size.should == 3
21
+ end
11
22
  end
12
23
 
13
- it '#find_exportables' do
14
- subject.find_exportables
15
- subject.exportables.size.should == 10
24
+ context '#find_exportables' do
25
+ it 'finds them' do
26
+ subject.find_exportables
27
+ subject.exportables.size.should == 10
28
+ end
29
+
30
+ it 'clears when rerunning' do
31
+ subject.find_exportables
32
+ subject.exportables.size.should == 10
33
+ subject.find_exportables
34
+ subject.exportables.size.should == 10
35
+ end
36
+ end
37
+
38
+ it '#delete_exportable' do
39
+ copied_file = Tempfile.new('copy_of_ruby_file_with_todos.rb')
40
+ copied_file.write(File.open('spec/resources/ruby_file_with_todos.rb', 'rb').read)
41
+ copied_file.rewind
42
+ s = TodosExport::Main.new(copied_file.path)
43
+ lines = File.readlines(copied_file.path).size
44
+
45
+ s.find_exportables
46
+ s.exportables.size.should == 8
47
+
48
+ while !s.exportables.empty? do
49
+ s.delete_exportable(s.exportables[0][:file], s.exportables[0][:line])
50
+ s.find_exportables
51
+ end
52
+
53
+ s.find_exportables
54
+ s.exportables.size.should == 0
55
+ File.readlines(copied_file.path).size.should == (lines - 8)
56
+ end
57
+
58
+ it '#delete_exportables' do
59
+ copied_file = Tempfile.new('copy_of_ruby_file_with_todos.rb')
60
+ copied_file.write(File.open('spec/resources/ruby_file_with_todos.rb', 'rb').read)
61
+ copied_file.rewind
62
+ s = TodosExport::Main.new(copied_file.path)
63
+ lines = File.readlines(copied_file.path).size
64
+
65
+ s.find_exportables
66
+ s.exportables.size.should == 8
67
+
68
+ s.delete_exportables
69
+ s.find_exportables
70
+ s.exportables.size.should == 0
71
+ File.readlines(copied_file.path).size.should == (lines - 8)
16
72
  end
17
73
 
18
74
  it '#exportables' do
@@ -21,61 +77,81 @@ describe TodosExport::Main do
21
77
  {
22
78
  :type => "FIXME",
23
79
  :content => "This is a useless class, what we really need to do is sit down and eat some cheese",
80
+ :original_content => "# fixme: This is a useless class, what we really need to do is sit down and eat some cheese",
24
81
  :file => 'spec/resources/ruby_file_with_todos.rb',
82
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
25
83
  :line => 2
26
84
  },
27
85
  {
28
86
  :type => "TODO",
29
87
  :content => "Find a kinder message",
88
+ :original_content => "#TODO: Find a kinder message",
30
89
  :file => 'spec/resources/ruby_file_with_todos.rb',
90
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
31
91
  :line => 12
32
92
  },
33
93
  {
34
94
  :type => "TODO",
35
95
  :content => "Make a list",
96
+ :original_content => "# TODO: Make a list",
36
97
  :file => 'spec/resources/ruby_file_with_todos.rb',
98
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
37
99
  :line => 18
38
100
  },
39
101
  {
40
102
  :type => "FIXME",
41
103
  :content => "Use case statement",
104
+ :original_content => "#FIXME: Use case statement",
42
105
  :file => 'spec/resources/ruby_file_with_todos.rb',
106
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
43
107
  :line => 22
44
108
  },
45
109
  {
46
110
  :type => "TODO",
47
111
  :content => "Add more cheese types",
112
+ :original_content => "#todo: Add more cheese types",
48
113
  :file => 'spec/resources/ruby_file_with_todos.rb',
114
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
49
115
  :line => 26
50
116
  },
51
117
  {
52
118
  :type => "TODO",
53
119
  :content => "Add more region cheeses",
120
+ :original_content => "#todo Add more region cheeses",
54
121
  :file => 'spec/resources/ruby_file_with_todos.rb',
122
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
55
123
  :line => 35
56
124
  },
57
125
  {
58
126
  :type => "TODO",
59
127
  :content => "Personalize the class to your taste",
128
+ :original_content => "# TODO Personalize the class to your taste",
60
129
  :file => 'spec/resources/ruby_file_with_todos.rb',
130
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
61
131
  :line => 41
62
132
  },
63
133
  {
64
134
  :type => "BUG",
65
135
  :content => "This should be false",
136
+ :original_content => "# BUG: This should be false",
66
137
  :file => 'spec/resources/ruby_file_with_todos.rb',
138
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
67
139
  :line => 46
68
140
  },
69
141
  {
70
142
  :type => "TODO",
71
143
  :content => "Be a better Ruby file",
144
+ :original_content => "# TODO: Be a better Ruby file",
72
145
  :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
146
+ :original_file => "spec/resources/sub_directory/another_ruby_file_with_todos.rb",
73
147
  :line => 1
74
148
  },
75
149
  {
76
150
  :type => "BUG",
77
151
  :content => "This should say it's a Ruby file",
152
+ :original_content => "# BUG: This should say it's a Ruby file",
78
153
  :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
154
+ :original_file => "spec/resources/sub_directory/another_ruby_file_with_todos.rb",
79
155
  :line => 2
80
156
  }
81
157
  ]
@@ -87,37 +163,49 @@ describe TodosExport::Main do
87
163
  {
88
164
  :type => "TODO",
89
165
  :content => "Find a kinder message",
166
+ :original_content => "#TODO: Find a kinder message",
90
167
  :file => 'spec/resources/ruby_file_with_todos.rb',
168
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
91
169
  :line => 12
92
170
  },
93
171
  {
94
172
  :type => "TODO",
95
173
  :content => "Make a list",
174
+ :original_content => "# TODO: Make a list",
96
175
  :file => 'spec/resources/ruby_file_with_todos.rb',
176
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
97
177
  :line => 18
98
178
  },
99
179
  {
100
180
  :type => "TODO",
101
181
  :content => "Add more cheese types",
182
+ :original_content => "#todo: Add more cheese types",
102
183
  :file => 'spec/resources/ruby_file_with_todos.rb',
184
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
103
185
  :line => 26
104
186
  },
105
187
  {
106
188
  :type => "TODO",
107
189
  :content => "Add more region cheeses",
190
+ :original_content => "#todo Add more region cheeses",
108
191
  :file => 'spec/resources/ruby_file_with_todos.rb',
192
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
109
193
  :line => 35
110
194
  },
111
195
  {
112
196
  :type => "TODO",
113
197
  :content => "Personalize the class to your taste",
198
+ :original_content => "# TODO Personalize the class to your taste",
114
199
  :file => 'spec/resources/ruby_file_with_todos.rb',
200
+ :original_file => "spec/resources/ruby_file_with_todos.rb",
115
201
  :line => 41
116
202
  },
117
203
  {
118
204
  :type => "TODO",
119
205
  :content => "Be a better Ruby file",
206
+ :original_content => "# TODO: Be a better Ruby file",
120
207
  :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
208
+ :original_file => "spec/resources/sub_directory/another_ruby_file_with_todos.rb",
121
209
  :line => 1
122
210
  }
123
211
  ]
@@ -129,13 +217,17 @@ describe TodosExport::Main do
129
217
  {
130
218
  :type => "FIXME",
131
219
  :content => "This is a useless class, what we really need to do is sit down and eat some cheese",
220
+ :original_content => "# fixme: This is a useless class, what we really need to do is sit down and eat some cheese",
132
221
  :file => 'spec/resources/ruby_file_with_todos.rb',
222
+ :original_file => 'spec/resources/ruby_file_with_todos.rb',
133
223
  :line => 2
134
224
  },
135
225
  {
136
226
  :type => "FIXME",
137
227
  :content => "Use case statement",
228
+ :original_content => "#FIXME: Use case statement",
138
229
  :file => 'spec/resources/ruby_file_with_todos.rb',
230
+ :original_file => 'spec/resources/ruby_file_with_todos.rb',
139
231
  :line => 22
140
232
  }
141
233
  ]
@@ -147,13 +239,17 @@ describe TodosExport::Main do
147
239
  {
148
240
  :type => "BUG",
149
241
  :content => "This should be false",
242
+ :original_content => "# BUG: This should be false",
150
243
  :file => 'spec/resources/ruby_file_with_todos.rb',
244
+ :original_file => 'spec/resources/ruby_file_with_todos.rb',
151
245
  :line => 46
152
246
  },
153
247
  {
154
248
  :type => "BUG",
155
249
  :content => "This should say it's a Ruby file",
250
+ :original_content => "# BUG: This should say it's a Ruby file",
156
251
  :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
252
+ :original_file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
157
253
  :line => 2
158
254
  }
159
255
  ]
@@ -0,0 +1,2 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
data/todos_export.gemspec CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
24
25
 
25
26
  spec.add_runtime_dependency "highline"
26
27
  spec.add_runtime_dependency "octokit"
27
28
  spec.add_runtime_dependency "json"
28
- spec.add_runtime_dependency "system_timer"
29
29
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todos_export
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Caught
@@ -15,13 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-17 00:00:00 -04:00
18
+ date: 2013-06-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: bundler
22
+ type: :development
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ~>
@@ -31,12 +31,12 @@ dependencies:
31
31
  - 1
32
32
  - 3
33
33
  version: "1.3"
34
- type: :development
35
- version_requirements: *id001
34
+ name: bundler
35
+ requirement: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- name: rake
37
+ type: :development
38
38
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ">="
@@ -45,12 +45,12 @@ dependencies:
45
45
  segments:
46
46
  - 0
47
47
  version: "0"
48
- type: :development
49
- version_requirements: *id002
48
+ name: rake
49
+ requirement: *id002
50
50
  - !ruby/object:Gem::Dependency
51
- name: rspec
51
+ type: :development
52
52
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
56
  - - ">="
@@ -59,12 +59,12 @@ dependencies:
59
59
  segments:
60
60
  - 0
61
61
  version: "0"
62
- type: :development
63
- version_requirements: *id003
62
+ name: rspec
63
+ requirement: *id003
64
64
  - !ruby/object:Gem::Dependency
65
- name: highline
65
+ type: :development
66
66
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements:
70
70
  - - ">="
@@ -73,12 +73,12 @@ dependencies:
73
73
  segments:
74
74
  - 0
75
75
  version: "0"
76
- type: :runtime
77
- version_requirements: *id004
76
+ name: coveralls
77
+ requirement: *id004
78
78
  - !ruby/object:Gem::Dependency
79
- name: octokit
79
+ type: :runtime
80
80
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
82
  none: false
83
83
  requirements:
84
84
  - - ">="
@@ -87,12 +87,12 @@ dependencies:
87
87
  segments:
88
88
  - 0
89
89
  version: "0"
90
- type: :runtime
91
- version_requirements: *id005
90
+ name: highline
91
+ requirement: *id005
92
92
  - !ruby/object:Gem::Dependency
93
- name: json
93
+ type: :runtime
94
94
  prerelease: false
95
- requirement: &id006 !ruby/object:Gem::Requirement
95
+ version_requirements: &id006 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ">="
@@ -101,12 +101,12 @@ dependencies:
101
101
  segments:
102
102
  - 0
103
103
  version: "0"
104
- type: :runtime
105
- version_requirements: *id006
104
+ name: octokit
105
+ requirement: *id006
106
106
  - !ruby/object:Gem::Dependency
107
- name: system_timer
107
+ type: :runtime
108
108
  prerelease: false
109
- requirement: &id007 !ruby/object:Gem::Requirement
109
+ version_requirements: &id007 !ruby/object:Gem::Requirement
110
110
  none: false
111
111
  requirements:
112
112
  - - ">="
@@ -115,8 +115,8 @@ dependencies:
115
115
  segments:
116
116
  - 0
117
117
  version: "0"
118
- type: :runtime
119
- version_requirements: *id007
118
+ name: json
119
+ requirement: *id007
120
120
  description: Export comment Todo's, Fixme's and Bug's from your code
121
121
  email:
122
122
  - rcaught@gmail.com
@@ -128,6 +128,7 @@ extra_rdoc_files: []
128
128
 
129
129
  files:
130
130
  - .gitignore
131
+ - .rspec
131
132
  - Gemfile
132
133
  - LICENSE.txt
133
134
  - README.md
@@ -142,6 +143,7 @@ files:
142
143
  - spec/resources/ruby_file_with_todos.rb
143
144
  - spec/resources/ruby_file_without_todos.rb
144
145
  - spec/resources/sub_directory/another_ruby_file_with_todos.rb
146
+ - spec/spec_helper.rb
145
147
  - todos_export.gemspec
146
148
  has_rdoc: true
147
149
  homepage: https://github.com/rcaught/todos_export
@@ -184,3 +186,4 @@ test_files:
184
186
  - spec/resources/ruby_file_with_todos.rb
185
187
  - spec/resources/ruby_file_without_todos.rb
186
188
  - spec/resources/sub_directory/another_ruby_file_with_todos.rb
189
+ - spec/spec_helper.rb