Skip to content

Commit

Permalink
added activesupport dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
morgoth committed Jul 23, 2010
1 parent f01687d commit b7d6832
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 48 deletions.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ begin
gem.authors = ["morellon", "fnando", "rafaelrosafu", "dalcico"]
gem.add_development_dependency "rspec"
gem.add_dependency "ffi"
gem.add_dependency "activesupport"
end
Jeweler::GemcutterTasks.new
rescue LoadError
Expand Down
18 changes: 9 additions & 9 deletions lib/rrd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@
require "rrd/base"
require "rrd/graph"
require "rrd/builder"
require "rrd/ext/fixnum"
require "rrd/time_extension"

module RRD
extend self

BANG_METHODS = [:graph!]

def graph(image_file, options = {}, &block)
graph = Graph.new(image_file, options)
graph.instance_eval(&block)
graph.save
end

def error
Wrapper.error
end

def to_line_parameters(hash, known_flags = [])
used_flags = []
known_flags.each do |flag|
used_flags << "--#{flag}".gsub(/_/, "-") if hash.delete(flag)
end

line_params = []
hash.each_pair { |key,value| line_params += ["--#{key}".gsub(/_/, "-"), value.to_s] }
line_params = Hash[*line_params]

params = []
line_params.keys.sort.each { |key| params += [key, line_params[key]] }
used_flags + params
end

def methods
super + BANG_METHODS
end

def bang(method, *args, &block)
result = send(method, *args, &block)
raise error unless result
Expand Down
39 changes: 0 additions & 39 deletions lib/rrd/ext/fixnum.rb

This file was deleted.

18 changes: 18 additions & 0 deletions lib/rrd/time_extension.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'active_support/version'

if ActiveSupport::VERSION::MAJOR >= 3
require 'active_support/core_ext/numeric/time'
require 'active_support/core_ext/integer/time'
else
require 'active_support/duration'
require 'active_support/core_ext/numeric/time'
require 'active_support/core_ext/integer/time'

class Numeric
include ActiveSupport::CoreExtensions::Numeric::Time
end

class Integer
include ActiveSupport::CoreExtensions::Integer::Time
end
end

0 comments on commit b7d6832

Please sign in to comment.