mvz-dnote 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,15 @@
1
- module DNote
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec/core/rake_task'
2
4
 
5
+ module DNote
3
6
  # = Developmer's Notes Rake Task
4
7
  #
5
8
  class RakeTask < Rake::TaskLib
6
-
7
9
  require 'rake/clean'
8
10
 
9
11
  # Default note labels to looked for in source code.
10
- DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']
12
+ DEFAULT_LABELS = %w(TODO FIXME OPTIMIZE DEPRECATE).freeze
11
13
 
12
14
  # File paths to search.
13
15
  attr_accessor :files
@@ -26,27 +28,24 @@ module DNote
26
28
 
27
29
  # Output directory to save notes file. Defaults to <tt>dnote/</tt> under
28
30
  # the project log directory (eg. <tt>log/dnote/</tt>).
29
- attr_accessor :output
31
+ attr_reader :output
30
32
 
31
33
  # Title to use if temaplte can use it.
32
34
  attr_accessor :title
33
35
 
34
- #
35
36
  def output=(path)
36
37
  @output = Pathname.new(path)
37
38
  end
38
39
 
39
- #
40
40
  def init
41
41
  require 'dnote'
42
42
  require 'dnote/format'
43
- @files = "**/*.rb"
43
+ @files = '**/*.rb'
44
44
  @output = 'log/dnote'
45
45
  @formats = ['index']
46
- @labels = nil #DEFAULT_LABELS
46
+ @labels = nil
47
47
  end
48
48
 
49
- #
50
49
  def define
51
50
  desc "Collect Developer's Notes"
52
51
  task 'dnote' do
@@ -55,7 +54,7 @@ module DNote
55
54
  task 'dnote:clobber' do
56
55
  clean
57
56
  end
58
- task :clobber => ['dnote:clobber']
57
+ task clobber: ['dnote:clobber']
59
58
  end
60
59
 
61
60
  # Generate notes document(s).
@@ -66,51 +65,36 @@ module DNote
66
65
  s.paths = files
67
66
  s.exclude = exclude
68
67
  s.ignore = ignore
69
- s.labels = labels #|| DEFAULT_LABELS
68
+ s.labels = labels
70
69
  s.title = title
71
70
  s.output = output
72
- s.dryrun = application.options.dryrun #trial?
71
+ s.dryrun = application.options.dryrun # trial?
73
72
  end
74
73
 
75
74
  formats.each do |format|
76
75
  if format == 'index'
77
76
  session.format = 'html'
78
- session.output = File.join(self.output, 'index.html')
77
+ session.output = File.join(output, 'index.html')
79
78
  else
80
79
  session.format = format
81
80
  end
82
81
  session.run
83
- report "Updated #{output.to_s.sub(Dir.pwd+'/','')}" unless trial?
82
+ report "Updated #{output.to_s.sub(Dir.pwd + '/', '')}" unless trial?
84
83
  end
85
84
  end
86
85
 
87
- # Reset output directory, marking it as out-of-date.
88
- def reset
89
- #if File.directory?(output)
90
- File.utime(0,0,output) unless $NOOP
91
- puts "Marked #{output} as out-of-date"
92
- #end
93
- end
94
-
95
86
  # Remove output files.
96
87
  def clean
97
- #if File.directory?(output)
98
- formats.each do |format|
99
- if format == 'index'
100
- file = (output + "index.html").to_s
101
- else
102
- ext = ::DNote::Format::EXTENSIONS[format] || format
103
- file = (output + "notes.#{ext}").to_s
104
- end
105
- rm(file)
106
- report "Removed #{output}"
88
+ formats.each do |format|
89
+ if format == 'index'
90
+ file = (output + 'index.html').to_s
91
+ else
92
+ ext = ::DNote::Format::EXTENSIONS[format] || format
93
+ file = (output + "notes.#{ext}").to_s
107
94
  end
108
- #else
109
- # rm(output)
110
- # report "Removed #{output}"
111
- #end
95
+ rm(file)
96
+ report "Removed #{output}"
97
+ end
112
98
  end
113
-
114
99
  end
115
-
116
100
  end
@@ -1,9 +1,10 @@
1
- module DNote
1
+ # frozen_string_literal: true
2
2
 
3
- require 'dnote/core_ext'
4
- require 'dnote/notes'
5
- require 'dnote/format'
3
+ require 'dnote/core_ext'
4
+ require 'dnote/notes'
5
+ require 'dnote/format'
6
6
 
7
+ module DNote
7
8
  # User session which is used by commandline interface.
8
9
  #
9
10
  # By making this a class it makes it easy for external
@@ -11,13 +12,12 @@ module DNote
11
12
  # calling the commandline, but without the need to shellout.
12
13
  #
13
14
  class Session
14
-
15
15
  # Directory relative to this script. This is used
16
16
  # to lookup the available format templates.
17
17
  DIR = File.dirname(__FILE__)
18
18
 
19
19
  # Default format.
20
- DEFAULT_FORMAT = "text"
20
+ DEFAULT_FORMAT = 'text'
21
21
 
22
22
  # Default title.
23
23
  DEFAULT_TITLE = "Developer's Notes"
@@ -59,7 +59,7 @@ module DNote
59
59
 
60
60
  # String template for line URLs (mainly for HTML format). For example,
61
61
  # DNote uses GitHub so we could use a link template:
62
- #
62
+ #
63
63
  # "https://github.com/rubyworks/dnote/blob/master/%s#L%s"
64
64
  #
65
65
  attr_accessor :url
@@ -67,13 +67,13 @@ module DNote
67
67
  # Number of lines of context to display. The default is zero.
68
68
  attr_accessor :context
69
69
 
70
- private
70
+ private
71
71
 
72
72
  # New Session.
73
- def initialize(options={})
73
+ def initialize(options = {})
74
74
  options ||= {}
75
75
  initialize_defaults
76
- options.each{ |k,v| __send__("#{k}=", v) }
76
+ options.each { |k, v| __send__("#{k}=", v) }
77
77
  yield(self) if block_given?
78
78
  end
79
79
 
@@ -91,7 +91,7 @@ module DNote
91
91
  @context = 0
92
92
  end
93
93
 
94
- public
94
+ public
95
95
 
96
96
  # Set exclude list ensuring that the value is an array.
97
97
  def exclude=(list)
@@ -105,7 +105,7 @@ module DNote
105
105
 
106
106
  # Run session.
107
107
  def run
108
- notes = Notes.new(files, :labels=>labels, :colon=>colon, :marker=>marker, :url=>url, :context=>context)
108
+ notes = Notes.new(files, labels: labels, colon: colon, marker: marker, url: url, context: context)
109
109
  formatter = Format.new(notes) do |f|
110
110
  f.format = format
111
111
  f.template = template
@@ -122,13 +122,13 @@ module DNote
122
122
  list = [paths].flatten.compact
123
123
  list = ['**/*.rb'] if list.empty?
124
124
  list = glob(list)
125
- list = list - glob(exclude)
125
+ list -= glob(exclude)
126
126
  list.reject do |path|
127
- path.split('/').any?{ |part| ignore.any?{ |ig| File.fnmatch?(ig, part) } }
127
+ path.split('/').any? { |part| ignore.any? { |ig| File.fnmatch?(ig, part) } }
128
128
  end
129
129
  end
130
130
 
131
- # Collect the file glob of each path given. If
131
+ # Collect the file glob of each path given. If
132
132
  # a path is a directory, inclue all content.
133
133
  def glob(paths)
134
134
  paths.map do |path|
@@ -140,18 +140,6 @@ module DNote
140
140
  end.flatten.uniq
141
141
  end
142
142
 
143
- # Set special labels.
144
- #def labels=(labels)
145
- # @labels = (
146
- # case labels
147
- # when String
148
- # labels.split(/[:;,]/)
149
- # else
150
- # labels = [labels].flatten.compact.uniq.map{ |s| s.to_s }
151
- # end
152
- # )
153
- #end
154
-
155
143
  # Commandline interface.
156
144
  def self.main(*argv)
157
145
  require 'optparse'
@@ -161,109 +149,100 @@ module DNote
161
149
  opts = OptionParser.new do |opt|
162
150
  opt.banner = "DNote v#{DNote::VERSION}"
163
151
 
164
- opt.separator(" ")
152
+ opt.separator(' ')
165
153
  opt.separator("USAGE:\n dnote [OPTIONS] path1 [path2 ...]")
166
154
 
167
- opt.separator(" ")
168
- opt.separator("OUTPUT FORMAT: (choose one)")
155
+ opt.separator(' ')
156
+ opt.separator('OUTPUT FORMAT: (choose one)')
169
157
 
170
- opt.on("--format", "-f NAME", "select a format [text]") do |format|
158
+ opt.on('--format', '-f NAME', 'select a format [text]') do |format|
171
159
  session.format = format
172
160
  end
173
161
 
174
- opt.on("--custom", "-C FILE", "use a custom ERB template") do |file|
162
+ opt.on('--custom', '-C FILE', 'use a custom ERB template') do |file|
175
163
  session.format = 'custom'
176
164
  session.template = file
177
165
  end
178
166
 
179
- opt.on("--file", "shortcut for text/file format") do
167
+ opt.on('--file', 'shortcut for text/file format') do
180
168
  session.format = 'text/file'
181
169
  end
182
170
 
183
- opt.on("--list", "shortcut for text/list format") do
171
+ opt.on('--list', 'shortcut for text/list format') do
184
172
  session.format = 'text/list'
185
173
  end
186
174
 
187
- opt.separator(" ")
188
- opt.separator("OTHER OPTIONS:")
175
+ opt.separator(' ')
176
+ opt.separator('OTHER OPTIONS:')
189
177
 
190
- opt.on("--label", "-l LABEL", "labels to collect") do |lbl|
178
+ opt.on('--label', '-l LABEL', 'labels to collect') do |lbl|
191
179
  session.labels.concat(lbl.split(':'))
192
180
  end
193
181
 
194
- opt.on("--[no-]colon", "match labels with/without colon suffix") do |val|
182
+ opt.on('--[no-]colon', 'match labels with/without colon suffix') do |val|
195
183
  session.colon = val
196
184
  end
197
185
 
198
- opt.on("--marker", "-m MARK", "alternative remark marker") do |mark|
199
- session.marker = mark
186
+ opt.on('--marker', '-m MARK', 'alternative remark marker') do |mark|
187
+ session.marker = mark
200
188
  end
201
189
 
202
- opt.on("--url", "-u TEMPLATE", "url template for line entries (for HTML)") do |url|
203
- session.url = url
190
+ opt.on('--url', '-u TEMPLATE', 'url template for line entries (for HTML)') do |url|
191
+ session.url = url
204
192
  end
205
193
 
206
- opt.on("--context", "-c INTEGER", "number of lines of context to display") do |int|
207
- session.context = int.to_i
194
+ opt.on('--context', '-c INTEGER', 'number of lines of context to display') do |int|
195
+ session.context = int.to_i
208
196
  end
209
197
 
210
- opt.on("--exclude", "-x PATH", "exclude file or directory") do |path|
198
+ opt.on('--exclude', '-x PATH', 'exclude file or directory') do |path|
211
199
  session.exclude << path
212
200
  end
213
201
 
214
- opt.on("--ignore", "-i NAME", "ignore file based on any part of pathname") do |name|
202
+ opt.on('--ignore', '-i NAME', 'ignore file based on any part of pathname') do |name|
215
203
  session.ignore << name
216
204
  end
217
205
 
218
- opt.on("--title", "-t TITLE", "title to use in header") do |title|
206
+ opt.on('--title', '-t TITLE', 'title to use in header') do |title|
219
207
  session.title = title
220
208
  end
221
209
 
222
- opt.on("--output", "-o PATH", "save to file or directory") do |path|
210
+ opt.on('--output', '-o PATH', 'save to file or directory') do |path|
223
211
  session.output = path
224
212
  end
225
213
 
226
- opt.on("--dryrun", "-n", "do not actually write to disk") do
214
+ opt.on('--dryrun', '-n', 'do not actually write to disk') do
227
215
  session.dryrun = true
228
216
  end
229
217
 
230
- opt.on("--debug", "debug mode") do
218
+ opt.on('--debug', 'debug mode') do
231
219
  $DEBUG = true
232
220
  $VERBOSE = true
233
221
  end
234
222
 
235
- opt.separator(" ")
236
- opt.separator("COMMAND OPTIONS:")
223
+ opt.separator(' ')
224
+ opt.separator('COMMAND OPTIONS:')
237
225
 
