From ec50a07fece332a6c5e6a275311ca63742962189 Mon Sep 17 00:00:00 2001 From: Aaron Quint Date: Thu, 28 Apr 2011 17:37:40 -0400 Subject: [PATCH] Dont require rubigen in the gemspec --- Rakefile | 4 ++-- generators/static_model/static_model_generator.rb | 14 ++++++++++---- lib/static_model.rb | 2 +- lib/static_model/associations.rb | 10 +++++----- static_model.gemspec | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Rakefile b/Rakefile index d7be86c..68e41f9 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ begin s.description = %q{StaticModel provides a Base class much like ActiveRecord which supports reading from a YAML file and basic associations to ActiveRecord} s.rubyforge_project = %q{quirkey} s.add_runtime_dependency(%q, ["~>2.3.8"]) - s.add_runtime_dependency(%q, [">= 1.5.1"]) + # s.add_runtime_dependency(%q, [">= 1.5.1"]) s.add_development_dependency(%q, [">= 1.2.0"]) end Jeweler::GemcutterTasks.new @@ -30,4 +30,4 @@ end Dir['tasks/**/*.rake'].each { |t| load t } -task :default => :test \ No newline at end of file +task :default => :test diff --git a/generators/static_model/static_model_generator.rb b/generators/static_model/static_model_generator.rb index 88ec8f0..1b659fe 100644 --- a/generators/static_model/static_model_generator.rb +++ b/generators/static_model/static_model_generator.rb @@ -1,3 +1,9 @@ +begin + require 'rubigen' +rescue => LoadError + warn "Please install rubigen" +end + class StaticModelGenerator < RubiGen::Base default_options :author => nil @@ -29,15 +35,15 @@ def banner USAGE: #{$0} #{spec.name} ModelName EOS end - + def class_name @name.classify end - + def table_name @name.tableize end - + def add_options!(opts) # opts.separator '' # opts.separator 'Options:' @@ -54,4 +60,4 @@ def extract_options @lib_dir = options[:lib_dir] || File.join('app', 'models') @data_dir = options[:data_dir] || File.join('config', 'data') end -end \ No newline at end of file +end diff --git a/lib/static_model.rb b/lib/static_model.rb index a557720..9b6d973 100644 --- a/lib/static_model.rb +++ b/lib/static_model.rb @@ -8,7 +8,7 @@ require 'active_support' module StaticModel - VERSION = '0.3.1' + VERSION = '0.3.2' end require 'static_model/errors' diff --git a/lib/static_model/associations.rb b/lib/static_model/associations.rb index f5ff351..d75eebe 100644 --- a/lib/static_model/associations.rb +++ b/lib/static_model/associations.rb @@ -14,7 +14,7 @@ def associations def has_many(association_name, options = {}) self.associations[association_name.to_sym] = HasManyAssociation.new(self, association_name.to_sym, {:foreign_key => "#{self.to_s.foreign_key}"}.merge(options)) end - + def belongs_to(association_name, options = {}) self.associations[association_name.to_sym] = BelongsToAssociation.new(self, association_name.to_sym, {:foreign_key => "#{association_name.to_s.foreign_key}"}.merge(options)) end @@ -33,10 +33,10 @@ def initialize(klass, name, options = {}) @foreign_key = @options[:foreign_key] define_association_methods end - + def reflection_klass Object.const_get(@reflection_klass_name) - rescue + rescue eval <<-EOT class #{@reflection_klass_name}; end; #{@reflection_klass_name} @@ -68,7 +68,7 @@ def #{name} end class BelongsToAssociation < Association - + def define_association_methods klass.module_eval <<-EOT def #{name} @@ -79,4 +79,4 @@ def #{name} end end -end \ No newline at end of file +end diff --git a/static_model.gemspec b/static_model.gemspec index e2d731e..2fa50d0 100644 --- a/static_model.gemspec +++ b/static_model.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Aaron Quint"] - s.date = %q{2009-12-03} + s.date = %q{2010-10-22} s.description = %q{StaticModel provides a Base class much like ActiveRecord which supports reading from a YAML file and basic associations to ActiveRecord} s.email = %q{aaron at quirkey dot com} s.extra_rdoc_files = [