Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails3 #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]'
s.homepage = 'http://www.pluginaweek.org'
s.rubyforge_project = 'pluginaweek'
Expand Down
7 changes: 0 additions & 7 deletions generators/preferences/preferences_generator.rb

This file was deleted.

1 change: 0 additions & 1 deletion init.rb

This file was deleted.

2 changes: 1 addition & 1 deletion generators/preferences/USAGE → lib/generators/USAGE
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions lib/generators/preferences_generator.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
5 changes: 3 additions & 2 deletions lib/preferences.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'preferences/engine'
require 'preferences/preference_definition'

# Adds support for defining preferences on ActiveRecord models.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/preferences/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Preferences
class Engine < Rails::Engine
end
end
15 changes: 7 additions & 8 deletions preferences.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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{[email protected]}
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
Expand Down