baja 0.5.2 → 0.5.3
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.
- checksums.yaml +4 -4
- data/lib/baja/version.rb +1 -1
- data/lib/baja.rb +48 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e291b74ec1b04cc10870c318ce486ca6802d14
|
4
|
+
data.tar.gz: 18dec3601eeffb5351ed72ca7a99d8f898c9bdec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7659ac7f8b20d33cc3e9099218ce18f4605ac9bcd65d97c4e2e1a55b4d1ff396eadab3b22c4dba78db06f6bd034ce250301cf2fe2efe4e86ce291c48ce9d591
|
7
|
+
data.tar.gz: a765ae7400a7e2fa3e9497890778d49e91c66b4927834d33c793b7b53a66ef32629781572d36d8f88949686bb90f150ec18bbf03af6ceaa28d510a3586a0177d
|
data/lib/baja/version.rb
CHANGED
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
|
-
|
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
|