238
- opt.on_tail('--templates', "-T", "list available format templates") do
226
+ opt.on_tail('--templates', '-T', 'list available format templates') do
239
227
  tdir = File.join(DIR, 'templates')
240
228
  tfiles = Dir[File.join(tdir, '**/*.erb')]
241
- tnames = tfiles.map{ |tname| tname.sub(tdir+'/', '').chomp('.erb') }
242
- groups = tnames.group_by{ |tname| tname.split('/').first }
243
- groups.sort.each do |(type, names)|
244
- puts("%-18s " * names.size % names.sort)
229
+ tnames = tfiles.map { |tname| tname.sub(tdir + '/', '').chomp('.erb') }
230
+ groups = tnames.group_by { |tname| tname.split('/').first }
231
+ groups.sort.each do |(_type, names)|
232
+ puts('%-18s ' * names.size % names.sort)
245
233
  end
246
234
  exit
247
235
  end
248
236
 
249
- opt.on_tail('--help', '-h', "show this help information") do
237
+ opt.on_tail('--help', '-h', 'show this help information') do
250
238
  puts opt
251
239
  exit
252
240
  end
253
241
  end
254
242
 
255
- begin
256
- opts.parse!(argv)
257
- session.paths.replace(argv)
258
- session.run
259
- rescue => err
260
- raise err if $DEBUG
261
- puts err
262
- exit 1
263
- end
243
+ opts.parse!(argv)
244
+ session.paths.replace(argv)
245
+ session.run
264
246
  end
265
-
266
247
  end
267
-
268
248
  end
269
-
@@ -1,17 +1,5 @@
1
- module DNote
2
- VERSION = '1.7.2'
3
-
4
- #
5
- def self.metadata
6
- @metadata ||= (
7
- require 'yaml'
8
- YAML.load_file(File.dirname(__FILE__) + '/../dnote.yml')
9
- )
10
- end
11
-
12
- #
13
- def self.const_missing(name)
14
- metadata[name.to_s.downcase] || super(name)
15
- end
1
+ # frozen_string_literal: true
16
2
 
3
+ module DNote
4
+ VERSION = '1.8.0'
17
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mvz-dnote
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Sawyer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-05 00:00:00.000000000 Z
12
+ date: 2018-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aruba
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '2.4'
34
+ version: '3.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '2.4'
41
+ version: '3.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.5'
70
+ - !ruby/object:Gem::Dependency
71
+ name: simplecov
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.16.1
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 0.16.1
70
84
  description: |2
71
85
  DNote makes it easy to extract developer's notes from source code,
72
86
  and supports almost any language.
@@ -77,15 +91,14 @@ executables:
77
91
  extensions: []
78
92
  extra_rdoc_files:
79
93
  - HISTORY.rdoc
80
- - README.rdoc
94
+ - README.md
81
95
  - COPYING.rdoc
82
96
  files:
83
97
  - COPYING.rdoc
84
98
  - HISTORY.rdoc
85
- - README.rdoc
99
+ - README.md
86
100
  - bin/dnote
87
101
  - lib/dnote.rb
88
- - lib/dnote.yml
89
102
  - lib/dnote/core_ext.rb
90
103
  - lib/dnote/format.rb
91
104
  - lib/dnote/note.rb
@@ -129,9 +142,6 @@ files:
129
142
  - lib/dnote/templates/yaml/label.erb
130
143
  - lib/dnote/templates/yaml/list.erb
131
144
  - lib/dnote/version.rb
132
- - try/sample.bas
133
- - try/sample.js
134
- - try/sample.rb
135
145
  homepage: https://github.com/mvz/dnote
136
146
  licenses: []
137
147
  metadata: {}
@@ -143,15 +153,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
153
  requirements:
144
154
  - - ">="
145
155
  - !ruby/object:Gem::Version
146
- version: '0'
156
+ version: 2.3.0
147
157
  required_rubygems_version: !ruby/object:Gem::Requirement
148
158
  requirements:
149
159
  - - ">="
150
160
  - !ruby/object:Gem::Version
151
161
  version: '0'
152
162
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.6.8
163
+ rubygems_version: 3.0.1
155
164
  signing_key:
156
165
  specification_version: 4
157
166
  summary: Extract developer's notes from source code.