Commit 91f4f8eb authored by Coraline Ehmke's avatar Coraline Ehmke

Initial commit

parents
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
*.bundle
*.so
*.o
*.a
mkmf.log
source 'https://rubygems.org'
# Specify your gem's dependencies in snuffle.gemspec
gemspec
Copyright (c) 2014 Bantik
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Snuffle
TODO: Write a gem description
## Installation
Add this line to your application's Gemfile:
gem 'snuffle'
And then execute:
$ bundle
Or install it yourself as:
$ gem install snuffle
## Usage
TODO: Write usage instructions here
## Contributing
1. Fork it ( https://github.com/[my-github-username]/snuffle/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
require "bundler/gem_tasks"
require "snuffle/version"
module Snuffle
# Your code goes here...
end
require 'thor'
require 'snuffle'
module Snuffle
class CLI < Thor
desc_text = "Formats are text (default, to STDOUT), html, and csv. "
desc_text << "Example: snuffle check foo/ -f html"
desc "check PATH_TO_FILE [-f FORMAT] [-t MAX_COMPLEXITY_ALLOWED]", desc_text
method_option :format, :type => :string, :default => 'text', :aliases => "-f"
method_option :threshold, :type => :numeric, :default => 0, :aliases => "-t"
def check(path="./")
file_list(path).each{ |path_to_file| parse(path_to_file) }
handle_index(summaries)
report
end
default_task :check
attr_accessor :summaries, :last_file
private
def file_list(start_file)
if File.directory?(start_file)
return Dir.glob(File.join(start_file, "**", "*")).select{|n| n =~ /\.rb$/}
else
return [start_file]
end
end
def formatter
case options['format']
when 'html'
Formatters::Html
when 'csv'
Formatters::Csv
else
Formatters::Text
end
end
def handle_index(file_summary)
return unless options['format'] == 'html'
index = Formatters::HtmlIndex.new(file_summary)
self.last_file = "#{index.output_path}/#{index.filename}"
index.export
end
def parse(path_to_file, options={})
file = ParsedFile.new(path_to_file: path_to_file)
parser = formatter.new(file)
parser.export
self.summaries ||= []
self.summaries << file.summary.merge(results_file: parser.path_to_results)
last_file = file
end
def report
unless options['format'] == "text"
puts "Results written to:"
puts last_file.present? && "#{last_file}" || results_files.join("\r\n")
end
report_complexity
end
def results_files
summaries.map{|s| s[:results_file]}
end
end
end
module Snuffle
VERSION = "0.0.1"
end
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'snuffle/version'
Gem::Specification.new do |spec|
spec.name = "snuffle"
spec.version = Snuffle::VERSION
spec.authors = ["Coraline Ada Ehmke", "Kerri Miller"]
spec.email = ["coraline@idolhands.com"]
spec.summary = %q{Snuffle detects latent objects in your Ruby code.}
spec.description = %q{Snuffle detects latent objects in your Ruby code.}
spec.homepage = ""
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_dependency "parser"
spec.add_dependency "thor"
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "simplecov"
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment