baja 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/baja/version.rb +1 -1
  3. data/lib/baja.rb +48 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2efabf4408adbb35bc549596535b334e27e5f76
4
- data.tar.gz: c0c08123714d3a2611bfb7112885e8f2940fa47a
3
+ metadata.gz: 53e291b74ec1b04cc10870c318ce486ca6802d14
4
+ data.tar.gz: 18dec3601eeffb5351ed72ca7a99d8f898c9bdec
5
5
  SHA512:
6
- metadata.gz: 552531516d0f3124d735909a4f3503b52ca319fabdbab3ccfce50b1e417700f29b64b820dede7b40bde0e18767e40a9f4f1662d18637bdd09776567f1cfb2f17
7
- data.tar.gz: 36ff25bcc120924ad73e7a0d80cb5b88f5484ed375c2c77a3ee6a63cefbcc35da63d10ecdfd5afb8c1d13a1396cc514a59a59b8c272255e75de944ca7f41246d
6
+ metadata.gz: d7659ac7f8b20d33cc3e9099218ce18f4605ac9bcd65d97c4e2e1a55b4d1ff396eadab3b22c4dba78db06f6bd034ce250301cf2fe2efe4e86ce291c48ce9d591
7
+ data.tar.gz: a765ae7400a7e2fa3e9497890778d49e91c66b4927834d33c793b7b53a66ef32629781572d36d8f88949686bb90f150ec18bbf03af6ceaa28d510a3586a0177d
data/lib/baja/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Baja
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
data/lib/baja.rb CHANGED
@@ -4,7 +4,8 @@ require 'yaml'
4
4
  require 'bundler'
5
5
  require 'factory_girl_rails'
6
6
  module Baja
7
- class Blast
7
+ class Blast
8
+ @@in_namespace
8
9
  def self.now!
9
10
  baja = YAML.load_file('baja.yml')
10
11
  baja = JSON.parse(baja.to_json,:symbolize_names => true)
@@ -15,7 +16,7 @@ module Baja
15
16
  end
16
17
  puts "throwing it down!"
17
18
  FactoryGirl.definition_file_paths.uniq!
18
- #FactoryGirl.find_definitions
19
+ @@in_namespace = false
19
20
  end
20
21
  end
21
22
  class Railtie < Rails::Railtie
@@ -49,3 +50,48 @@ end
49
50
  end
50
51
  end
51
52
  end
53
+
54
+ class FactoryGirl
55
+ def self.find_definitions
56
+ absolute_definition_file_paths = definition_file_paths.map { |path| File.expand_path(path) }
57
+
58
+ absolute_definition_file_paths.uniq.each do |path|
59
+ FactoryLoad.load(path)
60
+
61
+ if File.directory? path
62
+ Dir[File.join(path, '**', '*.rb')].sort.each do |file|
63
+ load file
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ module FactoryLoad
71
+ @path
72
+ def load(path)
73
+ @path = path
74
+ load("#{path}.rb") if File.exist?("#{path}.rb")
75
+ end
76
+
77
+ FactoryGirl::Syntax::Default::DSL
78
+ class FactoryGirl::Syntax::Default::DSL
79
+
80
+ def factory(name, options = {}, &block)
81
+ puts "path: @path"
82
+ options[:class] = name.to_s.gsub(/_list/,'') unless options.has_key?(:class)
83
+ name = :"#{@namespace}___#{name.to_s}" unless @namespace.nil?
84
+ puts name
85
+ factory = FactoryGirl::Factory.new(name, options)
86
+ proxy = FactoryGirl::DefinitionProxy.new(factory.definition)
87
+ proxy.instance_eval(&block) if block_given?
88
+
89
+ FactoryGirl.register_factory(factory)
90
+
91
+ proxy.child_factories.each do |(child_name, child_options, child_block)|
92
+ parent_factory = child_options.delete(:parent) || name
93
+ factory(child_name, child_options.merge(parent: parent_factory), &child_block)
94
+ end
95
+ end
96
+ end
97
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baja
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Zuercher