yaml_conditions 0.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +34 -0
- data/README.rdoc +66 -0
- data/Rakefile +16 -0
- data/TESTS.rdoc +12 -0
- data/bin/console.sh +2 -0
- data/init.rb +1 -0
- data/lib/orms/active_record.rb +8 -0
- data/lib/orms/active_record/version2/delayed_job.rb +44 -0
- data/lib/orms/active_record/version_2.rb +45 -0
- data/lib/orms/active_record/version_3.rb +7 -0
- data/lib/orms/datamapper.rb +4 -0
- data/lib/yaml/conditions.rb +19 -0
- data/lib/yaml/query_builder.rb +150 -0
- data/lib/yaml/query_builder/sql/mysql.rb +15 -0
- data/lib/yaml/query_builder/sql/postgresql.rb +15 -0
- data/lib/yaml_conditions.rb +15 -0
- data/out.txt +0 -0
- data/spec/ar_spec_helper.rb +33 -0
- data/spec/cases/orms/active_record/version_2_delayed_job_spec.rb +177 -0
- data/spec/cases/orms/active_record/version_2_spec.rb +346 -0
- data/spec/connections/mysql/connection.rb +18 -0
- data/spec/connections/postgresql/connection.rb +18 -0
- data/spec/datamapper_spec_helper.rb +2 -0
- data/spec/models/delayed/job.rb +6 -0
- data/spec/models/delayed/performable_method.rb +4 -0
- data/spec/models/job.rb +5 -0
- data/spec/models/period.rb +2 -0
- data/spec/models/priority.rb +5 -0
- data/spec/models/user.rb +3 -0
- data/spec/models/user_data.rb +3 -0
- data/spec/schema.rb +44 -0
- data/spec/spec_helper.rb +13 -0
- data/tasks/yaml_conditions.rake +147 -0
- data/yaml_conditions.gemspec +35 -0
- metadata +132 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
print "Using native MySQL\n"
|
2
|
+
require 'logger'
|
3
|
+
$ADAPTER = 'mysql'
|
4
|
+
|
5
|
+
ActiveRecord::Base.logger = Logger.new("debug.log")
|
6
|
+
|
7
|
+
# GRANT ALL PRIVILEGES ON yaml_conditions_db.* to 'yaml_conditions'@'localhost';
|
8
|
+
|
9
|
+
ActiveRecord::Base.configurations = {
|
10
|
+
'yaml_conditions_db' => {
|
11
|
+
'adapter' => 'mysql',
|
12
|
+
'username' => 'yaml_conditions',
|
13
|
+
'encoding' => 'utf8',
|
14
|
+
'database' => 'yaml_conditions_db',
|
15
|
+
},
|
16
|
+
}
|
17
|
+
|
18
|
+
ActiveRecord::Base.establish_connection 'yaml_conditions_db'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
print "Using native Postgres\n"
|
2
|
+
require 'logger'
|
3
|
+
$ADAPTER = 'postgresql'
|
4
|
+
|
5
|
+
ActiveRecord::Base.logger = Logger.new("debug.log")
|
6
|
+
|
7
|
+
# GRANT ALL PRIVILEGES ON yaml_conditions_db.* to 'yaml_conditions'@'localhost';
|
8
|
+
|
9
|
+
ActiveRecord::Base.configurations = {
|
10
|
+
'yaml_conditions_db' => {
|
11
|
+
'adapter' => 'postgresql',
|
12
|
+
'username' => 'yaml_conditions',
|
13
|
+
'encoding' => 'utf8',
|
14
|
+
'database' => 'yaml_conditions_db',
|
15
|
+
},
|
16
|
+
}
|
17
|
+
|
18
|
+
ActiveRecord::Base.establish_connection 'yaml_conditions_db'
|
data/spec/models/job.rb
ADDED
data/spec/models/user.rb
ADDED
data/spec/schema.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
create_table :jobs do |t|
|
3
|
+
t.string :name
|
4
|
+
t.string :desc
|
5
|
+
t.text :data
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
|
9
|
+
create_table :users do |t|
|
10
|
+
t.string :name
|
11
|
+
t.string :address
|
12
|
+
t.text :details
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
|
16
|
+
create_table :user_datas do |t|
|
17
|
+
t.integer :social_number
|
18
|
+
t.string :title
|
19
|
+
t.integer :age
|
20
|
+
t.integer :period_id
|
21
|
+
end
|
22
|
+
|
23
|
+
create_table :periods do |t|
|
24
|
+
t.string :year
|
25
|
+
end
|
26
|
+
|
27
|
+
create_table :priorities do |t|
|
28
|
+
t.integer :job_id
|
29
|
+
t.integer :value
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table "delayed_jobs", :force => true do |t|
|
33
|
+
t.integer "priority", :default => 0
|
34
|
+
t.integer "attempts", :default => 0
|
35
|
+
t.text "handler"
|
36
|
+
t.text "last_error"
|
37
|
+
t.datetime "run_at"
|
38
|
+
t.datetime "locked_at"
|
39
|
+
t.datetime "failed_at"
|
40
|
+
t.string "locked_by"
|
41
|
+
t.datetime "created_at"
|
42
|
+
t.datetime "updated_at"
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), '..', 'lib', 'yaml_conditions')
|
2
|
+
if ENV['VERSION_3']
|
3
|
+
gem 'activesupport', [ '>= 3.0.0'], :require => 'active_support'
|
4
|
+
else
|
5
|
+
gem 'activesupport', [ '>= 2.3.4', '<= 2.3.10' ], :require => 'active_support'
|
6
|
+
end
|
7
|
+
|
8
|
+
def with_warnings(flag)
|
9
|
+
old_verbose, $VERBOSE = $VERBOSE, flag
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
$VERBOSE = old_verbose
|
13
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'date'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
require 'mocha'
|
6
|
+
require 'hanna/rdoctask'
|
7
|
+
|
8
|
+
# Removes spec task defiened in dependency gems
|
9
|
+
module Rake
|
10
|
+
def self.remove_task(task_name)
|
11
|
+
Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
Rake.remove_task 'spec'
|
15
|
+
|
16
|
+
def source_version
|
17
|
+
line = File.read('lib/yaml_conitions.rb')[/^\s*VERSION = .*/]
|
18
|
+
line.match(/.*VERSION = '(.*)'/)[1]
|
19
|
+
end
|
20
|
+
|
21
|
+
# SPECS ===============================================================
|
22
|
+
|
23
|
+
desc 'Run mysql, sqlite, and postgresql tests by default'
|
24
|
+
task :default => :spec
|
25
|
+
|
26
|
+
desc 'Run mysql, sqlite, and postgresql tests'
|
27
|
+
task :spec do
|
28
|
+
tasks = defined?(JRUBY_VERSION) ?
|
29
|
+
%w(spec_jdbcmysql spec_jdbcpostgresql) :
|
30
|
+
%w(spec_mysql spec_postgresql)
|
31
|
+
run_without_aborting(*tasks)
|
32
|
+
end
|
33
|
+
|
34
|
+
def run_without_aborting(*tasks)
|
35
|
+
errors = []
|
36
|
+
|
37
|
+
tasks.each do |task|
|
38
|
+
begin
|
39
|
+
Rake::Task[task].invoke
|
40
|
+
rescue Exception
|
41
|
+
errors << task
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
abort "Errors running #{errors.join(', ')}" if errors.any?
|
46
|
+
end
|
47
|
+
|
48
|
+
task :default => :spec
|
49
|
+
|
50
|
+
for adapter in %w( mysql postgresql )
|
51
|
+
|
52
|
+
Spec::Rake::SpecTask.new("spec_#{adapter}") do |t|
|
53
|
+
t.spec_opts = ['--color']
|
54
|
+
t.rcov = false
|
55
|
+
if adapter =~ /jdbc/
|
56
|
+
t.libs << "spec/connections/jdbc_#{adapter}"
|
57
|
+
else
|
58
|
+
t.libs << "spec/connections/#{adapter}"
|
59
|
+
end
|
60
|
+
t.spec_files = FileList[ 'spec/cases/**/*_spec.rb', 'spec/lib/**/*_spec.rb' ]
|
61
|
+
end
|
62
|
+
|
63
|
+
namespace adapter do
|
64
|
+
#task "spec_#{adapter}" => [ "rebuild_#{adapter}_databases", "spec_#{adapter}_def" ]
|
65
|
+
task :spec => "spec_#{adapter}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# DB ==================================================================
|
70
|
+
# CREATE USER yaml_conditions
|
71
|
+
MYSQL_DB_USER = 'yaml_conditions'
|
72
|
+
|
73
|
+
namespace :mysql do
|
74
|
+
desc 'Build the MySQL test databases'
|
75
|
+
task :build_databases do
|
76
|
+
%x( echo "create DATABASE yaml_conditions_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
|
77
|
+
end
|
78
|
+
|
79
|
+
desc 'Drop the MySQL test databases'
|
80
|
+
task :drop_databases do
|
81
|
+
%x( mysqladmin -u#{MYSQL_DB_USER} -f drop yaml_conditions_db )
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'Rebuild the MySQL test databases'
|
85
|
+
task :rebuild_databases => [:drop_databases, :build_databases]
|
86
|
+
end
|
87
|
+
|
88
|
+
task :build_mysql_databases => 'mysql:build_databases'
|
89
|
+
task :drop_mysql_databases => 'mysql:drop_databases'
|
90
|
+
task :rebuild_mysql_databases => 'mysql:rebuild_databases'
|
91
|
+
|
92
|
+
|
93
|
+
namespace :postgresql do
|
94
|
+
desc 'Build the PostgreSQL test databases'
|
95
|
+
task :build_databases do
|
96
|
+
%x( createdb -E UTF8 yaml_conditions_db )
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Drop the PostgreSQL test databases'
|
100
|
+
task :drop_databases do
|
101
|
+
%x( dropdb yaml_conditions_db )
|
102
|
+
end
|
103
|
+
|
104
|
+
desc 'Rebuild the PostgreSQL test databases'
|
105
|
+
task :rebuild_databases => [:drop_databases, :build_databases]
|
106
|
+
end
|
107
|
+
|
108
|
+
task :build_postgresql_databases => 'postgresql:build_databases'
|
109
|
+
task :drop_postgresql_databases => 'postgresql:drop_databases'
|
110
|
+
task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'
|
111
|
+
|
112
|
+
# Rcov ================================================================
|
113
|
+
namespace :spec do
|
114
|
+
desc 'Mesures test coverage'
|
115
|
+
task :coverage do
|
116
|
+
rm_f "coverage"
|
117
|
+
rcov = "rcov --text-summary -Ilib"
|
118
|
+
system("#{rcov} --no-html --no-color spec/lib/*_spec.rb")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Website =============================================================
|
123
|
+
# Building docs requires HAML and the hanna gem:
|
124
|
+
# gem install mislav-hanna --source=http://gems.github.com
|
125
|
+
|
126
|
+
desc 'Generate RDoc under doc/api'
|
127
|
+
task 'doc' => ['doc:api']
|
128
|
+
|
129
|
+
task 'doc:api' => ['doc/api/index.html']
|
130
|
+
|
131
|
+
file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
|
132
|
+
require 'rbconfig'
|
133
|
+
hanna = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'hanna')
|
134
|
+
rb_files = f.prerequisites
|
135
|
+
sh((<<-end).gsub(/\s+/, ' '))
|
136
|
+
#{hanna}
|
137
|
+
--charset utf8
|
138
|
+
--fmt html
|
139
|
+
--inline-source
|
140
|
+
--line-numbers
|
141
|
+
--main README.rdoc
|
142
|
+
--op doc/api
|
143
|
+
--title 'RTT API Documentation'
|
144
|
+
#{rb_files.join(' ')}
|
145
|
+
end
|
146
|
+
end
|
147
|
+
CLEAN.include 'doc/api'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{yaml_conditions}
|
5
|
+
s.version = "0.0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Marcelo Giorgi"]
|
9
|
+
s.date = %q{2010-11-27}
|
10
|
+
s.default_executable = %q{console.sh}
|
11
|
+
s.description = %q{}
|
12
|
+
s.email = %q{marklazz.uy@gmail.com}
|
13
|
+
s.executables = ["console.sh"]
|
14
|
+
s.extra_rdoc_files = ["README.rdoc", "bin/console.sh", "lib/orms/active_record.rb", "lib/orms/active_record/version2/delayed_job.rb", "lib/orms/active_record/version_2.rb", "lib/orms/active_record/version_3.rb", "lib/orms/datamapper.rb", "lib/yaml/conditions.rb", "lib/yaml/query_builder.rb", "lib/yaml/query_builder/sql/mysql.rb", "lib/yaml/query_builder/sql/postgresql.rb", "lib/yaml_conditions.rb", "tasks/yaml_conditions.rake"]
|
15
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "TESTS.rdoc", "bin/console.sh", "init.rb", "lib/orms/active_record.rb", "lib/orms/active_record/version2/delayed_job.rb", "lib/orms/active_record/version_2.rb", "lib/orms/active_record/version_3.rb", "lib/orms/datamapper.rb", "lib/yaml/conditions.rb", "lib/yaml/query_builder.rb", "lib/yaml/query_builder/sql/mysql.rb", "lib/yaml/query_builder/sql/postgresql.rb", "lib/yaml_conditions.rb", "out.txt", "spec/ar_spec_helper.rb", "spec/cases/orms/active_record/version_2_delayed_job_spec.rb", "spec/cases/orms/active_record/version_2_spec.rb", "spec/connections/mysql/connection.rb", "spec/connections/postgresql/connection.rb", "spec/datamapper_spec_helper.rb", "spec/models/delayed/job.rb", "spec/models/delayed/performable_method.rb", "spec/models/job.rb", "spec/models/period.rb", "spec/models/priority.rb", "spec/models/user.rb", "spec/models/user_data.rb", "spec/schema.rb", "spec/spec_helper.rb", "tasks/yaml_conditions.rake", "yaml_conditions.gemspec"]
|
16
|
+
s.homepage = %q{http://github.com/marklazz/yaml_conditions}
|
17
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Yaml_conditions", "--main", "README.rdoc"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rubyforge_project = %q{yaml_conditions}
|
20
|
+
s.rubygems_version = %q{1.3.7}
|
21
|
+
s.summary = %q{}
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 3
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_development_dependency(%q<spec>, [">= 0"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<spec>, [">= 0"])
|
31
|
+
end
|
32
|
+
else
|
33
|
+
s.add_dependency(%q<spec>, [">= 0"])
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yaml_conditions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 77
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- 1
|
11
|
+
version: 0.0.0.1
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- Marcelo Giorgi
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-11-27 00:00:00 -02:00
|
20
|
+
default_executable: console.sh
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: spec
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
description: ""
|
37
|
+
email: marklazz.uy@gmail.com
|
38
|
+
executables:
|
39
|
+
- console.sh
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- README.rdoc
|
44
|
+
- bin/console.sh
|
45
|
+
- lib/orms/active_record.rb
|
46
|
+
- lib/orms/active_record/version2/delayed_job.rb
|
47
|
+
- lib/orms/active_record/version_2.rb
|
48
|
+
- lib/orms/active_record/version_3.rb
|
49
|
+
- lib/orms/datamapper.rb
|
50
|
+
- lib/yaml/conditions.rb
|
51
|
+
- lib/yaml/query_builder.rb
|
52
|
+
- lib/yaml/query_builder/sql/mysql.rb
|
53
|
+
- lib/yaml/query_builder/sql/postgresql.rb
|
54
|
+
- lib/yaml_conditions.rb
|
55
|
+
- tasks/yaml_conditions.rake
|
56
|
+
files:
|
57
|
+
- Manifest
|
58
|
+
- README.rdoc
|
59
|
+
- Rakefile
|
60
|
+
- TESTS.rdoc
|
61
|
+
- bin/console.sh
|
62
|
+
- init.rb
|
63
|
+
- lib/orms/active_record.rb
|
64
|
+
- lib/orms/active_record/version2/delayed_job.rb
|
65
|
+
- lib/orms/active_record/version_2.rb
|
66
|
+
- lib/orms/active_record/version_3.rb
|
67
|
+
- lib/orms/datamapper.rb
|
68
|
+
- lib/yaml/conditions.rb
|
69
|
+
- lib/yaml/query_builder.rb
|
70
|
+
- lib/yaml/query_builder/sql/mysql.rb
|
71
|
+
- lib/yaml/query_builder/sql/postgresql.rb
|
72
|
+
- lib/yaml_conditions.rb
|
73
|
+
- out.txt
|
74
|
+
- spec/ar_spec_helper.rb
|
75
|
+
- spec/cases/orms/active_record/version_2_delayed_job_spec.rb
|
76
|
+
- spec/cases/orms/active_record/version_2_spec.rb
|
77
|
+
- spec/connections/mysql/connection.rb
|
78
|
+
- spec/connections/postgresql/connection.rb
|
79
|
+
- spec/datamapper_spec_helper.rb
|
80
|
+
- spec/models/delayed/job.rb
|
81
|
+
- spec/models/delayed/performable_method.rb
|
82
|
+
- spec/models/job.rb
|
83
|
+
- spec/models/period.rb
|
84
|
+
- spec/models/priority.rb
|
85
|
+
- spec/models/user.rb
|
86
|
+
- spec/models/user_data.rb
|
87
|
+
- spec/schema.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- tasks/yaml_conditions.rake
|
90
|
+
- yaml_conditions.gemspec
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: http://github.com/marklazz/yaml_conditions
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --line-numbers
|
98
|
+
- --inline-source
|
99
|
+
- --title
|
100
|
+
- Yaml_conditions
|
101
|
+
- --main
|
102
|
+
- README.rdoc
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 11
|
120
|
+
segments:
|
121
|
+
- 1
|
122
|
+
- 2
|
123
|
+
version: "1.2"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project: yaml_conditions
|
127
|
+
rubygems_version: 1.3.7
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: ""
|
131
|
+
test_files: []
|
132
|
+
|