moniker_activeresource 0.1.0
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/Gemfile +20 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +16 -0
- data/README.rdoc +156 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/lib/hot_fixes.rb +60 -0
- data/lib/moniker.rb +43 -0
- data/lib/moniker/base.rb +133 -0
- data/lib/moniker/common.rb +55 -0
- data/lib/moniker/domain.rb +91 -0
- data/lib/moniker/record.rb +124 -0
- data/lib/moniker/server.rb +65 -0
- data/lib/moniker_activeresource.rb +1 -0
- data/moniker_activeresource.gemspec +89 -0
- data/test/.gitignore +2 -0
- data/test/helper.rb +34 -0
- data/test/test_configuration-sample.yml +14 -0
- data/test/test_domains.rb +108 -0
- data/test/test_records.rb +137 -0
- data/test/test_servers.rb +100 -0
- data/test/utils.rb +55 -0
- metadata +234 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (C) 2013 Unidata S.p.A. (Davide Guerri - davide.guerri@gmail.com)
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
module Moniker
|
17
|
+
|
18
|
+
class Common < Base
|
19
|
+
|
20
|
+
# Overrides ActiveResource::Base::element_path to remove .<extension> from resources path
|
21
|
+
def self.element_path(id, prefix_options = {}, query_options = nil)
|
22
|
+
check_prefix_options(prefix_options)
|
23
|
+
|
24
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
25
|
+
"#{prefix(prefix_options)}#{collection_name}/#{URI.parser.escape id.to_s}#{query_string(query_options)}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Overrides ActiveResource::Base::collection_path to remove .<extension> from resources path
|
29
|
+
def self.collection_path(prefix_options = {}, query_options = nil)
|
30
|
+
check_prefix_options(prefix_options)
|
31
|
+
|
32
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
33
|
+
"#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}"
|
34
|
+
end
|
35
|
+
|
36
|
+
# Overrides ActiveResource::CustomMethods to remove .<extension>
|
37
|
+
def self.custom_method_collection_url(method_name, options = {})
|
38
|
+
prefix_options, query_options = split_options(options)
|
39
|
+
"#{prefix(prefix_options)}#{collection_name}/#{method_name}#{query_string(query_options)}"
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def custom_method_element_url(method_name, options = {})
|
45
|
+
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}#{self.class.__send__(:query_string, options)}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def custom_method_new_element_url(method_name, options = {})
|
49
|
+
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}#{self.class.__send__(:query_string, options)}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# This file is part of the Moniker-ActiveResource
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Unidata S.p.A. (Davide Guerri - davide.guerri@gmail.com)
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
module Moniker
|
19
|
+
|
20
|
+
# A Moniker Domain
|
21
|
+
#
|
22
|
+
# ==== Attributes
|
23
|
+
# * +name+ - Name of this image
|
24
|
+
# * +email+ - e-mail of the registrant
|
25
|
+
# * +ttl+ - domain ttl
|
26
|
+
# * +serial+ - domain serial
|
27
|
+
# * +updated_at+ - Modification date
|
28
|
+
# * +created_at+ - Creation date
|
29
|
+
class Domain < Common
|
30
|
+
schema do
|
31
|
+
attribute :name, :string
|
32
|
+
attribute :email, :string
|
33
|
+
attribute :ttl, :integer
|
34
|
+
attribute :serial, :integer
|
35
|
+
attribute :updated_at, :datetime
|
36
|
+
attribute :created_at, :datetime
|
37
|
+
end
|
38
|
+
|
39
|
+
validates :name,
|
40
|
+
:presence => true,
|
41
|
+
:format => {:with => /\A[\w\.\-\_]{2,}\Z/, :allow_blank => true},
|
42
|
+
:length => {:maximum => 255}
|
43
|
+
validates :ttl,
|
44
|
+
:numericality => {:greater_than => 0, :less_than_or_equal_to => 86400, :only_integer => true, :allow_blank => true}
|
45
|
+
validates :email,
|
46
|
+
:presence => true,
|
47
|
+
:format => {:with => /\A[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}\Z/i, :allow_blank => true}
|
48
|
+
|
49
|
+
def initialize(attributes = {}, persisted = false) # :notnew:
|
50
|
+
attributes = attributes.with_indifferent_access
|
51
|
+
new_attributes = {
|
52
|
+
:id => attributes[:id],
|
53
|
+
:name => attributes[:name],
|
54
|
+
:email => attributes[:email],
|
55
|
+
:ttl => attributes[:ttl].present? ? attributes[:ttl].to_i : nil,
|
56
|
+
:serial => attributes[:serial].present? ? attributes[:serial] : nil,
|
57
|
+
:updated_at => attributes[:updated].present? ? DateTime.strptime(attributes[:updated], Moniker::DATETIME_FORMAT) : nil,
|
58
|
+
:created_at => attributes[:created].present? ? DateTime.strptime(attributes[:created], Moniker::DATETIME_FORMAT) : nil
|
59
|
+
}
|
60
|
+
|
61
|
+
super(new_attributes, persisted)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Overloads ActiveRecord::encode method
|
65
|
+
def encode(options={}) # :nodoc: Custom encoding to deal with moniker API
|
66
|
+
to_encode = {
|
67
|
+
:name => name,
|
68
|
+
:email => email,
|
69
|
+
}
|
70
|
+
|
71
|
+
to_encode[:ttl] = ttl if ttl.present?
|
72
|
+
to_encode[:serial] = serial if serial.present?
|
73
|
+
|
74
|
+
to_encode.send("to_#{self.class.format.extension}", options)
|
75
|
+
end
|
76
|
+
|
77
|
+
def records
|
78
|
+
persisted? ? Record.find(:all, :domain_id => id) : []
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.find_by_name(name, options = {})
|
82
|
+
all(options).detect { |domain| domain.name == name }
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.find_all_by_email(email, options = {})
|
86
|
+
all(options).select { |domain| domain.email == email }
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# This file is part of the Moniker-ActiveResource
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Unidata S.p.A. (Davide Guerri - davide.guerri@gmail.com)
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
module Moniker
|
19
|
+
|
20
|
+
# A Moniker Domain
|
21
|
+
#
|
22
|
+
# ==== Attributes
|
23
|
+
# * +name+ - Name of this image
|
24
|
+
# * +email+ - e-mail of the registrant
|
25
|
+
# * +ttl+ - domain ttl
|
26
|
+
# * +serial+ - domain serial
|
27
|
+
# * +updated_at+ - Modification date
|
28
|
+
# * +created_at+ - Creation date
|
29
|
+
class Record < Common
|
30
|
+
self.site = "#{self.superclass.site}/domains/:domain_id"
|
31
|
+
|
32
|
+
schema do
|
33
|
+
attribute :name, :string
|
34
|
+
attribute :type, :string
|
35
|
+
attribute :ttl, :integer
|
36
|
+
attribute :priority, :integer
|
37
|
+
attribute :data, :string
|
38
|
+
attribute :domain_id, :string
|
39
|
+
attribute :updated_at, :datetime
|
40
|
+
attribute :created_at, :datetime
|
41
|
+
end
|
42
|
+
|
43
|
+
validates :name,
|
44
|
+
:presence => true,
|
45
|
+
:format => {:with => /\A[\w\.\-\_]{2,}\Z/, :allow_blank => true},
|
46
|
+
:length => {:maximum => 255}
|
47
|
+
validates :type,
|
48
|
+
:presence => true,
|
49
|
+
:inclusion => {:in => %w(A AAAA CNAME MX SRV TXT NS PTR)}
|
50
|
+
validates :data,
|
51
|
+
:presence => true,
|
52
|
+
:length => {:maximum => 255}
|
53
|
+
validates :ttl,
|
54
|
+
:numericality => {:greater_than => 0, :less_than_or_equal_to => 86400, :only_integer => true, :allow_blank => true}
|
55
|
+
validates :priority,
|
56
|
+
:numericality => {:greater_than => 0, :less_than_or_equal_to => 255, :only_integer => true, :allow_blank => true}
|
57
|
+
|
58
|
+
|
59
|
+
def initialize(attributes = {}, persisted = false) # :notnew:
|
60
|
+
attributes = attributes.with_indifferent_access
|
61
|
+
new_attributes = {
|
62
|
+
:id => attributes[:id],
|
63
|
+
:name => attributes[:name],
|
64
|
+
:type => attributes[:type],
|
65
|
+
:domain_id => attributes[:domain_id],
|
66
|
+
:ttl => attributes[:ttl].present? ? attributes[:ttl].to_i : nil,
|
67
|
+
:priority => attributes[:priority].present? ? attributes[:priority].to_i : nil,
|
68
|
+
:data => attributes[:data],
|
69
|
+
:updated_at => attributes[:created_at].present? ? DateTime.strptime(attributes[:created_at], Moniker::DATETIME_FORMAT) : nil,
|
70
|
+
:created_at => attributes[:created_at].present? ? DateTime.strptime(attributes[:created_at], Moniker::DATETIME_FORMAT) : nil
|
71
|
+
}
|
72
|
+
|
73
|
+
super(new_attributes, persisted)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Overloads ActiveRecord::encode method
|
77
|
+
# @param [Object] options
|
78
|
+
def encode(options={}) # :nodoc: Custom encoding to deal with moniker API
|
79
|
+
to_encode = {
|
80
|
+
:name => name,
|
81
|
+
:type => type,
|
82
|
+
:data => data
|
83
|
+
}
|
84
|
+
|
85
|
+
to_encode[:ttl] = ttl if ttl.present?
|
86
|
+
to_encode[:priority] = priority if priority.present?
|
87
|
+
|
88
|
+
to_encode.send("to_#{self.class.format.extension}", options)
|
89
|
+
end
|
90
|
+
|
91
|
+
def update_attributes(attributes)
|
92
|
+
super attributes.merge @prefix_options
|
93
|
+
end
|
94
|
+
|
95
|
+
def domain_id
|
96
|
+
@prefix_options[:domain_id]
|
97
|
+
end
|
98
|
+
|
99
|
+
def domain
|
100
|
+
domain_id.present? ? (Domain.find domain_id) : nil
|
101
|
+
rescue ActiveResource::ResourceNotFound => e
|
102
|
+
|
103
|
+
nil
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.find_by_name(name, options = {})
|
107
|
+
all(options).detect { |record| record.name == name }
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.find_all_by_name(name, options = {})
|
111
|
+
all(options).select { |record| record.name == name }
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.find_all_by_type(type, options = {})
|
115
|
+
all(options).select { |record| record.type == type }
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.find_all_by_data(data, options = {})
|
119
|
+
all(options).select { |record| record.data == data }
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# This file is part of the Moniker-ActiveResource
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Unidata S.p.A. (Davide Guerri - davide.guerri@gmail.com)
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
module Moniker
|
19
|
+
|
20
|
+
# A Moniker Server
|
21
|
+
#
|
22
|
+
# ==== Attributes
|
23
|
+
# * +name+ - Name of this image
|
24
|
+
# * +updated_at+ - Modification date
|
25
|
+
# * +created_at+ - Creation date
|
26
|
+
class Server < Common
|
27
|
+
schema do
|
28
|
+
attribute :name, :string
|
29
|
+
attribute :updated_at, :datetime
|
30
|
+
attribute :created_at, :datetime
|
31
|
+
end
|
32
|
+
|
33
|
+
validates :name,
|
34
|
+
:presence => true,
|
35
|
+
:format => {:with => /\A[\w\.\-\_]{2,}\Z/, :allow_blank => true},
|
36
|
+
:length => {:maximum => 255}
|
37
|
+
|
38
|
+
def initialize(attributes = {}, persisted = false) # :notnew:
|
39
|
+
attributes = attributes.with_indifferent_access
|
40
|
+
new_attributes = {
|
41
|
+
:id => attributes[:id],
|
42
|
+
:name => attributes[:name],
|
43
|
+
:updated_at => attributes[:created_at].present? ? DateTime.strptime(attributes[:created_at], Moniker::DATETIME_FORMAT) : nil,
|
44
|
+
:created_at => attributes[:created_at].present? ? DateTime.strptime(attributes[:created_at], Moniker::DATETIME_FORMAT) : nil
|
45
|
+
}
|
46
|
+
|
47
|
+
super(new_attributes, persisted)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Overloads ActiveRecord::encode method
|
51
|
+
def encode(options={}) # :nodoc: Custom encoding to deal with moniker API
|
52
|
+
to_encode = {
|
53
|
+
:name => name
|
54
|
+
}
|
55
|
+
|
56
|
+
to_encode.send("to_#{self.class.format.extension}", options)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.find_by_name(name, options = {})
|
60
|
+
all(options).detect { |domain| domain.name == name }
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'moniker'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
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 = "moniker_activeresource"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Davide Guerri"]
|
12
|
+
s.date = "2013-03-06"
|
13
|
+
s.description = "Moniker Ruby and RoR bindings implemented with ActiveResource - See also http://www.unicloud.it"
|
14
|
+
s.email = "d.guerri@rd.unidata.it"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/hot_fixes.rb",
|
28
|
+
"lib/moniker.rb",
|
29
|
+
"lib/moniker/base.rb",
|
30
|
+
"lib/moniker/common.rb",
|
31
|
+
"lib/moniker/domain.rb",
|
32
|
+
"lib/moniker/record.rb",
|
33
|
+
"lib/moniker/server.rb",
|
34
|
+
"lib/moniker_activeresource.rb",
|
35
|
+
"moniker_activeresource.gemspec",
|
36
|
+
"test/.gitignore",
|
37
|
+
"test/helper.rb",
|
38
|
+
"test/test_configuration-sample.yml",
|
39
|
+
"test/test_domains.rb",
|
40
|
+
"test/test_records.rb",
|
41
|
+
"test/test_servers.rb",
|
42
|
+
"test/utils.rb"
|
43
|
+
]
|
44
|
+
s.homepage = "https://github.com/Unidata-SpA/moniker_activeresource"
|
45
|
+
s.licenses = ["GPLv3"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = "1.8.24"
|
48
|
+
s.summary = "Moniker Ruby and RoR bindings implemented with ActiveResource"
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<activemodel>, ["~> 3.2.12"])
|
55
|
+
s.add_runtime_dependency(%q<activeresource>, ["~> 3.2.12"])
|
56
|
+
s.add_runtime_dependency(%q<oj>, ["~> 1.2.9"])
|
57
|
+
s.add_runtime_dependency(%q<json>, ["~> 1.7.7"])
|
58
|
+
s.add_runtime_dependency(%q<openstack_activeresource>, ["~> 0.5.0"])
|
59
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
60
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
62
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<test-unit>, [">= 0"])
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<activemodel>, ["~> 3.2.12"])
|
66
|
+
s.add_dependency(%q<activeresource>, ["~> 3.2.12"])
|
67
|
+
s.add_dependency(%q<oj>, ["~> 1.2.9"])
|
68
|
+
s.add_dependency(%q<json>, ["~> 1.7.7"])
|
69
|
+
s.add_dependency(%q<openstack_activeresource>, ["~> 0.5.0"])
|
70
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
71
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
73
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
74
|
+
s.add_dependency(%q<test-unit>, [">= 0"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<activemodel>, ["~> 3.2.12"])
|
78
|
+
s.add_dependency(%q<activeresource>, ["~> 3.2.12"])
|
79
|
+
s.add_dependency(%q<oj>, ["~> 1.2.9"])
|
80
|
+
s.add_dependency(%q<json>, ["~> 1.7.7"])
|
81
|
+
s.add_dependency(%q<openstack_activeresource>, ["~> 0.5.0"])
|
82
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
83
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
84
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
85
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
86
|
+
s.add_dependency(%q<test-unit>, [">= 0"])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
data/test/.gitignore
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
|
16
|
+
class Test::Unit::TestCase
|
17
|
+
end
|
18
|
+
|
19
|
+
# Load test configuration for Moniker API
|
20
|
+
test_path = File.expand_path('..', __FILE__)
|
21
|
+
$:.unshift(test_path)
|
22
|
+
|
23
|
+
unless File.exist? "#{test_path}/test_configuration.yml"
|
24
|
+
raise "\n****" +
|
25
|
+
"\n**** Please add a valid 'test_configuration.yml' file in '#{test_path}'." +
|
26
|
+
"\n**** See #{test_path}/test_configuration-sample.yml for an example" +
|
27
|
+
"\n****"
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'moniker_activeresource'
|
31
|
+
require 'utils'
|
32
|
+
|
33
|
+
TEST_CONFIG = (YAML.load_file("#{test_path}/test_configuration.yml")['test_configuration']).with_indifferent_access
|
34
|
+
|