montage_rails 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/montage_rails/base/column.rb +13 -1
- data/lib/montage_rails/boolean.rb +10 -0
- data/lib/montage_rails/version.rb +1 -1
- data/test/dummy/log/test.log +112 -0
- data/test/montage_rails/base/column_test.rb +21 -0
- data/test/montage_rails/boolean_test.rb +49 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e6695e6e5e56ffc3fb558492594866e2ffeaf2a
|
4
|
+
data.tar.gz: 0b698d680b5e4f4f27d28be1509f8bb4a52f3fc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/test/dummy/log/test.log
CHANGED
@@ -26842,3 +26842,115 @@ Started POST "/montage_rails_mock/api/v1/schemas/movies/query/" for 127.0.0.1 at
|
|
26842
26842
|
[1m[36mMovie Load (6.1ms)[0m [1m{:filter=>{:title=>"The Jerk"}}[0m
|
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
|
[1m[35mMovie Load (6.2ms)[0m {:filter=>{:votes__gt=>900000}}
|
26845
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26846
|
+
[1m[36m (1.7ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26847
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26848
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26849
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26850
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26851
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26852
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26853
|
+
[1m[36m (2.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26854
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26855
|
+
[1m[36m (1.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26856
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26857
|
+
[1m[36m (0.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26858
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26859
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26860
|
+
[1m[36m (1.1ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26861
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26862
|
+
[1m[36m (1.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26863
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26864
|
+
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26865
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26866
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26867
|
+
[1m[36m (2.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26868
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26869
|
+
[1m[36m (1.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26870
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26871
|
+
[1m[36m (0.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26872
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26873
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26874
|
+
[1m[36m (1.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26875
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26876
|
+
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26877
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26878
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26879
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26880
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26881
|
+
[1m[36m (1.9ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26882
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26883
|
+
[1m[36m (1.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26884
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26885
|
+
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26886
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26887
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26888
|
+
[1m[36m (1.6ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26889
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26890
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26891
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26892
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26893
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26894
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26895
|
+
[1m[36m (1.9ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26896
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26897
|
+
[1m[36m (1.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26898
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26899
|
+
[1m[36m (0.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26900
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26901
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26902
|
+
[1m[36m (1.7ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26903
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26904
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26905
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26906
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26907
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26908
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26909
|
+
[1m[36m (1.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26910
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26911
|
+
[1m[36m (1.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26912
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26913
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26914
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26915
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26916
|
+
[1m[36m (1.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26917
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26918
|
+
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26919
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26920
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26921
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26922
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26923
|
+
[1m[36m (37.9ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26924
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26925
|
+
[1m[36m (1.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26926
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26927
|
+
[1m[36m (1.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26928
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26929
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26930
|
+
[1m[36m (1.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26931
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26932
|
+
[1m[36m (1.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26933
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26934
|
+
[1m[36m (0.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26935
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26936
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26937
|
+
[1m[36m (1.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26938
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26939
|
+
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26940
|
+
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
26941
|
+
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26942
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26943
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26944
|
+
[1m[36m (1.4ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26945
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26946
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26947
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26948
|
+
[1m[36m (0.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26949
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
26950
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26951
|
+
[1m[36m (1.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26952
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
26953
|
+
[1m[36m (1.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
26954
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
26955
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
26956
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m 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.
|
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
|