machinist_mongo 1.2.0 → 2.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -2,23 +2,32 @@ h1. Machinist Mongo
2
2
 
3
3
  It aims to replace "machinist_mongomapper":http://github.com/yeastymobs/machinist_mongomapper to provide "Machinist":http://github.com/notahat/machinist adapters not just for "MongoMapper":http://mongomapper.com but for all the others MongoDB ORMs too. Right now it supports "Mongoid":http://mongoid.com and "MongoMapper":http://mongomapper.com, but we aim to support _all_ "mongoDB":http://www.mongodb.org/ ORMs, so If you're using something other than MongoMapper or Mongoid, please be sure to write a adapter for it.
4
4
 
5
- h2. For Rails 2
5
+ h2. Usage
6
6
 
7
- Current Machinist Mongo versions are only compatible with Rails 3. Use 1.x versions to use Machinist Mongo with Rails 2.
7
+ Using Machinist MongoMapper is simple. Put this in your @Gemfile@:
8
8
 
9
- h2. For Machinist 2
9
+ bc. gem 'machinist_mongo'
10
10
 
11
- There's a machinist2 branch if you want to use Machinist Mongo with Machinist 2. It will be merge in the master branch before the Machinist Mongo 2.0.0 final version.
11
+ And run:
12
12
 
13
- h2. Usage
13
+ bc. bundle install
14
14
 
15
- Using Machinist MongoMapper is simple. Put this in your @Gemfile@:
15
+ Or if you’re using Rails 2.x put this in @config/environment.rb@:
16
16
 
17
- bc. gem 'machinist_mongo', :require => 'machinist/mongoid' # or mongo_mapper
17
+ bc. config.gem 'machinist_mongo'
18
18
 
19
19
  And run:
20
20
 
21
- bc. bundle install
21
+ bc. rake gems:install
22
+
23
+ Now create your @spec/blueprints.rb@ or @test/blueprints.rb@ file as you normally would, only using "Mongoid":http://mongoid.com or "MongoMapper":http://mongomapper.com instead of ActiveRecord:
24
+
25
+ bc. require 'machinist/mongo_mapper' # or mongoid
26
+ require 'sham'
27
+
28
+ Don't forget to require the new @blueprints.rb@ file in your @spec_helper@ (or @test_helper@):
29
+
30
+ bc. require File.expand_path(File.dirname(__FILE__) + "/blueprints")
22
31
 
23
32
  And you're all set. Be sure read "Machinist's README":http://github.com/notahat/machinist to find out how to create your objects and get this thing running.
24
33
 
@@ -57,7 +57,7 @@ module Machinist
57
57
  end
58
58
 
59
59
  def make_unsaved(*args)
60
- Machinist.with_save_nerfed{ make(*args) }.tap do |object|
60
+ returning(Machinist.with_save_nerfed { make(*args) }) do |object|
61
61
  yield object if block_given?
62
62
  end
63
63
  end
@@ -19,13 +19,13 @@ module Machinist
19
19
  end
20
20
  end
21
21
  end
22
-
22
+
23
23
  class MongoidAdapter
24
24
  class << self
25
25
  def has_association?(object, attribute)
26
26
  object.class.associations[attribute.to_s]
27
27
  end
28
-
28
+
29
29
  def class_for_association(object, attribute)
30
30
  association = object.class.associations[attribute.to_s]
31
31
  association && association.klass
@@ -35,17 +35,17 @@ module Machinist
35
35
  attributes = {}
36
36
  lathe.assigned_attributes.each_pair do |attribute, value|
37
37
  association = lathe.object.class.associations[attribute.to_s]
38
- if association && (association.macro == :referenced_in) && !value.nil?
38
+ if association && (association.macro == :belongs_to_related) && !value.nil?
39
39
  attributes[association.foreign_key.to_sym] = value.id
40
40
  else
41
41
  attributes[attribute] = value
42
42
  end
43
43
  end
44
- attributes
45
- end
44
+ attributes
45
+ end
46
46
  end
47
47
  end
48
-
48
+
49
49
  module MongoidExtensions
50
50
  module Document
51
51
  def make(*args, &block)
@@ -56,13 +56,13 @@ module Machinist
56
56
  end
57
57
  lathe.object(&block)
58
58
  end
59
-
59
+
60
60
  def make_unsaved(*args)
61
- Machinist.with_save_nerfed { make(*args) }.tap do |object|
61
+ returning(Machinist.with_save_nerfed { make(*args) }) do |object|
62
62
  yield object if block_given?
63
63
  end
64
64
  end
65
-
65
+
66
66
  def plan(*args)
67
67
  lathe = Lathe.run(Machinist::MongoidAdapter, self.new, *args)
68
68
  Machinist::MongoidAdapter.assigned_attributes_without_associations(lathe)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: machinist_mongo
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
- - 1
7
6
  - 2
8
7
  - 0
9
- version: 1.2.0
8
+ - 0
9
+ - pre
10
+ version: 2.0.0.pre
10
11
  platform: ruby
11
12
  authors:
12
13
  - "Nicolas M\xC3\xA9rouze"
@@ -15,14 +16,13 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-01-12 00:00:00 +01:00
19
+ date: 2010-06-04 00:00:00 +02:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: machinist
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
@@ -47,9 +47,6 @@ files:
47
47
  - lib/machinist/mongo_mapper.rb
48
48
  - lib/machinist/mongoid.rb
49
49
  - README.textile
50
- - spec/mongo_mapper_spec.rb
51
- - spec/mongoid_spec.rb
52
- - spec/spec_helper.rb
53
50
  has_rdoc: true
54
51
  homepage: http://github.com/nmerouze/machinist_mongo
55
52
  licenses: []
@@ -60,7 +57,6 @@ rdoc_options:
60
57
  require_paths:
61
58
  - lib
62
59
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
60
  requirements:
65
61
  - - ">="
66
62
  - !ruby/object:Gem::Version
@@ -68,17 +64,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
64
  - 0
69
65
  version: "0"
70
66
  required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
67
  requirements:
73
- - - ">="
68
+ - - ">"
74
69
  - !ruby/object:Gem::Version
75
70
  segments:
76
- - 0
77
- version: "0"
71
+ - 1
72
+ - 3
73
+ - 1
74
+ version: 1.3.1
78
75
  requirements: []
79
76
 
80
77
  rubyforge_project:
81
- rubygems_version: 1.3.7
78
+ rubygems_version: 1.3.6
82
79
  signing_key:
83
80
  specification_version: 3
84
81
  summary: Machinist adapters for MongoDB ORMs