machinist 2.0.0.beta1 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  .DS_Store
3
3
  coverage
4
4
  doc
5
+ pkg
5
6
  tags
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.0.beta2
@@ -1,4 +1,5 @@
1
1
  require 'machinist/blueprint'
2
+ require 'machinist/configuration'
2
3
  require 'machinist/exceptions'
3
4
  require 'machinist/lathe'
4
5
  require 'machinist/machinable'
@@ -0,0 +1,32 @@
1
+ module Machinist
2
+
3
+ # Configure Machinist.
4
+ #
5
+ # To change Machinist configuration, do something like this in your
6
+ # config/environments/test.rb or somewhere similar:
7
+ #
8
+ # Machinist.configure do |config|
9
+ # config.cache_objects = false
10
+ # end
11
+ class Configuration
12
+ # Set this to false to disable object caching. Defaults to true.
13
+ attr_accessor :cache_objects
14
+
15
+ def cache_objects? #:nodoc:
16
+ @cache_objects
17
+ end
18
+
19
+ def initialize #:nodoc:
20
+ self.cache_objects = true
21
+ end
22
+ end
23
+
24
+ def self.configuration
25
+ @configuration ||= Configuration.new
26
+ end
27
+
28
+ def self.configure
29
+ yield(configuration)
30
+ end
31
+
32
+ end
@@ -51,7 +51,11 @@ module Machinist
51
51
  # Arguments are the same as for make.
52
52
  def make!(*args)
53
53
  decode_args_to_make(*args) do |blueprint, attributes|
54
- Shop.instance.buy(blueprint, attributes)
54
+ if Machinist.configuration.cache_objects?
55
+ Shop.instance.buy(blueprint, attributes)
56
+ else
57
+ blueprint.make!(attributes)
58
+ end
55
59
  end
56
60
  end
57
61
 
@@ -0,0 +1,78 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{machinist}
8
+ s.version = "2.0.0.beta2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Pete Yandell"]
12
+ s.date = %q{2010-07-07}
13
+ s.email = %q{pete@notahat.com}
14
+ s.extra_rdoc_files = [
15
+ "README.markdown"
16
+ ]
17
+ s.files = [
18
+ ".gitignore",
19
+ "Gemfile",
20
+ "MIT-LICENSE",
21
+ "README.markdown",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/generators/machinist/install/USAGE",
25
+ "lib/generators/machinist/install/install_generator.rb",
26
+ "lib/generators/machinist/install/templates/blueprints.rb",
27
+ "lib/generators/machinist/install/templates/machinist.rb.erb",
28
+ "lib/generators/machinist/model/model_generator.rb",
29
+ "lib/machinist.rb",
30
+ "lib/machinist/active_record.rb",
31
+ "lib/machinist/active_record/blueprint.rb",
32
+ "lib/machinist/active_record/lathe.rb",
33
+ "lib/machinist/blueprint.rb",
34
+ "lib/machinist/configuration.rb",
35
+ "lib/machinist/exceptions.rb",
36
+ "lib/machinist/lathe.rb",
37
+ "lib/machinist/machinable.rb",
38
+ "lib/machinist/shop.rb",
39
+ "lib/machinist/warehouse.rb",
40
+ "machinist.gemspec",
41
+ "spec/active_record_spec.rb",
42
+ "spec/blueprint_spec.rb",
43
+ "spec/exceptions_spec.rb",
44
+ "spec/inheritance_spec.rb",
45
+ "spec/machinable_spec.rb",
46
+ "spec/shop_spec.rb",
47
+ "spec/spec_helper.rb",
48
+ "spec/support/active_record_environment.rb",
49
+ "spec/warehouse_spec.rb"
50
+ ]
51
+ s.homepage = %q{http://github.com/notahat/machinist}
52
+ s.rdoc_options = ["--charset=UTF-8"]
53
+ s.require_paths = ["lib"]
54
+ s.rubygems_version = %q{1.3.7}
55
+ s.summary = %q{Fixtures aren't fun. Machinist is.}
56
+ s.test_files = [
57
+ "spec/active_record_spec.rb",
58
+ "spec/blueprint_spec.rb",
59
+ "spec/exceptions_spec.rb",
60
+ "spec/inheritance_spec.rb",
61
+ "spec/machinable_spec.rb",
62
+ "spec/shop_spec.rb",
63
+ "spec/spec_helper.rb",
64
+ "spec/support/active_record_environment.rb",
65
+ "spec/warehouse_spec.rb"
66
+ ]
67
+
68
+ if s.respond_to? :specification_version then
69
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
70
+ s.specification_version = 3
71
+
72
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
73
+ else
74
+ end
75
+ else
76
+ end
77
+ end
78
+
@@ -48,6 +48,16 @@ describe Machinist::ActiveRecord do
48
48
  fake_a_test { post_b = Post.make! }
49
49
  post_a.should == post_b
50
50
  end
51
+
52
+ it "should not buy objects from the shop if caching is disabled" do
53
+ Machinist.configuration.cache_objects = false
54
+ Post.blueprint { }
55
+ post_a, post_b = nil, nil
56
+ fake_a_test { post_a = Post.make! }
57
+ fake_a_test { post_b = Post.make! }
58
+ post_a.should_not == post_b
59
+ Machinist.configuration.cache_objects = true
60
+ end
51
61
  end
52
62
 
53
63
  context "associations support" do
@@ -5,3 +5,7 @@ require 'rubygems'
5
5
  require 'test/unit'
6
6
  require 'rspec'
7
7
  require 'machinist'
8
+
9
+ Machinist.configure do |config|
10
+ config.cache_objects = true
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: machinist
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1848230035
4
+ hash: -1848230038
5
5
  prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
9
  - 0
10
- - beta1
11
- version: 2.0.0.beta1
10
+ - beta2
11
+ version: 2.0.0.beta2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Pete Yandell
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-06 00:00:00 +10:00
19
+ date: 2010-07-07 00:00:00 +10:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -34,6 +34,7 @@ files:
34
34
  - MIT-LICENSE
35
35
  - README.markdown
36
36
  - Rakefile
37
+ - VERSION
37
38
  - lib/generators/machinist/install/USAGE
38
39
  - lib/generators/machinist/install/install_generator.rb
39
40
  - lib/generators/machinist/install/templates/blueprints.rb
@@ -44,11 +45,13 @@ files:
44
45
  - lib/machinist/active_record/blueprint.rb
45
46
  - lib/machinist/active_record/lathe.rb
46
47
  - lib/machinist/blueprint.rb
48
+ - lib/machinist/configuration.rb
47
49
  - lib/machinist/exceptions.rb
48
50
  - lib/machinist/lathe.rb
49
51
  - lib/machinist/machinable.rb
50
52
  - lib/machinist/shop.rb
51
53
  - lib/machinist/warehouse.rb
54
+ - machinist.gemspec
52
55
  - spec/active_record_spec.rb
53
56
  - spec/blueprint_spec.rb
54
57
  - spec/exceptions_spec.rb