prepor-artester 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +49 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/artester.gemspec +51 -0
- data/lib/artester/base.rb +16 -0
- data/lib/artester/model.rb +25 -0
- data/lib/artester.rb +36 -0
- data/test/artester_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +67 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Andrew Rudenko
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
= artester
|
2
|
+
|
3
|
+
Tool for testing AR implementation independent components (like plugins).
|
4
|
+
|
5
|
+
It recreate for every test tables (stores by sqlite in memory) and models.
|
6
|
+
|
7
|
+
= Example
|
8
|
+
|
9
|
+
Artester.def :yaacl do
|
10
|
+
|
11
|
+
model :user do
|
12
|
+
definition do |t|
|
13
|
+
t.string :name
|
14
|
+
t.string :global_roles_list, :default => ''
|
15
|
+
end
|
16
|
+
|
17
|
+
klass do
|
18
|
+
include YAACL::User
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
model :role do
|
23
|
+
definition do |t|
|
24
|
+
t.integer :user_id
|
25
|
+
t.string :entity_type
|
26
|
+
t.integer :entity_id
|
27
|
+
t.string :role
|
28
|
+
end
|
29
|
+
|
30
|
+
klass do
|
31
|
+
include YAACL::Role
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class UnitTest < Test::Unit::TestCase
|
37
|
+
context "User creation" do
|
38
|
+
setup do
|
39
|
+
Artester[:yaacl].reload
|
40
|
+
@author = User.create :name => 'Andrew'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Now you can use User as usual AR-model.
|
46
|
+
|
47
|
+
== Copyright
|
48
|
+
|
49
|
+
Copyright (c) 2009 Andrew Rudenko. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "artester"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "ceo@prepor.ru"
|
10
|
+
gem.homepage = "http://github.com/prepor/artester"
|
11
|
+
gem.authors = ["Andrew Rudenko"]
|
12
|
+
end
|
13
|
+
|
14
|
+
rescue LoadError
|
15
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rake/testtask'
|
19
|
+
Rake::TestTask.new(:test) do |test|
|
20
|
+
test.libs << 'lib' << 'test'
|
21
|
+
test.pattern = 'test/**/*_test.rb'
|
22
|
+
test.verbose = true
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'rcov/rcovtask'
|
27
|
+
Rcov::RcovTask.new do |test|
|
28
|
+
test.libs << 'test'
|
29
|
+
test.pattern = 'test/**/*_test.rb'
|
30
|
+
test.verbose = true
|
31
|
+
end
|
32
|
+
rescue LoadError
|
33
|
+
task :rcov do
|
34
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
task :default => :test
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
if File.exist?('VERSION.yml')
|
44
|
+
config = YAML.load(File.read('VERSION.yml'))
|
45
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
46
|
+
else
|
47
|
+
version = ""
|
48
|
+
end
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "artester #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
55
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
data/artester.gemspec
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{artester}
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Andrew Rudenko"]
|
12
|
+
s.date = %q{2009-09-02}
|
13
|
+
s.email = %q{ceo@prepor.ru}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"artester.gemspec",
|
26
|
+
"lib/artester.rb",
|
27
|
+
"lib/artester/base.rb",
|
28
|
+
"lib/artester/model.rb",
|
29
|
+
"test/artester_test.rb",
|
30
|
+
"test/test_helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/prepor/artester}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.5}
|
36
|
+
s.summary = %q{TODO}
|
37
|
+
s.test_files = [
|
38
|
+
"test/artester_test.rb",
|
39
|
+
"test/test_helper.rb"
|
40
|
+
]
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
+
else
|
48
|
+
end
|
49
|
+
else
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Base
|
2
|
+
attr_accessor :name, :models
|
3
|
+
def initialize(name, &block)
|
4
|
+
self.name = name.to_s
|
5
|
+
self.models = {}
|
6
|
+
instance_eval(&block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def model(name, &block)
|
10
|
+
self.models[name.to_sym] = Artester::Model.new(name, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def reload
|
14
|
+
self.models.each { |name, m| m.reload }
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Model
|
2
|
+
attr_accessor :name, :definition_block, :klass_block
|
3
|
+
def initialize(name, &block)
|
4
|
+
self.name = name.to_s
|
5
|
+
instance_eval(&block)
|
6
|
+
end
|
7
|
+
|
8
|
+
def definition(&block)
|
9
|
+
self.definition_block = block
|
10
|
+
end
|
11
|
+
|
12
|
+
def klass(&block)
|
13
|
+
self.klass_block = block
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def reload
|
18
|
+
ActiveRecord::Base.connection.create_table(name.tableize, :force => true, &definition_block)
|
19
|
+
|
20
|
+
Object.send(:remove_const, name.classify) rescue nil
|
21
|
+
Object.const_set(name.classify, Class.new(ActiveRecord::Base))
|
22
|
+
name.classify.constantize.class_eval(&klass_block)
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/artester.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require 'active_record'
|
4
|
+
require 'active_support'
|
5
|
+
|
6
|
+
require 'artester/base'
|
7
|
+
require 'artester/model'
|
8
|
+
|
9
|
+
module Artester
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def init
|
13
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
14
|
+
ActiveRecord::Base.establish_connection(config)
|
15
|
+
end
|
16
|
+
|
17
|
+
def config
|
18
|
+
{ 'adapter' => 'sqlite3',
|
19
|
+
'database' => 'memory'}
|
20
|
+
end
|
21
|
+
|
22
|
+
def def(name, &block)
|
23
|
+
artesters[name.to_sym] = block
|
24
|
+
end
|
25
|
+
|
26
|
+
def artesters
|
27
|
+
@@artesters ||= {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def [](name)
|
31
|
+
Artester::Base.new(name, &artesters[name])
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prepor-artester
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Rudenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-02 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: ceo@prepor.ru
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- VERSION
|
32
|
+
- artester.gemspec
|
33
|
+
- lib/artester.rb
|
34
|
+
- lib/artester/base.rb
|
35
|
+
- lib/artester/model.rb
|
36
|
+
- test/artester_test.rb
|
37
|
+
- test/test_helper.rb
|
38
|
+
has_rdoc: false
|
39
|
+
homepage: http://github.com/prepor/artester
|
40
|
+
licenses:
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --charset=UTF-8
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.3.5
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: TODO
|
65
|
+
test_files:
|
66
|
+
- test/artester_test.rb
|
67
|
+
- test/test_helper.rb
|