Normalise line endings.

This commit is contained in:
Tom Hughes 2010-04-19 15:17:18 +01:00
parent 3e67d08c13
commit a36185b22f
48 changed files with 2078 additions and 2078 deletions

View file

@ -1,5 +1,5 @@
--- ---
log_file: log/mongrel.log log_file: log/mongrel.log
port: 8000 port: 8000
pid_file: tmp/mongrel.pid pid_file: tmp/mongrel.pid
servers: 8 servers: 8

View file

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/"> xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>OpenStreetMap</ShortName> <ShortName>OpenStreetMap</ShortName>
<LongName>OpenStreetMap Search</LongName> <LongName>OpenStreetMap Search</LongName>
<Description>Search for a place in OpenStreetMap, the Wiki World Map</Description> <Description>Search for a place in OpenStreetMap, the Wiki World Map</Description>
<InputEncoding>UTF-8</InputEncoding> <InputEncoding>UTF-8</InputEncoding>
<OutputEncoding>UTF-8</OutputEncoding> <OutputEncoding>UTF-8</OutputEncoding>
<Image width="16" height="16">data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%19tEXtSoftware%00www.inkscape.org%9B%EE%3C%1A%00%00%01'IDATx%9C%9D%93%B1q%C30%0CE%1F%5Dd%80l%90I%C4*%A7%22%95%CF%85J%97%AE%B2%82%3DC%CE%03%A0%B3%9B%B8f%95%A3%17H%93%05%5C%A7%C8%0A%3F%05E%8A%92l%E7.%D0%E9N%02%81%07%E0Cr%FCaf%A6%FC%BC%5E%AF%DD%F4%3C%3Bt%C5%87%99)%84P%0E%DA%B6%BD%0AI%00%A1%A8%A8%1E%263S%D7u%C9'F%FE%9B%80%0C%C9%C9%22%BD'%B0%0A%AC%86%2CJ%DB%0E%22%11%8F%2F%D4%B3%22%8D%F34%CE%13u%06R%0C%40%D7u%AA%01%C5r%40%0Dq%88%C6%F9i%E8%7C%8CX%5D%A9M%95%D6%A3%A2Ti%C3Xx%CA%9C%F5mf3h%11%B6%07%B8%0APh%97%DD%1E%9E%5E%08!%D0%B6m%F1%87%108%1E%8EY5%007%03%5Cv%7B%00%3E%BF%3E%F8~x%1E%CD%B89l%00%F0I%0FWw%00%20%DB%AEJr%B6%E5%FB%09%80%C6y%CE%7D%91%1AP%B6p%2B%D9%BB%06%18V%3A%B5E%9F%AC%5B%95%AFY%3F%EE%20%A2mW%AA%93%DFN%3F%A0%E1%9B%F0u%E5%BC%BC%89%88%BC.%1F%D5'%DF%FD%C1%EE%F8%FFg%BFp%96%DF%E2%DCw%25%2B%00%00%00%00IEND%AEB%60%82</Image> <Image width="16" height="16">data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%19tEXtSoftware%00www.inkscape.org%9B%EE%3C%1A%00%00%01'IDATx%9C%9D%93%B1q%C30%0CE%1F%5Dd%80l%90I%C4*%A7%22%95%CF%85J%97%AE%B2%82%3DC%CE%03%A0%B3%9B%B8f%95%A3%17H%93%05%5C%A7%C8%0A%3F%05E%8A%92l%E7.%D0%E9N%02%81%07%E0Cr%FCaf%A6%FC%BC%5E%AF%DD%F4%3C%3Bt%C5%87%99)%84P%0E%DA%B6%BD%0AI%00%A1%A8%A8%1E%263S%D7u%C9'F%FE%9B%80%0C%C9%C9%22%BD'%B0%0A%AC%86%2CJ%DB%0E%22%11%8F%2F%D4%B3%22%8D%F34%CE%13u%06R%0C%40%D7u%AA%01%C5r%40%0Dq%88%C6%F9i%E8%7C%8CX%5D%A9M%95%D6%A3%A2Ti%C3Xx%CA%9C%F5mf3h%11%B6%07%B8%0APh%97%DD%1E%9E%5E%08!%D0%B6m%F1%87%108%1E%8EY5%007%03%5Cv%7B%00%3E%BF%3E%F8~x%1E%CD%B89l%00%F0I%0FWw%00%20%DB%AEJr%B6%E5%FB%09%80%C6y%CE%7D%91%1AP%B6p%2B%D9%BB%06%18V%3A%B5E%9F%AC%5B%95%AFY%3F%EE%20%A2mW%AA%93%DFN%3F%A0%E1%9B%F0u%E5%BC%BC%89%88%BC.%1F%D5'%DF%FD%C1%EE%F8%FFg%BFp%96%DF%E2%DCw%25%2B%00%00%00%00IEND%AEB%60%82</Image>
<Url type="text/html" method="post" template="http://www.openstreetmap.org/"> <Url type="text/html" method="post" template="http://www.openstreetmap.org/">
<Param name="query" value="{searchTerms}"/> <Param name="query" value="{searchTerms}"/>
</Url> </Url>
<Query role="example" searchTerms="Reigate" /> <Query role="example" searchTerms="Reigate" />
<Developer>Jonathan Bennett</Developer> <Developer>Jonathan Bennett</Developer>
<AdultContent>false</AdultContent> <AdultContent>false</AdultContent>
<Attribution>Data &amp;copy; OpenStreetMap contributors, Some Rights Reserved. CC by-sa 2.0. Geolocation provided by npemap.org.uk, geocoder.us, geocoder.ca and geonames.org.</Attribution> <Attribution>Data &amp;copy; OpenStreetMap contributors, Some Rights Reserved. CC by-sa 2.0. Geolocation provided by npemap.org.uk, geocoder.us, geocoder.ca and geonames.org.</Attribution>
</OpenSearchDescription> </OpenSearchDescription>

View file

@ -1,41 +1,41 @@
= Composite Primary Keys for ActiveRecords = Composite Primary Keys for ActiveRecords
== Summary == Summary
ActiveRecords/Rails famously doesn't support composite primary keys. ActiveRecords/Rails famously doesn't support composite primary keys.
This RubyGem extends the activerecord gem to provide CPK support. This RubyGem extends the activerecord gem to provide CPK support.
== Installation == Installation
gem install composite_primary_keys gem install composite_primary_keys
== Usage == Usage
require 'composite_primary_keys' require 'composite_primary_keys'
class ProductVariation class ProductVariation
set_primary_keys :product_id, :variation_seq set_primary_keys :product_id, :variation_seq
end end
pv = ProductVariation.find(345, 12) pv = ProductVariation.find(345, 12)
It even supports composite foreign keys for associations. It even supports composite foreign keys for associations.
See http://compositekeys.rubyforge.org for more. See http://compositekeys.rubyforge.org for more.
== Running Tests == Running Tests
See test/README.tests.txt See test/README.tests.txt
== Url == Url
http://compositekeys.rubyforge.org http://compositekeys.rubyforge.org
== Questions, Discussion and Contributions == Questions, Discussion and Contributions
http://groups.google.com/compositekeys http://groups.google.com/compositekeys
== Author == Author
Written by Dr Nic Williams, drnicwilliams@gmail Written by Dr Nic Williams, drnicwilliams@gmail
Contributions by many! Contributions by many!

View file

@ -1,65 +1,65 @@
require 'rubygems' require 'rubygems'
require 'rake' require 'rake'
require 'rake/clean' require 'rake/clean'
require 'rake/testtask' require 'rake/testtask'
require 'rake/rdoctask' require 'rake/rdoctask'
require 'rake/packagetask' require 'rake/packagetask'
require 'rake/gempackagetask' require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher' require 'rake/contrib/rubyforgepublisher'
require 'fileutils' require 'fileutils'
require 'hoe' require 'hoe'
include FileUtils include FileUtils
require File.join(File.dirname(__FILE__), 'lib', 'composite_primary_keys', 'version') require File.join(File.dirname(__FILE__), 'lib', 'composite_primary_keys', 'version')
AUTHOR = "Dr Nic Williams" AUTHOR = "Dr Nic Williams"
EMAIL = "drnicwilliams@gmail.com" EMAIL = "drnicwilliams@gmail.com"
DESCRIPTION = "Composite key support for ActiveRecords" DESCRIPTION = "Composite key support for ActiveRecords"
GEM_NAME = "composite_primary_keys" # what ppl will type to install your gem GEM_NAME = "composite_primary_keys" # what ppl will type to install your gem
if File.exists?("~/.rubyforge/user-config.yml") if File.exists?("~/.rubyforge/user-config.yml")
# TODO this should prob go in a local/ file # TODO this should prob go in a local/ file
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml"))) config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
RUBYFORGE_USERNAME = config["username"] RUBYFORGE_USERNAME = config["username"]
end end
RUBYFORGE_PROJECT = "compositekeys" RUBYFORGE_PROJECT = "compositekeys"
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
VERS = ENV['VERSION'] || (CompositePrimaryKeys::VERSION::STRING + (REV ? ".#{REV}" : "")) VERS = ENV['VERSION'] || (CompositePrimaryKeys::VERSION::STRING + (REV ? ".#{REV}" : ""))
CLEAN.include ['**/.*.sw?', '*.gem', '.config','debug.log','*.db','logfile','log/**/*','**/.DS_Store', '.project'] CLEAN.include ['**/.*.sw?', '*.gem', '.config','debug.log','*.db','logfile','log/**/*','**/.DS_Store', '.project']
RDOC_OPTS = ['--quiet', '--title', "newgem documentation", RDOC_OPTS = ['--quiet', '--title', "newgem documentation",
"--opname", "index.html", "--opname", "index.html",
"--line-numbers", "--line-numbers",
"--main", "README", "--main", "README",
"--inline-source"] "--inline-source"]
class Hoe class Hoe
def extra_deps def extra_deps
@extra_deps.reject { |x| Array(x).first == 'hoe' } @extra_deps.reject { |x| Array(x).first == 'hoe' }
end end
end end
# Generate all the Rake tasks # Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory) # Run 'rake -T' to see list of generated tasks (from gem root directory)
hoe = Hoe.new(GEM_NAME, VERS) do |p| hoe = Hoe.new(GEM_NAME, VERS) do |p|
p.author = AUTHOR p.author = AUTHOR
p.description = DESCRIPTION p.description = DESCRIPTION
p.email = EMAIL p.email = EMAIL
p.summary = DESCRIPTION p.summary = DESCRIPTION
p.url = HOMEPATH p.url = HOMEPATH
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
p.test_globs = ["test/**/test*.rb"] p.test_globs = ["test/**/test*.rb"]
p.clean_globs |= CLEAN #An array of file patterns to delete on clean. p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
# == Optional # == Optional
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
p.extra_deps = [['activerecord', '>= 2.2.0']] #An array of rubygem dependencies. p.extra_deps = [['activerecord', '>= 2.2.0']] #An array of rubygem dependencies.
#p.spec_extras - A hash of extra values to set in the gemspec. #p.spec_extras - A hash of extra values to set in the gemspec.
end end
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n") CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
PATH = RUBYFORGE_PROJECT PATH = RUBYFORGE_PROJECT
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc') hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
PROJECT_ROOT = File.expand_path(".") PROJECT_ROOT = File.expand_path(".")
require 'loader' require 'loader'

View file

