enum_records 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/enum_records.gemspec +77 -0
- data/lib/enum_records.rb +105 -0
- data/spec/db/database.yml +9 -0
- data/spec/db/schema.rb +25 -0
- data/spec/db/schema_loader.rb +11 -0
- data/spec/enum_records_spec.rb +107 -0
- data/spec/models/article.rb +3 -0
- data/spec/models/document.rb +12 -0
- data/spec/models/page.rb +11 -0
- data/spec/spec_helper.rb +26 -0
- metadata +205 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.3.0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.4"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
gem 'activerecord', '>= 3.0.9'
|
14
|
+
gem 'activesupport', '>= 3.0.9'
|
15
|
+
gem 'sqlite3'
|
16
|
+
gem 'globalize3'
|
17
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Alex Tkachev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= enum_records
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to enum_records
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Alex Tkachev. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "enum_records"
|
18
|
+
gem.homepage = "http://github.com/alextk/enum_records"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Allows to create named model records (enums).}
|
21
|
+
gem.description = %Q{This gem allows to created enum records (named records) and to retrieve them easily. Support globalize3 localization in enum fields initialization. }
|
22
|
+
gem.email = "tkachev.alex@gmail.com"
|
23
|
+
gem.authors = ["Alex Tkachev"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "enum_records #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{enum_records}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alex Tkachev"]
|
12
|
+
s.date = %q{2011-07-24}
|
13
|
+
s.description = %q{This gem allows to created enum records (named records) and to retrieve them easily. Support globalize3 localization in enum fields initialization. }
|
14
|
+
s.email = %q{tkachev.alex@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"enum_records.gemspec",
|
28
|
+
"lib/enum_records.rb",
|
29
|
+
"spec/db/database.yml",
|
30
|
+
"spec/db/schema.rb",
|
31
|
+
"spec/db/schema_loader.rb",
|
32
|
+
"spec/enum_records_spec.rb",
|
33
|
+
"spec/models/article.rb",
|
34
|
+
"spec/models/document.rb",
|
35
|
+
"spec/models/page.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/alextk/enum_records}
|
39
|
+
s.licenses = ["MIT"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.4.2}
|
42
|
+
s.summary = %q{Allows to create named model records (enums).}
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
51
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<activerecord>, [">= 3.0.9"])
|
53
|
+
s.add_development_dependency(%q<activesupport>, [">= 3.0.9"])
|
54
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<globalize3>, [">= 0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
60
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
61
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.9"])
|
62
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.9"])
|
63
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
64
|
+
s.add_dependency(%q<globalize3>, [">= 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
68
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
69
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
70
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
71
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.9"])
|
72
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.9"])
|
73
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
74
|
+
s.add_dependency(%q<globalize3>, [">= 0"])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
data/lib/enum_records.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
module EnumRecords
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.send(:include, InstanceMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
|
12
|
+
def acts_as_enum(enum_column_name = 'enum_key')
|
13
|
+
self.class_eval do
|
14
|
+
# first cehck for enum column name existance
|
15
|
+
raise ArgumentError, "Enum column #{enum_column_name} doesn't exsist in the table" unless self.columns_hash.keys.include?(enum_column_name)
|
16
|
+
|
17
|
+
# stores all the names for named records (and their optoins) that are defined in the model.
|
18
|
+
self.class_attribute :_enums
|
19
|
+
self._enums = {
|
20
|
+
:definitions => {},
|
21
|
+
:column_name => enum_column_name
|
22
|
+
}
|
23
|
+
|
24
|
+
#define class methods
|
25
|
+
def self.define_enums *args, &block
|
26
|
+
self._enums[:globalized] = self.respond_to?(:translations_table_name)
|
27
|
+
EnumRecords::Definer.new self, &block
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.enums
|
31
|
+
self.where(self._enums[:column_name].to_sym => self._enums[:definitions].keys)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.enum(key)
|
35
|
+
self.send "find_by_#{self._enums[:column_name]}", key
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module InstanceMethods
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
# use the Enumeration class capture enum names as methods or contants
|
49
|
+
class Definer
|
50
|
+
def initialize model_class, &block
|
51
|
+
@model_class = model_class
|
52
|
+
EnumNameCapturer.new(self, &block)
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_new_enum(method_sym, options)
|
56
|
+
# Check that the model's translation table exist if locales are passed so that in migration we will not have an exception
|
57
|
+
return if @model_class._enums[:globalized] && !options[:locales].blank? && !@model_class.connection.table_exists?(@model_class.translations_table_name)
|
58
|
+
|
59
|
+
enum_name = method_sym.to_s
|
60
|
+
@model_class._enums[:definitions][enum_name] = options
|
61
|
+
|
62
|
+
# Reject options that aren't real data base fields.
|
63
|
+
fields = options.reject { |k, v| !@model_class.columns_hash.keys.include?(k.to_s) }
|
64
|
+
|
65
|
+
localized_fields = options[:locales] || {}
|
66
|
+
|
67
|
+
# Create or find the record associated with the enum.
|
68
|
+
if !localized_fields.blank? # In case locales hash is passed
|
69
|
+
# Reject options that aren't real data base fields for localized fields.
|
70
|
+
for locale in localized_fields.keys
|
71
|
+
localized_fields[locale] = localized_fields[locale].reject { |k, v| !@model_class.columns_hash.keys.include?(k.to_s) }
|
72
|
+
end
|
73
|
+
if @model_class.enum(enum_name).nil? #enum hasn't been created yet
|
74
|
+
record = find_or_create_enum_record(enum_name, fields)
|
75
|
+
localized_fields.each_pair do |locale, l_fields|
|
76
|
+
Globalize.with_locale locale do
|
77
|
+
record.update_attributes(l_fields)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
else # no localization needed => create or find the record associated with the enum.
|
82
|
+
find_or_create_enum_record(enum_name, fields)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_or_create_enum_record(enum_name, fields)
|
87
|
+
@model_class.send "find_or_create_by_#{@model_class._enums[:column_name]}", enum_name, fields
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class EnumNameCapturer
|
92
|
+
def initialize definer, &block
|
93
|
+
@definer = definer
|
94
|
+
instance_eval(&block)
|
95
|
+
end
|
96
|
+
|
97
|
+
def method_missing method_sym, *args, &block
|
98
|
+
@definer.add_new_enum method_sym, args[0]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
ActiveRecord::Base.send :include, EnumRecords::ActiveRecord
|
data/spec/db/schema.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
ActiveRecord::Schema.define(:version => 0) do
|
2
|
+
|
3
|
+
create_table :articles, :force => true do |t|
|
4
|
+
t.string :name
|
5
|
+
t.timestamps
|
6
|
+
end
|
7
|
+
|
8
|
+
create_table :documents, :force => true do |t|
|
9
|
+
t.string :name
|
10
|
+
t.string :enum_key
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
create_table :pages do |t|
|
15
|
+
t.string :title, :enum_key
|
16
|
+
t.text :intro
|
17
|
+
t.boolean :published
|
18
|
+
t.integer :position
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
require File.join(File.dirname(__FILE__), '..', 'models', 'page')
|
25
|
+
Page.create_translation_table! :title => :string, :intro => :text
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def load_schema
|
2
|
+
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
3
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
4
|
+
|
5
|
+
db_adapter = 'sqlite3'
|
6
|
+
|
7
|
+
ActiveRecord::Base.establish_connection(config[db_adapter])
|
8
|
+
load(File.dirname(__FILE__) + "/schema.rb")
|
9
|
+
end
|
10
|
+
|
11
|
+
load_schema
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "ActiveRecord::Base" do
|
4
|
+
it "should respond to :define_enums" do
|
5
|
+
ActiveRecord::Base.respond_to?(:acts_as_enum).should be_true
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Article" do
|
10
|
+
it "should not act_as_enum" do
|
11
|
+
Article.should_not respond_to :define_enums
|
12
|
+
Article.should_not respond_to :enums
|
13
|
+
Article.should_not respond_to :enum
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should check for enum column existance" do
|
17
|
+
lambda { Article.acts_as_enum }.should raise_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "Document" do
|
22
|
+
|
23
|
+
before(:all) do
|
24
|
+
@non_enum = Document.create(:name => 'not enum')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should act_as_enum" do
|
28
|
+
Document.should respond_to :define_enums
|
29
|
+
Document.should respond_to :enums
|
30
|
+
Document.should respond_to :enum
|
31
|
+
Document._enums[:column_name].should == 'enum_key'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should find defined "home" enum' do
|
35
|
+
enum_doc = Document.enum(:home)
|
36
|
+
enum_doc.should_not be_nil
|
37
|
+
enum_doc.name.should == 'Home page'
|
38
|
+
enum_doc.should == Document.enum('home')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should not recreate defined enum' do
|
42
|
+
enum_doc = Document.enum(:home)
|
43
|
+
enum_doc.id.should == Document.enum(:home).id
|
44
|
+
enum_doc.id.should == enum_doc.id.should
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should find defined "about" enum' do
|
48
|
+
enum_doc = Document.enum(:about)
|
49
|
+
enum_doc.should_not be_nil
|
50
|
+
enum_doc.name.should == 'About page'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should find defined "contact_form" enum' do
|
54
|
+
enum_doc = Document.enum(:contact_form)
|
55
|
+
enum_doc.should_not be_nil
|
56
|
+
enum_doc.name.should == 'Contact us'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should not find "foo" enum' do
|
60
|
+
enum_doc = Document.enum(:foo)
|
61
|
+
enum_doc.should be_nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should find 3 defined enums' do
|
65
|
+
enums = Document.enums
|
66
|
+
enums.length.should == 3
|
67
|
+
Document.count.should == 4
|
68
|
+
enums.should include(Document.enum(:home), Document.enum(:about), Document.enum(:contact_form))
|
69
|
+
enums.should_not include(@non_enum)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "Page" do
|
75
|
+
before(:all) do
|
76
|
+
@non_enum = Page.create(:title => 'not enum')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should find 3 defined enums' do
|
80
|
+
enums = Page.enums
|
81
|
+
enums.length.should == 3
|
82
|
+
Page.count.should == 4
|
83
|
+
enums.should include(Page.enum(:home), Page.enum(:profile), Page.enum(:project_categories))
|
84
|
+
enums.should_not include(@non_enum)
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'should have localized enums fields' do
|
88
|
+
|
89
|
+
it 'when locale is en-US' do
|
90
|
+
I18n.locale = :'en-US'
|
91
|
+
I18n.locale.should == :'en-US'
|
92
|
+
Page.enum(:home).title.should == 'Home'
|
93
|
+
Page.enum(:profile).title.should == 'Profile'
|
94
|
+
Page.enum(:project_categories).title.should == 'Projects'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'when locale is he-IL' do
|
98
|
+
I18n.locale = :'he-IL'
|
99
|
+
I18n.locale.should == :'he-IL'
|
100
|
+
Page.enum(:home).title.should == 'דף הבית'
|
101
|
+
Page.enum(:profile).title.should == 'פרופיל'
|
102
|
+
Page.enum(:project_categories).title.should == 'פרויקטים'
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Document < ActiveRecord::Base
|
2
|
+
acts_as_enum
|
3
|
+
|
4
|
+
define_enums do
|
5
|
+
home :name => 'Home page'
|
6
|
+
about :name => 'About page'
|
7
|
+
contact_form :name => 'Contact us'
|
8
|
+
end
|
9
|
+
|
10
|
+
#define 'Home', :name=>"home page"
|
11
|
+
#define :About, :name=>"about page", :link_to => 'google'
|
12
|
+
end
|
data/spec/models/page.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
class Page < ActiveRecord::Base
|
2
|
+
acts_as_enum
|
3
|
+
|
4
|
+
translates :title, :intro
|
5
|
+
|
6
|
+
define_enums do
|
7
|
+
home :position=>1, :published => true, :locales => {'en-US'=>{:title=>'Home'}, 'he-IL'=>{:title=>'דף הבית'}}
|
8
|
+
profile :position=>2, :published => true, :locales=>{'en-US'=>{:title=>'Profile'}, 'he-IL'=>{:title=>'פרופיל'}}
|
9
|
+
project_categories :position=>3, :published=>true, :locales=>{'en-US'=>{:title=>'Projects'}, 'he-IL'=>{:title=>'פרויקטים'}}
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
|
5
|
+
require 'logger'
|
6
|
+
require 'active_record'
|
7
|
+
require 'active_support'
|
8
|
+
require 'sqlite3'
|
9
|
+
require 'globalize3'
|
10
|
+
|
11
|
+
require 'enum_records'
|
12
|
+
|
13
|
+
#load models schema (create tables)
|
14
|
+
require "db/schema_loader"
|
15
|
+
|
16
|
+
#load models
|
17
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'models'))
|
18
|
+
Dir["#{File.dirname(__FILE__)}/models/**/*.rb"].each {|f| require f}
|
19
|
+
|
20
|
+
# Requires supporting files with custom matchers and macros, etc,
|
21
|
+
# in ./support/ and its subdirectories.
|
22
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
23
|
+
|
24
|
+
RSpec.configure do |config|
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: enum_records
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alex Tkachev
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-07-24 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 3
|
32
|
+
- 0
|
33
|
+
version: 2.3.0
|
34
|
+
type: :development
|
35
|
+
name: rspec
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 23
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
version: 1.0.0
|
50
|
+
type: :development
|
51
|
+
name: bundler
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 7
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 6
|
64
|
+
- 4
|
65
|
+
version: 1.6.4
|
66
|
+
type: :development
|
67
|
+
name: jeweler
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
type: :development
|
81
|
+
name: rcov
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 21
|
91
|
+
segments:
|
92
|
+
- 3
|
93
|
+
- 0
|
94
|
+
- 9
|
95
|
+
version: 3.0.9
|
96
|
+
type: :development
|
97
|
+
name: activerecord
|
98
|
+
version_requirements: *id005
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
prerelease: false
|
101
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 21
|
107
|
+
segments:
|
108
|
+
- 3
|
109
|
+
- 0
|
110
|
+
- 9
|
111
|
+
version: 3.0.9
|
112
|
+
type: :development
|
113
|
+
name: activesupport
|
114
|
+
version_requirements: *id006
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
prerelease: false
|
117
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
126
|
+
type: :development
|
127
|
+
name: sqlite3
|
128
|
+
version_requirements: *id007
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
prerelease: false
|
131
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
hash: 3
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
type: :development
|
141
|
+
name: globalize3
|
142
|
+
version_requirements: *id008
|
143
|
+
description: "This gem allows to created enum records (named records) and to retrieve them easily. Support globalize3 localization in enum fields initialization. "
|
144
|
+
email: tkachev.alex@gmail.com
|
145
|
+
executables: []
|
146
|
+
|
147
|
+
extensions: []
|
148
|
+
|
149
|
+
extra_rdoc_files:
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.rdoc
|
152
|
+
files:
|
153
|
+
- .document
|
154
|
+
- .rspec
|
155
|
+
- Gemfile
|
156
|
+
- LICENSE.txt
|
157
|
+
- README.rdoc
|
158
|
+
- Rakefile
|
159
|
+
- VERSION
|
160
|
+
- enum_records.gemspec
|
161
|
+
- lib/enum_records.rb
|
162
|
+
- spec/db/database.yml
|
163
|
+
- spec/db/schema.rb
|
164
|
+
- spec/db/schema_loader.rb
|
165
|
+
- spec/enum_records_spec.rb
|
166
|
+
- spec/models/article.rb
|
167
|
+
- spec/models/document.rb
|
168
|
+
- spec/models/page.rb
|
169
|
+
- spec/spec_helper.rb
|
170
|
+
has_rdoc: true
|
171
|
+
homepage: http://github.com/alextk/enum_records
|
172
|
+
licenses:
|
173
|
+
- MIT
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options: []
|
176
|
+
|
177
|
+
require_paths:
|
178
|
+
- lib
|
179
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
+
none: false
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
hash: 3
|
185
|
+
segments:
|
186
|
+
- 0
|
187
|
+
version: "0"
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
hash: 3
|
194
|
+
segments:
|
195
|
+
- 0
|
196
|
+
version: "0"
|
197
|
+
requirements: []
|
198
|
+
|
199
|
+
rubyforge_project:
|
200
|
+
rubygems_version: 1.4.2
|
201
|
+
signing_key:
|
202
|
+
specification_version: 3
|
203
|
+
summary: Allows to create named model records (enums).
|
204
|
+
test_files: []
|
205
|
+
|