cruft 0.0.1
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.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/bin/cruft +14 -0
- data/cruft.gemspec +17 -0
- data/lib/cruft.rb +7 -0
- data/lib/cruft/cruft_collector.rb +53 -0
- data/lib/cruft/version.rb +3 -0
- data/lib/tasks/collect_cruft.rb +7 -0
- metadata +59 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jure Triglav
|
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,46 @@
|
|
1
|
+

|
2
|
+
|
3
|
+
The Hardvard Cruft Laboratory, birthplace of the term 'cruft'. Image by @brettstil.
|
4
|
+
|
5
|
+
# Cruft
|
6
|
+
|
7
|
+
Cruft enables you to keep track of workarounds you had to implement in order
|
8
|
+
to make your code work at the time your code was written. Years later,
|
9
|
+
the assumptions you made when the code was written, may no longer hold true, while
|
10
|
+
your code is still written with those assumptions and is needlessly complex.
|
11
|
+
|
12
|
+
Cruft compiles a Cruftfile by looking at all Ruby files in your `app` directory,
|
13
|
+
and finding comments which start with `#cruft:`. Every line until the next line that is not a comment,
|
14
|
+
will be included in the `Cruftfile`.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
gem 'cruft'
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install cruft
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
You cd into the Rails app directory:
|
33
|
+
|
34
|
+
$ cd /path/to/rails_app
|
35
|
+
|
36
|
+
And run cruft with bundle exec:
|
37
|
+
|
38
|
+
$ bundle exec cruft
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/cruft
ADDED
data/cruft.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/cruft/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jure Triglav"]
|
6
|
+
gem.email = ["me@juretriglav.si"]
|
7
|
+
gem.description = %q{Keeps a cruft.txt file in the app directory, which collects #cruft: notes from the app source code in a single place.}
|
8
|
+
gem.summary = %q{Cruft manager}
|
9
|
+
gem.homepage = "https://github.com/jure/cruft"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "cruft"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Cruft::VERSION
|
17
|
+
end
|
data/lib/cruft.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module CruftCollector
|
2
|
+
class << self
|
3
|
+
def app_dir
|
4
|
+
@app_dir || "app"
|
5
|
+
end
|
6
|
+
|
7
|
+
def app_dir=(dir)
|
8
|
+
@app_dir = dir
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_files(options={})
|
12
|
+
files = []
|
13
|
+
begin
|
14
|
+
Dir.chdir(app_dir) do
|
15
|
+
files = Dir['**/*.rb']
|
16
|
+
end
|
17
|
+
rescue SystemCallError
|
18
|
+
puts "No cruftworthy files found in directory 'app'."
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
files
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_cruft_from_file(file)
|
25
|
+
cruft = []
|
26
|
+
cruft_count = -1
|
27
|
+
cruft_mode = false
|
28
|
+
|
29
|
+
File.readlines(File.join(app_dir, file)).each_with_index do |line, index|
|
30
|
+
if cruft_mode && line =~ /^\s*#/
|
31
|
+
cruft[cruft_count] += line
|
32
|
+
elsif line =~ /^\s*#cruft:/
|
33
|
+
cruft_count += 1
|
34
|
+
cruft[cruft_count] = "#{DateTime.now.to_s}, File: #{file} Line number: #{index}\n"
|
35
|
+
cruft[cruft_count] += line
|
36
|
+
cruft_mode = true
|
37
|
+
else
|
38
|
+
cruft_mode = false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
cruft
|
42
|
+
end
|
43
|
+
|
44
|
+
def collect(options={})
|
45
|
+
File.open('Cruftfile', 'w') do |cruftfile|
|
46
|
+
get_files.each do |file|
|
47
|
+
cruftfile.write(get_cruft_from_file(file).join('\n'))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cruft
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jure Triglav
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-16 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! 'Keeps a cruft.txt file in the app directory, which collects #cruft:
|
15
|
+
notes from the app source code in a single place.'
|
16
|
+
email:
|
17
|
+
- me@juretriglav.si
|
18
|
+
executables:
|
19
|
+
- cruft
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- .gitignore
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/cruft
|
29
|
+
- cruft.gemspec
|
30
|
+
- lib/cruft.rb
|
31
|
+
- lib/cruft/cruft_collector.rb
|
32
|
+
- lib/cruft/version.rb
|
33
|
+
- lib/tasks/collect_cruft.rb
|
34
|
+
homepage: https://github.com/jure/cruft
|
35
|
+
licenses: []
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.24
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Cruft manager
|
58
|
+
test_files: []
|
59
|
+
has_rdoc:
|