Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
Use bundler as gem builder
Browse files Browse the repository at this point in the history
  • Loading branch information
iain committed Sep 11, 2011
1 parent 22237cd commit 8be762b
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 88 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -1 +1,5 @@
*.gem
.bundle
Gemfile.lock
pkg/*
.rvmrc
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in metrical.gemspec
gemspec
30 changes: 30 additions & 0 deletions README.md
@@ -0,0 +1,30 @@
# Metrical

MetricFu is awesome! Metrical strives to make it a little bit easier to get working.

* Don't make MetricFu or any metrics part of the dependencies of your project;
so you don't need to add anything to your Gemfile.

* You can run MetricFu in any project:

$ gem install metrical
$ cd /path/of/your/project
$ metrical

* Per project configuration can be done in a simple `.metrics` file in the
root directory of your project. In here you can configure MetricFu as you
normally would. Example:

MetricFu::Configuration.run do
config.graph_engine = :gchart
end

For more information on configuring your metrics, please visit the
[MetricFu homepage](http://metric-fu.rubyforge.org/). Any configuration options
you see there can be done in the `.metrics` file.

And that's all there is too it. If you have any suggestions, ideas or bug fixes,
please drop me a line, or make a github issue.

---
Copyright 2010-2011, [Iain Hecker](http://iain.nl) - Released under the MIT License.
31 changes: 0 additions & 31 deletions README.rdoc

This file was deleted.

1 change: 1 addition & 0 deletions Rakefile
@@ -0,0 +1 @@
require "bundler/gem_tasks"
44 changes: 2 additions & 42 deletions bin/metrical
@@ -1,44 +1,4 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'metric_fu'

# Required for RCOV
require 'active_support'
require 'active_support/core_ext'

# Load default configuration
MetricFu::Configuration.run {}

# RCov fixes (should be okay for everybody)
test_files = Dir['{spec,test}/**/*_{spec,test}.rb']
MetricFu::Configuration.run do |config|
config.rcov[:test_files] = test_files
config.rcov[:rcov_opts] = [
"--sort coverage",
"--no-html",
"--text-coverage",
"--no-color",
"--profile",
"--exclude-only '.*'",
'--include-file "\Aapp,\Alib"'
]
config.rcov[:rcov_opts] << "-Ispec" if File.exist?("spec")
end

# Load local metrics settings
file = File.join(Dir.pwd, '.metrics')
load file if File.exist?(file)

# Run metric fu!
MetricFu.metrics.each {|metric| MetricFu.report.add(metric) }
MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.base_directory, "report.yml")
MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml")
MetricFu.report.save_templatized_report

MetricFu.graphs.each {|graph| MetricFu.graph.add(graph, MetricFu.graph_engine) }
MetricFu.graph.generate

if MetricFu.report.open_in_browser?
MetricFu.report.show_in_browser(MetricFu.output_directory)
end
require "metrical"
Metrical.run(*ARGV)
66 changes: 66 additions & 0 deletions lib/metrical.rb
@@ -0,0 +1,66 @@
require "metrical/version"

require 'rubygems'
require 'json'
require 'metric_fu'

# Required for RCOV
require 'active_support'
require 'active_support/core_ext'

module Metrical
extend self

def run(*)
load_defaults
set_new_rcov_defaults
load_user_configuration
run_metric_fu
open_in_browser
end

private

def load_defaults
MetricFu::Configuration.run {}
end

def set_new_rcov_defaults
test_files = Dir['{spec,test}/**/*_{spec,test}.rb']
MetricFu::Configuration.run do |config|
config.rcov[:test_files] = test_files
config.rcov[:rcov_opts] = [
"--sort coverage",
"--no-html",
"--text-coverage",
"--no-color",
"--profile",
"--exclude-only '.*'",
'--include-file "\Aapp,\Alib"'
]
config.rcov[:rcov_opts] << "-Ispec" if File.exist?("spec")
end
end

def load_user_configuration
file = File.join(Dir.pwd, '.metrics')
load file if File.exist?(file)
end

def run_metric_fu
MetricFu.metrics.each {|metric| MetricFu.report.add(metric) }
MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.base_directory, "report.yml")
MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml")
MetricFu.report.save_templatized_report

MetricFu.graphs.each {|graph| MetricFu.graph.add(graph, MetricFu.graph_engine) }
MetricFu.graph.generate
end

def open_in_browser
if MetricFu.report.open_in_browser?
MetricFu.report.show_in_browser(MetricFu.output_directory)
end
end

end
3 changes: 3 additions & 0 deletions lib/metrical/version.rb
@@ -0,0 +1,3 @@
module Metrical
VERSION = "0.0.6"
end
35 changes: 20 additions & 15 deletions metrical.gemspec
@@ -1,19 +1,24 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "metrical/version"

Gem::Specification.new do |s|
s.name = "metrical"
s.version = Metrical::VERSION
s.authors = ["iain"]
s.email = ["iain@iain.nl"]
s.homepage = "https://github.com/iain/metrical"
s.summary = %q{Run metric_fu without making it a project dependency}
s.description = %q{MetricFu is awesome! The only problem is that it's kinda obtrusive. Metrical provides a executable so you can run metric fu on any project without making changes to the project.}

s.rubyforge_project = "metrical"

s.name = "metrical"
s.version = "0.0.6"
s.summary = "Run metric_fu without making it a project dependency"
s.email = "iain@iain.nl"
s.homepage = "http://github.com/iain/metrical/"
s.description = "MetricFu is awesome! The only problem is that it's kinda obtrusive. Metrical provides a executable so you can run metric fu on any project without making changes to the project."
s.authors = ["Iain Hecker"]
s.files = [ "README.rdoc", 'bin/metrical' ]
s.has_rdoc = true
s.rdoc_options = ["--main", "README.rdoc"]
s.extra_rdoc_files = []
s.executables = ["metrical"]
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency "metric_fu", "~> 2.1.1"
s.add_dependency "activesupport"
s.add_dependency "main", "~> 4.6.0"
s.add_runtime_dependency "metric_fu", "~> 2.1.1"
s.add_runtime_dependency "activesupport"
s.add_runtime_dependency "main", "~> 4.6.0"
end

0 comments on commit 8be762b

Please sign in to comment.