yard-clean 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6119c23749a074e6e55dc0363f70c3f890ddcade
4
+ data.tar.gz: e50ab51467b260034b76ecd644e065193c6be25e
5
+ SHA512:
6
+ metadata.gz: 721a9289529ffb09bdbfb3e3016aed3761e9cd2da7e748de1d6cab435aa05a6b020f7bf26b86228cf21e0baddf9b06635220a0474076c92e07087a02856a422f
7
+ data.tar.gz: 93f243868390878590de0ec7de594a11c614306b863112ce9943619621429ccdda033835f939b912fb372394a6fedcf26b0174f32868125c9efbf3009525bac4
@@ -0,0 +1,104 @@
1
+ ##############################################################################
2
+ # BEGIN Global/macOS.gitingore
3
+ #
4
+ # General
5
+ .DS_Store
6
+ .AppleDouble
7
+ .LSOverride
8
+
9
+ # Icon must end with two \r
10
+ Icon
11
+
12
+
13
+ # Thumbnails
14
+ ._*
15
+
16
+ # Files that might appear in the root of a volume
17
+ .DocumentRevisions-V100
18
+ .fseventsd
19
+ .Spotlight-V100
20
+ .TemporaryItems
21
+ .Trashes
22
+ .VolumeIcon.icns
23
+ .com.apple.timemachine.donotpresent
24
+
25
+ # Directories potentially created on remote AFP share
26
+ .AppleDB
27
+ .AppleDesktop
28
+ Network Trash Folder
29
+ Temporary Items
30
+ .apdisk
31
+ #
32
+ # END Global/macOS.gitingore
33
+ ##############################################################################
34
+
35
+ ##############################################################################
36
+ # BEGIN Ruby.gitingore
37
+ #
38
+ # General Git ignore file for Ruby, including support for:
39
+ #
40
+ # - Bundler
41
+ # - RDoc and Yard
42
+ # - RBEnv and RVM
43
+ # - DotEnv (optional)
44
+ #
45
+ # Additional support is available in separate ignore files:
46
+ #
47
+ # - Gem.gitignore (for gem source directories)
48
+ # - Rails.gitignore
49
+ # - RubyMotion.gitignore
50
+ #
51
+
52
+ /*.gem
53
+ *.rbc
54
+ /.config
55
+ /coverage/
56
+ /InstalledFiles
57
+ /pkg/
58
+ /spec/reports/
59
+ /spec/examples.txt
60
+ /test/tmp/
61
+ /test/version_tmp/
62
+ /tmp/
63
+
64
+ # Used by dotenv library to load environment variables.
65
+ # .env
66
+
67
+ ## Documentation cache and generated files:
68
+ /.yardoc/
69
+ /_yardoc/
70
+ # /doc/ # We Use `//doc` for additional hand-written documentation
71
+ /rdoc/
72
+
73
+ ## Environment normalization:
74
+ .bundle/
75
+ /vendor/bundle
76
+ /lib/bundler/man/
77
+
78
+ # for a library or gem, add `Gem.gitignore`
79
+
80
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
81
+ .rvmrc
82
+ #
83
+ # END Ruby.gitingore
84
+ ##############################################################################
85
+
86
+ ##############################################################################
87
+ # BEGIN Gem.gitingore
88
+ #
89
+ /Gemfile.lock
90
+ /.ruby-version
91
+ /.ruby-gemset
92
+ #
93
+ # END Gem.gitingore
94
+ ##############################################################################
95
+
96
+
97
+ # Project Rules
98
+ # ============================================================================
99
+
100
+ # Generated doc site (YARD)
101
+ /site/
102
+
103
+ # rspec failure tracking
104
+ .rspec_status
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in yard-clean.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 nrser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ Yard::Clean by NRSER
2
+ ==============================================================================
3
+
4
+ Yeah this just adds a `yard clean` command to remove the db files.
5
+
6
+ Sometimes `yard server --reload` just doesn't cut it... generated HTML doesn't
7
+ update, or ends up in a mixed state of old and new. This seems especially
8
+ prevalent when using plugins.
9
+
10
+ In these cases, my easy answer is to whack the database directory (defaults to
11
+ `.yardoc/`), causing the YARD server to rebuild the database on the next page
12
+ load.
13
+
14
+ Yeah, this is basically `rm -rf ./.yardoc`, but I get sick of typing it, and
15
+ scared that I'll fat-finger it and lose some uncommitted code.
16
+
17
+ So, this could just be a one-liner shell script, except when someone changes
18
+ the database directory with `--db FILE`, and then I still need to distribute it
19
+ somehow, so this gem seems almost reasonable.
20
+
21
+ Enjoy!
22
+
23
+
24
+ Installation
25
+ ------------------------------------------------------------------------------
26
+
27
+ Add this line to your application's Gemfile:
28
+
29
+ ```ruby
30
+ gem 'yard-clean'
31
+ ```
32
+
33
+ And then execute:
34
+
35
+ $ bundle
36
+
37
+ Or install it yourself as:
38
+
39
+ $ gem install yard-clean
40
+
41
+ If you're running on a recent YARD, you also need to enable the plugin.
42
+
43
+ Add this to your `.yardopts`:
44
+
45
+ --plugin yard-clean
46
+
47
+
48
+ Usage
49
+ ------------------------------------------------------------------------------
50
+
51
+ $ yard clean
52
+
53
+
54
+ License
55
+ ------------------------------------------------------------------------------
56
+
57
+ The gem is available as open source under the terms of the [MIT
58
+ License](https://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ require 'yard'
2
+ require_relative "./yard/clean/version"
3
+ require_relative "./yard/cli/clean"
4
+
5
+ YARD::CLI::CommandParser.commands[:clean] = YARD::CLI::Clean
@@ -0,0 +1,5 @@
1
+ module YARD
2
+ module Clean
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,144 @@
1
+ # Requirements
2
+ # ============================================================================
3
+
4
+ require 'yard'
5
+ require_relative "../clean/version"
6
+
7
+
8
+ # Namespace
9
+ # ============================================================================
10
+
11
+ module YARD
12
+ module CLI
13
+
14
+ class Clean < YardoptsCommand
15
+
16
+ # String to explain `yard clean` in `yard help` output. Also used in the
17
+ # command help messages for the command itself.
18
+ #
19
+ # @return [String]
20
+ #
21
+ def description
22
+ 'Remove the database files.'
23
+ end
24
+
25
+
26
+ # Runs the command, removing the DB directory (if it exists and *is* a
27
+ # directory).
28
+ #
29
+ # @param [Array<String>] args
30
+ # Shell-split arguments from the CLI.
31
+ #
32
+ # @return [nil]
33
+ #
34
+ # @note
35
+ # Exits the program on failure.
36
+ #
37
+ def run *args_and_opts
38
+ args = parse_arguments *args_and_opts
39
+
40
+ unless args.empty?
41
+ log.warn "`yard clean` does not accept arguments (only options), " +
42
+ "found #{ args.inspect }. See `yard clean --help` for usage."
43
+ end
44
+
45
+ # This gets set to the correct DB file location by {#optparse}, which is
46
+ # run *first* for any yardopts file, then for any CLI options. If the DB
47
+ # option is found in neither, it will remain at it's default `.yardoc`
48
+ db = YARD::Registry.yardoc_file
49
+
50
+ if File.exists? db
51
+ if File.directory? db
52
+ log.info "Found DB directory at #{ db.inspect }, removing..."
53
+ FileUtils.rm_rf db
54
+
55
+ else
56
+ log.error "DB path #{ db.inspect } exists, but is NOT a directory!"
57
+ log.error "Exiting..."
58
+ exit false
59
+ end
60
+ else
61
+ log.info "DB path #{ db.inspect } does no exist, nothing to do."
62
+ end
63
+
64
+ log.info "Done."
65
+
66
+ nil
67
+ end # #run
68
+
69
+
70
+ # Parse argument strings. Called by {YARD::CLI::YardoptsCommand} for *both*
71
+ # the yardopts file (if any) and the CLI arguments.
72
+ #
73
+ # We kick this off with our call to
74
+ # {YARD::CLI::YardoptsCommand#parse_arguments} up in {#run}.
75
+ #
76
+ # @param [Array<String>] args
77
+ # Shell-split argument strings (including options/switches).
78
+ #
79
+ # @return [Array<String>]
80
+ # The non-option arguments remaining after option parsing.
81
+ #
82
+ def optparse *args
83
+ opts = OptionParser.new
84
+ opts.banner = "Usage: yard clean [options]"
85
+ opts.separator ""
86
+ opts.separator description
87
+ opts.separator ""
88
+ opts.separator "Options:"
89
+
90
+ opts.on('-b', '--db FILE', 'Use a specified .yardoc db to load from or save to',
91
+ ' (defaults to .yardoc)') do |yardoc_file|
92
+ YARD::Registry.yardoc_file = yardoc_file
93
+ end
94
+
95
+ opts.on_tail('-q', '--quiet', 'Show no warnings.') {
96
+ log.level = Logger::ERROR
97
+ }
98
+
99
+ opts.on_tail('--verbose', 'Show more information.') {
100
+ log.level = Logger::INFO
101
+ }
102
+
103
+ opts.on_tail('--debug', 'Show debugging information.') {
104
+ log.level = Logger::DEBUG
105
+ }
106
+
107
+ opts.on_tail('-v', '--version', 'Show version information.') {
108
+ log.puts "yard clean #{YARD::Clean::VERSION}"
109
+ exit
110
+ }
111
+
112
+ opts.on_tail('--bare-version', 'Show JUST version.') {
113
+ log.print "#{YARD::Clean::VERSION}"
114
+ exit
115
+ }
116
+
117
+ opts.on_tail('-h', '--help', 'Show this help.') {
118
+ log.puts opts
119
+ exit
120
+ }
121
+
122
+ parse_options opts, args
123
+
124
+ args
125
+ end # #optparse
126
+
127
+
128
+ # Callback when an unrecognized option is parsed. We ignore 'em... there are
129
+ # *many* options that can be defined in the *yardopts* that we don't handle
130
+ # and don't care about.
131
+ #
132
+ # @param [OptionParser::ParseError] err the exception raised by the
133
+ # option parser
134
+ def unrecognized_option err
135
+ # pass
136
+ end
137
+
138
+ end # class Clean
139
+
140
+ # /Namespace
141
+ # ============================================================================
142
+
143
+ end # module CLI
144
+ end # module YARD
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "yard/clean/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yard-clean"
8
+ spec.version = YARD::Clean::VERSION
9
+ spec.authors = ["nrser"]
10
+ spec.email = ["neil@neilsouza.com"]
11
+
12
+ spec.summary = %q{Yeah this just adds a `yard clean` command to remove files.}
13
+ # spec.description = %q{}
14
+
15
+ spec.homepage = "https://github.com/nrser/yard-clean"
16
+ spec.license = "MIT"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ # TODO No idea what version of YARD this will work back to...
28
+ spec.add_runtime_dependency "yard"
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ # spec.add_development_dependency "rspec", "~> 3.0"
33
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-clean
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nrser
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - neil@neilsouza.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/yard-clean.rb
68
+ - lib/yard/clean/version.rb
69
+ - lib/yard/cli/clean.rb
70
+ - yard-clean.gemspec
71
+ homepage: https://github.com/nrser/yard-clean
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.5.2.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Yeah this just adds a `yard clean` command to remove files.
95
+ test_files: []