@ -1,30 +1,30 @@
require 'rbconfig' require 'rbconfig'
require 'find' require 'find'
require 'ftools' require 'ftools'
include Config include Config
# this was adapted from rdoc's install.rb by ways of Log4r # this was adapted from rdoc's install.rb by ways of Log4r
$sitedir = CONFIG["sitelibdir"] $sitedir = CONFIG["sitelibdir"]
unless $sitedir unless $sitedir
version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"] version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
$libdir = File.join(CONFIG["libdir"], "ruby", version) $libdir = File.join(CONFIG["libdir"], "ruby", version)
$sitedir = $:.find {|x| x =~ /site_ruby/ } $sitedir = $:.find {|x| x =~ /site_ruby/ }
if !$sitedir if !$sitedir
$sitedir = File.join($libdir, "site_ruby") $sitedir = File.join($libdir, "site_ruby")
elsif $sitedir !~ Regexp.quote(version) elsif $sitedir !~ Regexp.quote(version)
$sitedir = File.join($sitedir, version) $sitedir = File.join($sitedir, version)
end end
end end
# the acual gruntwork # the acual gruntwork
Dir.chdir("lib") Dir.chdir("lib")
Find.find("composite_primary_keys", "composite_primary_keys.rb") { |f| Find.find("composite_primary_keys", "composite_primary_keys.rb") { |f|
if f[-3..-1] == ".rb" if f[-3..-1] == ".rb"
File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true) File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
else else
File::makedirs(File.join($sitedir, *f.split(/\//))) File::makedirs(File.join($sitedir, *f.split(/\//)))
end end
} }

View file

@ -1,55 +1,55 @@
#-- #--
# Copyright (c) 2006 Nic Williams # Copyright (c) 2006 Nic Williams
# #
# Permission is hereby granted, free of charge, to any person obtaining # Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the # a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including # "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, # without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to # distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to # permit persons to whom the Software is furnished to do so, subject to
# the following conditions: # the following conditions:
# #
# The above copyright notice and this permission notice shall be # The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++ #++
$:.unshift(File.dirname(__FILE__)) unless $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
unless defined?(ActiveRecord) unless defined?(ActiveRecord)
begin begin
require 'active_record' require 'active_record'
rescue LoadError rescue LoadError
require 'rubygems' require 'rubygems'
require_gem 'activerecord' require_gem 'activerecord'
end end
end end
require 'composite_primary_keys/fixtures' require 'composite_primary_keys/fixtures'
require 'composite_primary_keys/composite_arrays' require 'composite_primary_keys/composite_arrays'
require 'composite_primary_keys/associations' require 'composite_primary_keys/associations'
require 'composite_primary_keys/association_preload' require 'composite_primary_keys/association_preload'
require 'composite_primary_keys/reflection' require 'composite_primary_keys/reflection'
require 'composite_primary_keys/base' require 'composite_primary_keys/base'
require 'composite_primary_keys/calculations' require 'composite_primary_keys/calculations'
require 'composite_primary_keys/migration' require 'composite_primary_keys/migration'
require 'composite_primary_keys/attribute_methods' require 'composite_primary_keys/attribute_methods'
ActiveRecord::Base.class_eval do ActiveRecord::Base.class_eval do
include CompositePrimaryKeys::ActiveRecord::Base include CompositePrimaryKeys::ActiveRecord::Base
end end
Dir[File.dirname(__FILE__) + '/composite_primary_keys/connection_adapters/*.rb'].each do |adapter| Dir[File.dirname(__FILE__) + '/composite_primary_keys/connection_adapters/*.rb'].each do |adapter|
begin begin
require adapter.gsub('.rb','') require adapter.gsub('.rb','')
rescue MissingSourceFile rescue MissingSourceFile
end end
end end

View file

@ -1,341 +1,341 @@
module CompositePrimaryKeys module CompositePrimaryKeys
module ActiveRecord #:nodoc: module ActiveRecord #:nodoc:
class CompositeKeyError < StandardError #:nodoc: class CompositeKeyError < StandardError #:nodoc:
end end
module Base #:nodoc: module Base #:nodoc:
INVALID_FOR_COMPOSITE_KEYS = 'Not appropriate for composite primary keys' INVALID_FOR_COMPOSITE_KEYS = 'Not appropriate for composite primary keys'
NOT_IMPLEMENTED_YET = 'Not implemented for composite primary keys yet' NOT_IMPLEMENTED_YET = 'Not implemented for composite primary keys yet'
def self.append_features(base) def self.append_features(base)
super super
base.send(:include, InstanceMethods) base.send(:include, InstanceMethods)
base.extend(ClassMethods) base.extend(ClassMethods)
end end
module ClassMethods module ClassMethods
def set_primary_keys(*keys) def set_primary_keys(*keys)
keys = keys.first if keys.first.is_a?(Array) keys = keys.first if keys.first.is_a?(Array)
keys = keys.map { |k| k.to_sym } keys = keys.map { |k| k.to_sym }
cattr_accessor :primary_keys cattr_accessor :primary_keys
self.primary_keys = keys.to_composite_keys self.primary_keys = keys.to_composite_keys
class_eval <<-EOV class_eval <<-EOV
extend CompositeClassMethods extend CompositeClassMethods
include CompositeInstanceMethods include CompositeInstanceMethods
include CompositePrimaryKeys::ActiveRecord::Associations include CompositePrimaryKeys::ActiveRecord::Associations
include CompositePrimaryKeys::ActiveRecord::AssociationPreload include CompositePrimaryKeys::ActiveRecord::AssociationPreload
include CompositePrimaryKeys::ActiveRecord::Calculations include CompositePrimaryKeys::ActiveRecord::Calculations
include CompositePrimaryKeys::ActiveRecord::AttributeMethods include CompositePrimaryKeys::ActiveRecord::AttributeMethods
EOV EOV
end end
def composite? def composite?
false false
end end
end end
module InstanceMethods module InstanceMethods
def composite?; self.class.composite?; end def composite?; self.class.composite?; end
end end
module CompositeInstanceMethods module CompositeInstanceMethods
# A model instance's primary keys is always available as model.ids # A model instance's primary keys is always available as model.ids
# whether you name it the default 'id' or set it to something else. # whether you name it the default 'id' or set it to something else.
def id def id
attr_names = self.class.primary_keys attr_names = self.class.primary_keys
CompositeIds.new(attr_names.map { |attr_name| read_attribute(attr_name) }) CompositeIds.new(attr_names.map { |attr_name| read_attribute(attr_name) })
end end
alias_method :ids, :id alias_method :ids, :id
def to_param def to_param
id.to_s id.to_s
end end
def id_before_type_cast #:nodoc: def id_before_type_cast #:nodoc:
raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::NOT_IMPLEMENTED_YET raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::NOT_IMPLEMENTED_YET
end end
def quoted_id #:nodoc: def quoted_id #:nodoc:
[self.class.primary_keys, ids]. [self.class.primary_keys, ids].
transpose. transpose.
map {|attr_name,id| quote_value(id, column_for_attribute(attr_name))}. map {|attr_name,id| quote_value(id, column_for_attribute(attr_name))}.
to_composite_ids to_composite_ids
end end
# Sets the primary ID. # Sets the primary ID.
def id=(ids) def id=(ids)
ids = ids.split(ID_SEP) if ids.is_a?(String) ids = ids.split(ID_SEP) if ids.is_a?(String)
ids.flatten! ids.flatten!
unless ids.is_a?(Array) and ids.length == self.class.primary_keys.length unless ids.is_a?(Array) and ids.length == self.class.primary_keys.length
raise "#{self.class}.id= requires #{self.class.primary_keys.length} ids" raise "#{self.class}.id= requires #{self.class.primary_keys.length} ids"
end end
[primary_keys, ids].transpose.each {|key, an_id| write_attribute(key , an_id)} [primary_keys, ids].transpose.each {|key, an_id| write_attribute(key , an_id)}
id id
end end
# Returns a clone of the record that hasn't been assigned an id yet and # Returns a clone of the record that hasn't been assigned an id yet and
# is treated as a new record. Note that this is a "shallow" clone: # is treated as a new record. Note that this is a "shallow" clone:
# it copies the object's attributes only, not its associations. # it copies the object's attributes only, not its associations.
# The extent of a "deep" clone is application-specific and is therefore # The extent of a "deep" clone is application-specific and is therefore
# left to the application to implement according to its need. # left to the application to implement according to its need.
def clone def clone
attrs = self.attributes_before_type_cast attrs = self.attributes_before_type_cast
self.class.primary_keys.each {|key| attrs.delete(key.to_s)} self.class.primary_keys.each {|key| attrs.delete(key.to_s)}
self.class.new do |record| self.class.new do |record|
record.send :instance_variable_set, '@attributes', attrs record.send :instance_variable_set, '@attributes', attrs
end end
end end
private private
# The xx_without_callbacks methods are overwritten as that is the end of the alias chain # The xx_without_callbacks methods are overwritten as that is the end of the alias chain
# Creates a new record with values matching those of the instance attributes. # Creates a new record with values matching those of the instance attributes.
def create_without_callbacks def create_without_callbacks
unless self.id unless self.id
raise CompositeKeyError, "Composite keys do not generated ids from sequences, you must provide id values" raise CompositeKeyError, "Composite keys do not generated ids from sequences, you must provide id values"
end end
attributes_minus_pks = attributes_with_quotes(false) attributes_minus_pks = attributes_with_quotes(false)
quoted_pk_columns = self.class.primary_key.map { |col| connection.quote_column_name(col) } quoted_pk_columns = self.class.primary_key.map { |col| connection.quote_column_name(col) }
cols = quoted_column_names(attributes_minus_pks) << quoted_pk_columns cols = quoted_column_names(attributes_minus_pks) << quoted_pk_columns
vals = attributes_minus_pks.values << quoted_id vals = attributes_minus_pks.values << quoted_id
connection.insert( connection.insert(
"INSERT INTO #{self.class.quoted_table_name} " + "INSERT INTO #{self.class.quoted_table_name} " +
"(#{cols.join(', ')}) " + "(#{cols.join(', ')}) " +
"VALUES (#{vals.join(', ')})", "VALUES (#{vals.join(', ')})",
"#{self.class.name} Create", "#{self.class.name} Create",
self.class.primary_key, self.class.primary_key,
self.id self.id
) )
@new_record = false @new_record = false
return true return true
end end
# Updates the associated record with values matching those of the instance attributes. # Updates the associated record with values matching those of the instance attributes.
def update_without_callbacks def update_without_callbacks
where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair|
"(#{connection.quote_column_name(pair[0])} = #{pair[1]})" "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"
end end
where_clause = where_clause_terms.join(" AND ") where_clause = where_clause_terms.join(" AND ")
connection.update( connection.update(
"UPDATE #{self.class.quoted_table_name} " + "UPDATE #{self.class.quoted_table_name} " +
"SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " + "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +
"WHERE #{where_clause}", "WHERE #{where_clause}",
"#{self.class.name} Update" "#{self.class.name} Update"
) )
return true return true
end end
# Deletes the record in the database and freezes this instance to reflect that no changes should # Deletes the record in the database and freezes this instance to reflect that no changes should
# be made (since they can't be persisted). # be made (since they can't be persisted).
def destroy_without_callbacks def destroy_without_callbacks
where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair|
"(#{connection.quote_column_name(pair[0])} = #{pair[1]})" "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"
end end
where_clause = where_clause_terms.join(" AND ") where_clause = where_clause_terms.join(" AND ")
unless new_record? unless new_record?
connection.delete( connection.delete(
"DELETE FROM #{self.class.quoted_table_name} " + "DELETE FROM #{self.class.quoted_table_name} " +
"WHERE #{where_clause}", "WHERE #{where_clause}",
"#{self.class.name} Destroy" "#{self.class.name} Destroy"
) )
end end
freeze freeze
end end
end end
module CompositeClassMethods module CompositeClassMethods
def primary_key; primary_keys; end def primary_key; primary_keys; end
def primary_key=(keys); primary_keys = keys; end def primary_key=(keys); primary_keys = keys; end
def composite? def composite?
true true
end end
#ids_to_s([[1,2],[7,3]]) -> "(1,2),(7,3)" #ids_to_s([[1,2],[7,3]]) -> "(1,2),(7,3)"
#ids_to_s([[1,2],[7,3]], ',', ';') -> "1,2;7,3" #ids_to_s([[1,2],[7,3]], ',', ';') -> "1,2;7,3"
def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')') def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')
many_ids.map {|ids| "#{left_bracket}#{ids}#{right_bracket}"}.join(list_sep) many_ids.map {|ids| "#{left_bracket}#{ids}#{right_bracket}"}.join(list_sep)
end end
# Creates WHERE condition from list of composited ids # Creates WHERE condition from list of composited ids
# User.update_all({:role => 'admin'}, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> UPDATE admins SET admin.role='admin' WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2) # User.update_all({:role => 'admin'}, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> UPDATE admins SET admin.role='admin' WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2)
# User.find(:all, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> SELECT * FROM admins WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2) # User.find(:all, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> SELECT * FROM admins WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2)
def composite_where_clause(ids) def composite_where_clause(ids)
if ids.is_a?(String) if ids.is_a?(String)
ids = [[ids]] ids = [[ids]]
elsif not ids.first.is_a?(Array) # if single comp key passed, turn into an array of 1 elsif not ids.first.is_a?(Array) # if single comp key passed, turn into an array of 1
ids = [ids.to_composite_ids] ids = [ids.to_composite_ids]
end end
ids.map do |id_set| ids.map do |id_set|
[primary_keys, id_set].transpose.map do |key, id| [primary_keys, id_set].transpose.map do |key, id|
"#{table_name}.#{key.to_s}=#{sanitize(id)}" "#{table_name}.#{key.to_s}=#{sanitize(id)}"
end.join(" AND ") end.join(" AND ")
end.join(") OR (") end.join(") OR (")
end end
# Returns true if the given +ids+ represents the primary keys of a record in the database, false otherwise. # Returns true if the given +ids+ represents the primary keys of a record in the database, false otherwise.
# Example: # Example:
# Person.exists?(5,7) # Person.exists?(5,7)
def exists?(ids) def exists?(ids)
if ids.is_a?(Array) && ids.first.is_a?(String) if ids.is_a?(Array) && ids.first.is_a?(String)
count(:conditions => ids) > 0 count(:conditions => ids) > 0
else else
obj = find(ids) rescue false obj = find(ids) rescue false
!obj.nil? and obj.is_a?(self) !obj.nil? and obj.is_a?(self)
end end
end end
# Deletes the record with the given +ids+ without instantiating an object first, e.g. delete(1,2) # Deletes the record with the given +ids+ without instantiating an object first, e.g. delete(1,2)
# If an array of ids is provided (e.g. delete([1,2], [3,4]), all of them # If an array of ids is provided (e.g. delete([1,2], [3,4]), all of them
# are deleted. # are deleted.
def delete(*ids) def delete(*ids)
unless ids.is_a?(Array); raise "*ids must be an Array"; end unless ids.is_a?(Array); raise "*ids must be an Array"; end
ids = [ids.to_composite_ids] if not ids.first.is_a?(Array) ids = [ids.to_composite_ids] if not ids.first.is_a?(Array)
where_clause = ids.map do |id_set| where_clause = ids.map do |id_set|
[primary_keys, id_set].transpose.map do |key, id| [primary_keys, id_set].transpose.map do |key, id|
"#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{sanitize(id)}" "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{sanitize(id)}"
end.join(" AND ") end.join(" AND ")
end.join(") OR (") end.join(") OR (")
delete_all([ "(#{where_clause})" ]) delete_all([ "(#{where_clause})" ])
end end
# Destroys the record with the given +ids+ by instantiating the object and calling #destroy (all the callbacks are the triggered). # Destroys the record with the given +ids+ by instantiating the object and calling #destroy (all the callbacks are the triggered).
# If an array of ids is provided, all of them are destroyed. # If an array of ids is provided, all of them are destroyed.
def destroy(*ids) def destroy(*ids)
unless ids.is_a?(Array); raise "*ids must be an Array"; end unless ids.is_a?(Array); raise "*ids must be an Array"; end
if ids.first.is_a?(Array) if ids.first.is_a?(Array)
ids = ids.map{|compids| compids.to_composite_ids} ids = ids.map{|compids| compids.to_composite_ids}
else else
ids = ids.to_composite_ids ids = ids.to_composite_ids
end end
ids.first.is_a?(CompositeIds) ? ids.each { |id_set| find(id_set).destroy } : find(ids).destroy ids.first.is_a?(CompositeIds) ? ids.each { |id_set| find(id_set).destroy } : find(ids).destroy
end end
# Returns an array of column objects for the table associated with this class. # Returns an array of column objects for the table associated with this class.
# Each column that matches to one of the primary keys has its # Each column that matches to one of the primary keys has its
# primary attribute set to true # primary attribute set to true
def columns def columns
unless @columns unless @columns
@columns = connection.columns(table_name, "#{name} Columns") @columns = connection.columns(table_name, "#{name} Columns")
@columns.each {|column| column.primary = primary_keys.include?(column.name.to_sym)} @columns.each {|column| column.primary = primary_keys.include?(column.name.to_sym)}
end end
@columns @columns
end end
## DEACTIVATED METHODS ## ## DEACTIVATED METHODS ##
public public
# Lazy-set the sequence name to the connection's default. This method # Lazy-set the sequence name to the connection's default. This method
# is only ever called once since set_sequence_name overrides it. # is only ever called once since set_sequence_name overrides it.
def sequence_name #:nodoc: def sequence_name #:nodoc:
raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
end end
def reset_sequence_name #:nodoc: def reset_sequence_name #:nodoc:
raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
end end
def set_primary_key(value = nil, &block) def set_primary_key(value = nil, &block)
raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
end end
private private
def find_one(id, options) def find_one(id, options)
raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
end end
def find_some(ids, options) def find_some(ids, options)
raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
end end
def find_from_ids(ids, options) def find_from_ids(ids, options)
ids = ids.first if ids.last == nil ids = ids.first if ids.last == nil
conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions] conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
# if ids is just a flat list, then its size must = primary_key.length (one id per primary key, in order) # if ids is just a flat list, then its size must = primary_key.length (one id per primary key, in order)
# if ids is list of lists, then each inner list must follow rule above # if ids is list of lists, then each inner list must follow rule above
if ids.first.is_a? String if ids.first.is_a? String
# find '2,1' -> ids = ['2,1'] # find '2,1' -> ids = ['2,1']
# find '2,1;7,3' -> ids = ['2,1;7,3'] # find '2,1;7,3' -> ids = ['2,1;7,3']
ids = ids.first.split(ID_SET_SEP).map {|id_set| id_set.split(ID_SEP).to_composite_ids} ids = ids.first.split(ID_SET_SEP).map {|id_set| id_set.split(ID_SEP).to_composite_ids}
# find '2,1;7,3' -> ids = [['2','1'],['7','3']], inner [] are CompositeIds # find '2,1;7,3' -> ids = [['2','1'],['7','3']], inner [] are CompositeIds
end end
ids = [ids.to_composite_ids] if not ids.first.kind_of?(Array) ids = [ids.to_composite_ids] if not ids.first.kind_of?(Array)
ids.each do |id_set| ids.each do |id_set|
unless id_set.is_a?(Array) unless id_set.is_a?(Array)
raise "Ids must be in an Array, instead received: #{id_set.inspect}" raise "Ids must be in an Array, instead received: #{id_set.inspect}"
end end
unless id_set.length == primary_keys.length unless id_set.length == primary_keys.length
raise "#{id_set.inspect}: Incorrect number of primary keys for #{class_name}: #{primary_keys.inspect}" raise "#{id_set.inspect}: Incorrect number of primary keys for #{class_name}: #{primary_keys.inspect}"
end end
end end
# Let keys = [:a, :b] # Let keys = [:a, :b]
# If ids = [[10, 50], [11, 51]], then :conditions => # If ids = [[10, 50], [11, 51]], then :conditions =>
# "(#{quoted_table_name}.a, #{quoted_table_name}.b) IN ((10, 50), (11, 51))" # "(#{quoted_table_name}.a, #{quoted_table_name}.b) IN ((10, 50), (11, 51))"
conditions = ids.map do |id_set| conditions = ids.map do |id_set|
[primary_keys, id_set].transpose.map do |key, id| [primary_keys, id_set].transpose.map do |key, id|
col = columns_hash[key.to_s] col = columns_hash[key.to_s]
val = quote_value(id, col) val = quote_value(id, col)
"#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{val}" "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{val}"
end.join(" AND ") end.join(" AND ")
end.join(") OR (") end.join(") OR (")
options.update :conditions => "(#{conditions})" options.update :conditions => "(#{conditions})"
result = find_every(options) result = find_every(options)
if result.size == ids.size if result.size == ids.size
ids.size == 1 ? result[0] : result ids.size == 1 ? result[0] : result
else else
raise ::ActiveRecord::RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids.inspect})#{conditions}" raise ::ActiveRecord::RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids.inspect})#{conditions}"
end end
end end
end end
end end
end end
end end
module ActiveRecord module ActiveRecord
ID_SEP = ',' ID_SEP = ','
ID_SET_SEP = ';' ID_SET_SEP = ';'
class Base class Base
# Allows +attr_name+ to be the list of primary_keys, and returns the id # Allows +attr_name+ to be the list of primary_keys, and returns the id
# of the object # of the object
# e.g. @object[@object.class.primary_key] => [1,1] # e.g. @object[@object.class.primary_key] => [1,1]
def [](attr_name) def [](attr_name)
if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first
attr_name = attr_name.split(ID_SEP) attr_name = attr_name.split(ID_SEP)
end end
attr_name.is_a?(Array) ? attr_name.is_a?(Array) ?
attr_name.map {|name| read_attribute(name)} : attr_name.map {|name| read_attribute(name)} :
read_attribute(attr_name) read_attribute(attr_name)
end end
# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
# (Alias for the protected write_attribute method). # (Alias for the protected write_attribute method).
def []=(attr_name, value) def []=(attr_name, value)
if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first
attr_name = attr_name.split(ID_SEP) attr_name = attr_name.split(ID_SEP)
end end
if attr_name.is_a? Array if attr_name.is_a? Array
value = value.split(ID_SEP) if value.is_a? String value = value.split(ID_SEP) if value.is_a? String
unless value.length == attr_name.length unless value.length == attr_name.length
raise "Number of attr_names and values do not match" raise "Number of attr_names and values do not match"
end end
#breakpoint #breakpoint
[attr_name, value].transpose.map {|name,val| write_attribute(name.to_s, val)} [attr_name, value].transpose.map {|name,val| write_attribute(name.to_s, val)}
else else
write_attribute(attr_name, value) write_attribute(attr_name, value)
end end
end end
end end
end end

