very_dson 0.0.1 → 0.0.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: e1eae6da96c1ce00f1176893666445c2fcf5bb12
4
- data.tar.gz: e03900e5ebb062f7a52616d25caa5a63aecb22ce
3
+ metadata.gz: edce7cf1e57a7b6a68c8dbd49de963adfe93ff6a
4
+ data.tar.gz: ef268fb26ea1bf305a0dd0f7328fc6423b278d5f
5
5
  SHA512:
6
- metadata.gz: b43f8d8a353f3227b98c6b92b22e2da380acfe2d025454efb138329c66767c44dfbb7142d81d744da6964c6ba31aeabf70cc813f4415fdec889d58a3571030eb
7
- data.tar.gz: dacaae8f07f070e9904b047f17f149645d1beef9d3663a980171acfd8cc148fe59f135455a09317eede9816753ad5142bf2799166e9368fb3ef63ecbaf46dda7
6
+ metadata.gz: 58ed0b17dd9b8345a740616e5a661040b4260cd53da76ca95e780119ae7648d1527d88dac5e778395d3f6a0478a6b9c06f61df2cae6909ae4dc1dc260a32b687
7
+ data.tar.gz: 92293dbdd7672d59deb3cc16963314470b451b6189831211e73df893425edbdeb4eb1ba36851388b0eea22e218c2ca98f726653e2902761c9cc5ee19df4d1ab6
@@ -35,7 +35,7 @@ module VeryDSON
35
35
  value = delimited(:array, value)
36
36
  "so #{value} many"
37
37
  else
38
- raise "such fail #{value}"
38
+ raise "such fail - cannot stringify #{value}"
39
39
  end
40
40
  end
41
41
 
@@ -43,6 +43,8 @@ module VeryDSON
43
43
  case value
44
44
  when Symbol
45
45
  EscapedString.new(value.to_s)
46
+ when EscapedString
47
+ value
46
48
  when String
47
49
  EscapedString.new(value)
48
50
  when Numeric, NilClass, TrueClass, FalseClass
@@ -77,12 +79,20 @@ module VeryDSON
77
79
  end
78
80
 
79
81
  def object_to_key_value(value)
80
- if value.respond_to?(:attributes)
81
- value.attributes
82
+ if value.is_a?(Date) || value.is_a?(DateTime) || value.is_a?(ActiveSupport::TimeWithZone)
83
+ simplify(value.to_s)
84
+ elsif value.respond_to?(:to_a)
85
+ simplify(value.to_a)
86
+ elsif value.respond_to?(:attributes)
87
+ simplify(value.attributes)
82
88
  elsif value.respond_to?(:to_hash)
83
- value.to_hash
89
+ simplify(value.to_hash)
90
+ elsif value.respond_to?(:instance_values)
91
+ simplify(value.instance_values)
92
+ elsif value.respond_to?(:instance_values)
93
+ simplify(value.instance_values)
84
94
  else
85
- value.instance_values
95
+ raise "such fail - cannot convert to key value #{value}"
86
96
  end
87
97
  end
88
98
  end
@@ -1,4 +1,6 @@
1
1
  module VeryDSON
2
+ Mime::Type.register_alias "text/html", :dson
3
+
2
4
  ActionController::Renderers.add :dson do |dson, options|
3
5
  self.content_type ||= Mime::TEXT
4
6
  DSON.stringify(dson)
@@ -1,3 +1,3 @@
1
1
  module VeryDSON
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,12 @@
1
1
  class DogeController < ApplicationController
2
2
  def index
3
+ respond_to do |f|
4
+ f.html { render_it }
5
+ f.dson { render_it }
6
+ end
7
+ end
8
+
9
+ def render_it
3
10
  render dson: { "foo" => ["bar", "baz", "fizzbuzz"], doge: true }
4
11
  end
5
12
  end
@@ -18,6 +18,7 @@ module Dummy
18
18
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
19
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
20
  # config.i18n.default_locale = :de
21
+
22
+ config.secret_key_base = "test"
21
23
  end
22
24
  end
