montage_rails 0.7.2 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5670a0b572ae41ea4a4118199cb07309f40b8630
4
- data.tar.gz: 011f5b8d5fb0a0837624d276be7547f9c5818805
3
+ metadata.gz: 0e6695e6e5e56ffc3fb558492594866e2ffeaf2a
4
+ data.tar.gz: 0b698d680b5e4f4f27d28be1509f8bb4a52f3fc8
5
5
  SHA512:
6
- metadata.gz: cbd621fea215d3fc07146e92c9de9ca82b5f56da39497bcee2c7136850b0a6fde4efe3d91b51bbbae6ad89fcb1dc15c858f1824005dbb3f742503ccce4ce7c9f
7
- data.tar.gz: e1dd644a384d71fd43936f635d795603380693f136efb1c15e91f8213ac8fb898cf406d31abc49a9141673a10cc1c4147ffc99f11b76f9c42c4e2e4d7572df3d
6
+ metadata.gz: d3d2d8d01fd804226c6845b4fccad026e1d7d7e8f90686c6cd958c792a83e9fce912fdda838502cf79a4460db6df6bb9bb48ecfa00150b6ec1ab0c569501c470
7
+ data.tar.gz: ed66314510d029c6376396b12fee12da8ef9024b29ff0fd215e6eab2f1ccb5ffd8baac3df4eb4cdcebc264b8c56d29376895c20902a1d2f4743f9ec1674dbc2b
@@ -1,3 +1,5 @@
1
+ require 'montage_rails/boolean'
2
+
1
3
  module MontageRails
2
4
  class Base
3
5
  class Column
@@ -8,7 +10,8 @@ module MontageRails
8
10
  "date" => Date,
9
11
  "time" => Time,
10
12
  "datetime" => DateTime,
11
- "numeric" => Numeric
13
+ "numeric" => Numeric,
14
+ "boolean" => Boolean
12
15
  }
13
16
 
14
17
  attr_accessor :name, :type, :required
@@ -39,6 +42,13 @@ module MontageRails
39
42
  /\A\d+\.\d+\z/ =~ value.to_s
40
43
  end
41
44
 
45
+ # Determines if the string is a Boolean
46
+ # Returns true or false
47
+ #
48
+ def is_boolean?(value)
49
+ Boolean.is_me?(value)
50
+ end
51
+
42
52
  def coerce(value)
43
53
  return nil unless value
44
54
  return value if value.is_a?(TYPE_MAP[type])
@@ -47,6 +57,8 @@ module MontageRails
47
57
  coerce_to = Integer
48
58
  elsif is_f?(value)
49
59
  coerce_to = Float
60
+ elsif is_boolean?(value)
61
+ coerce_to = Axiom::Types::Boolean
50
62
  else
51
63
  coerce_to = TYPE_MAP[type]
52
64
  end
@@ -0,0 +1,10 @@
1
+ module MontageRails
2
+ class Boolean
3
+ def self.is_me?(value)
4
+ return true if value.is_a?(TrueClass)
5
+ return true if value.is_a?(FalseClass)
6
+ return true if ["true", "false", "1", "0"].include?(value.to_s.downcase)
7
+ false
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module MontageRails
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  end
@@ -26842,3 +26842,115 @@ Started POST "/montage_rails_mock/api/v1/schemas/movies/query/" for 127.0.0.1 at
26842
26842
  Movie Load (6.1ms) {:filter=>{:title=>"The Jerk"}}
26843
26843
  Started POST "/montage_rails_mock/api/v1/schemas/movies/query/" for 127.0.0.1 at 2015-11-19 16:47:20 -0800
26844
26844
  Movie Load (6.2ms) {:filter=>{:votes__gt=>900000}}
