machinist-couchrest-model 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE +20 -0
- data/README.md +17 -0
- data/README.rdoc +23 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/lib/machinist-couchrest-model.rb +20 -0
- data/lib/machinist_couchrest_model/blueprint.rb +16 -0
- data/lib/machinist_couchrest_model/lathe.rb +25 -0
- data/spec/machinist_couchrest_model/blueprint_spec.rb +11 -0
- data/spec/machinist_couchrest_model/lathe_spec.rb +18 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +8 -0
- metadata +132 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 OpenLogic, Inc
|
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.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= machinist-couchrest-model
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Peter Williams. See LICENSE for details.
|
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
machinist-couchrest-model
|
2
|
+
====
|
3
|
+
|
4
|
+
Provides CouchRest::Model support for Machinist.
|
5
|
+
|
6
|
+
Note on Patches/Pull Requests
|
7
|
+
----
|
8
|
+
|
9
|
+
* Fork the project.
|
10
|
+
* Make your feature addition or bug fix.
|
11
|
+
* Add tests for it. This is important so I don't break it in a
|
12
|
+
future version unintentionally.
|
13
|
+
* update the history and version (use [semantic versioning][semver])
|
14
|
+
* Commit
|
15
|
+
* Send me a pull request. Bonus points for topic branches.
|
16
|
+
|
17
|
+
[semver]: http://semver.org/
|
18
|
+
|
19
|
+
Copyright
|
20
|
+
----
|
21
|
+
|
22
|
+
Copyright (c) 2011 OpenLogic, Inc. See LICENSE for details.
|
23
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "machinist-couchrest-model"
|
8
|
+
gem.summary = %Q{Machinist support for CouchRest Model}
|
9
|
+
gem.description = %Q{Manufacture test CouchRest models with ease using Machinist}
|
10
|
+
gem.email = "pezra@barelyenough.org"
|
11
|
+
gem.homepage = "http://github.com/pezra/machinist-couchrest-model"
|
12
|
+
gem.authors = ["Peter Williams"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_development_dependency "yard", ">= 0"
|
15
|
+
gem.add_dependency "machinist", "~> 2.0"
|
16
|
+
gem.add_dependency "couchrest_model"
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'rspec/core/rake_task'
|
25
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
26
|
+
spec.ruby_opts = "-Ilib -Ispec"
|
27
|
+
end
|
28
|
+
|
29
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
30
|
+
spec.ruby_opts = "-Ilib -Ispex"
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
begin
|
40
|
+
require 'yard'
|
41
|
+
YARD::Rake::YardocTask.new
|
42
|
+
rescue LoadError
|
43
|
+
task :yardoc do
|
44
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
45
|
+
end
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'machinist'
|
2
|
+
require "couchrest_model"
|
3
|
+
|
4
|
+
module MachinistCouchrestModel
|
5
|
+
autoload "Blueprint", "machinist_couchrest_model/blueprint"
|
6
|
+
autoload "Lathe", "machinist_couchrest_model/lathe"
|
7
|
+
end
|
8
|
+
|
9
|
+
require "couchrest/model/base"
|
10
|
+
module CouchRest #:nodoc:
|
11
|
+
module Model #:nodoc:
|
12
|
+
class Base #:nodoc:
|
13
|
+
extend Machinist::Machinable
|
14
|
+
|
15
|
+
def self.blueprint_class
|
16
|
+
MachinistCouchrestModel::Blueprint
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MachinistCouchrestModel
|
2
|
+
class Blueprint < Machinist::Blueprint
|
3
|
+
|
4
|
+
# Make and save an object.
|
5
|
+
def make!(attributes = {})
|
6
|
+
object = make(attributes)
|
7
|
+
object.save!
|
8
|
+
object.reload
|
9
|
+
end
|
10
|
+
|
11
|
+
def lathe_class
|
12
|
+
MachinistCouchrestModel::Lathe
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MachinistCouchrestModel
|
2
|
+
|
3
|
+
class Lathe < Machinist::Lathe
|
4
|
+
|
5
|
+
def make_one_value(attribute, args) #:nodoc:
|
6
|
+
if block_given?
|
7
|
+
raise_argument_error(attribute) unless args.empty?
|
8
|
+
yield
|
9
|
+
else
|
10
|
+
make_association(attribute, args)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def make_association(attribute, args) #:nodoc:
|
15
|
+
raise NotImplementedError, "Associations are not yet supported"
|
16
|
+
# association = @klass.reflect_on_association(attribute)
|
17
|
+
# if association
|
18
|
+
# association.klass.make(*args)
|
19
|
+
# else
|
20
|
+
# raise_argument_error(attribute)
|
21
|
+
# end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
require 'machinist_couchrest_model/blueprint'
|
3
|
+
|
4
|
+
describe MachinistCouchrestModel::Blueprint do
|
5
|
+
subject {MachinistCouchrestModel::Blueprint.new(String)}
|
6
|
+
|
7
|
+
it "knows correct lathe class" do
|
8
|
+
subject.lathe_class.should == MachinistCouchrestModel::Lathe
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require "couchrest_model"
|
4
|
+
|
5
|
+
describe MachinistCouchrestModel::Lathe do
|
6
|
+
let(:model_class) do
|
7
|
+
Class.new(CouchRest::Model::Base) do
|
8
|
+
property :flavor, String
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
subject {MachinistCouchrestModel::Lathe.new(model_class, 42, {:flavor => 'test'})}
|
13
|
+
|
14
|
+
it "assign simple values" do
|
15
|
+
subject.object.flavor.should == 'test'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: machinist-couchrest-model
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Peter Williams
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-20 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 2
|
31
|
+
- 9
|
32
|
+
version: 1.2.9
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: yard
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: machinist
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 2
|
58
|
+
- 0
|
59
|
+
version: "2.0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: couchrest_model
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
type: :runtime
|
74
|
+
version_requirements: *id004
|
75
|
+
description: Manufacture test CouchRest models with ease using Machinist
|
76
|
+
email: pezra@barelyenough.org
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files:
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- README.rdoc
|
85
|
+
files:
|
86
|
+
- .document
|
87
|
+
- LICENSE
|
88
|
+
- README.md
|
89
|
+
- README.rdoc
|
90
|
+
- Rakefile
|
91
|
+
- VERSION
|
92
|
+
- lib/machinist-couchrest-model.rb
|
93
|
+
- lib/machinist_couchrest_model/blueprint.rb
|
94
|
+
- lib/machinist_couchrest_model/lathe.rb
|
95
|
+
- spec/machinist_couchrest_model/blueprint_spec.rb
|
96
|
+
- spec/machinist_couchrest_model/lathe_spec.rb
|
97
|
+
- spec/spec.opts
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
has_rdoc: true
|
100
|
+
homepage: http://github.com/pezra/machinist-couchrest-model
|
101
|
+
licenses: []
|
102
|
+
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.3.7
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Machinist support for CouchRest Model
|
131
|
+
test_files: []
|
132
|
+
|