todos_export 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in todos_export.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryan Caught
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,23 @@
1
+ # TodosExport
2
+
3
+ Export comment TODO's, FIXME's and BUG's from your code.
4
+
5
+ Available export locations:
6
+ - Github Issues
7
+
8
+ ## Installation
9
+
10
+ $ gem install todos_export
11
+
12
+ ## Usage
13
+
14
+ $ cd /my_project/
15
+ $ todos_export
16
+
17
+ ## Contributing
18
+
19
+ 1. Fork it
20
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
21
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
22
+ 4. Push to the branch (`git push origin my-new-feature`)
23
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/todos_export ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'todos_export'
5
+
6
+ Signal.trap(:INT, "EXIT")
7
+
8
+ target = ARGV[0] || './'
9
+ export = TodosExport::Main.new(target)
10
+ export.execute
@@ -0,0 +1,75 @@
1
+ require "todos_export/version"
2
+ require 'todos_export/github_issues'
3
+ require "highline/import"
4
+ require 'octokit'
5
+ HighLine.track_eof = false
6
+
7
+ module TodosExport
8
+ class Main
9
+ attr_accessor :target, :files, :exportables
10
+
11
+ def initialize(target)
12
+ self.target = target
13
+ self.exportables = []
14
+ end
15
+
16
+ def find_files
17
+ if File.file?(self.target)
18
+ self.files = [self.target]
19
+ elsif File.directory?(self.target)
20
+ self.files = Dir.glob(File.join(self.target, "**", "*.rb"))
21
+ else
22
+ abort "#{target} does not exist."
23
+ end
24
+
25
+ return self.files
26
+ end
27
+
28
+ def find_exportables
29
+ self.find_files
30
+
31
+ self.files.each do |file|
32
+ File.open(file) do |f|
33
+ f.each_with_index do |line, number|
34
+ search = line.scan(/(?:#)(?:| )(TODO|FIXME|BUG):?(.*)$/i)
35
+ if !search.empty?
36
+ self.exportables << {
37
+ :type => search[0][0].upcase,
38
+ :content => search[0][1].strip,
39
+ :file => file.gsub(/^(.\/|\/)/, ''),
40
+ :line => number + 1
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def exportable_todos
49
+ self.exportables.select { |x| x[:type] == 'TODO' }
50
+ end
51
+
52
+ def exportable_fixmes
53
+ self.exportables.select { |x| x[:type] == 'FIXME' }
54
+ end
55
+
56
+ def exportable_bugs
57
+ self.exportables.select { |x| x[:type] == 'BUG' }
58
+ end
59
+
60
+ def execute
61
+ self.find_exportables
62
+
63
+ say("Found #{self.exportable_todos.size} TODO's, " \
64
+ "#{self.exportable_fixmes.size} FIXME's and " \
65
+ "#{self.exportable_bugs.size} BUG's" \
66
+ " in #{self.exportables.map { |x| x[:file] }.uniq.size } of #{exportables.map { |x| x[:file] }.size } files searched.")
67
+ say("\n")
68
+
69
+ choose do |menu|
70
+ menu.prompt = "Export to: "
71
+ menu.choice('Github Issues') { TodosExport::GithubIssues.new(self).run }
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,71 @@
1
+ module TodosExport
2
+ class GithubIssues
3
+ attr_accessor :main
4
+
5
+ def initialize(main)
6
+ @main = main
7
+ end
8
+
9
+ def run
10
+ authenticate
11
+ select_repo
12
+ process_exportables
13
+ end
14
+
15
+ def authenticate
16
+ say("\n")
17
+ choose do |menu|
18
+ menu.prompt = "Choose authentication method: "
19
+
20
+ menu.choice('Username / Password') do
21
+ say("\n")
22
+ username = ask("Github Username:")
23
+ password = ask("Github Password:") { |q| q.echo = false }
24
+
25
+ @client = ::Octokit::Client.new(:login => username, :password => password)
26
+ end
27
+ menu.choice('Personal Access Token (https://github.com/settings/applications)') do
28
+ say("\n")
29
+ token = ask("Github token:")
30
+ @client = ::Octokit::Client.new(:oauth_token => token)
31
+ end
32
+ end
33
+ end
34
+
35
+ def select_repo
36
+ say("\n")
37
+ choose do |menu|
38
+ menu.prompt = "Choose a repository to add issues to:"
39
+
40
+ @client.repos.each do |repo|
41
+ menu.choice(repo.full_name) { @repo = repo.full_name }
42
+ end
43
+ end
44
+ end
45
+
46
+ def process_exportables
47
+ say("\n")
48
+ self.main.exportables.each do |ex|
49
+ say("Create a new Issue")
50
+ say("==================")
51
+ say("<%= color('Name:', :green) %>\n#{ex[:content]}")
52
+ say("<%= color('Description:', :green) %>\n#{ex[:content]}\n\nhttps://github.com/#{@repo}/blob/master/#{ex[:file]}#L#{ex[:line]}")
53
+ say("<%= color('Tags:', :green) %>\n'#{ex[:type].downcase}'")
54
+ say("\n")
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 })
62
+
63
+ say("\n<%= color('Created!', :green) %>\n\n")
64
+ else
65
+ say("\n<%= color('Not created!', :red) %>\n\n")
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module TodosExport
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'todos_export/github_issues'
2
+
3
+ describe TodosExport::GithubIssues do
4
+ subject do
5
+ main = TodosExport::Main.new('spec/resources')
6
+ main.find_exportables
7
+
8
+ TodosExport::GithubIssues.new(main)
9
+ end
10
+
11
+ end
@@ -0,0 +1,161 @@
1
+ require 'todos_export'
2
+
3
+ describe TodosExport::Main do
4
+ subject do
5
+ TodosExport::Main.new('spec/resources')
6
+ end
7
+
8
+ it '#find_files' do
9
+ subject.find_files
10
+ subject.files.size.should == 3
11
+ end
12
+
13
+ it '#find_exportables' do
14
+ subject.find_exportables
15
+ subject.exportables.size.should == 10
16
+ end
17
+
18
+ it '#exportables' do
19
+ subject.find_exportables
20
+ subject.exportables.should == [
21
+ {
22
+ :type => "FIXME",
23
+ :content => "This is a useless class, what we really need to do is sit down and eat some cheese",
24
+ :file => 'spec/resources/ruby_file_with_todos.rb',
25
+ :line => 2
26
+ },
27
+ {
28
+ :type => "TODO",
29
+ :content => "Find a kinder message",
30
+ :file => 'spec/resources/ruby_file_with_todos.rb',
31
+ :line => 12
32
+ },
33
+ {
34
+ :type => "TODO",
35
+ :content => "Make a list",
36
+ :file => 'spec/resources/ruby_file_with_todos.rb',
37
+ :line => 18
38
+ },
39
+ {
40
+ :type => "FIXME",
41
+ :content => "Use case statement",
42
+ :file => 'spec/resources/ruby_file_with_todos.rb',
43
+ :line => 22
44
+ },
45
+ {
46
+ :type => "TODO",
47
+ :content => "Add more cheese types",
48
+ :file => 'spec/resources/ruby_file_with_todos.rb',
49
+ :line => 26
50
+ },
51
+ {
52
+ :type => "TODO",
53
+ :content => "Add more region cheeses",
54
+ :file => 'spec/resources/ruby_file_with_todos.rb',
55
+ :line => 35
56
+ },
57
+ {
58
+ :type => "TODO",
59
+ :content => "Personalize the class to your taste",
60
+ :file => 'spec/resources/ruby_file_with_todos.rb',
61
+ :line => 41
62
+ },
63
+ {
64
+ :type => "BUG",
65
+ :content => "This should be false",
66
+ :file => 'spec/resources/ruby_file_with_todos.rb',
67
+ :line => 46
68
+ },
69
+ {
70
+ :type => "TODO",
71
+ :content => "Be a better Ruby file",
72
+ :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
73
+ :line => 1
74
+ },
75
+ {
76
+ :type => "BUG",
77
+ :content => "This should say it's a Ruby file",
78
+ :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
79
+ :line => 2
80
+ }
81
+ ]
82
+ end
83
+
84
+ it '#exportable_todos' do
85
+ subject.find_exportables
86
+ subject.exportable_todos.should == [
87
+ {
88
+ :type => "TODO",
89
+ :content => "Find a kinder message",
90
+ :file => 'spec/resources/ruby_file_with_todos.rb',
91
+ :line => 12
92
+ },
93
+ {
94
+ :type => "TODO",
95
+ :content => "Make a list",
96
+ :file => 'spec/resources/ruby_file_with_todos.rb',
97
+ :line => 18
98
+ },
99
+ {
100
+ :type => "TODO",
101
+ :content => "Add more cheese types",
102
+ :file => 'spec/resources/ruby_file_with_todos.rb',
103
+ :line => 26
104
+ },
105
+ {
106
+ :type => "TODO",
107
+ :content => "Add more region cheeses",
108
+ :file => 'spec/resources/ruby_file_with_todos.rb',
109
+ :line => 35
110
+ },
111
+ {
112
+ :type => "TODO",
113
+ :content => "Personalize the class to your taste",
114
+ :file => 'spec/resources/ruby_file_with_todos.rb',
115
+ :line => 41
116
+ },
117
+ {
118
+ :type => "TODO",
119
+ :content => "Be a better Ruby file",
120
+ :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
121
+ :line => 1
122
+ }
123
+ ]
124
+ end
125
+
126
+ it '#exportable_fixmes' do
127
+ subject.find_exportables
128
+ subject.exportable_fixmes.should == [
129
+ {
130
+ :type => "FIXME",
131
+ :content => "This is a useless class, what we really need to do is sit down and eat some cheese",
132
+ :file => 'spec/resources/ruby_file_with_todos.rb',
133
+ :line => 2
134
+ },
135
+ {
136
+ :type => "FIXME",
137
+ :content => "Use case statement",
138
+ :file => 'spec/resources/ruby_file_with_todos.rb',
139
+ :line => 22
140
+ }
141
+ ]
142
+ end
143
+
144
+ it '#exportable_bugs' do
145
+ subject.find_exportables
146
+ subject.exportable_bugs.should == [
147
+ {
148
+ :type => "BUG",
149
+ :content => "This should be false",
150
+ :file => 'spec/resources/ruby_file_with_todos.rb',
151
+ :line => 46
152
+ },
153
+ {
154
+ :type => "BUG",
155
+ :content => "This should say it's a Ruby file",
156
+ :file => 'spec/resources/sub_directory/another_ruby_file_with_todos.rb',
157
+ :line => 2
158
+ }
159
+ ]
160
+ end
161
+ end
@@ -0,0 +1,2 @@
1
+ # TODO: Be a python
2
+ print "I'm a python"
@@ -0,0 +1,49 @@
1
+ # There are many things TODO but this isn't a TODO: because it doesn't start with the words
2
+ # fixme: This is a useless class, what we really need to do is sit down and eat some cheese
3
+ # This is a class for cheeses
4
+
5
+ class Cheese
6
+ attr_accessor :cheese
7
+
8
+ def initialize(cheese)
9
+ if cheese
10
+ @cheese = cheese
11
+ else
12
+ #TODO: Find a kinder message
13
+ puts "Pick a tasty cheese dammit"
14
+ end
15
+ end
16
+
17
+ def needs_bread?
18
+ true # TODO: Make a list
19
+ end
20
+
21
+ def needs_wine?
22
+ #FIXME: Use case statement
23
+ if self.cheese == 'chedar'
24
+ return false
25
+ else
26
+ #todo: Add more cheese types
27
+ return true
28
+ end
29
+ end
30
+
31
+ def has_region_name?
32
+ if self.cheese == 'brie'
33
+ return true
34
+ else
35
+ #todo Add more region cheeses
36
+ return false
37
+ end
38
+ end
39
+
40
+ def yum?
41
+ # TODO Personalize the class to your taste
42
+ return true
43
+ end
44
+
45
+ def yuck?
46
+ # BUG: This should be false
47
+ return true
48
+ end
49
+ end
@@ -0,0 +1,6 @@
1
+ class Bread
2
+ def fresh?
3
+ # I'm never up early enough
4
+ return false
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ # TODO: Be a better Ruby file
2
+ # BUG: This should say it's a Ruby file
3
+ puts "I'm a Perl file"
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'todos_export/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "todos_export"
8
+ spec.version = TodosExport::VERSION
9
+ spec.authors = ["Ryan Caught"]
10
+ spec.email = ["rcaught@gmail.com"]
11
+ spec.description = %q{Export comment Todo's, Fixme's and Bug's from your code}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/rcaught/todos_export"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ spec.add_runtime_dependency "highline"
26
+ spec.add_runtime_dependency "octokit"
27
+ spec.add_runtime_dependency "json"
28
+ spec.add_runtime_dependency "system_timer"
29
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: todos_export
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Ryan Caught
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-06-17 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bundler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 1
32
+ - 3
33
+ version: "1.3"
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: highline
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: octokit
80
+ prerelease: false
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ type: :runtime
91
+ version_requirements: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: json
94
+ prerelease: false
95
+ requirement: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ type: :runtime
105
+ version_requirements: *id006
106
+ - !ruby/object:Gem::Dependency
107
+ name: system_timer
108
+ prerelease: false
109
+ requirement: &id007 !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ type: :runtime
119
+ version_requirements: *id007
120
+ description: Export comment Todo's, Fixme's and Bug's from your code
121
+ email:
122
+ - rcaught@gmail.com
123
+ executables:
124
+ - todos_export
125
+ extensions: []
126
+
127
+ extra_rdoc_files: []
128
+
129
+ files:
130
+ - .gitignore
131
+ - Gemfile
132
+ - LICENSE.txt
133
+ - README.md
134
+ - Rakefile
135
+ - bin/todos_export
136
+ - lib/todos_export.rb
137
+ - lib/todos_export/github_issues.rb
138
+ - lib/todos_export/version.rb
139
+ - spec/lib/todos_export/github_isses_spec.rb
140
+ - spec/lib/todos_export_spec.rb
141
+ - spec/resources/python_file.py
142
+ - spec/resources/ruby_file_with_todos.rb
143
+ - spec/resources/ruby_file_without_todos.rb
144
+ - spec/resources/sub_directory/another_ruby_file_with_todos.rb
145
+ - todos_export.gemspec
146
+ has_rdoc: true
147
+ homepage: https://github.com/rcaught/todos_export
148
+ licenses:
149
+ - MIT
150
+ post_install_message:
151
+ rdoc_options: []
152
+
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ hash: 3
161
+ segments:
162
+ - 0
163
+ version: "0"
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ hash: 3
170
+ segments:
171
+ - 0
172
+ version: "0"
173
+ requirements: []
174
+
175
+ rubyforge_project:
176
+ rubygems_version: 1.3.7
177
+ signing_key:
178
+ specification_version: 3
179
+ summary: Export comment Todo's, Fixme's and Bug's from your code
180
+ test_files:
181
+ - spec/lib/todos_export/github_isses_spec.rb
182
+ - spec/lib/todos_export_spec.rb
183
+ - spec/resources/python_file.py
184
+ - spec/resources/ruby_file_with_todos.rb
185
+ - spec/resources/ruby_file_without_todos.rb
186
+ - spec/resources/sub_directory/another_ruby_file_with_todos.rb