View file

@ -1,30 +1,30 @@
module CompositePrimaryKeys module CompositePrimaryKeys
ID_SEP = ',' ID_SEP = ','
ID_SET_SEP = ';' ID_SET_SEP = ';'
module ArrayExtension module ArrayExtension
def to_composite_keys def to_composite_keys
CompositeKeys.new(self) CompositeKeys.new(self)
end end
def to_composite_ids def to_composite_ids
CompositeIds.new(self) CompositeIds.new(self)
end end
end end
class CompositeArray < Array class CompositeArray < Array
def to_s def to_s
join(ID_SEP) join(ID_SEP)
end end
end end
class CompositeKeys < CompositeArray class CompositeKeys < CompositeArray
end end
class CompositeIds < CompositeArray class CompositeIds < CompositeArray
end end
end end
Array.send(:include, CompositePrimaryKeys::ArrayExtension) Array.send(:include, CompositePrimaryKeys::ArrayExtension)

View file

@ -1,19 +1,19 @@
module ActiveRecord module ActiveRecord
module Reflection module Reflection
class AssociationReflection class AssociationReflection
def primary_key_name def primary_key_name
return @primary_key_name if @primary_key_name return @primary_key_name if @primary_key_name
case case
when macro == :belongs_to when macro == :belongs_to
@primary_key_name = options[:foreign_key] || class_name.foreign_key @primary_key_name = options[:foreign_key] || class_name.foreign_key
when options[:as] when options[:as]
@primary_key_name = options[:foreign_key] || "#{options[:as]}_id" @primary_key_name = options[:foreign_key] || "#{options[:as]}_id"
else else
@primary_key_name = options[:foreign_key] || active_record.name.foreign_key @primary_key_name = options[:foreign_key] || active_record.name.foreign_key
end end
@primary_key_name = @primary_key_name.to_composite_keys.to_s if @primary_key_name.is_a? Array @primary_key_name = @primary_key_name.to_composite_keys.to_s if @primary_key_name.is_a? Array
@primary_key_name @primary_key_name
end end
end end
end end
end end

View file

@ -1,8 +1,8 @@
module CompositePrimaryKeys module CompositePrimaryKeys
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 2 MAJOR = 2
MINOR = 2 MINOR = 2
TINY = 2 TINY = 2
STRING = [MAJOR, MINOR, TINY].join('.') STRING = [MAJOR, MINOR, TINY].join('.')
end end
end end

View file

@ -1,5 +1,5 @@
class Article < ActiveRecord::Base class Article < ActiveRecord::Base
has_many :readings has_many :readings
has_many :users, :through => :readings has_many :users, :through => :readings
end end

View file

@ -1,6 +1,6 @@
first: first:
id: 1 id: 1
name: Article One name: Article One
second: second:
id: 2 id: 2
name: Article Two name: Article Two

View file

@ -1,7 +1,7 @@
class Product < ActiveRecord::Base class Product < ActiveRecord::Base
set_primary_keys :id # redundant set_primary_keys :id # redundant
has_many :product_tariffs, :foreign_key => :product_id has_many :product_tariffs, :foreign_key => :product_id
has_one :product_tariff, :foreign_key => :product_id has_one :product_tariff, :foreign_key => :product_id
has_many :tariffs, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date] has_many :tariffs, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
end end

View file

@ -1,5 +1,5 @@
class ProductTariff < ActiveRecord::Base class ProductTariff < ActiveRecord::Base
set_primary_keys :product_id, :tariff_id, :tariff_start_date set_primary_keys :product_id, :tariff_id, :tariff_start_date
belongs_to :product, :foreign_key => :product_id belongs_to :product, :foreign_key => :product_id
belongs_to :tariff, :foreign_key => [:tariff_id, :tariff_start_date] belongs_to :tariff, :foreign_key => [:tariff_id, :tariff_start_date]
end end

View file

@ -1,12 +1,12 @@
first_flat: first_flat:
product_id: 1 product_id: 1
tariff_id: 1 tariff_id: 1
tariff_start_date: <%= Date.today.to_s(:db) %> tariff_start_date: <%= Date.today.to_s(:db) %>
first_free: first_free:
product_id: 1 product_id: 1
tariff_id: 2 tariff_id: 2
tariff_start_date: <%= Date.today.to_s(:db) %> tariff_start_date: <%= Date.today.to_s(:db) %>
second_free: second_free:
product_id: 2 product_id: 2
tariff_id: 2 tariff_id: 2
tariff_start_date: <%= Date.today.to_s(:db) %> tariff_start_date: <%= Date.today.to_s(:db) %>

View file

@ -1,6 +1,6 @@
first_product: first_product:
id: 1 id: 1
name: Product One name: Product One
second_product: second_product:
id: 2 id: 2
name: Product Two name: Product Two

View file

@ -1,4 +1,4 @@
class Reading < ActiveRecord::Base class Reading < ActiveRecord::Base
belongs_to :article belongs_to :article
belongs_to :user belongs_to :user
end end

View file

@ -1,10 +1,10 @@
santiago_first: santiago_first:
id: 1 id: 1
user_id: 1 user_id: 1
article_id: 1 article_id: 1
rating: 4 rating: 4
santiago_second: santiago_second:
id: 2 id: 2
user_id: 1 user_id: 1
article_id: 2 article_id: 2
rating: 5 rating: 5

View file

@ -1,7 +1,7 @@
class ReferenceCode < ActiveRecord::Base class ReferenceCode < ActiveRecord::Base
set_primary_keys :reference_type_id, :reference_code set_primary_keys :reference_type_id, :reference_code
belongs_to :reference_type, :foreign_key => "reference_type_id" belongs_to :reference_type, :foreign_key => "reference_type_id"
validates_presence_of :reference_code, :code_label, :abbreviation validates_presence_of :reference_code, :code_label, :abbreviation
end end

View file

@ -1,28 +1,28 @@
name_prefix_mr: name_prefix_mr:
reference_type_id: 1 reference_type_id: 1
reference_code: 1 reference_code: 1
code_label: MR code_label: MR
abbreviation: Mr abbreviation: Mr
name_prefix_mrs: name_prefix_mrs:
reference_type_id: 1 reference_type_id: 1
reference_code: 2 reference_code: 2
code_label: MRS code_label: MRS
abbreviation: Mrs abbreviation: Mrs
name_prefix_ms: name_prefix_ms:
reference_type_id: 1 reference_type_id: 1
reference_code: 3 reference_code: 3
code_label: MS code_label: MS
abbreviation: Ms abbreviation: Ms
gender_male: gender_male:
reference_type_id: 2 reference_type_id: 2
reference_code: 1 reference_code: 1
code_label: MALE code_label: MALE
abbreviation: Male abbreviation: Male
gender_female: gender_female:
reference_type_id: 2 reference_type_id: 2
reference_code: 2 reference_code: 2
code_label: FEMALE code_label: FEMALE
abbreviation: Female abbreviation: Female

View file

@ -1,7 +1,7 @@
class ReferenceType < ActiveRecord::Base class ReferenceType < ActiveRecord::Base
set_primary_key :reference_type_id set_primary_key :reference_type_id
has_many :reference_codes, :foreign_key => "reference_type_id" has_many :reference_codes, :foreign_key => "reference_type_id"
validates_presence_of :type_label, :abbreviation validates_presence_of :type_label, :abbreviation
validates_uniqueness_of :type_label validates_uniqueness_of :type_label
end end

View file

@ -1,9 +1,9 @@
name_prefix: name_prefix:
reference_type_id: 1 reference_type_id: 1
type_label: NAME_PREFIX type_label: NAME_PREFIX
abbreviation: Name Prefix abbreviation: Name Prefix
gender: gender:
reference_type_id: 2 reference_type_id: 2
type_label: GENDER type_label: GENDER
abbreviation: Gender abbreviation: Gender

View file

@ -1,6 +1,6 @@
class Suburb < ActiveRecord::Base class Suburb < ActiveRecord::Base
set_primary_keys :city_id, :suburb_id set_primary_keys :city_id, :suburb_id
has_many :streets, :foreign_key => [:city_id, :suburb_id] has_many :streets, :foreign_key => [:city_id, :suburb_id]
has_many :first_streets, :foreign_key => [:city_id, :suburb_id], has_many :first_streets, :foreign_key => [:city_id, :suburb_id],
:class_name => 'Street', :conditions => "streets.name = 'First Street'" :class_name => 'Street', :conditions => "streets.name = 'First Street'"
end end

View file

@ -1,9 +1,9 @@
first: first:
city_id: 1 city_id: 1
suburb_id: 1 suburb_id: 1
name: First Suburb name: First Suburb
second: second:
city_id: 2 city_id: 2
suburb_id: 1 suburb_id: 1
name: Second Suburb name: Second Suburb

View file

@ -1,6 +1,6 @@
class Tariff < ActiveRecord::Base class Tariff < ActiveRecord::Base
set_primary_keys [:tariff_id, :start_date] set_primary_keys [:tariff_id, :start_date]
has_many :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date] has_many :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
has_one :product_tariff, :foreign_key => [:tariff_id, :tariff_start_date] has_one :product_tariff, :foreign_key => [:tariff_id, :tariff_start_date]
has_many :products, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date] has_many :products, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
end end

View file

@ -1,13 +1,13 @@
flat: flat:
tariff_id: 1 tariff_id: 1
start_date: <%= Date.today.to_s(:db) %> start_date: <%= Date.today.to_s(:db) %>
amount: 50 amount: 50
free: free:
tariff_id: 2 tariff_id: 2
start_date: <%= Date.today.to_s(:db) %> start_date: <%= Date.today.to_s(:db) %>
amount: 0 amount: 0
flat_future: flat_future:
tariff_id: 1 tariff_id: 1
start_date: <%= Date.today.next.to_s(:db) %> start_date: <%= Date.today.next.to_s(:db) %>
amount: 100 amount: 100

View file

@ -1,10 +1,10 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
has_many :readings has_many :readings
has_many :articles, :through => :readings has_many :articles, :through => :readings
has_many :comments, :as => :person has_many :comments, :as => :person
has_many :hacks, :through => :comments, :source => :hack has_many :hacks, :through => :comments, :source => :hack
def find_custom_articles def find_custom_articles
articles.find(:all, :conditions => ["name = ?", "Article One"]) articles.find(:all, :conditions => ["name = ?", "Article One"])
end end
end end

View file

@ -1,6 +1,6 @@
santiago: santiago:
id: 1 id: 1
name: Santiago name: Santiago
drnic: drnic:
id: 2 id: 2
name: Dr Nic name: Dr Nic

View file

@ -1,34 +1,34 @@
# From: # From:
# http://www.bigbold.com/snippets/posts/show/2178 # http://www.bigbold.com/snippets/posts/show/2178
# http://blog.caboo.se/articles/2006/06/11/stupid-hash-tricks # http://blog.caboo.se/articles/2006/06/11/stupid-hash-tricks
# #
# An example utilisation of these methods in a controller is: # An example utilisation of these methods in a controller is:
# def some_action # def some_action
# # some script kiddie also passed in :bee, which we don't want tampered with _here_. # # some script kiddie also passed in :bee, which we don't want tampered with _here_.
# @model = Model.create(params.pass(:foo, :bar)) # @model = Model.create(params.pass(:foo, :bar))
# end # end
class Hash class Hash
# lets through the keys in the argument # lets through the keys in the argument
# >> {:one => 1, :two => 2, :three => 3}.pass(:one) # >> {:one => 1, :two => 2, :three => 3}.pass(:one)
# => {:one=>1} # => {:one=>1}
def pass(*keys) def pass(*keys)
keys = keys.first if keys.first.is_a?(Array) keys = keys.first if keys.first.is_a?(Array)
tmp = self.clone tmp = self.clone
tmp.delete_if {|k,v| ! keys.include?(k.to_sym) } tmp.delete_if {|k,v| ! keys.include?(k.to_sym) }
tmp.delete_if {|k,v| ! keys.include?(k.to_s) } tmp.delete_if {|k,v| ! keys.include?(k.to_s) }
tmp tmp
end end
# blocks the keys in the arguments # blocks the keys in the arguments
# >> {:one => 1, :two => 2, :three => 3}.block(:one) # >> {:one => 1, :two => 2, :three => 3}.block(:one)
# => {:two=>2, :three=>3} # => {:two=>2, :three=>3}
def block(*keys) def block(*keys)
keys = keys.first if keys.first.is_a?(Array) keys = keys.first if keys.first.is_a?(Array)
tmp = self.clone tmp = self.clone
tmp.delete_if {|k,v| keys.include?(k.to_sym) } tmp.delete_if {|k,v| keys.include?(k.to_sym) }
tmp.delete_if {|k,v| keys.include?(k.to_s) } tmp.delete_if {|k,v| keys.include?(k.to_s) }
tmp tmp
end end
end end

View file

@ -1,160 +1,160 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/article' require 'fixtures/article'
require 'fixtures/product' require 'fixtures/product'
require 'fixtures/tariff' require 'fixtures/tariff'
require 'fixtures/product_tariff' require 'fixtures/product_tariff'
require 'fixtures/suburb' require 'fixtures/suburb'
require 'fixtures/street' require 'fixtures/street'
require 'fixtures/restaurant' require 'fixtures/restaurant'
require 'fixtures/dorm' require 'fixtures/dorm'
require 'fixtures/room' require 'fixtures/room'
require 'fixtures/room_attribute' require 'fixtures/room_attribute'
require 'fixtures/room_attribute_assignment' require 'fixtures/room_attribute_assignment'
require 'fixtures/student' require 'fixtures/student'
require 'fixtures/room_assignment' require 'fixtures/room_assignment'
require 'fixtures/user' require 'fixtures/user'
require 'fixtures/reading' require 'fixtures/reading'
class TestAssociations < Test::Unit::TestCase class TestAssociations < Test::Unit::TestCase
fixtures :articles, :products, :tariffs, :product_tariffs, :suburbs, :streets, :restaurants, :restaurants_suburbs, fixtures :articles, :products, :tariffs, :product_tariffs, :suburbs, :streets, :restaurants, :restaurants_suburbs,
:dorms, :rooms, :room_attributes, :room_attribute_assignments, :students, :room_assignments, :users, :readings :dorms, :rooms, :room_attributes, :room_attribute_assignments, :students, :room_assignments, :users, :readings
def test_has_many_through_with_conditions_when_through_association_is_not_composite def test_has_many_through_with_conditions_when_through_association_is_not_composite
user = User.find(:first) user = User.find(:first)
assert_equal 1, user.articles.find(:all, :conditions => ["articles.name = ?", "Article One"]).size assert_equal 1, user.articles.find(:all, :conditions => ["articles.name = ?", "Article One"]).size
end end
def test_has_many_through_with_conditions_when_through_association_is_composite def test_has_many_through_with_conditions_when_through_association_is_composite
room = Room.find(:first) room = Room.find(:first)
assert_equal 0, room.room_attributes.find(:all, :conditions => ["room_attributes.name != ?", "keg"]).size assert_equal 0, room.room_attributes.find(:all, :conditions => ["room_attributes.name != ?", "keg"]).size
end end
def test_has_many_through_on_custom_finder_when_through_association_is_composite_finder_when_through_association_is_not_composite def test_has_many_through_on_custom_finder_when_through_association_is_composite_finder_when_through_association_is_not_composite
user = User.find(:first) user = User.find(:first)
assert_equal 1, user.find_custom_articles.size assert_equal 1, user.find_custom_articles.size
end end
def test_has_many_through_on_custom_finder_when_through_association_is_composite def test_has_many_through_on_custom_finder_when_through_association_is_composite
room = Room.find(:first) room = Room.find(:first)
assert_equal 0, room.find_custom_room_attributes.size assert_equal 0, room.find_custom_room_attributes.size
end end
def test_count def test_count
assert_equal 2, Product.count(:include => :product_tariffs) assert_equal 2, Product.count(:include => :product_tariffs)
assert_equal 3, Tariff.count(:include => :product_tariffs) assert_equal 3, Tariff.count(:include => :product_tariffs)
assert_equal 2, Tariff.count(:group => :start_date).size assert_equal 2, Tariff.count(:group => :start_date).size
end end
def test_products def test_products
assert_not_nil products(:first_product).product_tariffs assert_not_nil products(:first_product).product_tariffs
assert_equal 2, products(:first_product).product_tariffs.length assert_equal 2, products(:first_product).product_tariffs.length
assert_not_nil products(:first_product).tariffs assert_not_nil products(:first_product).tariffs
assert_equal 2, products(:first_product).tariffs.length assert_equal 2, products(:first_product).tariffs.length
assert_not_nil products(:first_product).product_tariff assert_not_nil products(:first_product).product_tariff
end end
def test_product_tariffs def test_product_tariffs
assert_not_nil product_tariffs(:first_flat).product assert_not_nil product_tariffs(:first_flat).product
assert_not_nil product_tariffs(:first_flat).tariff assert_not_nil product_tariffs(:first_flat).tariff
assert_equal Product, product_tariffs(:first_flat).product.class assert_equal Product, product_tariffs(:first_flat).product.class
assert_equal Tariff, product_tariffs(:first_flat).tariff.class assert_equal Tariff, product_tariffs(:first_flat).tariff.class
end end
def test_tariffs def test_tariffs
assert_not_nil tariffs(:flat).product_tariffs assert_not_nil tariffs(:flat).product_tariffs
assert_equal 1, tariffs(:flat).product_tariffs.length assert_equal 1, tariffs(:flat).product_tariffs.length
assert_not_nil tariffs(:flat).products assert_not_nil tariffs(:flat).products
assert_equal 1, tariffs(:flat).products.length assert_equal 1, tariffs(:flat).products.length
assert_not_nil tariffs(:flat).product_tariff assert_not_nil tariffs(:flat).product_tariff
end end
# Its not generating the instances of associated classes from the rows # Its not generating the instances of associated classes from the rows
def test_find_includes_products def test_find_includes_products
assert @products = Product.find(:all, :include => :product_tariffs) assert @products = Product.find(:all, :include => :product_tariffs)
assert_equal 2, @products.length assert_equal 2, @products.length
assert_not_nil @products.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array' assert_not_nil @products.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'
assert_equal 3, @products.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, assert_equal 3, @products.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length},
"Incorrect number of product_tariffs returned" "Incorrect number of product_tariffs returned"
end end
def test_find_includes_tariffs def test_find_includes_tariffs
assert @tariffs = Tariff.find(:all, :include => :product_tariffs) assert @tariffs = Tariff.find(:all, :include => :product_tariffs)
assert_equal 3, @tariffs.length assert_equal 3, @tariffs.length
assert_not_nil @tariffs.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array' assert_not_nil @tariffs.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'
assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length},
"Incorrect number of product_tariffs returnedturned" "Incorrect number of product_tariffs returnedturned"
end end
def test_find_includes_product def test_find_includes_product
assert @product_tariffs = ProductTariff.find(:all, :include => :product) assert @product_tariffs = ProductTariff.find(:all, :include => :product)
assert_equal 3, @product_tariffs.length assert_equal 3, @product_tariffs.length
assert_not_nil @product_tariffs.first.instance_variable_get('@product'), '@product not set' assert_not_nil @product_tariffs.first.instance_variable_get('@product'), '@product not set'
end end
def test_find_includes_comp_belongs_to_tariff def test_find_includes_comp_belongs_to_tariff
assert @product_tariffs = ProductTariff.find(:all, :include => :tariff) assert @product_tariffs = ProductTariff.find(:all, :include => :tariff)
assert_equal 3, @product_tariffs.length assert_equal 3, @product_tariffs.length
assert_not_nil @product_tariffs.first.instance_variable_get('@tariff'), '@tariff not set' assert_not_nil @product_tariffs.first.instance_variable_get('@tariff'), '@tariff not set'
end end
def test_find_includes_extended def test_find_includes_extended
assert @products = Product.find(:all, :include => {:product_tariffs => :tariff}) assert @products = Product.find(:all, :include => {:product_tariffs => :tariff})
assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@product_tariffs').length}, assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@product_tariffs').length},
"Incorrect number of product_tariffs returned" "Incorrect number of product_tariffs returned"
assert @tariffs = Tariff.find(:all, :include => {:product_tariffs => :product}) assert @tariffs = Tariff.find(:all, :include => {:product_tariffs => :product})
assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length},
"Incorrect number of product_tariffs returned" "Incorrect number of product_tariffs returned"
end end
def test_join_where_clause def test_join_where_clause
@product = Product.find(:first, :include => :product_tariffs) @product = Product.find(:first, :include => :product_tariffs)
where_clause = @product.product_tariffs.composite_where_clause( where_clause = @product.product_tariffs.composite_where_clause(
['foo','bar'], [1,2] ['foo','bar'], [1,2]
) )
assert_equal('(foo=1 AND bar=2)', where_clause) assert_equal('(foo=1 AND bar=2)', where_clause)
end end
def test_has_many_through def test_has_many_through
@products = Product.find(:all, :include => :tariffs) @products = Product.find(:all, :include => :tariffs)
assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@tariffs').length}, assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@tariffs').length},
"Incorrect number of tariffs returned" "Incorrect number of tariffs returned"
end end
def test_has_many_through_when_not_pre_loaded def test_has_many_through_when_not_pre_loaded
student = Student.find(:first) student = Student.find(:first)
rooms = student.rooms rooms = student.rooms
assert_equal 1, rooms.size assert_equal 1, rooms.size
assert_equal 1, rooms.first.dorm_id assert_equal 1, rooms.first.dorm_id
assert_equal 1, rooms.first.room_id assert_equal 1, rooms.first.room_id
end end
def test_has_many_through_when_through_association_is_composite def test_has_many_through_when_through_association_is_composite
dorm = Dorm.find(:first) dorm = Dorm.find(:first)
assert_equal 1, dorm.rooms.length assert_equal 1, dorm.rooms.length
assert_equal 1, dorm.rooms.first.room_attributes.length assert_equal 1, dorm.rooms.first.room_attributes.length
assert_equal 'keg', dorm.rooms.first.room_attributes.first.name assert_equal 'keg', dorm.rooms.first.room_attributes.first.name
end end
def test_associations_with_conditions def test_associations_with_conditions
@suburb = Suburb.find([2, 1]) @suburb = Suburb.find([2, 1])
assert_equal 2, @suburb.streets.size assert_equal 2, @suburb.streets.size
@suburb = Suburb.find([2, 1]) @suburb = Suburb.find([2, 1])
assert_equal 1, @suburb.first_streets.size assert_equal 1, @suburb.first_streets.size
@suburb = Suburb.find([2, 1], :include => :streets) @suburb = Suburb.find([2, 1], :include => :streets)
assert_equal 2, @suburb.streets.size assert_equal 2, @suburb.streets.size
@suburb = Suburb.find([2, 1], :include => :first_streets) @suburb = Suburb.find([2, 1], :include => :first_streets)
assert_equal 1, @suburb.first_streets.size assert_equal 1, @suburb.first_streets.size
end end
def test_has_and_belongs_to_many def test_has_and_belongs_to_many
@restaurant = Restaurant.find([1,1]) @restaurant = Restaurant.find([1,1])
assert_equal 2, @restaurant.suburbs.size assert_equal 2, @restaurant.suburbs.size
@restaurant = Restaurant.find([1,1], :include => :suburbs) @restaurant = Restaurant.find([1,1], :include => :suburbs)
assert_equal 2, @restaurant.suburbs.size assert_equal 2, @restaurant.suburbs.size
end end
end end

View file

@ -1,34 +1,34 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
class TestClone < Test::Unit::TestCase class TestClone < Test::Unit::TestCase
fixtures :reference_types, :reference_codes fixtures :reference_types, :reference_codes
CLASSES = { CLASSES = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => :reference_type_id, :primary_keys => :reference_type_id,
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
}, },
} }
def setup def setup
self.class.classes = CLASSES self.class.classes = CLASSES
end end
def test_truth def test_truth
testing_with do testing_with do
clone = @first.clone clone = @first.clone
assert_equal @first.attributes.block(@klass.primary_key), clone.attributes assert_equal @first.attributes.block(@klass.primary_key), clone.attributes
if composite? if composite?
@klass.primary_key.each {|key| assert_nil clone[key], "Primary key '#{key}' should be nil"} @klass.primary_key.each {|key| assert_nil clone[key], "Primary key '#{key}' should be nil"}
else else
assert_nil clone[@klass.primary_key], "Sole primary key should be nil" assert_nil clone[@klass.primary_key], "Sole primary key should be nil"
end end
end end
end end
end end

View file

@ -1,96 +1,96 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
require 'fixtures/department' require 'fixtures/department'
require 'fixtures/employee' require 'fixtures/employee'
class TestDelete < Test::Unit::TestCase class TestDelete < Test::Unit::TestCase
fixtures :reference_types, :reference_codes, :departments, :employees fixtures :reference_types, :reference_codes, :departments, :employees
CLASSES = { CLASSES = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => :reference_type_id, :primary_keys => :reference_type_id,
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
}, },
} }
def setup def setup
self.class.classes = CLASSES self.class.classes = CLASSES
end end
def test_destroy_one def test_destroy_one
testing_with do testing_with do
#assert @first.destroy #assert @first.destroy
assert true assert true
end end
end end
def test_destroy_one_via_class def test_destroy_one_via_class
testing_with do testing_with do
assert @klass.destroy(*@first.id) assert @klass.destroy(*@first.id)
end end
end end
def test_destroy_one_alone_via_class def test_destroy_one_alone_via_class
testing_with do testing_with do
assert @klass.destroy(@first.id) assert @klass.destroy(@first.id)
end end
end end
def test_delete_one def test_delete_one
testing_with do testing_with do
assert @klass.delete(*@first.id) if composite? assert @klass.delete(*@first.id) if composite?
end end
end end
def test_delete_one_alone def test_delete_one_alone
testing_with do testing_with do
assert @klass.delete(@first.id) assert @klass.delete(@first.id)
end end
end end
def test_delete_many def test_delete_many
testing_with do testing_with do
to_delete = @klass.find(:all)[0..1] to_delete = @klass.find(:all)[0..1]
assert_equal 2, to_delete.length assert_equal 2, to_delete.length
end end
end end
def test_delete_all def test_delete_all
testing_with do testing_with do
@klass.delete_all @klass.delete_all
end end
end end
def test_clear_association def test_clear_association
department = Department.find(1,1) department = Department.find(1,1)
assert_equal 2, department.employees.size, "Before clear employee count should be 2." assert_equal 2, department.employees.size, "Before clear employee count should be 2."
department.employees.clear department.employees.clear
assert_equal 0, department.employees.size, "After clear employee count should be 0." assert_equal 0, department.employees.size, "After clear employee count should be 0."
department.reload department.reload
assert_equal 0, department.employees.size, "After clear and a reload from DB employee count should be 0." assert_equal 0, department.employees.size, "After clear and a reload from DB employee count should be 0."
end end
def test_delete_association def test_delete_association
department = Department.find(1,1) department = Department.find(1,1)
assert_equal 2, department.employees.size , "Before delete employee count should be 2." assert_equal 2, department.employees.size , "Before delete employee count should be 2."
first_employee = department.employees[0] first_employee = department.employees[0]
department.employees.delete(first_employee) department.employees.delete(first_employee)
assert_equal 1, department.employees.size, "After delete employee count should be 1." assert_equal 1, department.employees.size, "After delete employee count should be 1."
department.reload department.reload
assert_equal 1, department.employees.size, "After delete and a reload from DB employee count should be 1." assert_equal 1, department.employees.size, "After delete and a reload from DB employee count should be 1."
end end
def test_delete_records_for_has_many_association_with_composite_primary_key def test_delete_records_for_has_many_association_with_composite_primary_key
reference_type = ReferenceType.find(1) reference_type = ReferenceType.find(1)
codes_to_delete = reference_type.reference_codes[0..1] codes_to_delete = reference_type.reference_codes[0..1]
assert_equal 3, reference_type.reference_codes.size, "Before deleting records reference_code count should be 3." assert_equal 3, reference_type.reference_codes.size, "Before deleting records reference_code count should be 3."
reference_type.reference_codes.delete_records(codes_to_delete) reference_type.reference_codes.delete_records(codes_to_delete)
reference_type.reload reference_type.reload
assert_equal 1, reference_type.reference_codes.size, "After deleting 2 records and a reload from DB reference_code count should be 1." assert_equal 1, reference_type.reference_codes.size, "After deleting 2 records and a reload from DB reference_code count should be 1."
end end
end end

View file

@ -1,28 +1,28 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
class TestDummy < Test::Unit::TestCase class TestDummy < Test::Unit::TestCase
fixtures :reference_types, :reference_codes fixtures :reference_types, :reference_codes
classes = { classes = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => :reference_type_id, :primary_keys => :reference_type_id,
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
}, },
} }
def setup def setup
self.class.classes = classes self.class.classes = classes
end end
def test_truth def test_truth
testing_with do testing_with do
assert true assert true
end end
end end
end end

View file

@ -1,73 +1,73 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
# Testing the find action on composite ActiveRecords with two primary keys # Testing the find action on composite ActiveRecords with two primary keys
class TestFind < Test::Unit::TestCase class TestFind < Test::Unit::TestCase
fixtures :reference_types, :reference_codes fixtures :reference_types, :reference_codes
CLASSES = { CLASSES = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => [:reference_type_id], :primary_keys => [:reference_type_id],
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
}, },
:dual_strs => { :dual_strs => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => ['reference_type_id', 'reference_code'], :primary_keys => ['reference_type_id', 'reference_code'],
}, },
} }
def setup def setup
self.class.classes = CLASSES self.class.classes = CLASSES
end end
def test_find_first def test_find_first
testing_with do testing_with do
obj = @klass.find(:first) obj = @klass.find(:first)
assert obj assert obj
assert_equal @klass, obj.class assert_equal @klass, obj.class
end end
end end
def test_find def test_find
testing_with do testing_with do
found = @klass.find(*first_id) # e.g. find(1,1) or find 1,1 found = @klass.find(*first_id) # e.g. find(1,1) or find 1,1
assert found assert found
assert_equal @klass, found.class assert_equal @klass, found.class
assert_equal found, @klass.find(found.id) assert_equal found, @klass.find(found.id)
assert_equal found, @klass.find(found.to_param) assert_equal found, @klass.find(found.to_param)
end end
end end
def test_find_composite_ids def test_find_composite_ids
testing_with do testing_with do
found = @klass.find(first_id) # e.g. find([1,1].to_composite_ids) found = @klass.find(first_id) # e.g. find([1,1].to_composite_ids)
assert found assert found
assert_equal @klass, found.class assert_equal @klass, found.class
assert_equal found, @klass.find(found.id) assert_equal found, @klass.find(found.id)
assert_equal found, @klass.find(found.to_param) assert_equal found, @klass.find(found.to_param)
end end
end end
def test_to_param def test_to_param
testing_with do testing_with do
assert_equal first_id_str, @first.to_param.to_s assert_equal first_id_str, @first.to_param.to_s
end end
end end
def things_to_look_at def things_to_look_at
testing_with do testing_with do
assert_equal found, @klass.find(found.id.to_s) # fails for 2+ keys assert_equal found, @klass.find(found.id.to_s) # fails for 2+ keys
end end
end end
def test_not_found def test_not_found
assert_raise(::ActiveRecord::RecordNotFound) do assert_raise(::ActiveRecord::RecordNotFound) do
ReferenceCode.send :find, '999,999' ReferenceCode.send :find, '999,999'
end end
end end
end end

View file

@ -1,97 +1,97 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
class TestIds < Test::Unit::TestCase class TestIds < Test::Unit::TestCase
fixtures :reference_types, :reference_codes fixtures :reference_types, :reference_codes
CLASSES = { CLASSES = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => [:reference_type_id], :primary_keys => [:reference_type_id],
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
}, },
:dual_strs => { :dual_strs => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => ['reference_type_id', 'reference_code'], :primary_keys => ['reference_type_id', 'reference_code'],
}, },
} }
def setup def setup
self.class.classes = CLASSES self.class.classes = CLASSES
end end
def test_id def test_id
testing_with do testing_with do
assert_equal @first.id, @first.ids if composite? assert_equal @first.id, @first.ids if composite?
end end
end end
def test_id_to_s def test_id_to_s
testing_with do testing_with do
assert_equal first_id_str, @first.id.to_s assert_equal first_id_str, @first.id.to_s
assert_equal first_id_str, "#{@first.id}" assert_equal first_id_str, "#{@first.id}"
end end
end end
def test_ids_to_s def test_ids_to_s
testing_with do testing_with do
order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',') order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')
to_test = @klass.find(:all, :order => order)[0..1].map(&:id) to_test = @klass.find(:all, :order => order)[0..1].map(&:id)
assert_equal '(1,1),(1,2)', @klass.ids_to_s(to_test) if @key_test == :dual assert_equal '(1,1),(1,2)', @klass.ids_to_s(to_test) if @key_test == :dual
assert_equal '1,1;1,2', @klass.ids_to_s(to_test, ',', ';', '', '') if @key_test == :dual assert_equal '1,1;1,2', @klass.ids_to_s(to_test, ',', ';', '', '') if @key_test == :dual
end end
end end
def test_composite_where_clause def test_composite_where_clause
testing_with do testing_with do
where = 'reference_codes.reference_type_id=1 AND reference_codes.reference_code=2) OR (reference_codes.reference_type_id=2 AND reference_codes.reference_code=2' where = 'reference_codes.reference_type_id=1 AND reference_codes.reference_code=2) OR (reference_codes.reference_type_id=2 AND reference_codes.reference_code=2'
assert_equal(where, @klass.composite_where_clause([[1, 2], [2, 2]])) if @key_test == :dual assert_equal(where, @klass.composite_where_clause([[1, 2], [2, 2]])) if @key_test == :dual
end end
end end
def test_set_ids_string def test_set_ids_string
testing_with do testing_with do
array = @primary_keys.collect {|key| 5} array = @primary_keys.collect {|key| 5}
expected = composite? ? array.to_composite_keys : array.first expected = composite? ? array.to_composite_keys : array.first
@first.id = expected.to_s @first.id = expected.to_s
assert_equal expected, @first.id assert_equal expected, @first.id
end end
end end
def test_set_ids_array def test_set_ids_array
testing_with do testing_with do
array = @primary_keys.collect {|key| 5} array = @primary_keys.collect {|key| 5}
expected = composite? ? array.to_composite_keys : array.first expected = composite? ? array.to_composite_keys : array.first
@first.id = expected @first.id = expected
assert_equal expected, @first.id assert_equal expected, @first.id
end end
end end
def test_set_ids_comp def test_set_ids_comp
testing_with do testing_with do
array = @primary_keys.collect {|key| 5} array = @primary_keys.collect {|key| 5}
expected = composite? ? array.to_composite_keys : array.first expected = composite? ? array.to_composite_keys : array.first
@first.id = expected @first.id = expected
assert_equal expected, @first.id assert_equal expected, @first.id
end end
end end
def test_primary_keys def test_primary_keys
testing_with do testing_with do
if composite? if composite?
assert_not_nil @klass.primary_keys assert_not_nil @klass.primary_keys
assert_equal @primary_keys.map {|key| key.to_sym}, @klass.primary_keys assert_equal @primary_keys.map {|key| key.to_sym}, @klass.primary_keys
assert_equal @klass.primary_keys, @klass.primary_key assert_equal @klass.primary_keys, @klass.primary_key
else else
assert_not_nil @klass.primary_key assert_not_nil @klass.primary_key
assert_equal @primary_keys, [@klass.primary_key.to_sym] assert_equal @primary_keys, [@klass.primary_key.to_sym]
end end
assert_equal @primary_keys.join(','), @klass.primary_key.to_s assert_equal @primary_keys.join(','), @klass.primary_key.to_s
# Need a :primary_keys should be Array with to_s overridden # Need a :primary_keys should be Array with to_s overridden
end end
end end
end end

View file

@ -1,39 +1,39 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
class TestMiscellaneous < Test::Unit::TestCase class TestMiscellaneous < Test::Unit::TestCase
fixtures :reference_types, :reference_codes, :products fixtures :reference_types, :reference_codes, :products
CLASSES = { CLASSES = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => :reference_type_id, :primary_keys => :reference_type_id,
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
}, },
} }
def setup def setup
self.class.classes = CLASSES self.class.classes = CLASSES
end end
def test_composite_class def test_composite_class
testing_with do testing_with do
assert_equal composite?, @klass.composite? assert_equal composite?, @klass.composite?
end end
end end
def test_composite_instance def test_composite_instance
testing_with do testing_with do
assert_equal composite?, @first.composite? assert_equal composite?, @first.composite?
end end
end end
def test_count def test_count
assert_equal 2, Product.count assert_equal 2, Product.count
end end
end end

View file

@ -1,38 +1,38 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
require 'plugins/pagination' require 'plugins/pagination'
class TestPagination < Test::Unit::TestCase class TestPagination < Test::Unit::TestCase
fixtures :reference_types, :reference_codes fixtures :reference_types, :reference_codes
include ActionController::Pagination include ActionController::Pagination
DEFAULT_PAGE_SIZE = 2 DEFAULT_PAGE_SIZE = 2
attr_accessor :params attr_accessor :params
CLASSES = { CLASSES = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => :reference_type_id, :primary_keys => :reference_type_id,
:table => :reference_types, :table => :reference_types,
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
:table => :reference_codes, :table => :reference_codes,
}, },
} }
def setup def setup
self.class.classes = CLASSES self.class.classes = CLASSES
@params = {} @params = {}
end end
def test_paginate_all def test_paginate_all
testing_with do testing_with do
@object_pages, @objects = paginate @klass_info[:table], :per_page => DEFAULT_PAGE_SIZE @object_pages, @objects = paginate @klass_info[:table], :per_page => DEFAULT_PAGE_SIZE
assert_equal 2, @objects.length, "Each page should have #{DEFAULT_PAGE_SIZE} items" assert_equal 2, @objects.length, "Each page should have #{DEFAULT_PAGE_SIZE} items"
end end
end end
end end

View file

@ -1,27 +1,27 @@
# Test cases devised by Santiago that broke the Composite Primary Keys # Test cases devised by Santiago that broke the Composite Primary Keys
# code at one point in time. But no more!!! # code at one point in time. But no more!!!
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/user' require 'fixtures/user'
require 'fixtures/article' require 'fixtures/article'
require 'fixtures/reading' require 'fixtures/reading'
class TestSantiago < Test::Unit::TestCase class TestSantiago < Test::Unit::TestCase
fixtures :suburbs, :streets, :users, :articles, :readings fixtures :suburbs, :streets, :users, :articles, :readings
def test_normal_and_composite_associations def test_normal_and_composite_associations
assert_not_nil @suburb = Suburb.find(1,1) assert_not_nil @suburb = Suburb.find(1,1)
assert_equal 1, @suburb.streets.length assert_equal 1, @suburb.streets.length
assert_not_nil @street = Street.find(1) assert_not_nil @street = Street.find(1)
assert_not_nil @street.suburb assert_not_nil @street.suburb
end end
def test_single_keys def test_single_keys
@santiago = User.find(1) @santiago = User.find(1)
assert_not_nil @santiago.articles assert_not_nil @santiago.articles
assert_equal 2, @santiago.articles.length assert_equal 2, @santiago.articles.length
assert_not_nil @santiago.readings assert_not_nil @santiago.readings
assert_equal 2, @santiago.readings.length assert_equal 2, @santiago.readings.length
end end
end end

View file

@ -1,40 +1,40 @@
require 'abstract_unit' require 'abstract_unit'
require 'fixtures/reference_type' require 'fixtures/reference_type'
require 'fixtures/reference_code' require 'fixtures/reference_code'
class TestUpdate < Test::Unit::TestCase class TestUpdate < Test::Unit::TestCase
fixtures :reference_types, :reference_codes fixtures :reference_types, :reference_codes
CLASSES = { CLASSES = {
:single => { :single => {
:class => ReferenceType, :class => ReferenceType,
:primary_keys => :reference_type_id, :primary_keys => :reference_type_id,
:update => { :description => 'RT Desc' }, :update => { :description => 'RT Desc' },
}, },
:dual => { :dual => {
:class => ReferenceCode, :class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code], :primary_keys => [:reference_type_id, :reference_code],
:update => { :description => 'RT Desc' }, :update => { :description => 'RT Desc' },
}, },
} }
def setup def setup
self.class.classes = CLASSES self.class.classes = CLASSES
end end
def test_setup def test_setup
testing_with do testing_with do
assert_not_nil @klass_info[:update] assert_not_nil @klass_info[:update]
end end
end end
def test_update_attributes def test_update_attributes
testing_with do testing_with do
assert @first.update_attributes(@klass_info[:update]) assert @first.update_attributes(@klass_info[:update])
assert @first.reload assert @first.reload
@klass_info[:update].each_pair do |attr_name, new_value| @klass_info[:update].each_pair do |attr_name, new_value|
assert_equal new_value, @first[attr_name], "Attribute #{attr_name} is incorrect" assert_equal new_value, @first[attr_name], "Attribute #{attr_name} is incorrect"
end end
end end
end end
end end

View file

@ -1,126 +1,126 @@
body { body {
background-color: #2F30EE; background-color: #2F30EE;
font-family: "Georgia", sans-serif; font-family: "Georgia", sans-serif;
font-size: 16px; font-size: 16px;
line-height: 1.6em; line-height: 1.6em;
padding: 1.6em 0 0 0; padding: 1.6em 0 0 0;
color: #eee; color: #eee;
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
color: #FFEDFA; color: #FFEDFA;
} }
h1 { h1 {
font-family: sans-serif; font-family: sans-serif;
font-weight: normal; font-weight: normal;
font-size: 4em; font-size: 4em;
line-height: 0.8em; line-height: 0.8em;
letter-spacing: -0.1ex; letter-spacing: -0.1ex;
margin: 5px; margin: 5px;
} }
li { li {
padding: 0; padding: 0;
margin: 0; margin: 0;
list-style-type: square; list-style-type: square;
} }
a { a {
color: #99f; color: #99f;
font-weight: normal; font-weight: normal;
text-decoration: underline; text-decoration: underline;
} }
blockquote { blockquote {
font-size: 90%; font-size: 90%;
font-style: italic; font-style: italic;
border-left: 1px solid #eee; border-left: 1px solid #eee;
padding-left: 1em; padding-left: 1em;
} }
.caps { .caps {
font-size: 80%; font-size: 80%;
} }
#main { #main {
width: 45em; width: 45em;
padding: 0; padding: 0;
margin: 0 auto; margin: 0 auto;
} }
.coda { .coda {
text-align: right; text-align: right;
color: #77f; color: #77f;
font-size: smaller; font-size: smaller;
} }
table { table {
font-size: 90%; font-size: 90%;
line-height: 1.4em; line-height: 1.4em;
color: #ff8; color: #ff8;
background-color: #111; background-color: #111;
padding: 2px 10px 2px 10px; padding: 2px 10px 2px 10px;
border-style: dashed; border-style: dashed;
} }
th { th {
color: #fff; color: #fff;
} }
td { td {
padding: 2px 10px 2px 10px; padding: 2px 10px 2px 10px;
} }
.success { .success {
color: #0CC52B; color: #0CC52B;
} }
.failed { .failed {
color: #E90A1B; color: #E90A1B;
} }
.unknown { .unknown {
color: #995000; color: #995000;
} }
pre, code { pre, code {
font-family: monospace; font-family: monospace;
font-size: 90%; font-size: 90%;
line-height: 1.4em; line-height: 1.4em;
color: #ff8; color: #ff8;
background-color: #111; background-color: #111;
padding: 2px 10px 2px 10px; padding: 2px 10px 2px 10px;
} }
.comment { color: #aaa; font-style: italic; } .comment { color: #aaa; font-style: italic; }
.keyword { color: #eff; font-weight: bold; } .keyword { color: #eff; font-weight: bold; }
.punct { color: #eee; font-weight: bold; } .punct { color: #eee; font-weight: bold; }
.symbol { color: #0bb; } .symbol { color: #0bb; }
.string { color: #6b4; } .string { color: #6b4; }
.ident { color: #ff8; } .ident { color: #ff8; }
.constant { color: #66f; } .constant { color: #66f; }
.regex { color: #ec6; } .regex { color: #ec6; }
.number { color: #F99; } .number { color: #F99; }
.expr { color: #227; } .expr { color: #227; }
#version { #version {
float: right; float: right;
text-align: right; text-align: right;
font-family: sans-serif; font-family: sans-serif;
font-weight: normal; font-weight: normal;
background-color: #ff8; background-color: #ff8;
color: #66f; color: #66f;
padding: 15px 20px 10px 20px; padding: 15px 20px 10px 20px;
margin: 0 auto; margin: 0 auto;
margin-top: 15px; margin-top: 15px;
border: 3px solid #66f; border: 3px solid #66f;
} }
#version .numbers { #version .numbers {
display: block; display: block;
font-size: 4em; font-size: 4em;
line-height: 0.8em; line-height: 0.8em;
letter-spacing: -0.1ex; letter-spacing: -0.1ex;
} }
#version a { #version a {
text-decoration: none; text-decoration: none;
} }
.clickable { .clickable {
cursor: pointer; cursor: pointer;
cursor: hand; cursor: hand;
} }

View file

@ -1,2 +1,2 @@
h1. Announcement JS file h1. Announcement JS file
MagicAnnouncement.show('compositekeys', version); MagicAnnouncement.show('compositekeys', version);

View file

@ -1,4 +1,4 @@
// Version JS file // Version JS file
var version = "2.2.2"; var version = "2.2.2";
document.write(" - " + version); document.write(" - " + version);

View file

@ -1,3 +1,3 @@
h1. Version JS file h1. Version JS file
document.write(" - " + version); document.write(" - " + version);

View file

@ -1,182 +1,182 @@
# Lower Sorbian translations for Ruby on Rails # Lower Sorbian translations for Ruby on Rails
# by Michael Wolf (preklady@wolfmicha.de) # by Michael Wolf (preklady@wolfmicha.de)
dsb: dsb:
# ActiveSupport # ActiveSupport
support: support:
array: array:
words_connector: ", " words_connector: ", "
two_words_connector: " a " two_words_connector: " a "
last_word_connector: " a " last_word_connector: " a "
sentence_connector: "a" sentence_connector: "a"
skip_last_comma: true skip_last_comma: true
# Date # Date
date: date:
formats: formats:
default: "%d. %m. %Y" default: "%d. %m. %Y"
short: "%d %b" short: "%d %b"
long: "%d. %B %Y" long: "%d. %B %Y"
day_names: [njeźela, pónjeźele, wałtora, srjoda, stwórtk, pětk, sobota] day_names: [njeźela, pónjeźele, wałtora, srjoda, stwórtk, pětk, sobota]
abbr_day_names: [Nj, Pó, Wu, Sr, St, Pě, So] abbr_day_names: [Nj, Pó, Wu, Sr, St, Pě, So]
month_names: [~, Januar, Februar, Měrc, Apryl, Maj, Junij, Julij, Awgust, September, Oktober, Nowember, December] month_names: [~, Januar, Februar, Měrc, Apryl, Maj, Junij, Julij, Awgust, September, Oktober, Nowember, December]
abbr_month_names: [~, jan, feb, měr, apr, maj, jun, jul, awg, sep, okt, now, dec] abbr_month_names: [~, jan, feb, měr, apr, maj, jun, jul, awg, sep, okt, now, dec]
order: [:day, :month, :year] order: [:day, :month, :year]
# Time # Time
time: time:
formats: formats:
default: "%A, %d. %B %Y, %H:%M hodź" default: "%A, %d. %B %Y, %H:%M hodź"
short: "%d. %B, %H:%M hodź." short: "%d. %B, %H:%M hodź."
long: "%A, %d. %B %Y, %H:%M hodź." long: "%A, %d. %B %Y, %H:%M hodź."
am: "dopołdnja" am: "dopołdnja"
pm: "wótpołdnja" pm: "wótpołdnja"
# Numbers # Numbers
number: number:
format: format:
precision: 3 precision: 3
separator: "," separator: ","
delimiter: "." delimiter: "."
currency: currency:
format: format:
unit: "€" unit: "€"
precision: 2 precision: 2
format: "%n %u" format: "%n %u"
separator: "," separator: ","
delimiter: " " delimiter: " "
human: human:
format: format:
precision: 1 precision: 1
delimiter: "" delimiter: ""
storage_units: storage_units:
format: "%n %u" format: "%n %u"
units: units:
byte: byte:
one: "bajt" one: "bajt"
two: "bajta" two: "bajta"
few: "bajty" few: "bajty"
other: "bajtow" other: "bajtow"
kb: "KB" kb: "KB"
mb: "MB" mb: "MB"
gb: "GB" gb: "GB"
tb: "TB" tb: "TB"
percentage: percentage:
format: format:
delimiter: "" delimiter: ""
precision: precision:
format: format:
delimiter: "" delimiter: ""
# Distance of time ... helper # Distance of time ... helper
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words() # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
datetime: datetime:
distance_in_words: distance_in_words:
half_a_minute: "poł minuty" half_a_minute: "poł minuty"
less_than_x_seconds: less_than_x_seconds:
one: "mjenjej ako 1 sekundu" one: "mjenjej ako 1 sekundu"
two: "mjenjej ako {{count}} sekundoma" two: "mjenjej ako {{count}} sekundoma"
few: "mjenjej ako {{count}} sekundami" few: "mjenjej ako {{count}} sekundami"
other: "mjenjej ako {{count}} sekundami" other: "mjenjej ako {{count}} sekundami"
x_seconds: x_seconds:
one: "1 sekundu" one: "1 sekundu"
two: "{{count}} sekundoma" two: "{{count}} sekundoma"
few: "{{count}} sekundami" few: "{{count}} sekundami"
other: "{{count}} sekundami" other: "{{count}} sekundami"
less_than_x_minutes: less_than_x_minutes:
one: "mjenjej ako 1 minutu" one: "mjenjej ako 1 minutu"
two: "mjenjej ako {{count}} minutoma" two: "mjenjej ako {{count}} minutoma"
few: "mjenjej ako {{count}} minutami" few: "mjenjej ako {{count}} minutami"
other: "mjenjej ako {{count}} minutami" other: "mjenjej ako {{count}} minutami"
x_minutes: x_minutes:
one: "1 minutu" one: "1 minutu"
two: "{{count}} minutoma" two: "{{count}} minutoma"
few: "{{count}} minutami" few: "{{count}} minutami"
other: "{{count}} minutami" other: "{{count}} minutami"
about_x_hours: about_x_hours:
one: "něźi 1 góźinu" one: "něźi 1 góźinu"
two: "něźi {{count}} góźinoma" two: "něźi {{count}} góźinoma"
few: "něźi {{count}} góźinami" few: "něźi {{count}} góźinami"
other: "něźi {{count}} góźinami" other: "něźi {{count}} góźinami"
x_days: x_days:
one: "1 dnjom" one: "1 dnjom"
two: "{{count}} dnjoma" two: "{{count}} dnjoma"
few: "{{count}} dnjami" few: "{{count}} dnjami"
other: "{{count}} dnjami" other: "{{count}} dnjami"
about_x_months: about_x_months:
one: "něźi 1 mjasecom" one: "něźi 1 mjasecom"
two: "něźi {{count}} mjasecoma" two: "něźi {{count}} mjasecoma"
few: "něźi {{count}} mjasecami" few: "něźi {{count}} mjasecami"
other: "něźi {{count}} mjasecami" other: "něźi {{count}} mjasecami"
x_months: x_months:
one: "1 mjasecom" one: "1 mjasecom"
two: "{{count}} mjasecoma" two: "{{count}} mjasecoma"
few: "{{count}} mjasecami" few: "{{count}} mjasecami"
other: "{{count}} mjasecami" other: "{{count}} mjasecami"
about_x_years: about_x_years:
one: "něźi 1 lětom" one: "něźi 1 lětom"
two: "něźi {{count}} lětoma" two: "něźi {{count}} lětoma"
few: "něźi {{count}} lětami" few: "něźi {{count}} lětami"
other: "něźi {{count}} lětami" other: "něźi {{count}} lětami"
over_x_years: over_x_years:
one: "wěcej ako 1 lětom" one: "wěcej ako 1 lětom"
two: "wěcej ako {{count}} lětoma" two: "wěcej ako {{count}} lětoma"
few: "wěcej ako {{count}} lětami" few: "wěcej ako {{count}} lětami"
other: "wěcej ako {{count}} lětami" other: "wěcej ako {{count}} lětami"
prompts: prompts:
year: "Lěto" year: "Lěto"
month: "Mjasec" month: "Mjasec"
day: "Źeń" day: "Źeń"
hour: "Góźina" hour: "Góźina"
minute: "Minuta" minute: "Minuta"
second: "Sekunda" second: "Sekunda"
# ActiveRecord validation messages # ActiveRecord validation messages
activerecord: activerecord:
errors: errors:
messages: messages:
inclusion: "njejo płaśiwa gódnota" inclusion: "njejo płaśiwa gódnota"
exclusion: "njestoj k dispoziciji" exclusion: "njestoj k dispoziciji"
invalid: "njejo płaśiwy" invalid: "njejo płaśiwy"
confirmation: "njejo se wobkšuśiło" confirmation: "njejo se wobkšuśiło"
accepted: "musy se wobkšuśiś" accepted: "musy se wobkšuśiś"
empty: "njesmějo prozny byś" empty: "njesmějo prozny byś"
blank: "jo trěbny" blank: "jo trěbny"
too_long: too_long:
one: "jo pśedłujki (maks. 1 znamješko)" one: "jo pśedłujki (maks. 1 znamješko)"
two: "jo pśedłujki (maks. {{count}} znamješce)" two: "jo pśedłujki (maks. {{count}} znamješce)"
few: "jo pśedłujki (maks. {{count}} znamješka)" few: "jo pśedłujki (maks. {{count}} znamješka)"
other: "jo pśedłujki (maks. {{count}} znamješkow)" other: "jo pśedłujki (maks. {{count}} znamješkow)"
too_short: too_short:
one: "jo překrotki (min. 1 znamješko)" one: "jo překrotki (min. 1 znamješko)"
two: "jo překrotki (min. {{count}} znamješće)" two: "jo překrotki (min. {{count}} znamješće)"
few: "jo překrotki (min. {{count}} znamješka)" few: "jo překrotki (min. {{count}} znamješka)"
other: "jo překrotki (min. {{count}} znamješkow)" other: "jo překrotki (min. {{count}} znamješkow)"
wrong_length: wrong_length:
one: "njama pšawu dłujkosć (1 znamješko wócakane)" one: "njama pšawu dłujkosć (1 znamješko wócakane)"
two: "njama pšawu dłujkosć ({{count}} znamješce wócakanej)" two: "njama pšawu dłujkosć ({{count}} znamješce wócakanej)"
few: "njama pšawu dłujkosć ({{count}} znamješka wócakane)" few: "njama pšawu dłujkosć ({{count}} znamješka wócakane)"
other: "njama pšawu dłujkosć ({{count}} znamješkow wócakanych)" other: "njama pšawu dłujkosć ({{count}} znamješkow wócakanych)"
taken: "jo južo w datowej bance" taken: "jo južo w datowej bance"
not_a_number: "njejo licba" not_a_number: "njejo licba"
greater_than: "musy wětšy ako {{count}} byś" greater_than: "musy wětšy ako {{count}} byś"
greater_than_or_equal_to: "musy wětšy abo jadnak {{count}} być" greater_than_or_equal_to: "musy wětšy abo jadnak {{count}} być"
equal_to: "musy jadnak {{count}} byś" equal_to: "musy jadnak {{count}} byś"
less_than: "musy mjeńšy ako {{count}} byś" less_than: "musy mjeńšy ako {{count}} byś"
less_than_or_equal_to: "musy mjeńšy abo jadnak {{count}} byś" less_than_or_equal_to: "musy mjeńšy abo jadnak {{count}} byś"
odd: "musy njerowna licba byś" odd: "musy njerowna licba byś"
even: "musy rowna licba byś" even: "musy rowna licba byś"
template: template:
header: header:
one: "Pśi składowanju objekta {{model}} jo k zmólce dojšło a njejo było móžno składowaś" one: "Pśi składowanju objekta {{model}} jo k zmólce dojšło a njejo było móžno składowaś"
two: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś" two: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"
few: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś" few: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"
other: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś" other: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"
body: "Pšosym pśeglědaj slědujuce póla:" body: "Pšosym pśeglědaj slědujuce póla:"
models: models:

View file

@ -1,190 +1,190 @@
# Upper Sorbian translations for Ruby on Rails # Upper Sorbian translations for Ruby on Rails
# by Michael Wolf (preklady@wolfmicha.de) # by Michael Wolf (preklady@wolfmicha.de)
hsb: hsb:
# ActiveSupport # ActiveSupport
support: support:
array: array:
words_connector: ", " words_connector: ", "
two_words_connector: " a " two_words_connector: " a "
last_word_connector: " a " last_word_connector: " a "
sentence_connector: "a" sentence_connector: "a"
skip_last_comma: true skip_last_comma: true
# Date # Date
date: date:
formats: formats:
default: "%d. %m. %Y" default: "%d. %m. %Y"
short: "%d %b" short: "%d %b"
long: "%d. %B %Y" long: "%d. %B %Y"
day_names: [njedźela, póndźela, wutora, srjeda, štwórtk, pjatk, sobota] day_names: [njedźela, póndźela, wutora, srjeda, štwórtk, pjatk, sobota]
abbr_day_names: [Nj, Pó, Wu, Sr, Št, Pj, So] abbr_day_names: [Nj, Pó, Wu, Sr, Št, Pj, So]
month_names: [~, Januar, Februar, Měrc, Apryl, Meja, Junij, Julij, Awgust, September, Oktober, Nowember, December] month_names: [~, Januar, Februar, Měrc, Apryl, Meja, Junij, Julij, Awgust, September, Oktober, Nowember, December]
abbr_month_names: [~, jan, feb, měr, apr, mej, jun, jul, awg, sep, okt, now, dec] abbr_month_names: [~, jan, feb, měr, apr, mej, jun, jul, awg, sep, okt, now, dec]
order: [:day, :month, :year] order: [:day, :month, :year]
# Time # Time
time: time:
formats: formats:
default: "%A, %d. %B %Y, %H:%M hodź" default: "%A, %d. %B %Y, %H:%M hodź"
short: "%d. %B, %H:%M hodź." short: "%d. %B, %H:%M hodź."
long: "%A, %d. %B %Y, %H:%M hodź." long: "%A, %d. %B %Y, %H:%M hodź."
am: "dopołdnja" am: "dopołdnja"
pm: "popołdnju" pm: "popołdnju"
# Numbers # Numbers
number: number:
format: format:
precision: 3 precision: 3
separator: "," separator: ","
delimiter: "." delimiter: "."
currency: currency:
format: format:
unit: "€" unit: "€"
precision: 2 precision: 2
format: "%n %u" format: "%n %u"
separator: "," separator: ","
delimiter: " " delimiter: " "
human: human:
format: format:
precision: 1 precision: 1
delimiter: "" delimiter: ""
storage_units: storage_units:
format: "%n %u" format: "%n %u"
units: units:
byte: byte:
one: "bajt" one: "bajt"
two: "bajtaj" two: "bajtaj"
few: "bajty" few: "bajty"
other: "bajtow" other: "bajtow"
kb: "KB" kb: "KB"
mb: "MB" mb: "MB"
gb: "GB" gb: "GB"
tb: "TB" tb: "TB"
percentage: percentage:
format: format:
delimiter: "" delimiter: ""
precision: precision:
format: format:
delimiter: "" delimiter: ""
# Distance of time ... helper # Distance of time ... helper
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words() # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
datetime: datetime:
distance_in_words: distance_in_words:
half_a_minute: "poł mjeńšiny" half_a_minute: "poł mjeńšiny"
less_than_x_seconds: less_than_x_seconds:
one: "mjenje hač 1 sekundu" one: "mjenje hač 1 sekundu"
two: "mjenje hač {{count}} sekundomaj" two: "mjenje hač {{count}} sekundomaj"
few: "mjenje hač {{count}} sekundami" few: "mjenje hač {{count}} sekundami"
other: "mjenje hač {{count}} sekundami" other: "mjenje hač {{count}} sekundami"
x_seconds: x_seconds:
one: "1 sekundu" one: "1 sekundu"
two: "{{count}} sekundomaj" two: "{{count}} sekundomaj"
few: "{{count}} sekundami" few: "{{count}} sekundami"
other: "{{count}} sekundami" other: "{{count}} sekundami"
less_than_x_minutes: less_than_x_minutes:
one: "mjenje hač 1 mjeńšinu" one: "mjenje hač 1 mjeńšinu"
two: "mjenje hač {{count}} mjeńšinomaj" two: "mjenje hač {{count}} mjeńšinomaj"
few: "mjenje hač {{count}} mjeńšinami" few: "mjenje hač {{count}} mjeńšinami"
other: "mjenje hač {{count}} mjeńšinami" other: "mjenje hač {{count}} mjeńšinami"
x_minutes: x_minutes:
one: "1 mjeńšinu" one: "1 mjeńšinu"
two: "{{count}} mjeńšinomaj" two: "{{count}} mjeńšinomaj"
few: "{{count}} mjeńšinami" few: "{{count}} mjeńšinami"
other: "{{count}} mjeńšinami" other: "{{count}} mjeńšinami"
about_x_hours: about_x_hours:
one: "něhdźe 1 hodźinu" one: "něhdźe 1 hodźinu"
two: "něhdźe {{count}} hodźinomaj" two: "něhdźe {{count}} hodźinomaj"
few: "něhdźe {{count}} hodźinami" few: "něhdźe {{count}} hodźinami"
other: "něhdźe {{count}} hodźinami" other: "něhdźe {{count}} hodźinami"
x_days: x_days:
one: "1 dnjom" one: "1 dnjom"
two: "{{count}} dnjomaj" two: "{{count}} dnjomaj"
few: "{{count}} dnjemi" few: "{{count}} dnjemi"
other: "{{count}} dnjemi" other: "{{count}} dnjemi"
about_x_months: about_x_months:
one: "něhdźe 1 měsacom" one: "něhdźe 1 měsacom"
two: "něhdźe {{count}} měsacomaj" two: "něhdźe {{count}} měsacomaj"
few: "něhdźe {{count}} měsacami" few: "něhdźe {{count}} měsacami"
other: "něhdźe {{count}} měsacami" other: "něhdźe {{count}} měsacami"
x_months: x_months:
one: "1 měsacom" one: "1 měsacom"
two: "{{count}} měsacomaj" two: "{{count}} měsacomaj"
few: "{{count}} měsacami" few: "{{count}} měsacami"
other: "{{count}} měsacami" other: "{{count}} měsacami"
about_x_years: about_x_years:
one: "něhdźe 1 lětom" one: "něhdźe 1 lětom"
two: "něhdźe {{count}} lětomaj" two: "něhdźe {{count}} lětomaj"
few: "něhdźe {{count}} lětami" few: "něhdźe {{count}} lětami"
other: "něhdźe {{count}} lětami" other: "něhdźe {{count}} lětami"
over_x_years: over_x_years:
one: "přez 1 lětom" one: "přez 1 lětom"
two: "přez {{count}} lětomaj" two: "přez {{count}} lětomaj"
few: "přez {{count}} lětami" few: "přez {{count}} lětami"
other: "přez {{count}} lětami" other: "přez {{count}} lětami"
prompts: prompts:
year: "Lěto" year: "Lěto"
month: "Měsac" month: "Měsac"
day: "Dźeń" day: "Dźeń"
hour: "Hodźina" hour: "Hodźina"
minute: "Mjeńšina" minute: "Mjeńšina"
second: "Sekunda" second: "Sekunda"
# ActiveRecord validation messages # ActiveRecord validation messages
activerecord: activerecord:
errors: errors:
messages: messages:
inclusion: "njeje płaćiwa hódnota" inclusion: "njeje płaćiwa hódnota"
exclusion: "njesteji k dispoziciji" exclusion: "njesteji k dispoziciji"
invalid: "njeje płaćiwy" invalid: "njeje płaćiwy"
confirmation: "njebu wobkrućene" confirmation: "njebu wobkrućene"
accepted: "dyrbi so wobkrućić" accepted: "dyrbi so wobkrućić"
empty: "njesmě prózdny być" empty: "njesmě prózdny być"
blank: "je trěbny" blank: "je trěbny"
too_long: too_long:
one: "je předołhi (maks. 1 znamješko)" one: "je předołhi (maks. 1 znamješko)"
two: "je předołhi (maks. {{count}} znamješce)" two: "je předołhi (maks. {{count}} znamješce)"
few: "je předołhi (maks. {{count}} znamješka)" few: "je předołhi (maks. {{count}} znamješka)"
other: "je předołhi (maks. {{count}} znamješkow)" other: "je předołhi (maks. {{count}} znamješkow)"
too_short: too_short:
one: "je překrótki (min. 1 znamješko)" one: "je překrótki (min. 1 znamješko)"
two: "je překrótki (min. {{count}} znamješće)" two: "je překrótki (min. {{count}} znamješće)"
few: "je překrótki (min. {{count}} znamješka)" few: "je překrótki (min. {{count}} znamješka)"
other: "je překrótki (min. {{count}} znamješkow)" other: "je překrótki (min. {{count}} znamješkow)"
wrong_length: wrong_length:
one: "nima prawu dołhosć (1 znamješko wočakowane)" one: "nima prawu dołhosć (1 znamješko wočakowane)"
two: "nima prawu dołhosć ({{count}} znamješce wočakowanej)" two: "nima prawu dołhosć ({{count}} znamješce wočakowanej)"
few: "nima prawu dołhosć ({{count}} znamješka wočakowane)" few: "nima prawu dołhosć ({{count}} znamješka wočakowane)"
other: "nima prawu dołhosć ({{count}} znamješkow wočakowanych)" other: "nima prawu dołhosć ({{count}} znamješkow wočakowanych)"
taken: "je hižo w datowej bance" taken: "je hižo w datowej bance"
not_a_number: "njeje ličba" not_a_number: "njeje ličba"
greater_than: "dyrbi wjetši hač {{count}} być" greater_than: "dyrbi wjetši hač {{count}} być"
greater_than_or_equal_to: "dyrbi wjetši abo runja {{count}} być" greater_than_or_equal_to: "dyrbi wjetši abo runja {{count}} być"
equal_to: "dyrbi runja {{count}} być" equal_to: "dyrbi runja {{count}} być"
less_than: "dyrbi mjenje hač {{count}} być" less_than: "dyrbi mjenje hač {{count}} być"
less_than_or_equal_to: "dyrbi mjenje abo runja {{count}} być" less_than_or_equal_to: "dyrbi mjenje abo runja {{count}} być"
odd: "dyrbi njeruna ličby być" odd: "dyrbi njeruna ličby być"
even: "dyrbi runa ličba być" even: "dyrbi runa ličba być"
template: template:
header: header:
one: "Při składowanju objekta {{model}} je k zmylkej dóšło a njebě móžno składować" one: "Při składowanju objekta {{model}} je k zmylkej dóšło a njebě móžno składować"
two: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować" two: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"
few: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować" few: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"
other: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować" other: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"
body: "Prošu přepruwuj slědowace pola:" body: "Prošu přepruwuj slědowace pola:"
models: models:

View file

@ -1,139 +1,139 @@
# Sample localization file for English. Add more files in this directory for other locales. # Sample localization file for English. Add more files in this directory for other locales.
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
# Slovak translations for Ruby on Rails (inspired by the Czech localization - thanx to Karel Minařík) # Slovak translations for Ruby on Rails (inspired by the Czech localization - thanx to Karel Minařík)
# by Jozef Fulop (jofi-rails@silake.com) # by Jozef Fulop (jofi-rails@silake.com)
sk: sk:
# ActiveSupport # ActiveSupport
support: support:
array: array:
words_connector: ', ' words_connector: ', '
two_words_connector: ' a ' two_words_connector: ' a '
last_word_connector: ' a ' last_word_connector: ' a '
# Date # Date
date: date:
formats: formats:
default: "%d. %m. %Y" default: "%d. %m. %Y"
short: "%d %b" short: "%d %b"
long: "%d. %B %Y" long: "%d. %B %Y"
day_names: [Nedeľa, Pondelok, Utorok, Streda, Štvrtok, Piatok, Sobota] day_names: [Nedeľa, Pondelok, Utorok, Streda, Štvrtok, Piatok, Sobota]
abbr_day_names: [Ne, Po, Ut, St, Št, Pi, So] abbr_day_names: [Ne, Po, Ut, St, Št, Pi, So]
month_names: [~, Január, Február, Marec, Apríl, Máj, Jún, Júl, August, September, Október, November, December] month_names: [~, Január, Február, Marec, Apríl, Máj, Jún, Júl, August, September, Október, November, December]
abbr_month_names: [~, Jan, Feb, Mar, Apr, Máj, Jún, Júl, Aug, Sep, Okt, Nov, Dec] abbr_month_names: [~, Jan, Feb, Mar, Apr, Máj, Jún, Júl, Aug, Sep, Okt, Nov, Dec]
order: [:day, :month, :year] order: [:day, :month, :year]
# Time # Time
time: time:
formats: formats:
default: "%a %d. %B %Y %H:%M %z" default: "%a %d. %B %Y %H:%M %z"
short: "%d. %m. %H:%M" short: "%d. %m. %H:%M"
long: "%A %d. %B %Y %H:%M" long: "%A %d. %B %Y %H:%M"
am: 'dopoludnia' am: 'dopoludnia'
pm: 'popoludní' pm: 'popoludní'
# Numbers # Numbers
number: number:
format: format:
precision: 3 precision: 3
separator: '.' separator: '.'
delimiter: ',' delimiter: ','
currency: currency:
format: format:
unit: '€' unit: '€'
precision: 2 precision: 2
format: '%n %u' format: '%n %u'
separator: "," separator: ","
delimiter: " " delimiter: " "
human: human:
format: format:
precision: 1 precision: 1
delimiter: '' delimiter: ''
storage_units: storage_units:
format: "%n %u" format: "%n %u"
units: units:
byte: byte:
other: "B" other: "B"
one: "B" one: "B"
kb: "KB" kb: "KB"
mb: "MB" mb: "MB"
gb: "GB" gb: "GB"
tb: "TB" tb: "TB"
percentage: percentage:
format: format:
delimiter: '' delimiter: ''
precision: precision:
format: format:
delimiter: '' delimiter: ''
# Distance of time ... helper # Distance of time ... helper
datetime: datetime:
prompts: prompts:
second: "Sekunda" second: "Sekunda"
minute: "Minúta" minute: "Minúta"
hour: "Hodina" hour: "Hodina"
day: "Deň" day: "Deň"
month: "Mesiac" month: "Mesiac"
year: "Rok" year: "Rok"
distance_in_words: distance_in_words:
half_a_minute: 'pol minutou' half_a_minute: 'pol minutou'
less_than_x_seconds: less_than_x_seconds:
one: 'asi pred sekundou' one: 'asi pred sekundou'
other: 'asi pred {{count}} sekundami' other: 'asi pred {{count}} sekundami'
x_seconds: x_seconds:
one: 'sekundou' one: 'sekundou'
other: '{{count}} sekundami' other: '{{count}} sekundami'
less_than_x_minutes: less_than_x_minutes:
one: 'pred necelou minútou' one: 'pred necelou minútou'
other: 'pred ani nie {{count}} minútami' other: 'pred ani nie {{count}} minútami'
x_minutes: x_minutes:
one: 'minútou' one: 'minútou'
other: '{{count}} minútami' other: '{{count}} minútami'
about_x_hours: about_x_hours:
one: 'asi hodinou' one: 'asi hodinou'
other: 'asi {{count}} hodinami' other: 'asi {{count}} hodinami'
x_days: x_days:
one: '24 hodinami' one: '24 hodinami'
other: '{{count}} dňami' other: '{{count}} dňami'
about_x_months: about_x_months:
one: 'asi mesiacom' one: 'asi mesiacom'
other: 'asi {{count}} mesiacmi' other: 'asi {{count}} mesiacmi'
x_months: x_months:
one: 'mesiacom' one: 'mesiacom'
other: '{{count}} mesiacmi' other: '{{count}} mesiacmi'
about_x_years: about_x_years:
one: 'asi rokom' one: 'asi rokom'
other: 'asi {{count}} rokmi' other: 'asi {{count}} rokmi'
over_x_years: over_x_years:
one: 'pred viac ako rokom' one: 'pred viac ako rokom'
other: 'viac ako {{count}} rokmi' other: 'viac ako {{count}} rokmi'
# ActiveRecord validation messages # ActiveRecord validation messages
activerecord: activerecord:
errors: errors:
messages: messages:
inclusion: "nie je v zozname povolených hodnôt" inclusion: "nie je v zozname povolených hodnôt"
exclusion: "je vyhradené pre iný účel" exclusion: "je vyhradené pre iný účel"
invalid: "nie je platná hodnota" invalid: "nie je platná hodnota"
confirmation: "nebolo potvrdené" confirmation: "nebolo potvrdené"
accepted: "musí byť potvrdené" accepted: "musí byť potvrdené"
empty: "nesmie byť prázdný/é" empty: "nesmie byť prázdný/é"
blank: "je povinná položka" blank: "je povinná položka"
too_long: "je príliš dlhá/ý (max. {{count}} znakov)" too_long: "je príliš dlhá/ý (max. {{count}} znakov)"
too_short: "je príliš krátký/á (min. {{count}} znakov)" too_short: "je príliš krátký/á (min. {{count}} znakov)"
wrong_length: "nemá správnu dĺžku (očakáva sa {{count}} znakov)" wrong_length: "nemá správnu dĺžku (očakáva sa {{count}} znakov)"
taken: "sa už nachádza v databáze" taken: "sa už nachádza v databáze"
not_a_number: "nie je číslo" not_a_number: "nie je číslo"
greater_than: "musí byť väčšíe ako {{count}}" greater_than: "musí byť väčšíe ako {{count}}"
greater_than_or_equal_to: "musí byť väčšie alebo rovnaké ako {{count}}" greater_than_or_equal_to: "musí byť väčšie alebo rovnaké ako {{count}}"
equal_to: "sa musí rovnať {{count}}" equal_to: "sa musí rovnať {{count}}"
less_than: "musí byť menšie ako {{count}}" less_than: "musí byť menšie ako {{count}}"
less_than_or_equal_to: "musí byť menšie ako {{count}}" less_than_or_equal_to: "musí byť menšie ako {{count}}"
odd: "musí byť nepárne číslo" odd: "musí byť nepárne číslo"
even: "musí byť párne číslo" even: "musí byť párne číslo"
template: template:
header: header:
one: "Pri ukladaní objektu {{model}} došlo k chybám a nebolo možné objekt uložiť" one: "Pri ukladaní objektu {{model}} došlo k chybám a nebolo možné objekt uložiť"
other: "Pri ukladaní objektu {{model}} došlo ku {{count}} chybe/ám a nebolo možné objekt uložiť" other: "Pri ukladaní objektu {{model}} došlo ku {{count}} chybe/ám a nebolo možné objekt uložiť"
body: "Nasledujúce polia obsahujú chybne vyplnené údaje:" body: "Nasledujúce polia obsahujú chybne vyplnené údaje:"

View file

@ -1,20 +1,20 @@
Copyright (c) 2006 Alex Dunae Copyright (c) 2006 Alex Dunae
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
the following conditions: the following conditions:
The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1 +1 @@
require 'validates_email_format_of' require 'validates_email_format_of'