----\r
-log_file: log/mongrel.log\r
-port: 8000\r
-pid_file: tmp/mongrel.pid\r
+---
+log_file: log/mongrel.log
+port: 8000
+pid_file: tmp/mongrel.pid
servers: 8
\ No newline at end of file
-<?xml version="1.0" encoding="UTF-8"?>\r
-<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"\r
- xmlns:moz="http://www.mozilla.org/2006/browser/search/">\r
- <ShortName>OpenStreetMap</ShortName>\r
- <LongName>OpenStreetMap Search</LongName>\r
- <Description>Search for a place in OpenStreetMap, the Wiki World Map</Description>\r
- <InputEncoding>UTF-8</InputEncoding>\r
- <OutputEncoding>UTF-8</OutputEncoding>\r
- <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>\r
- <Url type="text/html" method="post" template="http://www.openstreetmap.org/">\r
- <Param name="query" value="{searchTerms}"/>\r
- </Url>\r
- <Query role="example" searchTerms="Reigate" />\r
- <Developer>Jonathan Bennett</Developer>\r
- <AdultContent>false</AdultContent>\r
- <Attribution>Data &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>\r
-</OpenSearchDescription>\r
+<?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 &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>
-= Composite Primary Keys for ActiveRecords\r
-\r
-== Summary\r
-\r
-ActiveRecords/Rails famously doesn't support composite primary keys. \r
-This RubyGem extends the activerecord gem to provide CPK support.\r
-\r
-== Installation\r
-\r
- gem install composite_primary_keys\r
- \r
-== Usage\r
- \r
- require 'composite_primary_keys'\r
- class ProductVariation\r
- set_primary_keys :product_id, :variation_seq\r
- end\r
- \r
- pv = ProductVariation.find(345, 12)\r
- \r
-It even supports composite foreign keys for associations.\r
-\r
-See http://compositekeys.rubyforge.org for more.\r
-\r
-== Running Tests\r
-\r
-See test/README.tests.txt\r
-\r
-== Url\r
-\r
-http://compositekeys.rubyforge.org\r
-\r
-== Questions, Discussion and Contributions\r
-\r
-http://groups.google.com/compositekeys\r
-\r
-== Author\r
-\r
-Written by Dr Nic Williams, drnicwilliams@gmail\r
-Contributions by many!\r
-\r
+= 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!
+
-require 'rubygems'\r
-require 'rake'\r
-require 'rake/clean'\r
-require 'rake/testtask'\r
-require 'rake/rdoctask'\r
-require 'rake/packagetask'\r
-require 'rake/gempackagetask'\r
-require 'rake/contrib/rubyforgepublisher'\r
-require 'fileutils'\r
-require 'hoe'\r
-include FileUtils\r
-require File.join(File.dirname(__FILE__), 'lib', 'composite_primary_keys', 'version')\r
-\r
-AUTHOR = "Dr Nic Williams"\r
-EMAIL = "drnicwilliams@gmail.com"\r
-DESCRIPTION = "Composite key support for ActiveRecords"\r
-GEM_NAME = "composite_primary_keys" # what ppl will type to install your gem\r
-if File.exists?("~/.rubyforge/user-config.yml")\r
- # TODO this should prob go in a local/ file\r
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))\r
- RUBYFORGE_USERNAME = config["username"]\r
-end\r
-RUBYFORGE_PROJECT = "compositekeys"\r
-HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"\r
-\r
-REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil\r
-VERS = ENV['VERSION'] || (CompositePrimaryKeys::VERSION::STRING + (REV ? ".#{REV}" : ""))\r
-CLEAN.include ['**/.*.sw?', '*.gem', '.config','debug.log','*.db','logfile','log/**/*','**/.DS_Store', '.project']\r
-RDOC_OPTS = ['--quiet', '--title', "newgem documentation",\r
- "--opname", "index.html",\r
- "--line-numbers", \r
- "--main", "README",\r
- "--inline-source"]\r
-\r
-class Hoe\r
- def extra_deps \r
- @extra_deps.reject { |x| Array(x).first == 'hoe' } \r
- end \r
-end\r
-\r
-# Generate all the Rake tasks\r
-# Run 'rake -T' to see list of generated tasks (from gem root directory)\r
-hoe = Hoe.new(GEM_NAME, VERS) do |p|\r
- p.author = AUTHOR \r
- p.description = DESCRIPTION\r
- p.email = EMAIL\r
- p.summary = DESCRIPTION\r
- p.url = HOMEPATH\r
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT\r
- p.test_globs = ["test/**/test*.rb"]\r
- p.clean_globs |= CLEAN #An array of file patterns to delete on clean.\r
-\r
- # == Optional\r
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")\r
- p.extra_deps = [['activerecord', '>= 2.2.0']] #An array of rubygem dependencies.\r
- #p.spec_extras - A hash of extra values to set in the gemspec.\r
-end\r
-\r
-CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")\r
-PATH = RUBYFORGE_PROJECT\r
-hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')\r
-\r
-PROJECT_ROOT = File.expand_path(".")\r
-\r
-require 'loader'\r
+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 'rbconfig'\r
-require 'find'\r
-require 'ftools'\r
-\r
-include Config\r
-\r
-# this was adapted from rdoc's install.rb by ways of Log4r\r
-\r
-$sitedir = CONFIG["sitelibdir"]\r
-unless $sitedir\r
- version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]\r
- $libdir = File.join(CONFIG["libdir"], "ruby", version)\r
- $sitedir = $:.find {|x| x =~ /site_ruby/ }\r
- if !$sitedir\r
- $sitedir = File.join($libdir, "site_ruby")\r
- elsif $sitedir !~ Regexp.quote(version)\r
- $sitedir = File.join($sitedir, version)\r
- end\r
-end\r
-\r
-# the acual gruntwork\r
-Dir.chdir("lib")\r
-\r
-Find.find("composite_primary_keys", "composite_primary_keys.rb") { |f|\r
- if f[-3..-1] == ".rb"\r
- File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)\r
- else\r
- File::makedirs(File.join($sitedir, *f.split(/\//)))\r
- end\r
-}\r
+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
+}
-#--\r
-# Copyright (c) 2006 Nic Williams\r
-#\r
-# Permission is hereby granted, free of charge, to any person obtaining\r
-# a copy of this software and associated documentation files (the\r
-# "Software"), to deal in the Software without restriction, including\r
-# without limitation the rights to use, copy, modify, merge, publish,\r
-# distribute, sublicense, and/or sell copies of the Software, and to\r
-# permit persons to whom the Software is furnished to do so, subject to\r
-# the following conditions:\r
-#\r
-# The above copyright notice and this permission notice shall be\r
-# included in all copies or substantial portions of the Software.\r
-#\r
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-#++\r
-\r
-$:.unshift(File.dirname(__FILE__)) unless\r
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))\r
-\r
-unless defined?(ActiveRecord)\r
- begin\r
- require 'active_record' \r
- rescue LoadError\r
- require 'rubygems'\r
- require_gem 'activerecord'\r
- end\r
-end\r
-\r
-require 'composite_primary_keys/fixtures'\r
-require 'composite_primary_keys/composite_arrays'\r
-require 'composite_primary_keys/associations'\r
-require 'composite_primary_keys/association_preload'\r
-require 'composite_primary_keys/reflection'\r
-require 'composite_primary_keys/base'\r
-require 'composite_primary_keys/calculations'\r
-require 'composite_primary_keys/migration'\r
-require 'composite_primary_keys/attribute_methods'\r
-\r
-ActiveRecord::Base.class_eval do\r
- include CompositePrimaryKeys::ActiveRecord::Base\r
-end\r
-\r
-Dir[File.dirname(__FILE__) + '/composite_primary_keys/connection_adapters/*.rb'].each do |adapter|\r
- begin\r
- require adapter.gsub('.rb','')\r
- rescue MissingSourceFile\r
- end\r
-end\r
+#--
+# 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
-module CompositePrimaryKeys\r
- module ActiveRecord #:nodoc:\r
- class CompositeKeyError < StandardError #:nodoc:\r
- end\r
-\r
- module Base #:nodoc:\r
-\r
- INVALID_FOR_COMPOSITE_KEYS = 'Not appropriate for composite primary keys'\r
- NOT_IMPLEMENTED_YET = 'Not implemented for composite primary keys yet'\r
-\r
- def self.append_features(base)\r
- super\r
- base.send(:include, InstanceMethods)\r
- base.extend(ClassMethods)\r
- end\r
-\r
- module ClassMethods\r
- def set_primary_keys(*keys)\r
- keys = keys.first if keys.first.is_a?(Array)\r
- keys = keys.map { |k| k.to_sym }\r
- cattr_accessor :primary_keys\r
- self.primary_keys = keys.to_composite_keys\r
-\r
- class_eval <<-EOV\r
- extend CompositeClassMethods\r
- include CompositeInstanceMethods\r
-\r
- include CompositePrimaryKeys::ActiveRecord::Associations\r
- include CompositePrimaryKeys::ActiveRecord::AssociationPreload\r
- include CompositePrimaryKeys::ActiveRecord::Calculations\r
- include CompositePrimaryKeys::ActiveRecord::AttributeMethods\r
- EOV\r
- end\r
-\r
- def composite?\r
- false\r
- end\r
- end\r
-\r
- module InstanceMethods\r
- def composite?; self.class.composite?; end\r
- end\r
-\r
- module CompositeInstanceMethods\r
-\r
- # A model instance's primary keys is always available as model.ids\r
- # whether you name it the default 'id' or set it to something else.\r
- def id\r
- attr_names = self.class.primary_keys\r
- CompositeIds.new(attr_names.map { |attr_name| read_attribute(attr_name) })\r
- end\r
- alias_method :ids, :id\r
-\r
- def to_param\r
- id.to_s\r
- end\r
-\r
- def id_before_type_cast #:nodoc:\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::NOT_IMPLEMENTED_YET\r
- end\r
-\r
- def quoted_id #:nodoc:\r
- [self.class.primary_keys, ids].\r
- transpose.\r
- map {|attr_name,id| quote_value(id, column_for_attribute(attr_name))}.\r
- to_composite_ids\r
- end\r
-\r
- # Sets the primary ID.\r
- def id=(ids)\r
- ids = ids.split(ID_SEP) if ids.is_a?(String)\r
- ids.flatten!\r
- unless ids.is_a?(Array) and ids.length == self.class.primary_keys.length\r
- raise "#{self.class}.id= requires #{self.class.primary_keys.length} ids"\r
- end\r
- [primary_keys, ids].transpose.each {|key, an_id| write_attribute(key , an_id)}\r
- id\r
- end\r
-\r
- # Returns a clone of the record that hasn't been assigned an id yet and\r
- # is treated as a new record. Note that this is a "shallow" clone:\r
- # it copies the object's attributes only, not its associations.\r
- # The extent of a "deep" clone is application-specific and is therefore\r
- # left to the application to implement according to its need.\r
- def clone\r
- attrs = self.attributes_before_type_cast\r
- self.class.primary_keys.each {|key| attrs.delete(key.to_s)}\r
- self.class.new do |record|\r
- record.send :instance_variable_set, '@attributes', attrs\r
- end\r
- end\r
-\r
-\r
- private\r
- # The xx_without_callbacks methods are overwritten as that is the end of the alias chain\r
-\r
- # Creates a new record with values matching those of the instance attributes.\r
- def create_without_callbacks\r
- unless self.id\r
- raise CompositeKeyError, "Composite keys do not generated ids from sequences, you must provide id values"\r
- end\r
- attributes_minus_pks = attributes_with_quotes(false)\r
- quoted_pk_columns = self.class.primary_key.map { |col| connection.quote_column_name(col) }\r
- cols = quoted_column_names(attributes_minus_pks) << quoted_pk_columns\r
- vals = attributes_minus_pks.values << quoted_id\r
- connection.insert(\r
- "INSERT INTO #{self.class.quoted_table_name} " +\r
- "(#{cols.join(', ')}) " +\r
- "VALUES (#{vals.join(', ')})",\r
- "#{self.class.name} Create",\r
- self.class.primary_key,\r
- self.id\r
- )\r
- @new_record = false\r
- return true\r
- end\r
-\r
- # Updates the associated record with values matching those of the instance attributes.\r
- def update_without_callbacks\r
- where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| \r
- "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"\r
- end\r
- where_clause = where_clause_terms.join(" AND ")\r
- connection.update(\r
- "UPDATE #{self.class.quoted_table_name} " +\r
- "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +\r
- "WHERE #{where_clause}",\r
- "#{self.class.name} Update"\r
- )\r
- return true\r
- end\r
-\r
- # Deletes the record in the database and freezes this instance to reflect that no changes should\r
- # be made (since they can't be persisted).\r
- def destroy_without_callbacks\r
- where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| \r
- "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"\r
- end\r
- where_clause = where_clause_terms.join(" AND ")\r
- unless new_record?\r
- connection.delete(\r
- "DELETE FROM #{self.class.quoted_table_name} " +\r
- "WHERE #{where_clause}",\r
- "#{self.class.name} Destroy"\r
- )\r
- end\r
- freeze\r
- end\r
- end\r
-\r
- module CompositeClassMethods\r
- def primary_key; primary_keys; end\r
- def primary_key=(keys); primary_keys = keys; end\r
-\r
- def composite?\r
- true\r
- end\r
-\r
- #ids_to_s([[1,2],[7,3]]) -> "(1,2),(7,3)"\r
- #ids_to_s([[1,2],[7,3]], ',', ';') -> "1,2;7,3"\r
- def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')\r
- many_ids.map {|ids| "#{left_bracket}#{ids}#{right_bracket}"}.join(list_sep)\r
- end\r
- \r
- # Creates WHERE condition from list of composited ids\r
- # 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)\r
- # 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)\r
- def composite_where_clause(ids)\r
- if ids.is_a?(String)\r
- ids = [[ids]]\r
- elsif not ids.first.is_a?(Array) # if single comp key passed, turn into an array of 1\r
- ids = [ids.to_composite_ids]\r
- end\r
- \r
- ids.map do |id_set|\r
- [primary_keys, id_set].transpose.map do |key, id|\r
- "#{table_name}.#{key.to_s}=#{sanitize(id)}"\r
- end.join(" AND ")\r
- end.join(") OR (") \r
- end\r
-\r
- # Returns true if the given +ids+ represents the primary keys of a record in the database, false otherwise.\r
- # Example:\r
- # Person.exists?(5,7)\r
- def exists?(ids)\r
- if ids.is_a?(Array) && ids.first.is_a?(String)\r
- count(:conditions => ids) > 0\r
- else\r
- obj = find(ids) rescue false\r
- !obj.nil? and obj.is_a?(self) \r
- end\r
- end\r
-\r
- # Deletes the record with the given +ids+ without instantiating an object first, e.g. delete(1,2)\r
- # If an array of ids is provided (e.g. delete([1,2], [3,4]), all of them\r
- # are deleted.\r
- def delete(*ids)\r
- unless ids.is_a?(Array); raise "*ids must be an Array"; end\r
- ids = [ids.to_composite_ids] if not ids.first.is_a?(Array)\r
- where_clause = ids.map do |id_set|\r
- [primary_keys, id_set].transpose.map do |key, id|\r
- "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{sanitize(id)}"\r
- end.join(" AND ")\r
- end.join(") OR (")\r
- delete_all([ "(#{where_clause})" ])\r
- end\r
-\r
- # Destroys the record with the given +ids+ by instantiating the object and calling #destroy (all the callbacks are the triggered).\r
- # If an array of ids is provided, all of them are destroyed.\r
- def destroy(*ids)\r
- unless ids.is_a?(Array); raise "*ids must be an Array"; end\r
- if ids.first.is_a?(Array)\r
- ids = ids.map{|compids| compids.to_composite_ids}\r
- else\r
- ids = ids.to_composite_ids\r
- end\r
- ids.first.is_a?(CompositeIds) ? ids.each { |id_set| find(id_set).destroy } : find(ids).destroy\r
- end\r
-\r
- # Returns an array of column objects for the table associated with this class.\r
- # Each column that matches to one of the primary keys has its\r
- # primary attribute set to true\r
- def columns\r
- unless @columns\r
- @columns = connection.columns(table_name, "#{name} Columns")\r
- @columns.each {|column| column.primary = primary_keys.include?(column.name.to_sym)}\r
- end\r
- @columns\r
- end\r
-\r
- ## DEACTIVATED METHODS ##\r
- public\r
- # Lazy-set the sequence name to the connection's default. This method\r
- # is only ever called once since set_sequence_name overrides it.\r
- def sequence_name #:nodoc:\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def reset_sequence_name #:nodoc:\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def set_primary_key(value = nil, &block)\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- private\r
- def find_one(id, options)\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def find_some(ids, options)\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def find_from_ids(ids, options)\r
- ids = ids.first if ids.last == nil\r
- conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]\r
- # if ids is just a flat list, then its size must = primary_key.length (one id per primary key, in order)\r
- # if ids is list of lists, then each inner list must follow rule above\r
- if ids.first.is_a? String\r
- # find '2,1' -> ids = ['2,1']\r
- # find '2,1;7,3' -> ids = ['2,1;7,3']\r
- ids = ids.first.split(ID_SET_SEP).map {|id_set| id_set.split(ID_SEP).to_composite_ids}\r
- # find '2,1;7,3' -> ids = [['2','1'],['7','3']], inner [] are CompositeIds\r
- end\r
- ids = [ids.to_composite_ids] if not ids.first.kind_of?(Array)\r
- ids.each do |id_set|\r
- unless id_set.is_a?(Array)\r
- raise "Ids must be in an Array, instead received: #{id_set.inspect}"\r
- end\r
- unless id_set.length == primary_keys.length\r
- raise "#{id_set.inspect}: Incorrect number of primary keys for #{class_name}: #{primary_keys.inspect}"\r
- end\r
- end\r
-\r
- # Let keys = [:a, :b]\r
- # If ids = [[10, 50], [11, 51]], then :conditions => \r
- # "(#{quoted_table_name}.a, #{quoted_table_name}.b) IN ((10, 50), (11, 51))"\r
-\r
- conditions = ids.map do |id_set|\r
- [primary_keys, id_set].transpose.map do |key, id|\r
- col = columns_hash[key.to_s]\r
- val = quote_value(id, col)\r
- "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{val}"\r
- end.join(" AND ")\r
- end.join(") OR (")\r
- \r
- options.update :conditions => "(#{conditions})"\r
-\r
- result = find_every(options)\r
-\r
- if result.size == ids.size\r
- ids.size == 1 ? result[0] : result\r
- else\r
- raise ::ActiveRecord::RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids.inspect})#{conditions}"\r
- end\r
- end\r
- end\r
- end\r
- end\r
-end\r
-\r
-\r
-module ActiveRecord\r
- ID_SEP = ','\r
- ID_SET_SEP = ';'\r
-\r
- class Base\r
- # Allows +attr_name+ to be the list of primary_keys, and returns the id\r
- # of the object\r
- # e.g. @object[@object.class.primary_key] => [1,1]\r
- def [](attr_name)\r
- if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first\r
- attr_name = attr_name.split(ID_SEP)\r
- end\r
- attr_name.is_a?(Array) ?\r
- attr_name.map {|name| read_attribute(name)} :\r
- read_attribute(attr_name)\r
- end\r
-\r
- # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.\r
- # (Alias for the protected write_attribute method).\r
- def []=(attr_name, value)\r
- if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first\r
- attr_name = attr_name.split(ID_SEP)\r
- end\r
-\r
- if attr_name.is_a? Array\r
- value = value.split(ID_SEP) if value.is_a? String\r
- unless value.length == attr_name.length\r
- raise "Number of attr_names and values do not match"\r
- end\r
- #breakpoint\r
- [attr_name, value].transpose.map {|name,val| write_attribute(name.to_s, val)}\r
- else\r
- write_attribute(attr_name, value)\r
- end\r
- end\r
- end\r
-end\r
+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\r
- ID_SEP = ','\r
- ID_SET_SEP = ';'\r
-\r
- module ArrayExtension\r
- def to_composite_keys\r
- CompositeKeys.new(self)\r
- end\r
-\r
- def to_composite_ids\r
- CompositeIds.new(self)\r
- end\r
- end\r
-\r
- class CompositeArray < Array\r
- def to_s\r
- join(ID_SEP)\r
- end\r
- end\r
-\r
- class CompositeKeys < CompositeArray\r
-\r
- end\r
-\r
- class CompositeIds < CompositeArray\r
-\r
- end\r
-end\r
-\r
-Array.send(:include, CompositePrimaryKeys::ArrayExtension)\r
+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 ActiveRecord\r
- module Reflection\r
- class AssociationReflection\r
- def primary_key_name\r
- return @primary_key_name if @primary_key_name\r
- case\r
- when macro == :belongs_to\r
- @primary_key_name = options[:foreign_key] || class_name.foreign_key\r
- when options[:as]\r
- @primary_key_name = options[:foreign_key] || "#{options[:as]}_id"\r
- else\r
- @primary_key_name = options[:foreign_key] || active_record.name.foreign_key\r
- end\r
- @primary_key_name = @primary_key_name.to_composite_keys.to_s if @primary_key_name.is_a? Array\r
- @primary_key_name\r
- end\r
- end\r
- end\r
+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
\ No newline at end of file
-module CompositePrimaryKeys\r
- module VERSION #:nodoc:\r
- MAJOR = 2\r
- MINOR = 2\r
- TINY = 2\r
- STRING = [MAJOR, MINOR, TINY].join('.')\r
- end\r
-end\r
+module CompositePrimaryKeys
+ module VERSION #:nodoc:
+ MAJOR = 2
+ MINOR = 2
+ TINY = 2
+ STRING = [MAJOR, MINOR, TINY].join('.')
+ end
+end
-class Article < ActiveRecord::Base\r
- has_many :readings\r
- has_many :users, :through => :readings\r
-end\r
-\r
+class Article < ActiveRecord::Base
+ has_many :readings
+ has_many :users, :through => :readings
+end
+
-first:\r
- id: 1\r
- name: Article One\r
-second:\r
- id: 2\r
+first:
+ id: 1
+ name: Article One
+second:
+ id: 2
name: Article Two
\ No newline at end of file
-class Product < ActiveRecord::Base\r
- set_primary_keys :id # redundant\r
- has_many :product_tariffs, :foreign_key => :product_id\r
- has_one :product_tariff, :foreign_key => :product_id\r
-\r
- has_many :tariffs, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]\r
-end\r
+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 ProductTariff < ActiveRecord::Base\r
- set_primary_keys :product_id, :tariff_id, :tariff_start_date\r
- belongs_to :product, :foreign_key => :product_id\r
- belongs_to :tariff, :foreign_key => [:tariff_id, :tariff_start_date]\r
-end\r
+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
-first_flat:\r
- product_id: 1\r
- tariff_id: 1\r
- tariff_start_date: <%= Date.today.to_s(:db) %>\r
-first_free: \r
- product_id: 1\r
- tariff_id: 2\r
- tariff_start_date: <%= Date.today.to_s(:db) %>\r
-second_free:\r
- product_id: 2\r
- tariff_id: 2\r
- tariff_start_date: <%= Date.today.to_s(:db) %>\r
+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_product:\r
- id: 1\r
- name: Product One\r
-second_product:\r
- id: 2\r
+first_product:
+ id: 1
+ name: Product One
+second_product:
+ id: 2
name: Product Two
\ No newline at end of file
-class Reading < ActiveRecord::Base\r
- belongs_to :article\r
- belongs_to :user\r
-end \r
+class Reading < ActiveRecord::Base
+ belongs_to :article
+ belongs_to :user
+end
-santiago_first:\r
- id: 1\r
- user_id: 1\r
- article_id: 1\r
- rating: 4\r
-santiago_second:\r
- id: 2\r
- user_id: 1\r
- article_id: 2\r
+santiago_first:
+ id: 1
+ user_id: 1
+ article_id: 1
+ rating: 4
+santiago_second:
+ id: 2
+ user_id: 1
+ article_id: 2
rating: 5
\ No newline at end of file
-class ReferenceCode < ActiveRecord::Base\r
- set_primary_keys :reference_type_id, :reference_code\r
- \r
- belongs_to :reference_type, :foreign_key => "reference_type_id"\r
- \r
- validates_presence_of :reference_code, :code_label, :abbreviation\r
-end\r
+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
-name_prefix_mr:\r
- reference_type_id: 1\r
- reference_code: 1\r
- code_label: MR\r
- abbreviation: Mr\r
-name_prefix_mrs:\r
- reference_type_id: 1\r
- reference_code: 2\r
- code_label: MRS\r
- abbreviation: Mrs\r
-name_prefix_ms:\r
- reference_type_id: 1\r
- reference_code: 3\r
- code_label: MS\r
- abbreviation: Ms\r
- \r
-gender_male:\r
- reference_type_id: 2\r
- reference_code: 1\r
- code_label: MALE\r
- abbreviation: Male\r
-gender_female:\r
- reference_type_id: 2\r
- reference_code: 2\r
- code_label: FEMALE\r
- abbreviation: Female\r
-\r
+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
+
\ No newline at end of file
-class ReferenceType < ActiveRecord::Base\r
- set_primary_key :reference_type_id\r
- has_many :reference_codes, :foreign_key => "reference_type_id"\r
- \r
- validates_presence_of :type_label, :abbreviation\r
- validates_uniqueness_of :type_label\r
-end\r
+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
-name_prefix:\r
- reference_type_id: 1\r
- type_label: NAME_PREFIX\r
- abbreviation: Name Prefix\r
-\r
-gender:\r
- reference_type_id: 2\r
- type_label: GENDER\r
- abbreviation: Gender\r
+name_prefix:
+ reference_type_id: 1
+ type_label: NAME_PREFIX
+ abbreviation: Name Prefix
+
+gender:
+ reference_type_id: 2
+ type_label: GENDER
+ abbreviation: Gender
-class Suburb < ActiveRecord::Base\r
- set_primary_keys :city_id, :suburb_id\r
- has_many :streets, :foreign_key => [:city_id, :suburb_id]\r
- has_many :first_streets, :foreign_key => [:city_id, :suburb_id], \r
- :class_name => 'Street', :conditions => "streets.name = 'First Street'"\r
+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
\ No newline at end of file
-first:\r
- city_id: 1\r
- suburb_id: 1\r
- name: First Suburb\r
-second:\r
- city_id: 2\r
- suburb_id: 1\r
- name: Second Suburb\r
+first:
+ city_id: 1
+ suburb_id: 1
+ name: First Suburb
+second:
+ city_id: 2
+ suburb_id: 1
+ name: Second Suburb
\ No newline at end of file
-class Tariff < ActiveRecord::Base\r
- set_primary_keys [:tariff_id, :start_date]\r
- has_many :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]\r
- has_one :product_tariff, :foreign_key => [:tariff_id, :tariff_start_date]\r
- has_many :products, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]\r
-end\r
+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
-flat:\r
- tariff_id: 1\r
- start_date: <%= Date.today.to_s(:db) %>\r
- amount: 50\r
-free:\r
- tariff_id: 2\r
- start_date: <%= Date.today.to_s(:db) %>\r
- amount: 0\r
-flat_future:\r
- tariff_id: 1\r
- start_date: <%= Date.today.next.to_s(:db) %>\r
- amount: 100\r
+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
\ No newline at end of file
-class User < ActiveRecord::Base\r
- has_many :readings\r
- has_many :articles, :through => :readings\r
- has_many :comments, :as => :person\r
- has_many :hacks, :through => :comments, :source => :hack\r
- \r
- def find_custom_articles\r
- articles.find(:all, :conditions => ["name = ?", "Article One"])\r
- end\r
-end\r
+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
-santiago:\r
- id: 1\r
- name: Santiago\r
-drnic:\r
- id: 2\r
+santiago:
+ id: 1
+ name: Santiago
+drnic:
+ id: 2
name: Dr Nic
\ No newline at end of file
-# From:\r
-# http://www.bigbold.com/snippets/posts/show/2178\r
-# http://blog.caboo.se/articles/2006/06/11/stupid-hash-tricks\r
-# \r
-# An example utilisation of these methods in a controller is:\r
-# def some_action\r
-# # some script kiddie also passed in :bee, which we don't want tampered with _here_.\r
-# @model = Model.create(params.pass(:foo, :bar))\r
-# end\r
-class Hash\r
-\r
- # lets through the keys in the argument\r
- # >> {:one => 1, :two => 2, :three => 3}.pass(:one)\r
- # => {:one=>1}\r
- def pass(*keys)\r
- keys = keys.first if keys.first.is_a?(Array)\r
- tmp = self.clone\r
- tmp.delete_if {|k,v| ! keys.include?(k.to_sym) }\r
- tmp.delete_if {|k,v| ! keys.include?(k.to_s) }\r
- tmp\r
- end\r
-\r
- # blocks the keys in the arguments\r
- # >> {:one => 1, :two => 2, :three => 3}.block(:one)\r
- # => {:two=>2, :three=>3}\r
- def block(*keys)\r
- keys = keys.first if keys.first.is_a?(Array)\r
- tmp = self.clone\r
- tmp.delete_if {|k,v| keys.include?(k.to_sym) }\r
- tmp.delete_if {|k,v| keys.include?(k.to_s) }\r
- tmp\r
- end\r
-\r
-end\r
+# 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
-require 'abstract_unit'\r
-require 'fixtures/article'\r
-require 'fixtures/product'\r
-require 'fixtures/tariff'\r
-require 'fixtures/product_tariff'\r
-require 'fixtures/suburb'\r
-require 'fixtures/street'\r
-require 'fixtures/restaurant'\r
-require 'fixtures/dorm'\r
-require 'fixtures/room'\r
-require 'fixtures/room_attribute'\r
-require 'fixtures/room_attribute_assignment'\r
-require 'fixtures/student'\r
-require 'fixtures/room_assignment'\r
-require 'fixtures/user'\r
-require 'fixtures/reading'\r
-\r
-class TestAssociations < Test::Unit::TestCase\r
- fixtures :articles, :products, :tariffs, :product_tariffs, :suburbs, :streets, :restaurants, :restaurants_suburbs,\r
- :dorms, :rooms, :room_attributes, :room_attribute_assignments, :students, :room_assignments, :users, :readings\r
- \r
- def test_has_many_through_with_conditions_when_through_association_is_not_composite\r
- user = User.find(:first)\r
- assert_equal 1, user.articles.find(:all, :conditions => ["articles.name = ?", "Article One"]).size\r
- end\r
-\r
- def test_has_many_through_with_conditions_when_through_association_is_composite\r
- room = Room.find(:first)\r
- assert_equal 0, room.room_attributes.find(:all, :conditions => ["room_attributes.name != ?", "keg"]).size\r
- end\r
-\r
- def test_has_many_through_on_custom_finder_when_through_association_is_composite_finder_when_through_association_is_not_composite\r
- user = User.find(:first)\r
- assert_equal 1, user.find_custom_articles.size\r
- end\r
-\r
- def test_has_many_through_on_custom_finder_when_through_association_is_composite\r
- room = Room.find(:first)\r
- assert_equal 0, room.find_custom_room_attributes.size\r
- end\r
- \r
- def test_count\r
- assert_equal 2, Product.count(:include => :product_tariffs)\r
- assert_equal 3, Tariff.count(:include => :product_tariffs)\r
- assert_equal 2, Tariff.count(:group => :start_date).size\r
- end\r
- \r
- def test_products\r
- assert_not_nil products(:first_product).product_tariffs\r
- assert_equal 2, products(:first_product).product_tariffs.length\r
- assert_not_nil products(:first_product).tariffs\r
- assert_equal 2, products(:first_product).tariffs.length\r
- assert_not_nil products(:first_product).product_tariff\r
- end\r
- \r
- def test_product_tariffs\r
- assert_not_nil product_tariffs(:first_flat).product\r
- assert_not_nil product_tariffs(:first_flat).tariff\r
- assert_equal Product, product_tariffs(:first_flat).product.class\r
- assert_equal Tariff, product_tariffs(:first_flat).tariff.class\r
- end\r
- \r
- def test_tariffs\r
- assert_not_nil tariffs(:flat).product_tariffs\r
- assert_equal 1, tariffs(:flat).product_tariffs.length\r
- assert_not_nil tariffs(:flat).products\r
- assert_equal 1, tariffs(:flat).products.length\r
- assert_not_nil tariffs(:flat).product_tariff\r
- end\r
- \r
- # Its not generating the instances of associated classes from the rows\r
- def test_find_includes_products\r
- assert @products = Product.find(:all, :include => :product_tariffs)\r
- assert_equal 2, @products.length\r
- assert_not_nil @products.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'\r
- assert_equal 3, @products.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, \r
- "Incorrect number of product_tariffs returned"\r
- end\r
- \r
- def test_find_includes_tariffs\r
- assert @tariffs = Tariff.find(:all, :include => :product_tariffs)\r
- assert_equal 3, @tariffs.length\r
- assert_not_nil @tariffs.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'\r
- assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, \r
- "Incorrect number of product_tariffs returnedturned"\r
- end\r
- \r
- def test_find_includes_product\r
- assert @product_tariffs = ProductTariff.find(:all, :include => :product)\r
- assert_equal 3, @product_tariffs.length\r
- assert_not_nil @product_tariffs.first.instance_variable_get('@product'), '@product not set'\r
- end\r
- \r
- def test_find_includes_comp_belongs_to_tariff\r
- assert @product_tariffs = ProductTariff.find(:all, :include => :tariff)\r
- assert_equal 3, @product_tariffs.length\r
- assert_not_nil @product_tariffs.first.instance_variable_get('@tariff'), '@tariff not set'\r
- end\r
- \r
- def test_find_includes_extended\r
- assert @products = Product.find(:all, :include => {:product_tariffs => :tariff})\r
- assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@product_tariffs').length},\r
- "Incorrect number of product_tariffs returned"\r
- \r
- assert @tariffs = Tariff.find(:all, :include => {:product_tariffs => :product})\r
- assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, \r
- "Incorrect number of product_tariffs returned"\r
- end\r
- \r
- def test_join_where_clause\r
- @product = Product.find(:first, :include => :product_tariffs)\r
- where_clause = @product.product_tariffs.composite_where_clause(\r
- ['foo','bar'], [1,2]\r
- )\r
- assert_equal('(foo=1 AND bar=2)', where_clause)\r
- end\r
- \r
- def test_has_many_through\r
- @products = Product.find(:all, :include => :tariffs)\r
- assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@tariffs').length},\r
- "Incorrect number of tariffs returned"\r
- end\r
- \r
- def test_has_many_through_when_not_pre_loaded\r
- student = Student.find(:first)\r
- rooms = student.rooms\r
- assert_equal 1, rooms.size\r
- assert_equal 1, rooms.first.dorm_id\r
- assert_equal 1, rooms.first.room_id\r
- end\r
- \r
- def test_has_many_through_when_through_association_is_composite\r
- dorm = Dorm.find(:first)\r
- assert_equal 1, dorm.rooms.length\r
- assert_equal 1, dorm.rooms.first.room_attributes.length\r
- assert_equal 'keg', dorm.rooms.first.room_attributes.first.name\r
- end\r
-\r
- def test_associations_with_conditions\r
- @suburb = Suburb.find([2, 1])\r
- assert_equal 2, @suburb.streets.size\r
-\r
- @suburb = Suburb.find([2, 1])\r
- assert_equal 1, @suburb.first_streets.size\r
-\r
- @suburb = Suburb.find([2, 1], :include => :streets)\r
- assert_equal 2, @suburb.streets.size\r
-\r
- @suburb = Suburb.find([2, 1], :include => :first_streets)\r
- assert_equal 1, @suburb.first_streets.size\r
- end\r
- \r
- def test_has_and_belongs_to_many\r
- @restaurant = Restaurant.find([1,1])\r
- assert_equal 2, @restaurant.suburbs.size\r
- \r
- @restaurant = Restaurant.find([1,1], :include => :suburbs)\r
- assert_equal 2, @restaurant.suburbs.size \r
- end\r
-end\r
+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'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestClone < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_truth\r
- testing_with do\r
- clone = @first.clone\r
- assert_equal @first.attributes.block(@klass.primary_key), clone.attributes\r
- if composite?\r
- @klass.primary_key.each {|key| assert_nil clone[key], "Primary key '#{key}' should be nil"} \r
- else\r
- assert_nil clone[@klass.primary_key], "Sole primary key should be nil"\r
- end\r
- end\r
- end\r
+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
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-require 'fixtures/department'\r
-require 'fixtures/employee'\r
-\r
-class TestDelete < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes, :departments, :employees\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_destroy_one\r
- testing_with do\r
- #assert @first.destroy\r
- assert true\r
- end\r
- end\r
- \r
- def test_destroy_one_via_class\r
- testing_with do\r
- assert @klass.destroy(*@first.id)\r
- end\r
- end\r
- \r
- def test_destroy_one_alone_via_class\r
- testing_with do\r
- assert @klass.destroy(@first.id)\r
- end\r
- end\r
- \r
- def test_delete_one\r
- testing_with do\r
- assert @klass.delete(*@first.id) if composite?\r
- end\r
- end\r
- \r
- def test_delete_one_alone\r
- testing_with do\r
- assert @klass.delete(@first.id)\r
- end\r
- end\r
- \r
- def test_delete_many\r
- testing_with do\r
- to_delete = @klass.find(:all)[0..1]\r
- assert_equal 2, to_delete.length\r
- end\r
- end\r
- \r
- def test_delete_all\r
- testing_with do\r
- @klass.delete_all\r
- end\r
- end\r
-\r
- def test_clear_association\r
- department = Department.find(1,1)\r
- assert_equal 2, department.employees.size, "Before clear employee count should be 2."\r
- department.employees.clear\r
- assert_equal 0, department.employees.size, "After clear employee count should be 0."\r
- department.reload\r
- assert_equal 0, department.employees.size, "After clear and a reload from DB employee count should be 0."\r
- end\r
-\r
- def test_delete_association\r
- department = Department.find(1,1)\r
- assert_equal 2, department.employees.size , "Before delete employee count should be 2."\r
- first_employee = department.employees[0]\r
- department.employees.delete(first_employee)\r
- assert_equal 1, department.employees.size, "After delete employee count should be 1."\r
- department.reload\r
- assert_equal 1, department.employees.size, "After delete and a reload from DB employee count should be 1."\r
- end\r
-\r
- def test_delete_records_for_has_many_association_with_composite_primary_key\r
- reference_type = ReferenceType.find(1)\r
- codes_to_delete = reference_type.reference_codes[0..1]\r
- assert_equal 3, reference_type.reference_codes.size, "Before deleting records reference_code count should be 3."\r
- reference_type.reference_codes.delete_records(codes_to_delete)\r
- reference_type.reload\r
- assert_equal 1, reference_type.reference_codes.size, "After deleting 2 records and a reload from DB reference_code count should be 1."\r
- end\r
-end\r
+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'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestDummy < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- classes = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = classes\r
- end\r
- \r
- def test_truth\r
- testing_with do\r
- assert true\r
- end\r
- end\r
+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
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-# Testing the find action on composite ActiveRecords with two primary keys\r
-class TestFind < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => [:reference_type_id],\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- :dual_strs => { \r
- :class => ReferenceCode,\r
- :primary_keys => ['reference_type_id', 'reference_code'],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_find_first\r
- testing_with do\r
- obj = @klass.find(:first)\r
- assert obj\r
- assert_equal @klass, obj.class\r
- end\r
- end\r
- \r
- def test_find\r
- testing_with do\r
- found = @klass.find(*first_id) # e.g. find(1,1) or find 1,1\r
- assert found\r
- assert_equal @klass, found.class\r
- assert_equal found, @klass.find(found.id)\r
- assert_equal found, @klass.find(found.to_param)\r
- end\r
- end\r
- \r
- def test_find_composite_ids\r
- testing_with do\r
- found = @klass.find(first_id) # e.g. find([1,1].to_composite_ids)\r
- assert found\r
- assert_equal @klass, found.class\r
- assert_equal found, @klass.find(found.id)\r
- assert_equal found, @klass.find(found.to_param)\r
- end\r
- end\r
- \r
- def test_to_param\r
- testing_with do\r
- assert_equal first_id_str, @first.to_param.to_s\r
- end\r
- end\r
- \r
- def things_to_look_at\r
- testing_with do\r
- assert_equal found, @klass.find(found.id.to_s) # fails for 2+ keys\r
- end\r
- end\r
- \r
- def test_not_found\r
- assert_raise(::ActiveRecord::RecordNotFound) do\r
- ReferenceCode.send :find, '999,999'\r
- end\r
- end\r
+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
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestIds < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => [:reference_type_id],\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- :dual_strs => { \r
- :class => ReferenceCode,\r
- :primary_keys => ['reference_type_id', 'reference_code'],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_id\r
- testing_with do\r
- assert_equal @first.id, @first.ids if composite?\r
- end\r
- end\r
- \r
- def test_id_to_s\r
- testing_with do\r
- assert_equal first_id_str, @first.id.to_s\r
- assert_equal first_id_str, "#{@first.id}"\r
- end\r
- end\r
- \r
- def test_ids_to_s\r
- testing_with do\r
- order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')\r
- to_test = @klass.find(:all, :order => order)[0..1].map(&:id)\r
- assert_equal '(1,1),(1,2)', @klass.ids_to_s(to_test) if @key_test == :dual\r
- assert_equal '1,1;1,2', @klass.ids_to_s(to_test, ',', ';', '', '') if @key_test == :dual\r
- end\r
- end\r
- \r
- def test_composite_where_clause\r
- testing_with do\r
- 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'\r
- assert_equal(where, @klass.composite_where_clause([[1, 2], [2, 2]])) if @key_test == :dual\r
- end\r
- end\r
- \r
- def test_set_ids_string\r
- testing_with do\r
- array = @primary_keys.collect {|key| 5}\r
- expected = composite? ? array.to_composite_keys : array.first\r
- @first.id = expected.to_s\r
- assert_equal expected, @first.id\r
- end\r
- end\r
- \r
- def test_set_ids_array\r
- testing_with do\r
- array = @primary_keys.collect {|key| 5}\r
- expected = composite? ? array.to_composite_keys : array.first\r
- @first.id = expected\r
- assert_equal expected, @first.id\r
- end\r
- end\r
- \r
- def test_set_ids_comp\r
- testing_with do\r
- array = @primary_keys.collect {|key| 5}\r
- expected = composite? ? array.to_composite_keys : array.first\r
- @first.id = expected\r
- assert_equal expected, @first.id\r
- end\r
- end\r
- \r
- def test_primary_keys\r
- testing_with do\r
- if composite?\r
- assert_not_nil @klass.primary_keys\r
- assert_equal @primary_keys.map {|key| key.to_sym}, @klass.primary_keys\r
- assert_equal @klass.primary_keys, @klass.primary_key\r
- else\r
- assert_not_nil @klass.primary_key\r
- assert_equal @primary_keys, [@klass.primary_key.to_sym]\r
- end\r
- assert_equal @primary_keys.join(','), @klass.primary_key.to_s\r
- # Need a :primary_keys should be Array with to_s overridden\r
- end\r
- end\r
+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
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestMiscellaneous < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes, :products\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
-\r
- def test_composite_class\r
- testing_with do\r
- assert_equal composite?, @klass.composite?\r
- end\r
- end\r
-\r
- def test_composite_instance\r
- testing_with do\r
- assert_equal composite?, @first.composite?\r
- end\r
- end\r
- \r
- def test_count\r
- assert_equal 2, Product.count\r
- end\r
- \r
+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
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-require 'plugins/pagination'\r
-\r
-class TestPagination < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- include ActionController::Pagination\r
- DEFAULT_PAGE_SIZE = 2\r
- \r
- attr_accessor :params\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- :table => :reference_types,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- :table => :reference_codes,\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- @params = {}\r
- end\r
-\r
- def test_paginate_all\r
- testing_with do\r
- @object_pages, @objects = paginate @klass_info[:table], :per_page => DEFAULT_PAGE_SIZE\r
- assert_equal 2, @objects.length, "Each page should have #{DEFAULT_PAGE_SIZE} items"\r
- end\r
- end\r
+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
\ No newline at end of file
-# Test cases devised by Santiago that broke the Composite Primary Keys\r
-# code at one point in time. But no more!!!\r
-\r
-require 'abstract_unit'\r
-require 'fixtures/user'\r
-require 'fixtures/article'\r
-require 'fixtures/reading'\r
-\r
-class TestSantiago < Test::Unit::TestCase\r
- fixtures :suburbs, :streets, :users, :articles, :readings\r
- \r
- def test_normal_and_composite_associations\r
- assert_not_nil @suburb = Suburb.find(1,1)\r
- assert_equal 1, @suburb.streets.length\r
- \r
- assert_not_nil @street = Street.find(1)\r
- assert_not_nil @street.suburb\r
- end\r
- \r
- def test_single_keys\r
- @santiago = User.find(1)\r
- assert_not_nil @santiago.articles\r
- assert_equal 2, @santiago.articles.length\r
- assert_not_nil @santiago.readings\r
- assert_equal 2, @santiago.readings.length\r
- end\r
-end\r
+# 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
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestUpdate < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- :update => { :description => 'RT Desc' },\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- :update => { :description => 'RT Desc' },\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_setup\r
- testing_with do\r
- assert_not_nil @klass_info[:update]\r
- end\r
- end\r
- \r
- def test_update_attributes\r
- testing_with do\r
- assert @first.update_attributes(@klass_info[:update])\r
- assert @first.reload\r
- @klass_info[:update].each_pair do |attr_name, new_value|\r
- assert_equal new_value, @first[attr_name], "Attribute #{attr_name} is incorrect"\r
- end\r
- end\r
- end\r
+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
\ No newline at end of file
-body {\r
- background-color: #2F30EE;\r
- font-family: "Georgia", sans-serif;\r
- font-size: 16px;\r
- line-height: 1.6em;\r
- padding: 1.6em 0 0 0;\r
- color: #eee;\r
-}\r
-h1, h2, h3, h4, h5, h6 {\r
- color: #FFEDFA;\r
-}\r
-h1 { \r
- font-family: sans-serif;\r
- font-weight: normal;\r
- font-size: 4em;\r
- line-height: 0.8em;\r
- letter-spacing: -0.1ex;\r
- margin: 5px;\r
-}\r
-li {\r
- padding: 0;\r
- margin: 0;\r
- list-style-type: square;\r
-}\r
-a {\r
- color: #99f;\r
- font-weight: normal;\r
- text-decoration: underline;\r
-}\r
-blockquote {\r
- font-size: 90%;\r
- font-style: italic;\r
- border-left: 1px solid #eee;\r
- padding-left: 1em;\r
-}\r
-.caps {\r
- font-size: 80%;\r
-}\r
-\r
-#main {\r
- width: 45em;\r
- padding: 0;\r
- margin: 0 auto;\r
-}\r
-.coda {\r
- text-align: right;\r
- color: #77f;\r
- font-size: smaller;\r
-}\r
-\r
-table {\r
- font-size: 90%;\r
- line-height: 1.4em;\r
- color: #ff8;\r
- background-color: #111;\r
- padding: 2px 10px 2px 10px;\r
- border-style: dashed;\r
-}\r
-\r
-th {\r
- color: #fff;\r
-}\r
-\r
-td {\r
- padding: 2px 10px 2px 10px;\r
-}\r
-\r
-.success {\r
- color: #0CC52B;\r
-}\r
-\r
-.failed {\r
- color: #E90A1B;\r
-}\r
-\r
-.unknown {\r
- color: #995000;\r
-}\r
-pre, code {\r
- font-family: monospace;\r
- font-size: 90%;\r
- line-height: 1.4em;\r
- color: #ff8;\r
- background-color: #111;\r
- padding: 2px 10px 2px 10px;\r
-}\r
-.comment { color: #aaa; font-style: italic; }\r
-.keyword { color: #eff; font-weight: bold; }\r
-.punct { color: #eee; font-weight: bold; }\r
-.symbol { color: #0bb; }\r
-.string { color: #6b4; }\r
-.ident { color: #ff8; }\r
-.constant { color: #66f; }\r
-.regex { color: #ec6; }\r
-.number { color: #F99; }\r
-.expr { color: #227; }\r
-\r
-#version {\r
- float: right;\r
- text-align: right;\r
- font-family: sans-serif;\r
- font-weight: normal;\r
- background-color: #ff8;\r
- color: #66f;\r
- padding: 15px 20px 10px 20px;\r
- margin: 0 auto;\r
- margin-top: 15px;\r
- border: 3px solid #66f;\r
-}\r
-\r
-#version .numbers {\r
- display: block;\r
- font-size: 4em;\r
- line-height: 0.8em;\r
- letter-spacing: -0.1ex;\r
-}\r
-\r
-#version a {\r
- text-decoration: none;\r
-}\r
-\r
-.clickable {\r
- cursor: pointer; \r
- cursor: hand;\r
-}\r
-\r
+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;
+}
+
-h1. Announcement JS file\r
+h1. Announcement JS file
MagicAnnouncement.show('compositekeys', version);
\ No newline at end of file
// Version JS file
var version = "2.2.2";
-\r
+
document.write(" - " + version);
-h1. Version JS file\r
-\r
+h1. Version JS file
+
document.write(" - " + version);
\ No newline at end of file
-# Lower Sorbian translations for Ruby on Rails\r
-# by Michael Wolf (preklady@wolfmicha.de)\r
-\r
-dsb:\r
- # ActiveSupport\r
- support:\r
- array:\r
- words_connector: ", "\r
- two_words_connector: " a "\r
- last_word_connector: " a "\r
- sentence_connector: "a"\r
- skip_last_comma: true\r
-\r
- # Date\r
- date:\r
- formats:\r
- default: "%d. %m. %Y"\r
- short: "%d %b"\r
- long: "%d. %B %Y"\r
- day_names: [njeźela, pónjeźele, wałtora, srjoda, stwórtk, pětk, sobota]\r
- abbr_day_names: [Nj, Pó, Wu, Sr, St, Pě, So]\r
- month_names: [~, Januar, Februar, Měrc, Apryl, Maj, Junij, Julij, Awgust, September, Oktober, Nowember, December]\r
- abbr_month_names: [~, jan, feb, měr, apr, maj, jun, jul, awg, sep, okt, now, dec]\r
- order: [:day, :month, :year]\r
-\r
- # Time\r
- time:\r
- formats:\r
- default: "%A, %d. %B %Y, %H:%M hodź"\r
- short: "%d. %B, %H:%M hodź."\r
- long: "%A, %d. %B %Y, %H:%M hodź."\r
- am: "dopołdnja"\r
- pm: "wótpołdnja"\r
-\r
-\r
- # Numbers\r
- number:\r
- format:\r
- precision: 3\r
- separator: ","\r
- delimiter: "."\r
- currency:\r
- format:\r
- unit: "€"\r
- precision: 2\r
- format: "%n %u"\r
- separator: ","\r
- delimiter: " "\r
- human:\r
- format:\r
- precision: 1\r
- delimiter: ""\r
- storage_units:\r
- format: "%n %u"\r
- units:\r
- byte:\r
- one: "bajt"\r
- two: "bajta"\r
- few: "bajty"\r
- other: "bajtow"\r
- kb: "KB"\r
- mb: "MB"\r
- gb: "GB"\r
- tb: "TB"\r
-\r
- percentage:\r
- format:\r
- delimiter: ""\r
-\r
- precision:\r
- format:\r
- delimiter: ""\r
-\r
-\r
- # Distance of time ... helper\r
- # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()\r
- datetime:\r
- distance_in_words:\r
- half_a_minute: "poł minuty"\r
- less_than_x_seconds:\r
- one: "mjenjej ako 1 sekundu"\r
- two: "mjenjej ako {{count}} sekundoma"\r
- few: "mjenjej ako {{count}} sekundami"\r
- other: "mjenjej ako {{count}} sekundami"\r
- x_seconds:\r
- one: "1 sekundu"\r
- two: "{{count}} sekundoma"\r
- few: "{{count}} sekundami"\r
- other: "{{count}} sekundami"\r
- less_than_x_minutes:\r
- one: "mjenjej ako 1 minutu"\r
- two: "mjenjej ako {{count}} minutoma"\r
- few: "mjenjej ako {{count}} minutami"\r
- other: "mjenjej ako {{count}} minutami"\r
- x_minutes:\r
- one: "1 minutu"\r
- two: "{{count}} minutoma"\r
- few: "{{count}} minutami"\r
- other: "{{count}} minutami"\r
- about_x_hours:\r
- one: "něźi 1 góźinu"\r
- two: "něźi {{count}} góźinoma"\r
- few: "něźi {{count}} góźinami"\r
- other: "něźi {{count}} góźinami"\r
- x_days:\r
- one: "1 dnjom"\r
- two: "{{count}} dnjoma"\r
- few: "{{count}} dnjami"\r
- other: "{{count}} dnjami"\r
- about_x_months:\r
- one: "něźi 1 mjasecom"\r
- two: "něźi {{count}} mjasecoma"\r
- few: "něźi {{count}} mjasecami"\r
- other: "něźi {{count}} mjasecami"\r
- x_months:\r
- one: "1 mjasecom"\r
- two: "{{count}} mjasecoma"\r
- few: "{{count}} mjasecami"\r
- other: "{{count}} mjasecami"\r
- about_x_years:\r
- one: "něźi 1 lětom"\r
- two: "něźi {{count}} lětoma"\r
- few: "něźi {{count}} lětami"\r
- other: "něźi {{count}} lětami"\r
- over_x_years:\r
- one: "wěcej ako 1 lětom"\r
- two: "wěcej ako {{count}} lětoma"\r
- few: "wěcej ako {{count}} lětami"\r
- other: "wěcej ako {{count}} lětami"\r
- prompts:\r
- year: "Lěto"\r
- month: "Mjasec"\r
- day: "Źeń"\r
- hour: "Góźina"\r
- minute: "Minuta"\r
- second: "Sekunda"\r
-\r
- # ActiveRecord validation messages\r
- activerecord:\r
- errors:\r
- messages:\r
- inclusion: "njejo płaśiwa gódnota"\r
- exclusion: "njestoj k dispoziciji"\r
- invalid: "njejo płaśiwy"\r
- confirmation: "njejo se wobkšuśiło"\r
- accepted: "musy se wobkšuśiś"\r
- empty: "njesmějo prozny byś"\r
- blank: "jo trěbny"\r
- too_long:\r
- one: "jo pśedłujki (maks. 1 znamješko)"\r
- two: "jo pśedłujki (maks. {{count}} znamješce)"\r
- few: "jo pśedłujki (maks. {{count}} znamješka)"\r
- other: "jo pśedłujki (maks. {{count}} znamješkow)"\r
- too_short:\r
- one: "jo překrotki (min. 1 znamješko)"\r
- two: "jo překrotki (min. {{count}} znamješće)"\r
- few: "jo překrotki (min. {{count}} znamješka)"\r
- other: "jo překrotki (min. {{count}} znamješkow)"\r
- wrong_length:\r
- one: "njama pšawu dłujkosć (1 znamješko wócakane)"\r
- two: "njama pšawu dłujkosć ({{count}} znamješce wócakanej)"\r
- few: "njama pšawu dłujkosć ({{count}} znamješka wócakane)"\r
- other: "njama pšawu dłujkosć ({{count}} znamješkow wócakanych)"\r
- taken: "jo južo w datowej bance"\r
- not_a_number: "njejo licba"\r
- greater_than: "musy wětšy ako {{count}} byś"\r
- greater_than_or_equal_to: "musy wětšy abo jadnak {{count}} być"\r
- equal_to: "musy jadnak {{count}} byś"\r
- less_than: "musy mjeńšy ako {{count}} byś"\r
- less_than_or_equal_to: "musy mjeńšy abo jadnak {{count}} byś"\r
- odd: "musy njerowna licba byś"\r
- even: "musy rowna licba byś"\r
-\r
- template:\r
- header:\r
- one: "Pśi składowanju objekta {{model}} jo k zmólce dojšło a njejo było móžno składowaś"\r
- two: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"\r
- few: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"\r
- other: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"\r
- body: "Pšosym pśeglědaj slědujuce póla:"\r
-\r
- models:\r
+# 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:
-# Upper Sorbian translations for Ruby on Rails\r
-# by Michael Wolf (preklady@wolfmicha.de)\r
-\r
-hsb:\r
-\r
- # ActiveSupport\r
- support:\r
- array:\r
- words_connector: ", "\r
- two_words_connector: " a "\r
- last_word_connector: " a "\r
- sentence_connector: "a"\r
- skip_last_comma: true\r
-\r
-\r
-\r
- # Date\r
- date:\r
- formats:\r
- default: "%d. %m. %Y"\r
- short: "%d %b"\r
- long: "%d. %B %Y"\r
-\r
- day_names: [njedźela, póndźela, wutora, srjeda, štwórtk, pjatk, sobota]\r
- abbr_day_names: [Nj, Pó, Wu, Sr, Št, Pj, So]\r
- month_names: [~, Januar, Februar, Měrc, Apryl, Meja, Junij, Julij, Awgust, September, Oktober, Nowember, December]\r
- abbr_month_names: [~, jan, feb, měr, apr, mej, jun, jul, awg, sep, okt, now, dec]\r
- order: [:day, :month, :year]\r
-\r
- # Time\r
- time:\r
- formats:\r
- default: "%A, %d. %B %Y, %H:%M hodź"\r
- short: "%d. %B, %H:%M hodź."\r
- long: "%A, %d. %B %Y, %H:%M hodź."\r
-\r
- am: "dopołdnja"\r
- pm: "popołdnju"\r
-\r
-\r
- # Numbers\r
- number:\r
- format:\r
- precision: 3\r
- separator: ","\r
- delimiter: "."\r
-\r
- currency:\r
- format:\r
- unit: "€"\r
- precision: 2\r
- format: "%n %u"\r
- separator: ","\r
- delimiter: " "\r
-\r
- human:\r
- format:\r
- precision: 1\r
- delimiter: ""\r
-\r
- storage_units:\r
- format: "%n %u"\r
- units:\r
- byte:\r
- one: "bajt"\r
- two: "bajtaj"\r
- few: "bajty"\r
- other: "bajtow"\r
- kb: "KB"\r
- mb: "MB"\r
- gb: "GB"\r
- tb: "TB"\r
-\r
- percentage:\r
- format:\r
- delimiter: ""\r
-\r
- precision:\r
- format:\r
- delimiter: ""\r
-\r
-\r
- # Distance of time ... helper\r
- # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()\r
- datetime:\r
- distance_in_words:\r
- half_a_minute: "poł mjeńšiny"\r
- less_than_x_seconds:\r
- one: "mjenje hač 1 sekundu"\r
- two: "mjenje hač {{count}} sekundomaj"\r
- few: "mjenje hač {{count}} sekundami"\r
- other: "mjenje hač {{count}} sekundami"\r
- x_seconds:\r
- one: "1 sekundu"\r
- two: "{{count}} sekundomaj"\r
- few: "{{count}} sekundami"\r
- other: "{{count}} sekundami"\r
- less_than_x_minutes:\r
- one: "mjenje hač 1 mjeńšinu"\r
- two: "mjenje hač {{count}} mjeńšinomaj"\r
- few: "mjenje hač {{count}} mjeńšinami"\r
- other: "mjenje hač {{count}} mjeńšinami"\r
- x_minutes:\r
- one: "1 mjeńšinu"\r
- two: "{{count}} mjeńšinomaj"\r
- few: "{{count}} mjeńšinami"\r
- other: "{{count}} mjeńšinami"\r
- about_x_hours:\r
- one: "něhdźe 1 hodźinu"\r
- two: "něhdźe {{count}} hodźinomaj"\r
- few: "něhdźe {{count}} hodźinami"\r
- other: "něhdźe {{count}} hodźinami"\r
- x_days:\r
- one: "1 dnjom"\r
- two: "{{count}} dnjomaj"\r
- few: "{{count}} dnjemi"\r
- other: "{{count}} dnjemi"\r
- about_x_months:\r
- one: "něhdźe 1 měsacom"\r
- two: "něhdźe {{count}} měsacomaj"\r
- few: "něhdźe {{count}} měsacami"\r
- other: "něhdźe {{count}} měsacami"\r
- x_months:\r
- one: "1 měsacom"\r
- two: "{{count}} měsacomaj"\r
- few: "{{count}} měsacami"\r
- other: "{{count}} měsacami"\r
- about_x_years:\r
- one: "něhdźe 1 lětom"\r
- two: "něhdźe {{count}} lětomaj"\r
- few: "něhdźe {{count}} lětami"\r
- other: "něhdźe {{count}} lětami"\r
- over_x_years:\r
- one: "přez 1 lětom"\r
- two: "přez {{count}} lětomaj"\r
- few: "přez {{count}} lětami"\r
- other: "přez {{count}} lětami"\r
- prompts:\r
- year: "Lěto"\r
- month: "Měsac"\r
- day: "Dźeń"\r
- hour: "Hodźina"\r
- minute: "Mjeńšina"\r
- second: "Sekunda"\r
-\r
- # ActiveRecord validation messages\r
- activerecord:\r
- errors:\r
- messages:\r
- inclusion: "njeje płaćiwa hódnota"\r
- exclusion: "njesteji k dispoziciji"\r
- invalid: "njeje płaćiwy"\r
- confirmation: "njebu wobkrućene"\r
- accepted: "dyrbi so wobkrućić"\r
- empty: "njesmě prózdny być"\r
- blank: "je trěbny"\r
- too_long: \r
- one: "je předołhi (maks. 1 znamješko)"\r
- two: "je předołhi (maks. {{count}} znamješce)"\r
- few: "je předołhi (maks. {{count}} znamješka)"\r
- other: "je předołhi (maks. {{count}} znamješkow)"\r
- too_short: \r
- one: "je překrótki (min. 1 znamješko)"\r
- two: "je překrótki (min. {{count}} znamješće)"\r
- few: "je překrótki (min. {{count}} znamješka)"\r
- other: "je překrótki (min. {{count}} znamješkow)"\r
- wrong_length:\r
- one: "nima prawu dołhosć (1 znamješko wočakowane)"\r
- two: "nima prawu dołhosć ({{count}} znamješce wočakowanej)"\r
- few: "nima prawu dołhosć ({{count}} znamješka wočakowane)"\r
- other: "nima prawu dołhosć ({{count}} znamješkow wočakowanych)"\r
- taken: "je hižo w datowej bance"\r
- not_a_number: "njeje ličba"\r
- greater_than: "dyrbi wjetši hač {{count}} być"\r
- greater_than_or_equal_to: "dyrbi wjetši abo runja {{count}} być"\r
- equal_to: "dyrbi runja {{count}} być"\r
- less_than: "dyrbi mjenje hač {{count}} być"\r
- less_than_or_equal_to: "dyrbi mjenje abo runja {{count}} być"\r
- odd: "dyrbi njeruna ličby być"\r
- even: "dyrbi runa ličba być"\r
-\r
- template:\r
- header:\r
- one: "Při składowanju objekta {{model}} je k zmylkej dóšło a njebě móžno składować"\r
- two: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"\r
- few: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"\r
- other: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"\r
- body: "Prošu přepruwuj slědowace pola:"\r
-\r
- models:\r
+# 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:
-# Sample localization file for English. Add more files in this directory for other locales.\r
-# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.\r
-\r
-# Slovak translations for Ruby on Rails (inspired by the Czech localization - thanx to Karel Minařík)\r
-# by Jozef Fulop (jofi-rails@silake.com)\r
- \r
-sk:\r
- # ActiveSupport\r
- support:\r
- array:\r
- words_connector: ', '\r
- two_words_connector: ' a '\r
- last_word_connector: ' a '\r
- \r
- # Date\r
- date:\r
- formats:\r
- default: "%d. %m. %Y"\r
- short: "%d %b"\r
- long: "%d. %B %Y"\r
- day_names: [Nedeľa, Pondelok, Utorok, Streda, Štvrtok, Piatok, Sobota]\r
- abbr_day_names: [Ne, Po, Ut, St, Št, Pi, So]\r
- month_names: [~, Január, Február, Marec, Apríl, Máj, Jún, Júl, August, September, Október, November, December]\r
- abbr_month_names: [~, Jan, Feb, Mar, Apr, Máj, Jún, Júl, Aug, Sep, Okt, Nov, Dec]\r
- order: [:day, :month, :year]\r
-\r
- # Time\r
- time:\r
- formats:\r
- default: "%a %d. %B %Y %H:%M %z"\r
- short: "%d. %m. %H:%M"\r
- long: "%A %d. %B %Y %H:%M"\r
- am: 'dopoludnia'\r
- pm: 'popoludní'\r
-\r
- # Numbers\r
- number:\r
- format:\r
- precision: 3\r
- separator: '.'\r
- delimiter: ','\r
- currency:\r
- format:\r
- unit: '€'\r
- precision: 2\r
- format: '%n %u'\r
- separator: ","\r
- delimiter: " "\r
- human:\r
- format:\r
- precision: 1\r
- delimiter: ''\r
- storage_units:\r
- format: "%n %u"\r
- units:\r
- byte:\r
- other: "B"\r
- one: "B"\r
- kb: "KB"\r
- mb: "MB"\r
- gb: "GB"\r
- tb: "TB"\r
- percentage:\r
- format:\r
- delimiter: ''\r
- precision:\r
- format:\r
- delimiter: ''\r
- \r
- # Distance of time ... helper\r
- datetime:\r
- prompts:\r
- second: "Sekunda"\r
- minute: "Minúta"\r
- hour: "Hodina"\r
- day: "Deň"\r
- month: "Mesiac"\r
- year: "Rok"\r
- distance_in_words: \r
- half_a_minute: 'pol minutou'\r
- less_than_x_seconds:\r
- one: 'asi pred sekundou'\r
- other: 'asi pred {{count}} sekundami'\r
- x_seconds:\r
- one: 'sekundou'\r
- other: '{{count}} sekundami'\r
- less_than_x_minutes:\r
- one: 'pred necelou minútou'\r
- other: 'pred ani nie {{count}} minútami'\r
- x_minutes:\r
- one: 'minútou'\r
- other: '{{count}} minútami'\r
- about_x_hours:\r
- one: 'asi hodinou'\r
- other: 'asi {{count}} hodinami'\r
- x_days:\r
- one: '24 hodinami'\r
- other: '{{count}} dňami'\r
- about_x_months:\r
- one: 'asi mesiacom'\r
- other: 'asi {{count}} mesiacmi'\r
- x_months:\r
- one: 'mesiacom'\r
- other: '{{count}} mesiacmi'\r
- about_x_years:\r
- one: 'asi rokom'\r
- other: 'asi {{count}} rokmi'\r
- over_x_years:\r
- one: 'pred viac ako rokom'\r
- other: 'viac ako {{count}} rokmi'\r
-\r
- # ActiveRecord validation messages\r
- activerecord: \r
- errors:\r
- messages:\r
- inclusion: "nie je v zozname povolených hodnôt"\r
- exclusion: "je vyhradené pre iný účel"\r
- invalid: "nie je platná hodnota"\r
- confirmation: "nebolo potvrdené"\r
- accepted: "musí byť potvrdené"\r
- empty: "nesmie byť prázdný/é"\r
- blank: "je povinná položka"\r
- too_long: "je príliš dlhá/ý (max. {{count}} znakov)"\r
- too_short: "je príliš krátký/á (min. {{count}} znakov)"\r
- wrong_length: "nemá správnu dĺžku (očakáva sa {{count}} znakov)"\r
- taken: "sa už nachádza v databáze"\r
- not_a_number: "nie je číslo"\r
- greater_than: "musí byť väčšíe ako {{count}}"\r
- greater_than_or_equal_to: "musí byť väčšie alebo rovnaké ako {{count}}"\r
- equal_to: "sa musí rovnať {{count}}"\r
- less_than: "musí byť menšie ako {{count}}"\r
- less_than_or_equal_to: "musí byť menšie ako {{count}}"\r
- odd: "musí byť nepárne číslo"\r
- even: "musí byť párne číslo"\r
- template:\r
- header:\r
- one: "Pri ukladaní objektu {{model}} došlo k chybám a nebolo možné objekt uložiť"\r
- other: "Pri ukladaní objektu {{model}} došlo ku {{count}} chybe/ám a nebolo možné objekt uložiť"\r
- body: "Nasledujúce polia obsahujú chybne vyplnené údaje:"\r
+# 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:"
-Copyright (c) 2006 Alex Dunae\r
-\r
-Permission is hereby granted, free of charge, to any person obtaining\r
-a copy of this software and associated documentation files (the\r
-"Software"), to deal in the Software without restriction, including\r
-without limitation the rights to use, copy, modify, merge, publish,\r
-distribute, sublicense, and/or sell copies of the Software, and to\r
-permit persons to whom the Software is furnished to do so, subject to\r
-the following conditions:\r
-\r
-The above copyright notice and this permission notice shall be\r
-included in all copies or substantial portions of the Software.\r
-\r
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+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.
-require 'validates_email_format_of'\r
+require 'validates_email_format_of'