26845
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26846
+  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26847
+  (0.1ms) select sqlite_version(*)
26848
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26849
+  (0.1ms) SELECT version FROM "schema_migrations"
26850
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26851
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26852
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26853
+  (2.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26854
+  (0.1ms) select sqlite_version(*)
26855
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26856
+  (0.1ms) SELECT version FROM "schema_migrations"
26857
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26858
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26859
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26860
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26861
+  (0.1ms) select sqlite_version(*)
26862
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26863
+  (0.1ms) SELECT version FROM "schema_migrations"
26864
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26865
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26866
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26867
+  (2.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26868
+  (0.1ms) select sqlite_version(*)
26869
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26870
+  (0.1ms) SELECT version FROM "schema_migrations"
26871
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26872
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26873
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26874
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26875
+  (0.1ms) select sqlite_version(*)
26876
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26877
+  (0.1ms) SELECT version FROM "schema_migrations"
26878
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26879
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26880
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26881
+  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26882
+  (0.1ms) select sqlite_version(*)
26883
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26884
+  (0.1ms) SELECT version FROM "schema_migrations"
26885
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26886
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26887
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26888
+  (1.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26889
+  (0.1ms) select sqlite_version(*)
26890
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26891
+  (0.1ms) SELECT version FROM "schema_migrations"
26892
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26893
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26894
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26895
+  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26896
+  (0.1ms) select sqlite_version(*)
26897
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26898
+  (0.1ms) SELECT version FROM "schema_migrations"
26899
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26900
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26901
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26902
+  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26903
+  (0.1ms) select sqlite_version(*)
26904
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26905
+  (0.1ms) SELECT version FROM "schema_migrations"
26906
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26907
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26908
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26909
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26910
+  (0.1ms) select sqlite_version(*)
26911
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26912
+  (0.1ms) SELECT version FROM "schema_migrations"
26913
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26914
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26915
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26916
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26917
+  (0.1ms) select sqlite_version(*)
26918
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26919
+  (0.1ms) SELECT version FROM "schema_migrations"
26920
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26921
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26922
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
26923
+  (37.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26924
+  (0.1ms) select sqlite_version(*)
26925
+  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26926
+  (0.1ms) SELECT version FROM "schema_migrations"
26927
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26928
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26929
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26930
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26931
+  (0.1ms) select sqlite_version(*)
26932
+  (1.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26933
+  (0.1ms) SELECT version FROM "schema_migrations"
26934
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26935
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26936
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26937
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26938
+  (0.1ms) select sqlite_version(*)
26939
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26940
+  (0.2ms) SELECT version FROM "schema_migrations"
26941
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26942
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26943
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26944
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26945
+  (0.1ms) select sqlite_version(*)
26946
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26947
+  (0.1ms) SELECT version FROM "schema_migrations"
26948
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26949
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26950
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26951
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26952
+  (0.1ms) select sqlite_version(*)
26953
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
26954
+  (0.1ms) SELECT version FROM "schema_migrations"
26955
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
26956
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -60,6 +60,27 @@ class MontageRails::Base::ColumnTest < Minitest::Test
60
60
  column = MontageRails::Base::Column.new("foo", "numeric")
61
61
  assert_equal 60.0, column.coerce(60.000000)
62
62
  end
63
+
64
+ should "coerce a 'true' string to a boolean" do
65
+ column = MontageRails::Base::Column.new("foo", "boolean")
66
+ assert column.coerce('true')
67
+ end
68
+
69
+ should "coerce a 'false' string to a boolean" do
70
+ column = MontageRails::Base::Column.new("foo", "boolean")
71
+ puts column.coerce('false')
72
+ refute column.coerce('false')
73
+ end
74
+
75
+ should "handle a TrueClass" do
76
+ column = MontageRails::Base::Column.new("foo", "boolean")
77
+ assert column.coerce(true)
78
+ end
79
+
80
+ should "handle a FalseClass" do
81
+ column = MontageRails::Base::Column.new("foo", "boolean")
82
+ refute column.coerce(false)
83
+ end
63
84
  end
64
85
 
65
86
  context "is_i?" do
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+ require 'montage_rails/boolean'
3
+
4
+ module MontageRails
5
+ class BooleanTest < MiniTest::Test
6
+ describe ".is_me?" do
7
+ context "when a 'true' string is passed in" do
8
+ should "return true" do
9
+ assert Boolean.is_me?('true')
10
+ end
11
+ end
12
+
13
+ context "when a 'false' string is passed in" do
14
+ should "return true" do
15
+ assert Boolean.is_me?('false')
16
+ end
17
+ end
18
+
19
+ context "when a TrueClass is passed in" do
20
+ should "return true" do
21
+ assert Boolean.is_me?(true)
22
+ end
23
+ end
24
+
25
+ context "when a FalseClass is passed in" do
26
+ should "return true" do
27
+ assert Boolean.is_me?(false)
28
+ end
29
+ end
30
+
31
+ context "when a 0 or 1 is passed in" do
32
+ should "return true" do
33
+ assert Boolean.is_me?(1)
34
+ assert Boolean.is_me?(0)
35
+ assert Boolean.is_me?("1")
36
+ assert Boolean.is_me?("0")
37
+ end
38
+ end
39
+
40
+ context "when the value is not a boolean" do
41
+ should "return false" do
42
+ refute Boolean.is_me?("foo")
43
+ refute Boolean.is_me?(2)
44
+ refute Boolean.is_me?("2")
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: montage_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dphaener
@@ -303,6 +303,7 @@ files:
303
303
  - lib/montage_rails/application_resource.rb
304
304
  - lib/montage_rails/base.rb
305
305
  - lib/montage_rails/base/column.rb
306
+ - lib/montage_rails/boolean.rb
306
307
  - lib/montage_rails/errors.rb
307
308
  - lib/montage_rails/log_subscriber.rb
308
309
  - lib/montage_rails/mock_server.rb
@@ -383,6 +384,7 @@ files:
383
384
  - test/montage_rails/application_resource_test.rb
384
385
  - test/montage_rails/base/column_test.rb
385
386
  - test/montage_rails/base_test.rb
387
+ - test/montage_rails/boolean_test.rb
386
388
  - test/montage_rails/query_cache_test.rb
387
389
  - test/montage_rails/relation_test.rb
388
390
  - test/montage_rails_test.rb
@@ -484,6 +486,7 @@ test_files:
484
486
  - test/montage_rails/application_resource_test.rb
485
487
  - test/montage_rails/base/column_test.rb
486
488
  - test/montage_rails/base_test.rb
489
+ - test/montage_rails/boolean_test.rb
487
490
  - test/montage_rails/query_cache_test.rb
488
491
  - test/montage_rails/relation_test.rb
489
492
  - test/montage_rails_test.rb