23
-
@@ -1,4 +1,4 @@
1
- Rails.application.configure do
1
+ Dummy::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # In the development environment your application's code is reloaded on
@@ -1,4 +1,4 @@
1
- Rails.application.configure do
1
+ Dummy::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
@@ -1,5 +1,5 @@
1
1
  Rails.application.routes.draw do
2
- root "doge#index"
2
+ get "doge", to: "doge#index"
3
3
  # The priority is based upon order of creation: first created -> highest priority.
4
4
  # See how all your routes lay out with "rake routes".
5
5
 
@@ -823,3 +823,249 @@ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
823
823
  Started GET "/" for 127.0.0.1 at 2014-06-08 23:34:06 -0400
824
824
  Processing by DogeController#index as HTML
825
825
  Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
826
+
827
+
828
+ Started GET "/" for 127.0.0.1 at 2014-06-09 00:21:07 -0400
829
+ Processing by Rails::WelcomeController#index as HTML
830
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/railties-4.0.2/lib/rails/templates/rails/welcome/index.html.erb (1.3ms)
831
+ Completed 200 OK in 7ms (Views: 6.5ms | ActiveRecord: 0.0ms)
832
+
833
+
834
+ Started GET "/" for 127.0.0.1 at 2014-06-09 00:21:07 -0400
835
+ Processing by Rails::WelcomeController#index as HTML
836
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/railties-4.0.2/lib/rails/templates/rails/welcome/index.html.erb (0.0ms)
837
+ Completed 200 OK in 1ms (Views: 1.0ms | ActiveRecord: 0.0ms)
838
+
839
+
840
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:21:11 -0400
841
+ Processing by DogeController#index as HTML
842
+ Completed 500 Internal Server Error in 1ms
843
+
844
+ NameError (uninitialized constant Mime::DSON):
845
+ app/controllers/doge_controller.rb:4:in `block in index'
846
+ app/controllers/doge_controller.rb:3:in `index'
847
+
848
+
849
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.5ms)
850
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
851
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (10.4ms)
852
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (22.9ms)
853
+
854
+
855
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:21:15 -0400
856
+ Processing by DogeController#index as
857
+ Completed 500 Internal Server Error in 1ms
858
+
859
+ NameError (uninitialized constant Mime::DSON):
860
+ app/controllers/doge_controller.rb:4:in `block in index'
861
+ app/controllers/doge_controller.rb:3:in `index'
862
+
863
+
864
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.5ms)
865
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
866
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.1ms)
867
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (9.8ms)
868
+
869
+
870
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:21:17 -0400
871
+ Processing by DogeController#index as
872
+ Completed 500 Internal Server Error in 1ms
873
+
874
+ NameError (uninitialized constant Mime::DSON):
875
+ app/controllers/doge_controller.rb:4:in `block in index'
876
+ app/controllers/doge_controller.rb:3:in `index'
877
+
878
+
879
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.5ms)
880
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
881
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
882
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (9.0ms)
883
+
884
+
885
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:22:37 -0400
886
+ Processing by DogeController#index as DSON
887
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
888
+
889
+
890
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:22:41 -0400
891
+ Processing by DogeController#index as DSON
892
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
893
+
894
+
895
+ Started GET "/doge." for 127.0.0.1 at 2014-06-09 00:24:30 -0400
896
+
897
+ ActionController::RoutingError (No route matches [GET] "/doge."):
898
+ actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
899
+ actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
900
+ railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
901
+ railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
902
+ activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
903
+ activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
904
+ activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
905
+ railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
906
+ actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
907
+ rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
908
+ rack (1.5.2) lib/rack/runtime.rb:17:in `call'
909
+ activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
910
+ rack (1.5.2) lib/rack/lock.rb:17:in `call'
911
+ actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
912
+ rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
913
+ railties (4.0.2) lib/rails/engine.rb:511:in `call'
914
+ railties (4.0.2) lib/rails/application.rb:97:in `call'
915
+ rack (1.5.2) lib/rack/lock.rb:17:in `call'
916
+ rack (1.5.2) lib/rack/content_length.rb:14:in `call'
917
+ rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
918
+ /Users/bolandrm/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
919
+ /Users/bolandrm/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
920
+ /Users/bolandrm/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
921
+
922
+
923
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
924
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/routes/_route.html.erb (0.5ms)
925
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/routes/_table.html.erb (4.0ms)
926
+ Rendered /Users/bolandrm/.rvm/gems/ruby-2.1.0-preview2/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (20.3ms)
927
+
928
+
929
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:24:32 -0400
930
+ Processing by DogeController#index as HTML
931
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
932
+
933
+
934
+ Started GET "/doge.html" for 127.0.0.1 at 2014-06-09 00:24:38 -0400
935
+ Processing by DogeController#index as HTML
936
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
937
+
938
+
939
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:24:42 -0400
940
+ Processing by DogeController#index as HTML
941
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
942
+
943
+
944
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:24:45 -0400
945
+ Processing by DogeController#index as DSON
946
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
947
+
948
+
949
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:25:26 -0400
950
+ Processing by DogeController#index as HTML
951
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
952
+
953
+
954
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:25:27 -0400
955
+ Processing by DogeController#index as HTML
956
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
957
+
958
+
959
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:25:31 -0400
960
+ Processing by DogeController#index as DSON
961
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
962
+
963
+
964
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:25:33 -0400
965
+ Processing by DogeController#index as HTML
966
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
967
+
968
+
969
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:25:34 -0400
970
+ Processing by DogeController#index as HTML
971
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
972
+
973
+
974
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:25:34 -0400
975
+ Processing by DogeController#index as HTML
976
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
977
+
978
+
979
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:25:35 -0400
980
+ Processing by DogeController#index as HTML
981
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
982
+
983
+
984
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:25:35 -0400
985
+ Processing by DogeController#index as HTML
986
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
987
+
988
+
989
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:27:49 -0400
990
+ Processing by DogeController#index as HTML
991
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
992
+
993
+
994
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:27:50 -0400
995
+ Processing by DogeController#index as HTML
996
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
997
+
998
+
999
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:27:52 -0400
1000
+ Processing by DogeController#index as DSON
1001
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1002
+
1003
+
1004
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:28:15 -0400
1005
+ Processing by DogeController#index as HTML
1006
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1007
+
1008
+
1009
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:28:16 -0400
1010
+ Processing by DogeController#index as HTML
1011
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1012
+
1013
+
1014
+ Started GET "/doge" for 127.0.0.1 at 2014-06-09 00:28:16 -0400
1015
+ Processing by DogeController#index as HTML
1016
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1017
+
1018
+
1019
+ Started GET "/doge.html" for 127.0.0.1 at 2014-06-09 00:28:18 -0400
1020
+ Processing by DogeController#index as HTML
1021
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1022
+
1023
+
1024
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:28:21 -0400
1025
+ Processing by DogeController#index as DSON
1026
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1027
+
1028
+
1029
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:28:21 -0400
1030
+ Processing by DogeController#index as DSON
1031
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1032
+
1033
+
1034
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:29:02 -0400
1035
+ Processing by DogeController#index as DSON
1036
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1037
+
1038
+
1039
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:29:09 -0400
1040
+ Processing by DogeController#index as DSON
1041
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1042
+
1043
+
1044
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:29:19 -0400
1045
+ Processing by DogeController#index as DSON
1046
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1047
+
1048
+
1049
+ Started GET "/doge.html" for 127.0.0.1 at 2014-06-09 00:29:36 -0400
1050
+ Processing by DogeController#index as HTML
1051
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1052
+
1053
+
1054
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:29:42 -0400
1055
+ Processing by DogeController#index as DSON
1056
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1057
+
1058
+
1059
+ Started GET "/doge.html" for 127.0.0.1 at 2014-06-09 00:29:57 -0400
1060
+ Processing by DogeController#index as HTML
1061
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1062
+
1063
+
1064
+ Started GET "/doge.html" for 127.0.0.1 at 2014-06-09 00:29:58 -0400
1065
+ Processing by DogeController#index as HTML
1066
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
1067
+
1068
+
1069
+ Started GET "/doge.dson" for 127.0.0.1 at 2014-06-09 00:30:00 -0400
1070
+ Processing by DogeController#index as DSON
1071
+ Completed 200 OK in 0ms (Views: 0.2ms | ActiveRecord: 0.0ms)