Skip to content

Loading…

Rails3 #2

Open
wants to merge 8 commits into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
6 Rakefile
@@ -6,17 +6,17 @@ require 'rake/gempackagetask'
spec = Gem::Specification.new do |s|
s.name = 'preferences'
- s.version = '0.4.2'
+ s.version = '0.5.0'
s.platform = Gem::Platform::RUBY
s.summary = 'Adds support for easily creating custom preferences for ActiveRecord models'
s.description = s.summary
- s.files = FileList['{app,generators,lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc) - FileList['test/app_root/{log,log/*,script,script/*}']
+ s.files = FileList['{app,generators,lib,test}/**/*'] + %w(CHANGELOG.rdoc LICENSE Rakefile README.rdoc) - FileList['test/app_root/{log,log/*,script,script/*}']
s.require_path = 'lib'
s.has_rdoc = true
s.test_files = Dir['test/**/*_test.rb']
- s.author = 'Aaron Pfeifer'
+ s.authors = ["Aaron Pfeifer", "Jack Dempsey"]
s.email = 'aaron@pluginaweek.org'
s.homepage = 'http://www.pluginaweek.org'
s.rubyforge_project = 'pluginaweek'
View
7 generators/preferences/preferences_generator.rb
@@ -1,7 +0,0 @@
-class PreferencesGenerator < Rails::Generator::Base
- def manifest
- record do |m|
- m.migration_template '001_create_preferences.rb', 'db/migrate', :migration_file_name => 'create_preferences'
- end
- end
-end
View
1 init.rb
@@ -1 +0,0 @@
-require 'preferences'
View
2 generators/preferences/USAGE → lib/generators/USAGE
@@ -1,5 +1,5 @@
Usage:
- script/generate preferences
+ rails generate preferences
This will create a migration that will add the proper table to store preferences.
View
17 lib/generators/preferences_generator.rb
@@ -0,0 +1,17 @@
+class PreferencesGenerator < Rails::Generators::Base
+ include Rails::Generators::Migration
+
+ source_root File.expand_path("../templates", __FILE__)
+
+ def self.next_migration_number(dirname)
+ if ActiveRecord::Base.timestamped_migrations
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
+ else
+ "%.3d" % (current_migration_number(dirname) + 1)
+ end
+ end
+
+ def create_migration_file
+ migration_template 'create_preferences.rb', "db/migrate/create_preferences.rb"
+ end
+end
View
6 ...ences/templates/001_create_preferences.rb → ...enerators/templates/create_preferences.rb
@@ -1,5 +1,5 @@
class CreatePreferences < ActiveRecord::Migration
- def self.up
+ def change
create_table :preferences do |t|
t.string :name, :null => false
t.references :owner, :polymorphic => true, :null => false
@@ -9,8 +9,4 @@ def self.up
end
add_index :preferences, [:owner_id, :owner_type, :name, :group_id, :group_type], :unique => true, :name => 'index_preferences_on_owner_and_name_and_preference'
end
-
- def self.down
- drop_table :preferences
- end
end
View
5 lib/preferences.rb
@@ -1,3 +1,4 @@
+require 'preferences/engine'
require 'preferences/preference_definition'
# Adds support for defining preferences on ActiveRecord models.
@@ -160,8 +161,8 @@ def preference(name, *args)
after_save :update_preferences
# Named scopes
- named_scope :with_preferences, lambda {|preferences| build_preference_scope(preferences)}
- named_scope :without_preferences, lambda {|preferences| build_preference_scope(preferences, true)}
+ scope :with_preferences, lambda {|preferences| build_preference_scope(preferences)}
+ scope :without_preferences, lambda {|preferences| build_preference_scope(preferences, true)}
extend Preferences::ClassMethods
include Preferences::InstanceMethods
View
4 lib/preferences/engine.rb
@@ -0,0 +1,4 @@
+module Preferences
+ class Engine < Rails::Engine
+ end
+end
View
15 preferences.gemspec
@@ -2,26 +2,25 @@
Gem::Specification.new do |s|
s.name = %q{preferences}
- s.version = "0.4.2"
+ s.version = "0.5.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Aaron Pfeifer"]
- s.date = %q{2010-04-17}
+ s.authors = ["Aaron Pfeifer", "Jack Dempsey"]
+ s.date = %q{2011-05-19}
s.description = %q{Adds support for easily creating custom preferences for ActiveRecord models}
s.email = %q{aaron@pluginaweek.org}
- s.files = ["app/models", "app/models/preference.rb", "generators/preferences", "generators/preferences/USAGE", "generators/preferences/preferences_generator.rb", "generators/preferences/templates", "generators/preferences/templates/001_create_preferences.rb", "lib/preferences", "lib/preferences/preference_definition.rb", "lib/preferences.rb", "test/unit", "test/unit/preference_test.rb", "test/unit/preference_definition_test.rb", "test/app_root", "test/app_root/db", "test/app_root/db/migrate", "test/app_root/db/migrate/003_create_employees.rb", "test/app_root/db/migrate/004_migrate_preferences_to_version_1.rb", "test/app_root/db/migrate/002_create_cars.rb", "test/app_root/db/migrate/001_create_users.rb", "test/app_root/app", "test/app_root/app/models", "test/app_root/app/models/car.rb", "test/app_root/app/models/employee.rb", "test/app_root/app/models/user.rb", "test/app_root/app/models/manager.rb", "test/test_helper.rb", "test/factory.rb", "test/functional", "test/functional/preferences_test.rb", "CHANGELOG.rdoc", "init.rb", "LICENSE", "Rakefile", "README.rdoc"]
+ s.files = ["app/models", "app/models/preference.rb", "lib/generators", "lib/generators/preferences_generator.rb", "lib/generators/templates", "lib/generators/templates/create_preferences.rb", "lib/generators/USAGE", "lib/preferences", "lib/preferences/engine.rb", "lib/preferences/preference_definition.rb", "lib/preferences.rb", "test/app_root", "test/app_root/app", "test/app_root/app/models", "test/app_root/app/models/car.rb", "test/app_root/app/models/employee.rb", "test/app_root/app/models/manager.rb", "test/app_root/app/models/user.rb", "test/app_root/db", "test/app_root/db/migrate", "test/app_root/db/migrate/001_create_users.rb", "test/app_root/db/migrate/002_create_cars.rb", "test/app_root/db/migrate/003_create_employees.rb", "test/app_root/db/migrate/004_migrate_preferences_to_version_1.rb", "test/factory.rb", "test/functional", "test/functional/preferences_test.rb", "test/test_helper.rb", "test/unit", "test/unit/preference_definition_test.rb", "test/unit/preference_test.rb", "CHANGELOG.rdoc", "LICENSE", "Rakefile", "README.rdoc"]
s.homepage = %q{http://www.pluginaweek.org}
s.require_paths = ["lib"]
s.rubyforge_project = %q{pluginaweek}
- s.rubygems_version = %q{1.3.5}
+ s.rubygems_version = %q{1.5.2}
s.summary = %q{Adds support for easily creating custom preferences for ActiveRecord models}
- s.test_files = ["test/unit/preference_test.rb", "test/unit/preference_definition_test.rb", "test/functional/preferences_test.rb"]
+ s.test_files = ["test/functional/preferences_test.rb", "test/unit/preference_definition_test.rb", "test/unit/preference_test.rb"]
if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
else
end
else
Something went wrong with that request. Please try again.