rails_model_stacker 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/build_sourceforge.sh +4 -0
- data/lib/rails_model_stacker/factory_stacker.rb +36 -4
- data/lib/rails_model_stacker/rms.rb +16 -0
- data/rails_model_stacker-0.0.5.gem +0 -0
- data/rails_model_stacker.gemspec +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5e04a9c2241866c5e23662daba91ce4019e9e9a
|
4
|
+
data.tar.gz: dd24dcdae9ae908ac1d55b910f18b4fd8273509d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1c8b6758eaa07ef22fe3d9094f113a18b2fcd562aff286444782e1dafaeeb7fbe2ecee3637acb49237866ed98110c820d74a85cdcd2b5e91763a0d4d8059722
|
7
|
+
data.tar.gz: f6481c1b6d7b5434ffe407ee7e215991ec19ebf94ed13389454af56393eada19d35e71885ac46d45bf5fd2d681ba926f1680d93764b5c272c169e8bdb636cd0e
|
@@ -8,14 +8,46 @@ module FactoryGirl
|
|
8
8
|
##
|
9
9
|
#short hand sequence
|
10
10
|
#+column+:: symbol of column name
|
11
|
-
|
12
|
-
|
11
|
+
#+type+:: symbol of type, :text or :money
|
12
|
+
def auto_sequence column, type = :text
|
13
|
+
sequence(column) do |n|
|
14
|
+
generate_as_text n, column.to_s, type
|
15
|
+
end
|
16
|
+
|
13
17
|
end
|
14
18
|
|
15
19
|
##
|
16
20
|
#short hand sequence for multiple columns
|
17
21
|
#+columns+:: array of symbols of column names
|
18
|
-
def auto_sequencer columns
|
19
|
-
columns.each { |k| sequence(k) }
|
22
|
+
def auto_sequencer columns, type
|
23
|
+
columns.each { |k| sequence(k, type) }
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
#sequence with money output
|
28
|
+
def auto_money_sequence column
|
29
|
+
auto_sequence column, :money
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
#multiple sequences with money type
|
34
|
+
def auto_monney_sequencer columns
|
35
|
+
auto_sequencer columns, :money
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
##
|
40
|
+
#makes the text for auto_sequence
|
41
|
+
#+index+:: index of item
|
42
|
+
#+template+:: only the prepended text atm
|
43
|
+
#+type+:: symbol of type, will handle any symbol gracefully
|
44
|
+
def generate_as_text index, template, type
|
45
|
+
case type
|
46
|
+
when :money
|
47
|
+
"#{index}.#{rand(99)}"
|
48
|
+
else
|
49
|
+
"#{template} #{index}"
|
50
|
+
end
|
51
|
+
|
20
52
|
end
|
21
53
|
end
|
@@ -15,6 +15,18 @@ module RailsModelStacker
|
|
15
15
|
attributes.each { |key| send(trait,key) }
|
16
16
|
end
|
17
17
|
|
18
|
+
##
|
19
|
+
#Declare traits for attributes
|
20
|
+
#
|
21
|
+
#+attributes+:: array of symbols of attributes
|
22
|
+
#+traits+:: array of symbols of traits
|
23
|
+
def declare_traits_for attributes, traits
|
24
|
+
attributes.each do |k|
|
25
|
+
traits.each { |t| sent(t, k) }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
18
30
|
##
|
19
31
|
#Ensures attributes will be present
|
20
32
|
#+attributes+:: array of symbols of field names
|
@@ -51,6 +63,10 @@ module RailsModelStacker
|
|
51
63
|
declare_trait_for attributes, :accepts_nested_attributes_for
|
52
64
|
end
|
53
65
|
|
66
|
+
def declare_has_many_nested attributes
|
67
|
+
declare_taits_for attributes, [:has_and_belongs_to_many, :accepts_nested_attributes_for]
|
68
|
+
end
|
69
|
+
|
54
70
|
end
|
55
71
|
end
|
56
72
|
|
Binary file
|
data/rails_model_stacker.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rails_model_stacker"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.6"
|
7
7
|
s.date = "2017-07-13"
|
8
8
|
s.summary = "Rails Model Stacker"
|
9
9
|
s.description = "Shorter Active Record validations and associations with RSpec and shoulda support"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_model_stacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Petricone
|
@@ -74,10 +74,12 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- build_sourceforge.sh
|
77
78
|
- lib/rails_model_stacker/factory_stacker.rb
|
78
79
|
- lib/rails_model_stacker/rms.rb
|
79
80
|
- lib/rails_model_stacker/spec_stacker.rb
|
80
81
|
- license
|
82
|
+
- rails_model_stacker-0.0.5.gem
|
81
83
|
- rails_model_stacker.gemspec
|
82
84
|
homepage:
|
83
85
|
licenses:
|