more refactoring

This commit is contained in:
John Bintz 2012-10-09 14:45:27 -04:00
parent 4f88e3977f
commit cd072c1d4c
5 changed files with 60 additions and 65 deletions

View File

@ -1,3 +1,3 @@
Given /^I am on the "([^"]*)" platform$/ do |os|
Penchant::PenchantFile.any_instance.stubs(:current_os).returns(os.to_sym)
Penchant::FileProcessor.any_instance.stubs(:current_os).returns(os.to_sym)
end

View File

@ -5,7 +5,6 @@ module Penchant
autoload :Hooks, 'penchant/hooks'
autoload :Env, 'penchant/env'
autoload :FileProcessor, 'penchant/file_processor'
autoload :PenchantFile, 'penchant/penchant_file'
autoload :Defaults, 'penchant/defaults'
autoload :CustomProperty, 'penchant/custom_property'
autoload :PropertyStack, 'penchant/property_stack'

View File

@ -160,6 +160,64 @@ module Penchant
host_os[%r{^[a-z]+}, 1].to_sym
end
end
def handle_result(data)
instance_eval(data)
end
def gem(*args)
gem_name = [ args.shift ]
template = {}
if args.last.kind_of?(::Hash)
template = args.pop
end
version = args.first
options = @properties.create_stack_for(template, @_strip_pathing_options).process_for_gem(gem_name.first, @_current_env_defaults)
args = [ gem_name.first ]
args << version if version
if options[:git]
@defined_git_repos << Penchant::Repo.new(options[:git])
end
args << options if !options.empty?
self << %{gem #{args_to_string(args)}}
end
def gemspec
@output << %{gemspec}
end
def gems(*args)
gems, template = split_args(args)
gems.flatten.each do |gem_name|
options = @properties.create_stack_for(template, @_strip_pathing_options).process_for_gem(gem_name)
args = [ gem_name ]
args << options if !options.empty?
gem *args
end
end
def group(*args, &block)
self << ""
self << %{group #{args_to_string(args)} do}
call_and_indent_output(block)
self << %{end}
end
def source(*args)
self << %{source #{args_to_string(args)}}
end
end
end

View File

@ -123,7 +123,7 @@ module Penchant
end
def builder
@builder ||= PenchantFile.new(template)
@builder ||= FileProcessor.new(template)
end
def template

View File

@ -1,62 +0,0 @@
module Penchant
class PenchantFile < FileProcessor
def handle_result(data)
instance_eval(data)
end
def gem(*args)
gem_name = [ args.shift ]
template = {}
if args.last.kind_of?(::Hash)
template = args.pop
end
version = args.first
options = @properties.create_stack_for(template, @_strip_pathing_options).process_for_gem(gem_name.first, @_current_env_defaults)
args = [ gem_name.first ]
args << version if version
if options[:git]
@defined_git_repos << Penchant::Repo.new(options[:git])
end
args << options if !options.empty?
self << %{gem #{args_to_string(args)}}
end
def gemspec
@output << %{gemspec}
end
def gems(*args)
gems, template = split_args(args)
gems.flatten.each do |gem_name|
options = @properties.create_stack_for(template, @_strip_pathing_options).process_for_gem(gem_name)
args = [ gem_name ]
args << options if !options.empty?
gem *args
end
end
def group(*args, &block)
self << ""
self << %{group #{args_to_string(args)} do}
call_and_indent_output(block)
self << %{end}
end
def source(*args)
self << %{source #{args_to_string(args)}}
end
end
end