HornsAndHooves-moribus 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +3 -3
- data/lib/moribus/macros.rb +16 -4
- data/lib/moribus/version.rb +1 -1
- 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: 78f55dc7ce48380cd5e0abab56ff669189a78720
|
4
|
+
data.tar.gz: e12ffe1c8b66b47b2d7fbebc420273dd4e91c755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38f92e8d95d1509b6f67b2d8e24242e352024746a989563edfc23c6b1e1fd8cbd5010fb408319b00a14d538a6dcac7821356c7e8093635e7239dedc332ffb2fa
|
7
|
+
data.tar.gz: dde51415193dae5676e4444bb12278871459ea3ef8693a3c87926a6333bd0428ea490681a46da1b0ef18ba83e1ce51e83edaed4426be997da04ddb69d762dfea
|
data/.simplecov
CHANGED
@@ -2,17 +2,17 @@ require "simplecov-rcov-text"
|
|
2
2
|
require "colorized_text"
|
3
3
|
include ColorizedText
|
4
4
|
|
5
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
6
6
|
SimpleCov::Formatter::RcovTextFormatter,
|
7
7
|
SimpleCov::Formatter::HTMLFormatter
|
8
|
-
]
|
8
|
+
])
|
9
9
|
SimpleCov.start do
|
10
10
|
add_filter "/spec/"
|
11
11
|
|
12
12
|
# Fail the build when coverage is weak:
|
13
13
|
at_exit do
|
14
14
|
SimpleCov.result.format!
|
15
|
-
threshold, actual =
|
15
|
+
threshold, actual = 96.875, SimpleCov.result.covered_percent
|
16
16
|
if actual < threshold
|
17
17
|
msg = "\nLow coverage: "
|
18
18
|
msg << red("#{actual}%")
|
data/lib/moribus/macros.rb
CHANGED
@@ -92,8 +92,7 @@ module Moribus
|
|
92
92
|
end
|
93
93
|
|
94
94
|
reflection = has_one(name, scope, options)
|
95
|
-
|
96
|
-
reflection = reflection["#{name}"] if reflection.respond_to? :[]
|
95
|
+
reflection = normalize_reflection(reflection, name)
|
97
96
|
reflection.options[:is_current] = true
|
98
97
|
accepts_nested_attributes_for name
|
99
98
|
define_effective_reader_for name
|
@@ -108,8 +107,7 @@ module Moribus
|
|
108
107
|
# Extensions::HasAggregatedExtension)
|
109
108
|
def has_aggregated(name, options = {})
|
110
109
|
reflection = belongs_to(name, options)
|
111
|
-
|
112
|
-
reflection = reflection["#{name}"] if reflection.respond_to? :[]
|
110
|
+
reflection = normalize_reflection(reflection, name)
|
113
111
|
reflection.options[:aggregated] = true
|
114
112
|
accepts_nested_attributes_for name
|
115
113
|
define_effective_reader_for name
|
@@ -118,6 +116,20 @@ module Moribus
|
|
118
116
|
end
|
119
117
|
private :has_aggregated
|
120
118
|
|
119
|
+
# Normalize reflection for Rails 4.1/4.2.
|
120
|
+
def normalize_reflection(reflection, name)
|
121
|
+
return reflection unless reflection.respond_to? :[]
|
122
|
+
|
123
|
+
if reflection.has_key?(name)
|
124
|
+
# Rails 4.1
|
125
|
+
reflection[name]
|
126
|
+
else
|
127
|
+
# Rails 4.2
|
128
|
+
reflection["#{name}"]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
private :normalize_reflection
|
132
|
+
|
121
133
|
# Declare a reader that will build associated object if it does not exist.
|
122
134
|
# We can actually extend an association's readers like:
|
123
135
|
#
|
data/lib/moribus/version.rb
CHANGED