florrick 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 495895562e335c2a36e35c3a6bdd8476a2756a1d
4
- data.tar.gz: a970aad1d680cf16079543a0ddb6970ddad5a319
3
+ metadata.gz: 72ded218986890ab953e08fd2827246f536c98e6
4
+ data.tar.gz: e3499a4fb82bec5a3d5d0f0a4fd6db718ba7474e
5
5
  SHA512:
6
- metadata.gz: eecfa6c2b2e54e7e6b8c54d67b743dae428e9c158727867ce69b50aeaef17cdc632d7248a83ea9fe19a175db5ce8ef8f2a200dfb71010c16237f69717d215e76
7
- data.tar.gz: 797bf52c99f07d9eea0dd2413bbb6dda79ae745b11de23cff5f25412cb00b8abed2033da4e271b9dfeccb5dc9b49429b83c03a394751e770949c95979be24f53
6
+ metadata.gz: 774763f7e32f619b9d3fd55726944cd9a14b485046ecbefef9269d701ced77e0c957996529861af11ca69968a023175641043dd072f9a459e54b917a760a9f9a
7
+ data.tar.gz: 48aaf1f0e22df3c6302c12ef6de6af79d2df94977b230bfed60aab6d7a6dd290a4630c6fe6b404ada233521ab7170a748f5a8438f8d85846420d4426dc37dd99
data/lib/florrick.rb CHANGED
@@ -6,10 +6,10 @@ require 'florrick/builtin_formatters'
6
6
  require 'florrick/railtie' if defined?(Rails)
7
7
 
8
8
  module Florrick
9
-
9
+
10
10
  # A quick helper method for quickly running conversion
11
11
  def self.convert(string, objects = {})
12
12
  Builder.new(string, objects).output
13
13
  end
14
-
14
+
15
15
  end
@@ -33,7 +33,9 @@ module Florrick
33
33
  # we can do this easily
34
34
  previous_object = previous_object.string_interpolation_value_for(var)
35
35
  # if the previous object was nil, just set to the fallback string or empty
36
- final_string = fallback_string || '' if previous_object.nil?
36
+ if previous_object.nil? || (previous_object.is_a?(Array) && previous_object.empty?)
37
+ final_string = fallback_string || ''
38
+ end
37
39
  elsif previous_object.class.string_interpolation_relationship_for?(var)
38
40
  # maybe we can do this on another object
39
41
  previous_object = previous_object.send(var)
@@ -1,17 +1,17 @@
1
1
  module Florrick
2
2
  class Formatter
3
-
3
+
4
4
  class << self
5
5
  # Return all formatters available
6
6
  def formatters
7
7
  @formatters ||= {}
8
8
  end
9
-
9
+
10
10
  # Add a new global formatter
11
11
  def add(name, types = [], &block)
12
12
  formatters[name.to_sym] = self.new(name, types, &block)
13
13
  end
14
-
14
+
15
15
  # Run a string through a given formatter and return the result. If not possible, return false.
16
16
  def convert(name, value)
17
17
  if formatter = formatters[name.to_sym]
@@ -21,11 +21,11 @@ module Florrick
21
21
  end
22
22
  end
23
23
  end
24
-
24
+
25
25
  def initialize(name, types, &block)
26
26
  @name, @types, @block = name, types, block
27
27
  end
28
-
28
+
29
29
  def convert(value)
30
30
  if @types.empty? || @types.any? { |t| value.is_a?(t)}
31
31
  @block.call(value)
@@ -35,6 +35,6 @@ module Florrick
35
35
  rescue
36
36
  '???'
37
37
  end
38
-
38
+
39
39
  end
40
40
  end
@@ -1,12 +1,12 @@
1
1
  module Florrick
2
2
  class Railtie < Rails::Railtie
3
-
3
+
4
4
  initializer 'florrick.initialize' do
5
5
  ActiveSupport.on_load(:active_record) do
6
6
  require 'florrick/active_record_extension'
7
7
  ActiveRecord::Base.send :include, Florrick::ActiveRecordExtension
8
8
  end
9
9
  end
10
-
10
+
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Florrick
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: florrick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke