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.
@@ -0,0 +1,18 @@
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
18
+ *DS_store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cruft.gemspec
4
+ gemspec
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.
@@ -0,0 +1,46 @@
1
+ ![Cruft](http://i.imgur.com/Y5JOL.jpg)
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
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler'
5
+ Bundler.setup
6
+ rescue Exception => e
7
+ end
8
+
9
+ here = File.expand_path(File.dirname __FILE__)
10
+ $:<< "#{here}/../lib"
11
+
12
+ require 'cruft'
13
+
14
+ CruftCollector.collect
@@ -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
@@ -0,0 +1,7 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require "cruft/version"
3
+ require 'cruft/cruft_collector'
4
+
5
+ module Cruft
6
+
7
+ end
@@ -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
@@ -0,0 +1,3 @@
1
+ module Cruft
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ cruft_lib = File.expand_path(File.dirname(File.dirname(__FILE__)))
2
+
3
+ desc "Collect cruft (#cruft:) comments into a single Cruftfile"
4
+ task :collect_cruft => :environment do
5
+ require "#{cruft_lib}/cruft/cruft_collector"
6
+ CruftCollector.collect(options)
7
+ 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: