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
port: 8000
pid_file: tmp/mongrel.pid
---
log_file: log/mongrel.log
port: 8000
pid_file: tmp/mongrel.pid
servers: 8

View file

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>OpenStreetMap</ShortName>
<LongName>OpenStreetMap Search</LongName>
<Description>Search for a place in OpenStreetMap, the Wiki World Map</Description>
<InputEncoding>UTF-8</InputEncoding>
<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>
<Url type="text/html" method="post" template="http://www.openstreetmap.org/">
<Param name="query" value="{searchTerms}"/>
</Url>
<Query role="example" searchTerms="Reigate" />
<Developer>Jonathan Bennett</Developer>
<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>
</OpenSearchDescription>
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>OpenStreetMap</ShortName>
<LongName>OpenStreetMap Search</LongName>
<Description>Search for a place in OpenStreetMap, the Wiki World Map</Description>
<InputEncoding>UTF-8</InputEncoding>
<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>
<Url type="text/html" method="post" template="http://www.openstreetmap.org/">
<Param name="query" value="{searchTerms}"/>
</Url>
<Query role="example" searchTerms="Reigate" />
<Developer>Jonathan Bennett</Developer>
<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>
</OpenSearchDescription>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
class Product < ActiveRecord::Base
set_primary_keys :id # redundant
has_many :product_tariffs, :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]
end
class Product < ActiveRecord::Base
set_primary_keys :id # redundant
has_many :product_tariffs, :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]
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
class Suburb < ActiveRecord::Base
set_primary_keys :city_id, :suburb_id
has_many :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 Suburb < ActiveRecord::Base
set_primary_keys :city_id, :suburb_id
has_many :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'"
end

View file

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

View file

@ -1,6 +1,6 @@
class Tariff < ActiveRecord::Base
set_primary_keys [:tariff_id, :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_many :products, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
end
class Tariff < ActiveRecord::Base
set_primary_keys [:tariff_id, :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_many :products, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,38 +1,38 @@
require 'abstract_unit'
require 'fixtures/reference_type'
require 'fixtures/reference_code'
require 'plugins/pagination'
class TestPagination < Test::Unit::TestCase
fixtures :reference_types, :reference_codes
include ActionController::Pagination
DEFAULT_PAGE_SIZE = 2
attr_accessor :params
CLASSES = {
:single => {
:class => ReferenceType,
:primary_keys => :reference_type_id,
:table => :reference_types,
},
:dual => {
:class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code],
:table => :reference_codes,
},
}
def setup
self.class.classes = CLASSES
@params = {}
end
def test_paginate_all
testing_with do
@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"
end
end
require 'abstract_unit'
require 'fixtures/reference_type'
require 'fixtures/reference_code'
require 'plugins/pagination'
class TestPagination < Test::Unit::TestCase
fixtures :reference_types, :reference_codes
include ActionController::Pagination
DEFAULT_PAGE_SIZE = 2
attr_accessor :params
CLASSES = {
:single => {
:class => ReferenceType,
:primary_keys => :reference_type_id,
:table => :reference_types,
},
:dual => {
:class => ReferenceCode,
:primary_keys => [:reference_type_id, :reference_code],
:table => :reference_codes,
},
}
def setup
self.class.classes = CLASSES
@params = {}
end
def test_paginate_all
testing_with do
@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"
end
end
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,139 +1,139 @@
# 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.
# Slovak translations for Ruby on Rails (inspired by the Czech localization - thanx to Karel Minařík)
# by Jozef Fulop (jofi-rails@silake.com)
sk:
# ActiveSupport
support:
array:
words_connector: ', '
two_words_connector: ' a '
last_word_connector: ' a '
# Date
date:
formats:
default: "%d. %m. %Y"
short: "%d %b"
long: "%d. %B %Y"
day_names: [Nedeľa, Pondelok, Utorok, Streda, Štvrtok, Piatok, Sobota]
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]
abbr_month_names: [~, Jan, Feb, Mar, Apr, Máj, Jún, Júl, Aug, Sep, Okt, Nov, Dec]
order: [:day, :month, :year]
# Time
time:
formats:
default: "%a %d. %B %Y %H:%M %z"
short: "%d. %m. %H:%M"
long: "%A %d. %B %Y %H:%M"
am: 'dopoludnia'
pm: 'popoludní'
# Numbers
number:
format:
precision: 3
separator: '.'
delimiter: ','
currency:
format:
unit: '€'
precision: 2
format: '%n %u'
separator: ","
delimiter: " "
human:
format:
precision: 1
delimiter: ''
storage_units:
format: "%n %u"
units:
byte:
other: "B"
one: "B"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"
percentage:
format:
delimiter: ''
precision:
format:
delimiter: ''
# Distance of time ... helper
datetime:
prompts:
second: "Sekunda"
minute: "Minúta"
hour: "Hodina"
day: "Deň"
month: "Mesiac"
year: "Rok"
distance_in_words:
half_a_minute: 'pol minutou'
less_than_x_seconds:
one: 'asi pred sekundou'
other: 'asi pred {{count}} sekundami'
x_seconds:
one: 'sekundou'
other: '{{count}} sekundami'
less_than_x_minutes:
one: 'pred necelou minútou'
other: 'pred ani nie {{count}} minútami'
x_minutes:
one: 'minútou'
other: '{{count}} minútami'
about_x_hours:
one: 'asi hodinou'
other: 'asi {{count}} hodinami'
x_days:
one: '24 hodinami'
other: '{{count}} dňami'
about_x_months:
one: 'asi mesiacom'
other: 'asi {{count}} mesiacmi'
x_months:
one: 'mesiacom'
other: '{{count}} mesiacmi'
about_x_years:
one: 'asi rokom'
other: 'asi {{count}} rokmi'
over_x_years:
one: 'pred viac ako rokom'
other: 'viac ako {{count}} rokmi'
# ActiveRecord validation messages
activerecord:
errors:
messages:
inclusion: "nie je v zozname povolených hodnôt"
exclusion: "je vyhradené pre iný účel"
invalid: "nie je platná hodnota"
confirmation: "nebolo potvrdené"
accepted: "musí byť potvrdené"
empty: "nesmie byť prázdný/é"
blank: "je povinná položka"
too_long: "je príliš dlhá/ý (max. {{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)"
taken: "sa už nachádza v databáze"
not_a_number: "nie je číslo"
greater_than: "musí byť väčšíe ako {{count}}"
greater_than_or_equal_to: "musí byť väčšie alebo rovnaké ako {{count}}"
equal_to: "sa musí rovnať {{count}}"
less_than: "musí byť menšie ako {{count}}"
less_than_or_equal_to: "musí byť menšie ako {{count}}"
odd: "musí byť nepárne číslo"
even: "musí byť párne číslo"
template:
header:
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ť"
body: "Nasledujúce polia obsahujú chybne vyplnené údaje:"
# 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.
# Slovak translations for Ruby on Rails (inspired by the Czech localization - thanx to Karel Minařík)
# by Jozef Fulop (jofi-rails@silake.com)
sk:
# ActiveSupport
support:
array:
words_connector: ', '
two_words_connector: ' a '
last_word_connector: ' a '
# Date
date:
formats:
default: "%d. %m. %Y"
short: "%d %b"
long: "%d. %B %Y"
day_names: [Nedeľa, Pondelok, Utorok, Streda, Štvrtok, Piatok, Sobota]
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]
abbr_month_names: [~, Jan, Feb, Mar, Apr, Máj, Jún, Júl, Aug, Sep, Okt, Nov, Dec]
order: [:day, :month, :year]
# Time
time:
formats:
default: "%a %d. %B %Y %H:%M %z"
short: "%d. %m. %H:%M"
long: "%A %d. %B %Y %H:%M"
am: 'dopoludnia'
pm: 'popoludní'
# Numbers
number:
format:
precision: 3
separator: '.'
delimiter: ','
currency:
format:
unit: '€'
precision: 2
format: '%n %u'
separator: ","
delimiter: " "
human:
format:
precision: 1
delimiter: ''
storage_units:
format: "%n %u"
units:
byte:
other: "B"
one: "B"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"
percentage:
format:
delimiter: ''
precision:
format:
delimiter: ''
# Distance of time ... helper
datetime:
prompts:
second: "Sekunda"
minute: "Minúta"
hour: "Hodina"
day: "Deň"
month: "Mesiac"
year: "Rok"
distance_in_words:
half_a_minute: 'pol minutou'
less_than_x_seconds:
one: 'asi pred sekundou'
other: 'asi pred {{count}} sekundami'
x_seconds:
one: 'sekundou'
other: '{{count}} sekundami'
less_than_x_minutes:
one: 'pred necelou minútou'
other: 'pred ani nie {{count}} minútami'
x_minutes:
one: 'minútou'
other: '{{count}} minútami'
about_x_hours:
one: 'asi hodinou'
other: 'asi {{count}} hodinami'
x_days:
one: '24 hodinami'
other: '{{count}} dňami'
about_x_months:
one: 'asi mesiacom'
other: 'asi {{count}} mesiacmi'
x_months:
one: 'mesiacom'
other: '{{count}} mesiacmi'
about_x_years:
one: 'asi rokom'
other: 'asi {{count}} rokmi'
over_x_years:
one: 'pred viac ako rokom'
other: 'viac ako {{count}} rokmi'
# ActiveRecord validation messages
activerecord:
errors:
messages:
inclusion: "nie je v zozname povolených hodnôt"
exclusion: "je vyhradené pre iný účel"
invalid: "nie je platná hodnota"
confirmation: "nebolo potvrdené"
accepted: "musí byť potvrdené"
empty: "nesmie byť prázdný/é"
blank: "je povinná položka"
too_long: "je príliš dlhá/ý (max. {{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)"
taken: "sa už nachádza v databáze"
not_a_number: "nie je číslo"
greater_than: "musí byť väčšíe ako {{count}}"
greater_than_or_equal_to: "musí byť väčšie alebo rovnaké ako {{count}}"
equal_to: "sa musí rovnať {{count}}"
less_than: "musí byť menšie ako {{count}}"
less_than_or_equal_to: "musí byť menšie ako {{count}}"
odd: "musí byť nepárne číslo"
even: "musí byť párne číslo"
template:
header:
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ť"
body: "Nasledujúce polia obsahujú chybne vyplnené údaje:"

View file

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