benschwarz-smoke 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/Rakefile +6 -0
  2. data/VERSION.yml +1 -1
  3. metadata +65 -196
  4. data/Gemfile +0 -10
  5. data/bin/edit_json.rb +0 -3
  6. data/bin/restclient +0 -3
  7. data/vendor/gems/cache/crack-0.1.1.gem +0 -0
  8. data/vendor/gems/cache/fakeweb-1.2.5.gem +0 -0
  9. data/vendor/gems/cache/json-1.1.3.gem +0 -0
  10. data/vendor/gems/cache/rest-client-1.0.1.gem +0 -0
  11. data/vendor/gems/cache/simple-rss-1.2.gem +0 -0
  12. data/vendor/gems/cache/wycats-moneta-0.6.0.gem +0 -0
  13. data/vendor/gems/environment.rb +0 -83
  14. data/vendor/gems/gems/crack-0.1.1/LICENSE +0 -20
  15. data/vendor/gems/gems/crack-0.1.1/README.rdoc +0 -22
  16. data/vendor/gems/gems/crack-0.1.1/VERSION.yml +0 -4
  17. data/vendor/gems/gems/crack-0.1.1/lib/crack.rb +0 -7
  18. data/vendor/gems/gems/crack-0.1.1/lib/crack/core_extensions.rb +0 -126
  19. data/vendor/gems/gems/crack-0.1.1/lib/crack/json.rb +0 -66
  20. data/vendor/gems/gems/crack-0.1.1/lib/crack/xml.rb +0 -211
  21. data/vendor/gems/gems/crack-0.1.1/test/crack_test.rb +0 -4
  22. data/vendor/gems/gems/crack-0.1.1/test/json_test.rb +0 -42
  23. data/vendor/gems/gems/crack-0.1.1/test/test_helper.rb +0 -12
  24. data/vendor/gems/gems/crack-0.1.1/test/xml_test.rb +0 -451
  25. data/vendor/gems/gems/fakeweb-1.2.5/CHANGELOG +0 -163
  26. data/vendor/gems/gems/fakeweb-1.2.5/LICENSE.txt +0 -281
  27. data/vendor/gems/gems/fakeweb-1.2.5/README.rdoc +0 -193
  28. data/vendor/gems/gems/fakeweb-1.2.5/Rakefile +0 -76
  29. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web.rb +0 -172
  30. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/ext/net_http.rb +0 -71
  31. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/registry.rb +0 -103
  32. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/responder.rb +0 -113
  33. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/response.rb +0 -10
  34. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/stub_socket.rb +0 -15
  35. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/utility.rb +0 -22
  36. data/vendor/gems/gems/fakeweb-1.2.5/lib/fakeweb.rb +0 -2
  37. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_from_curl +0 -12
  38. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_with_transfer_encoding +0 -17
  39. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_without_transfer_encoding +0 -11
  40. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_example.txt +0 -1
  41. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_txt_file +0 -3
  42. data/vendor/gems/gems/fakeweb-1.2.5/test/test_allow_net_connect.rb +0 -85
  43. data/vendor/gems/gems/fakeweb-1.2.5/test/test_deprecations.rb +0 -54
  44. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_authentication.rb +0 -92
  45. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web.rb +0 -518
  46. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web_open_uri.rb +0 -58
  47. data/vendor/gems/gems/fakeweb-1.2.5/test/test_helper.rb +0 -74
  48. data/vendor/gems/gems/fakeweb-1.2.5/test/test_missing_open_uri.rb +0 -25
  49. data/vendor/gems/gems/fakeweb-1.2.5/test/test_precedence.rb +0 -51
  50. data/vendor/gems/gems/fakeweb-1.2.5/test/test_query_string.rb +0 -45
  51. data/vendor/gems/gems/fakeweb-1.2.5/test/test_regexes.rb +0 -103
  52. data/vendor/gems/gems/fakeweb-1.2.5/test/test_response_headers.rb +0 -67
  53. data/vendor/gems/gems/fakeweb-1.2.5/test/test_trailing_slashes.rb +0 -53
  54. data/vendor/gems/gems/fakeweb-1.2.5/test/test_utility.rb +0 -70
  55. data/vendor/gems/gems/json-1.1.3/CHANGES +0 -93
  56. data/vendor/gems/gems/json-1.1.3/GPL +0 -340
  57. data/vendor/gems/gems/json-1.1.3/README +0 -78
  58. data/vendor/gems/gems/json-1.1.3/RUBY +0 -58
  59. data/vendor/gems/gems/json-1.1.3/Rakefile +0 -309
  60. data/vendor/gems/gems/json-1.1.3/TODO +0 -1
  61. data/vendor/gems/gems/json-1.1.3/VERSION +0 -1
  62. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark.txt +0 -133
  63. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_generator.rb +0 -48
  64. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_parser.rb +0 -26
  65. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_rails.rb +0 -26
  66. data/vendor/gems/gems/json-1.1.3/bin/edit_json.rb +0 -10
  67. data/vendor/gems/gems/json-1.1.3/bin/prettify_json.rb +0 -76
  68. data/vendor/gems/gems/json-1.1.3/data/example.json +0 -1
  69. data/vendor/gems/gems/json-1.1.3/data/index.html +0 -38
  70. data/vendor/gems/gems/json-1.1.3/data/prototype.js +0 -4184
  71. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator.bundle +0 -0
  72. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/Makefile +0 -150
  73. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/extconf.rb +0 -9
  74. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.bundle +0 -0
  75. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.c +0 -875
  76. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.o +0 -0
  77. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.c +0 -182
  78. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.h +0 -53
  79. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.o +0 -0
  80. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser.bundle +0 -0
  81. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/Makefile +0 -150
  82. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/extconf.rb +0 -9
  83. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.bundle +0 -0
  84. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.c +0 -1758
  85. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.o +0 -0
  86. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.rl +0 -638
  87. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.c +0 -154
  88. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.h +0 -58
  89. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.o +0 -0
  90. data/vendor/gems/gems/json-1.1.3/install.rb +0 -26
  91. data/vendor/gems/gems/json-1.1.3/lib/json.rb +0 -235
  92. data/vendor/gems/gems/json-1.1.3/lib/json/Array.xpm +0 -21
  93. data/vendor/gems/gems/json-1.1.3/lib/json/FalseClass.xpm +0 -21
  94. data/vendor/gems/gems/json-1.1.3/lib/json/Hash.xpm +0 -21
  95. data/vendor/gems/gems/json-1.1.3/lib/json/Key.xpm +0 -73
  96. data/vendor/gems/gems/json-1.1.3/lib/json/NilClass.xpm +0 -21
  97. data/vendor/gems/gems/json-1.1.3/lib/json/Numeric.xpm +0 -28
  98. data/vendor/gems/gems/json-1.1.3/lib/json/String.xpm +0 -96
  99. data/vendor/gems/gems/json-1.1.3/lib/json/TrueClass.xpm +0 -21
  100. data/vendor/gems/gems/json-1.1.3/lib/json/add/core.rb +0 -135
  101. data/vendor/gems/gems/json-1.1.3/lib/json/add/rails.rb +0 -58
  102. data/vendor/gems/gems/json-1.1.3/lib/json/common.rb +0 -354
  103. data/vendor/gems/gems/json-1.1.3/lib/json/editor.rb +0 -1362
  104. data/vendor/gems/gems/json-1.1.3/lib/json/ext.rb +0 -13
  105. data/vendor/gems/gems/json-1.1.3/lib/json/json.xpm +0 -1499
  106. data/vendor/gems/gems/json-1.1.3/lib/json/pure.rb +0 -75
  107. data/vendor/gems/gems/json-1.1.3/lib/json/pure/generator.rb +0 -394
  108. data/vendor/gems/gems/json-1.1.3/lib/json/pure/parser.rb +0 -259
  109. data/vendor/gems/gems/json-1.1.3/lib/json/version.rb +0 -9
  110. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail1.json +0 -1
  111. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail10.json +0 -1
  112. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail11.json +0 -1
  113. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail12.json +0 -1
  114. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail13.json +0 -1
  115. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail14.json +0 -1
  116. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail18.json +0 -1
  117. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail19.json +0 -1
  118. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail2.json +0 -1
  119. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail20.json +0 -1
  120. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail21.json +0 -1
  121. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail22.json +0 -1
  122. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail23.json +0 -1
  123. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail24.json +0 -1
  124. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail25.json +0 -1
  125. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail27.json +0 -2
  126. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail28.json +0 -2
  127. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail3.json +0 -1
  128. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail4.json +0 -1
  129. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail5.json +0 -1
  130. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail6.json +0 -1
  131. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail7.json +0 -1
  132. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail8.json +0 -1
  133. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail9.json +0 -1
  134. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass1.json +0 -56
  135. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass15.json +0 -1
  136. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass16.json +0 -1
  137. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass17.json +0 -1
  138. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass2.json +0 -1
  139. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass26.json +0 -1
  140. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass3.json +0 -6
  141. data/vendor/gems/gems/json-1.1.3/tests/runner.rb +0 -25
  142. data/vendor/gems/gems/json-1.1.3/tests/test_json.rb +0 -293
  143. data/vendor/gems/gems/json-1.1.3/tests/test_json_addition.rb +0 -161
  144. data/vendor/gems/gems/json-1.1.3/tests/test_json_fixtures.rb +0 -30
  145. data/vendor/gems/gems/json-1.1.3/tests/test_json_generate.rb +0 -100
  146. data/vendor/gems/gems/json-1.1.3/tests/test_json_rails.rb +0 -118
  147. data/vendor/gems/gems/json-1.1.3/tests/test_json_unicode.rb +0 -61
  148. data/vendor/gems/gems/json-1.1.3/tools/fuzz.rb +0 -140
  149. data/vendor/gems/gems/json-1.1.3/tools/server.rb +0 -62
  150. data/vendor/gems/gems/rest-client-1.0.1/README.rdoc +0 -151
  151. data/vendor/gems/gems/rest-client-1.0.1/Rakefile +0 -85
  152. data/vendor/gems/gems/rest-client-1.0.1/bin/restclient +0 -87
  153. data/vendor/gems/gems/rest-client-1.0.1/lib/rest_client.rb +0 -2
  154. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient.rb +0 -93
  155. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/exceptions.rb +0 -84
  156. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/mixin/response.rb +0 -43
  157. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/raw_response.rb +0 -30
  158. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/request.rb +0 -236
  159. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/resource.rb +0 -146
  160. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/response.rb +0 -20
  161. data/vendor/gems/gems/rest-client-1.0.1/spec/base.rb +0 -4
  162. data/vendor/gems/gems/rest-client-1.0.1/spec/exceptions_spec.rb +0 -54
  163. data/vendor/gems/gems/rest-client-1.0.1/spec/mixin/response_spec.rb +0 -46
  164. data/vendor/gems/gems/rest-client-1.0.1/spec/raw_response_spec.rb +0 -17
  165. data/vendor/gems/gems/rest-client-1.0.1/spec/request_spec.rb +0 -462
  166. data/vendor/gems/gems/rest-client-1.0.1/spec/resource_spec.rb +0 -75
  167. data/vendor/gems/gems/rest-client-1.0.1/spec/response_spec.rb +0 -16
  168. data/vendor/gems/gems/rest-client-1.0.1/spec/restclient_spec.rb +0 -53
  169. data/vendor/gems/gems/simple-rss-1.2/LICENSE +0 -429
  170. data/vendor/gems/gems/simple-rss-1.2/README +0 -43
  171. data/vendor/gems/gems/simple-rss-1.2/Rakefile +0 -212
  172. data/vendor/gems/gems/simple-rss-1.2/lib/simple-rss.rb +0 -149
  173. data/vendor/gems/gems/simple-rss-1.2/test/base/base_test.rb +0 -51
  174. data/vendor/gems/gems/simple-rss-1.2/test/data/atom.xml +0 -45
  175. data/vendor/gems/gems/simple-rss-1.2/test/data/not-rss.xml +0 -8
  176. data/vendor/gems/gems/simple-rss-1.2/test/data/rss09.rdf +0 -79
  177. data/vendor/gems/gems/simple-rss-1.2/test/data/rss20.xml +0 -818
  178. data/vendor/gems/gems/simple-rss-1.2/test/test_helper.rb +0 -4
  179. data/vendor/gems/gems/wycats-moneta-0.6.0/LICENSE +0 -20
  180. data/vendor/gems/gems/wycats-moneta-0.6.0/README +0 -50
  181. data/vendor/gems/gems/wycats-moneta-0.6.0/Rakefile +0 -60
  182. data/vendor/gems/gems/wycats-moneta-0.6.0/TODO +0 -4
  183. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta.rb +0 -76
  184. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/datamapper.rb +0 -117
  185. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/file.rb +0 -91
  186. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memcache.rb +0 -52
  187. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memory.rb +0 -11
  188. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/xattr.rb +0 -58
  189. data/vendor/gems/specifications/crack-0.1.1.gemspec +0 -29
  190. data/vendor/gems/specifications/fakeweb-1.2.5.gemspec +0 -34
  191. data/vendor/gems/specifications/json-1.1.3.gemspec +0 -33
  192. data/vendor/gems/specifications/rest-client-1.0.1.gemspec +0 -30
  193. data/vendor/gems/specifications/simple-rss-1.2.gemspec +0 -27
  194. data/vendor/gems/specifications/wycats-moneta-0.6.0.gemspec +0 -29
@@ -1,150 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- #### Start of system configuration section. ####
5
-
6
- srcdir = .
7
- topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
10
- prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
11
- exec_prefix = $(prefix)
12
- sitedir = $(DESTDIR)/Library/Ruby/Site
13
- rubylibdir = $(libdir)/ruby/$(ruby_version)
14
- docdir = $(datarootdir)/doc/$(PACKAGE)
15
- dvidir = $(docdir)
16
- datarootdir = $(prefix)/share
17
- archdir = $(rubylibdir)/$(arch)
18
- sbindir = $(exec_prefix)/sbin
19
- psdir = $(docdir)
20
- localedir = $(datarootdir)/locale
21
- htmldir = $(docdir)
22
- datadir = $(datarootdir)
23
- includedir = $(prefix)/include
24
- infodir = $(DESTDIR)/usr/share/info
25
- sysconfdir = $(prefix)/etc
26
- mandir = $(DESTDIR)/usr/share/man
27
- libdir = $(exec_prefix)/lib
28
- sharedstatedir = $(prefix)/com
29
- oldincludedir = $(DESTDIR)/usr/include
30
- pdfdir = $(docdir)
31
- sitearchdir = $(sitelibdir)/$(sitearch)
32
- bindir = $(exec_prefix)/bin
33
- localstatedir = $(prefix)/var
34
- sitelibdir = $(sitedir)/$(ruby_version)
35
- libexecdir = $(exec_prefix)/libexec
36
-
37
- CC = gcc
38
- LIBRUBY = $(LIBRUBY_SO)
39
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
40
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
41
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
42
-
43
- RUBY_EXTCONF_H =
44
- CFLAGS = -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -Wall
45
- INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
46
- DEFS =
47
- CPPFLAGS = $(DEFS)
48
- CXXFLAGS = $(CFLAGS)
49
- DLDFLAGS = -L. -arch ppc -arch i386
50
- LDSHARED = cc -arch ppc -arch i386 -pipe -bundle -undefined dynamic_lookup
51
- AR = ar
52
- EXEEXT =
53
-
54
- RUBY_INSTALL_NAME = ruby
55
- RUBY_SO_NAME = ruby
56
- arch = universal-darwin9.0
57
- sitearch = universal-darwin9.0
58
- ruby_version = 1.8
59
- ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
60
- RUBY = $(ruby)
61
- RM = rm -f
62
- MAKEDIRS = mkdir -p
63
- INSTALL = /usr/bin/install -c
64
- INSTALL_PROG = $(INSTALL) -m 0755
65
- INSTALL_DATA = $(INSTALL) -m 644
66
- COPY = cp
67
-
68
- #### End of system configuration section. ####
69
-
70
- preload =
71
-
72
- libpath = . $(libdir)
73
- LIBPATH = -L. -L$(libdir)
74
- DEFFILE =
75
-
76
- CLEANFILES = mkmf.log
77
- DISTCLEANFILES =
78
-
79
- extout =
80
- extout_prefix =
81
- target_prefix =
82
- LOCAL_LIBS =
83
- LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lm
84
- SRCS = generator.c unicode.c
85
- OBJS = generator.o unicode.o
86
- TARGET = generator
87
- DLLIB = $(TARGET).bundle
88
- EXTSTATIC =
89
- STATIC_LIB =
90
-
91
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
92
- RUBYLIBDIR = /Users/ben/Documents/Projects/smoke/vendor/gems/gems/json-1.1.3/ext/json/ext$(target_prefix)
93
- RUBYARCHDIR = /Users/ben/Documents/Projects/smoke/vendor/gems/gems/json-1.1.3/ext/json/ext$(target_prefix)
94
-
95
- TARGET_SO = $(DLLIB)
96
- CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
97
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
98
-
99
- all: $(DLLIB)
100
- static: $(STATIC_LIB)
101
-
102
- clean:
103
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
104
-
105
- distclean: clean
106
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
107
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
108
-
109
- realclean: distclean
110
- install: install-so install-rb
111
-
112
- install-so: $(RUBYARCHDIR)
113
- install-so: $(RUBYARCHDIR)/$(DLLIB)
114
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
115
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
116
- install-rb: pre-install-rb install-rb-default
117
- install-rb-default: pre-install-rb-default
118
- pre-install-rb: Makefile
119
- pre-install-rb-default: Makefile
120
- $(RUBYARCHDIR):
121
- $(MAKEDIRS) $@
122
-
123
- site-install: site-install-so site-install-rb
124
- site-install-so: install-so
125
- site-install-rb: install-rb
126
-
127
- .SUFFIXES: .c .m .cc .cxx .cpp .C .o
128
-
129
- .cc.o:
130
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
131
-
132
- .cxx.o:
133
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
134
-
135
- .cpp.o:
136
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
137
-
138
- .C.o:
139
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
140
-
141
- .c.o:
142
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
143
-
144
- $(DLLIB): $(OBJS)
145
- @-$(RM) $@
146
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
147
-
148
-
149
-
150
- $(OBJS): ruby.h defines.h
@@ -1,9 +0,0 @@
1
- require 'mkmf'
2
- require 'rbconfig'
3
-
4
- if CONFIG['CC'] =~ /gcc/
5
- $CFLAGS += ' -Wall'
6
- #$CFLAGS += ' -O0 -ggdb'
7
- end
8
-
9
- create_makefile 'generator'
@@ -1,875 +0,0 @@
1
- #include <string.h>
2
- #include "ruby.h"
3
- #include "st.h"
4
- #include "unicode.h"
5
- #include <math.h>
6
-
7
- #define check_max_nesting(state, depth) do { \
8
- long current_nesting = 1 + depth; \
9
- if (state->max_nesting != 0 && current_nesting > state->max_nesting) \
10
- rb_raise(eNestingError, "nesting of %ld is too deep", current_nesting); \
11
- } while (0);
12
-
13
- static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
14
- mHash, mArray, mInteger, mFloat, mString, mString_Extend,
15
- mTrueClass, mFalseClass, mNilClass, eGeneratorError,
16
- eCircularDatastructure, eNestingError;
17
-
18
- static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
19
- i_object_nl, i_array_nl, i_check_circular, i_max_nesting,
20
- i_allow_nan, i_pack, i_unpack, i_create_id, i_extend;
21
-
22
- typedef struct JSON_Generator_StateStruct {
23
- VALUE indent;
24
- VALUE space;
25
- VALUE space_before;
26
- VALUE object_nl;
27
- VALUE array_nl;
28
- int check_circular;
29
- VALUE seen;
30
- VALUE memo;
31
- VALUE depth;
32
- long max_nesting;
33
- int flag;
34
- int allow_nan;
35
- } JSON_Generator_State;
36
-
37
- #define GET_STATE(self) \
38
- JSON_Generator_State *state; \
39
- Data_Get_Struct(self, JSON_Generator_State, state);
40
-
41
- /*
42
- * Document-module: JSON::Ext::Generator
43
- *
44
- * This is the JSON generator implemented as a C extension. It can be
45
- * configured to be used by setting
46
- *
47
- * JSON.generator = JSON::Ext::Generator
48
- *
49
- * with the method generator= in JSON.
50
- *
51
- */
52
-
53
- static int hash_to_json_state_i(VALUE key, VALUE value, VALUE Vstate)
54
- {
55
- VALUE json, buf, Vdepth;
56
- GET_STATE(Vstate);
57
- buf = state->memo;
58
- Vdepth = state->depth;
59
-
60
- if (key == Qundef) return ST_CONTINUE;
61
- if (state->flag) {
62
- state->flag = 0;
63
- rb_str_buf_cat2(buf, ",");
64
- if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(buf, state->object_nl);
65
- }
66
- if (RSTRING_LEN(state->object_nl)) {
67
- rb_str_buf_append(buf, rb_str_times(state->indent, Vdepth));
68
- }
69
- json = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 2, Vstate, Vdepth);
70
- Check_Type(json, T_STRING);
71
- rb_str_buf_append(buf, json);
72
- OBJ_INFECT(buf, json);
73
- if (RSTRING_LEN(state->space_before)) {
74
- rb_str_buf_append(buf, state->space_before);
75
- }
76
- rb_str_buf_cat2(buf, ":");
77
- if (RSTRING_LEN(state->space)) rb_str_buf_append(buf, state->space);
78
- json = rb_funcall(value, i_to_json, 2, Vstate, Vdepth);
79
- Check_Type(json, T_STRING);
80
- state->flag = 1;
81
- rb_str_buf_append(buf, json);
82
- OBJ_INFECT(buf, json);
83
- state->depth = Vdepth;
84
- state->memo = buf;
85
- return ST_CONTINUE;
86
- }
87
-
88
- inline static VALUE mHash_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
89
- long depth, len = RHASH(self)->tbl->num_entries;
90
- VALUE result;
91
- GET_STATE(Vstate);
92
-
93
- depth = 1 + FIX2LONG(Vdepth);
94
- result = rb_str_buf_new(len);
95
- state->memo = result;
96
- state->depth = LONG2FIX(depth);
97
- state->flag = 0;
98
- rb_str_buf_cat2(result, "{");
99
- if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
100
- rb_hash_foreach(self, hash_to_json_state_i, Vstate);
101
- if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
102
- if (RSTRING_LEN(state->object_nl)) {
103
- rb_str_buf_append(result, rb_str_times(state->indent, Vdepth));
104
- }
105
- rb_str_buf_cat2(result, "}");
106
- return result;
107
- }
108
-
109
- static int hash_to_json_i(VALUE key, VALUE value, VALUE buf)
110
- {
111
- VALUE tmp;
112
-
113
- if (key == Qundef) return ST_CONTINUE;
114
- if (RSTRING_LEN(buf) > 1) rb_str_buf_cat2(buf, ",");
115
- tmp = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 0);
116
- Check_Type(tmp, T_STRING);
117
- rb_str_buf_append(buf, tmp);
118
- OBJ_INFECT(buf, tmp);
119
- rb_str_buf_cat2(buf, ":");
120
- tmp = rb_funcall(value, i_to_json, 0);
121
- Check_Type(tmp, T_STRING);
122
- rb_str_buf_append(buf, tmp);
123
- OBJ_INFECT(buf, tmp);
124
-
125
- return ST_CONTINUE;
126
- }
127
-
128
- /*
129
- * call-seq: to_json(state = nil, depth = 0)
130
- *
131
- * Returns a JSON string containing a JSON object, that is unparsed from
132
- * this Hash instance.
133
- * _state_ is a JSON::State object, that can also be used to configure the
134
- * produced JSON string output further.
135
- * _depth_ is used to find out nesting depth, to indent accordingly.
136
- */
137
- static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
138
- {
139
- VALUE Vstate, Vdepth, result;
140
- long depth;
141
-
142
- rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
143
- depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
144
- if (NIL_P(Vstate)) {
145
- long len = RHASH(self)->tbl->num_entries;
146
- result = rb_str_buf_new(len);
147
- rb_str_buf_cat2(result, "{");
148
- rb_hash_foreach(self, hash_to_json_i, result);
149
- rb_str_buf_cat2(result, "}");
150
- } else {
151
- GET_STATE(Vstate);
152
- check_max_nesting(state, depth);
153
- if (state->check_circular) {
154
- VALUE self_id = rb_obj_id(self);
155
- if (RTEST(rb_hash_aref(state->seen, self_id))) {
156
- rb_raise(eCircularDatastructure,
157
- "circular data structures not supported!");
158
- }
159
- rb_hash_aset(state->seen, self_id, Qtrue);
160
- result = mHash_json_transfrom(self, Vstate, LONG2FIX(depth));
161
- rb_hash_delete(state->seen, self_id);
162
- } else {
163
- result = mHash_json_transfrom(self, Vstate, LONG2FIX(depth));
164
- }
165
- }
166
- OBJ_INFECT(result, self);
167
- return result;
168
- }
169
-
170
- inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
171
- long i, len = RARRAY_LEN(self);
172
- VALUE shift, result;
173
- long depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
174
- VALUE delim = rb_str_new2(",");
175
- GET_STATE(Vstate);
176
-
177
- check_max_nesting(state, depth);
178
- if (state->check_circular) {
179
- VALUE self_id = rb_obj_id(self);
180
- rb_hash_aset(state->seen, self_id, Qtrue);
181
- result = rb_str_buf_new(len);
182
- if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
183
- shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
184
-
185
- rb_str_buf_cat2(result, "[");
186
- OBJ_INFECT(result, self);
187
- rb_str_buf_append(result, state->array_nl);
188
- for (i = 0; i < len; i++) {
189
- VALUE element = RARRAY_PTR(self)[i];
190
- if (RTEST(rb_hash_aref(state->seen, rb_obj_id(element)))) {
191
- rb_raise(eCircularDatastructure,
192
- "circular data structures not supported!");
193
- }
194
- OBJ_INFECT(result, element);
195
- if (i > 0) rb_str_buf_append(result, delim);
196
- rb_str_buf_append(result, shift);
197
- element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
198
- Check_Type(element, T_STRING);
199
- rb_str_buf_append(result, element);
200
- }
201
- if (RSTRING_LEN(state->array_nl)) {
202
- rb_str_buf_append(result, state->array_nl);
203
- rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
204
- }
205
- rb_str_buf_cat2(result, "]");
206
- rb_hash_delete(state->seen, self_id);
207
- } else {
208
- result = rb_str_buf_new(len);
209
- OBJ_INFECT(result, self);
210
- if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
211
- shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
212
-
213
- rb_str_buf_cat2(result, "[");
214
- rb_str_buf_append(result, state->array_nl);
215
- for (i = 0; i < len; i++) {
216
- VALUE element = RARRAY_PTR(self)[i];
217
- OBJ_INFECT(result, element);
218
- if (i > 0) rb_str_buf_append(result, delim);
219
- rb_str_buf_append(result, shift);
220
- element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
221
- Check_Type(element, T_STRING);
222
- rb_str_buf_append(result, element);
223
- }
224
- rb_str_buf_append(result, state->array_nl);
225
- if (RSTRING_LEN(state->array_nl)) {
226
- rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
227
- }
228
- rb_str_buf_cat2(result, "]");
229
- }
230
- return result;
231
- }
232
-
233
- /*
234
- * call-seq: to_json(state = nil, depth = 0)
235
- *
236
- * Returns a JSON string containing a JSON array, that is unparsed from
237
- * this Array instance.
238
- * _state_ is a JSON::State object, that can also be used to configure the
239
- * produced JSON string output further.
240
- * _depth_ is used to find out nesting depth, to indent accordingly.
241
- */
242
- static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
243
- VALUE Vstate, Vdepth, result;
244
-
245
- rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
246
- if (NIL_P(Vstate)) {
247
- long i, len = RARRAY_LEN(self);
248
- result = rb_str_buf_new(2 + 2 * len);
249
- rb_str_buf_cat2(result, "[");
250
- OBJ_INFECT(result, self);
251
- for (i = 0; i < len; i++) {
252
- VALUE element = RARRAY_PTR(self)[i];
253
- OBJ_INFECT(result, element);
254
- if (i > 0) rb_str_buf_cat2(result, ",");
255
- element = rb_funcall(element, i_to_json, 0);
256
- Check_Type(element, T_STRING);
257
- rb_str_buf_append(result, element);
258
- }
259
- rb_str_buf_cat2(result, "]");
260
- } else {
261
- result = mArray_json_transfrom(self, Vstate, Vdepth);
262
- }
263
- OBJ_INFECT(result, self);
264
- return result;
265
- }
266
-
267
- /*
268
- * call-seq: to_json(*)
269
- *
270
- * Returns a JSON string representation for this Integer number.
271
- */
272
- static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self)
273
- {
274
- return rb_funcall(self, i_to_s, 0);
275
- }
276
-
277
- /*
278
- * call-seq: to_json(*)
279
- *
280
- * Returns a JSON string representation for this Float number.
281
- */
282
- static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
283
- {
284
- JSON_Generator_State *state = NULL;
285
- VALUE Vstate, rest, tmp;
286
- double value = RFLOAT(self)->value;
287
- rb_scan_args(argc, argv, "01*", &Vstate, &rest);
288
- if (!NIL_P(Vstate)) Data_Get_Struct(Vstate, JSON_Generator_State, state);
289
- if (isinf(value)) {
290
- if (!state || state->allow_nan) {
291
- return rb_funcall(self, i_to_s, 0);
292
- } else {
293
- tmp = rb_funcall(self, i_to_s, 0);
294
- rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
295
- }
296
- } else if (isnan(value)) {
297
- if (!state || state->allow_nan) {
298
- return rb_funcall(self, i_to_s, 0);
299
- } else {
300
- tmp = rb_funcall(self, i_to_s, 0);
301
- rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
302
- }
303
- } else {
304
- return rb_funcall(self, i_to_s, 0);
305
- }
306
- }
307
-
308
- /*
309
- * call-seq: String.included(modul)
310
- *
311
- * Extends _modul_ with the String::Extend module.
312
- */
313
- static VALUE mString_included_s(VALUE self, VALUE modul) {
314
- return rb_funcall(modul, i_extend, 1, mString_Extend);
315
- }
316
-
317
- /*
318
- * call-seq: to_json(*)
319
- *
320
- * This string should be encoded with UTF-8 A call to this method
321
- * returns a JSON string encoded with UTF16 big endian characters as
322
- * \u????.
323
- */
324
- static VALUE mString_to_json(int argc, VALUE *argv, VALUE self)
325
- {
326
- VALUE result = rb_str_buf_new(RSTRING_LEN(self));
327
- rb_str_buf_cat2(result, "\"");
328
- JSON_convert_UTF8_to_JSON(result, self, strictConversion);
329
- rb_str_buf_cat2(result, "\"");
330
- return result;
331
- }
332
-
333
- /*
334
- * call-seq: to_json_raw_object()
335
- *
336
- * This method creates a raw object hash, that can be nested into
337
- * other data structures and will be unparsed as a raw string. This
338
- * method should be used, if you want to convert raw strings to JSON
339
- * instead of UTF-8 strings, e. g. binary data.
340
- */
341
- static VALUE mString_to_json_raw_object(VALUE self) {
342
- VALUE ary;
343
- VALUE result = rb_hash_new();
344
- rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self)));
345
- ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*"));
346
- rb_hash_aset(result, rb_str_new2("raw"), ary);
347
- return result;
348
- }
349
-
350
- /*
351
- * call-seq: to_json_raw(*args)
352
- *
353
- * This method creates a JSON text from the result of a call to
354
- * to_json_raw_object of this String.
355
- */
356
- static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self) {
357
- VALUE obj = mString_to_json_raw_object(self);
358
- Check_Type(obj, T_HASH);
359
- return mHash_to_json(argc, argv, obj);
360
- }
361
-
362
- /*
363
- * call-seq: json_create(o)
364
- *
365
- * Raw Strings are JSON Objects (the raw bytes are stored in an array for the
366
- * key "raw"). The Ruby String can be created by this module method.
367
- */
368
- static VALUE mString_Extend_json_create(VALUE self, VALUE o) {
369
- VALUE ary;
370
- Check_Type(o, T_HASH);
371
- ary = rb_hash_aref(o, rb_str_new2("raw"));
372
- return rb_funcall(ary, i_pack, 1, rb_str_new2("C*"));
373
- }
374
-
375
- /*
376
- * call-seq: to_json(state = nil, depth = 0)
377
- *
378
- * Returns a JSON string for true: 'true'.
379
- */
380
- static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self)
381
- {
382
- return rb_str_new2("true");
383
- }
384
-
385
- /*
386
- * call-seq: to_json(state = nil, depth = 0)
387
- *
388
- * Returns a JSON string for false: 'false'.
389
- */
390
- static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self)
391
- {
392
- return rb_str_new2("false");
393
- }
394
-
395
- /*
396
- * call-seq: to_json(state = nil, depth = 0)
397
- *
398
- */
399
- static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self)
400
- {
401
- return rb_str_new2("null");
402
- }
403
-
404
- /*
405
- * call-seq: to_json(*)
406
- *
407
- * Converts this object to a string (calling #to_s), converts
408
- * it to a JSON string, and returns the result. This is a fallback, if no
409
- * special method #to_json was defined for some object.
410
- */
411
- static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self)
412
- {
413
- VALUE string = rb_funcall(self, i_to_s, 0);
414
- Check_Type(string, T_STRING);
415
- return mString_to_json(argc, argv, string);
416
- }
417
-
418
- /*
419
- * Document-class: JSON::Ext::Generator::State
420
- *
421
- * This class is used to create State instances, that are use to hold data
422
- * while generating a JSON text from a a Ruby data structure.
423
- */
424
-
425
- static void State_mark(JSON_Generator_State *state)
426
- {
427
- rb_gc_mark_maybe(state->indent);
428
- rb_gc_mark_maybe(state->space);
429
- rb_gc_mark_maybe(state->space_before);
430
- rb_gc_mark_maybe(state->object_nl);
431
- rb_gc_mark_maybe(state->array_nl);
432
- rb_gc_mark_maybe(state->seen);
433
- rb_gc_mark_maybe(state->memo);
434
- rb_gc_mark_maybe(state->depth);
435
- }
436
-
437
- static JSON_Generator_State *State_allocate()
438
- {
439
- JSON_Generator_State *state = ALLOC(JSON_Generator_State);
440
- return state;
441
- }
442
-
443
- static VALUE cState_s_allocate(VALUE klass)
444
- {
445
- JSON_Generator_State *state = State_allocate();
446
- return Data_Wrap_Struct(klass, State_mark, -1, state);
447
- }
448
-
449
- /*
450
- * call-seq: configure(opts)
451
- *
452
- * Configure this State instance with the Hash _opts_, and return
453
- * itself.
454
- */
455
- static inline VALUE cState_configure(VALUE self, VALUE opts)
456
- {
457
- VALUE tmp;
458
- GET_STATE(self);
459
- tmp = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
460
- if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
461
- if (NIL_P(tmp)) {
462
- rb_raise(rb_eArgError, "opts has to be hash like or convertable into a hash");
463
- }
464
- opts = tmp;
465
- tmp = rb_hash_aref(opts, ID2SYM(i_indent));
466
- if (RTEST(tmp)) {
467
- Check_Type(tmp, T_STRING);
468
- state->indent = tmp;
469
- }
470
- tmp = rb_hash_aref(opts, ID2SYM(i_space));
471
- if (RTEST(tmp)) {
472
- Check_Type(tmp, T_STRING);
473
- state->space = tmp;
474
- }
475
- tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
476
- if (RTEST(tmp)) {
477
- Check_Type(tmp, T_STRING);
478
- state->space_before = tmp;
479
- }
480
- tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
481
- if (RTEST(tmp)) {
482
- Check_Type(tmp, T_STRING);
483
- state->array_nl = tmp;
484
- }
485
- tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
486
- if (RTEST(tmp)) {
487
- Check_Type(tmp, T_STRING);
488
- state->object_nl = tmp;
489
- }
490
- tmp = ID2SYM(i_check_circular);
491
- if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
492
- tmp = rb_hash_aref(opts, ID2SYM(i_check_circular));
493
- state->check_circular = RTEST(tmp);
494
- } else {
495
- state->check_circular = 1;
496
- }
497
- tmp = ID2SYM(i_max_nesting);
498
- state->max_nesting = 19;
499
- if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
500
- VALUE max_nesting = rb_hash_aref(opts, tmp);
501
- if (RTEST(max_nesting)) {
502
- Check_Type(max_nesting, T_FIXNUM);
503
- state->max_nesting = FIX2LONG(max_nesting);
504
- } else {
505
- state->max_nesting = 0;
506
- }
507
- }
508
- tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan));
509
- state->allow_nan = RTEST(tmp);
510
- return self;
511
- }
512
-
513
- /*
514
- * call-seq: to_h
515
- *
516
- * Returns the configuration instance variables as a hash, that can be
517
- * passed to the configure method.
518
- */
519
- static VALUE cState_to_h(VALUE self)
520
- {
521
- VALUE result = rb_hash_new();
522
- GET_STATE(self);
523
- rb_hash_aset(result, ID2SYM(i_indent), state->indent);
524
- rb_hash_aset(result, ID2SYM(i_space), state->space);
525
- rb_hash_aset(result, ID2SYM(i_space_before), state->space_before);
526
- rb_hash_aset(result, ID2SYM(i_object_nl), state->object_nl);
527
- rb_hash_aset(result, ID2SYM(i_array_nl), state->array_nl);
528
- rb_hash_aset(result, ID2SYM(i_check_circular), state->check_circular ? Qtrue : Qfalse);
529
- rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
530
- rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
531
- return result;
532
- }
533
-
534
-
535
- /*
536
- * call-seq: new(opts = {})
537
- *
538
- * Instantiates a new State object, configured by _opts_.
539
- *
540
- * _opts_ can have the following keys:
541
- *
542
- * * *indent*: a string used to indent levels (default: ''),
543
- * * *space*: a string that is put after, a : or , delimiter (default: ''),
544
- * * *space_before*: a string that is put before a : pair delimiter (default: ''),
545
- * * *object_nl*: a string that is put at the end of a JSON object (default: ''),
546
- * * *array_nl*: a string that is put at the end of a JSON array (default: ''),
547
- * * *check_circular*: true if checking for circular data structures
548
- * should be done, false (the default) otherwise.
549
- * * *allow_nan*: true if NaN, Infinity, and -Infinity should be
550
- * generated, otherwise an exception is thrown, if these values are
551
- * encountered. This options defaults to false.
552
- */
553
- static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
554
- {
555
- VALUE opts;
556
- GET_STATE(self);
557
-
558
- rb_scan_args(argc, argv, "01", &opts);
559
- state->indent = rb_str_new2("");
560
- state->space = rb_str_new2("");
561
- state->space_before = rb_str_new2("");
562
- state->array_nl = rb_str_new2("");
563
- state->object_nl = rb_str_new2("");
564
- if (NIL_P(opts)) {
565
- state->check_circular = 1;
566
- state->allow_nan = 0;
567
- state->max_nesting = 19;
568
- } else {
569
- cState_configure(self, opts);
570
- }
571
- state->seen = rb_hash_new();
572
- state->memo = Qnil;
573
- state->depth = INT2FIX(0);
574
- return self;
575
- }
576
-
577
- /*
578
- * call-seq: from_state(opts)
579
- *
580
- * Creates a State object from _opts_, which ought to be Hash to create a
581
- * new State instance configured by _opts_, something else to create an
582
- * unconfigured instance. If _opts_ is a State object, it is just returned.
583
- */
584
- static VALUE cState_from_state_s(VALUE self, VALUE opts)
585
- {
586
- if (rb_obj_is_kind_of(opts, self)) {
587
- return opts;
588
- } else if (rb_obj_is_kind_of(opts, rb_cHash)) {
589
- return rb_funcall(self, i_new, 1, opts);
590
- } else {
591
- return rb_funcall(self, i_new, 0);
592
- }
593
- }
594
-
595
- /*
596
- * call-seq: indent()
597
- *
598
- * This string is used to indent levels in the JSON text.
599
- */
600
- static VALUE cState_indent(VALUE self)
601
- {
602
- GET_STATE(self);
603
- return state->indent;
604
- }
605
-
606
- /*
607
- * call-seq: indent=(indent)
608
- *
609
- * This string is used to indent levels in the JSON text.
610
- */
611
- static VALUE cState_indent_set(VALUE self, VALUE indent)
612
- {
613
- GET_STATE(self);
614
- Check_Type(indent, T_STRING);
615
- return state->indent = indent;
616
- }
617
-
618
- /*
619
- * call-seq: space()
620
- *
621
- * This string is used to insert a space between the tokens in a JSON
622
- * string.
623
- */
624
- static VALUE cState_space(VALUE self)
625
- {
626
- GET_STATE(self);
627
- return state->space;
628
- }
629
-
630
- /*
631
- * call-seq: space=(space)
632
- *
633
- * This string is used to insert a space between the tokens in a JSON
634
- * string.
635
- */
636
- static VALUE cState_space_set(VALUE self, VALUE space)
637
- {
638
- GET_STATE(self);
639
- Check_Type(space, T_STRING);
640
- return state->space = space;
641
- }
642
-
643
- /*
644
- * call-seq: space_before()
645
- *
646
- * This string is used to insert a space before the ':' in JSON objects.
647
- */
648
- static VALUE cState_space_before(VALUE self)
649
- {
650
- GET_STATE(self);
651
- return state->space_before;
652
- }
653
-
654
- /*
655
- * call-seq: space_before=(space_before)
656
- *
657
- * This string is used to insert a space before the ':' in JSON objects.
658
- */
659
- static VALUE cState_space_before_set(VALUE self, VALUE space_before)
660
- {
661
- GET_STATE(self);
662
- Check_Type(space_before, T_STRING);
663
- return state->space_before = space_before;
664
- }
665
-
666
- /*
667
- * call-seq: object_nl()
668
- *
669
- * This string is put at the end of a line that holds a JSON object (or
670
- * Hash).
671
- */
672
- static VALUE cState_object_nl(VALUE self)
673
- {
674
- GET_STATE(self);
675
- return state->object_nl;
676
- }
677
-
678
- /*
679
- * call-seq: object_nl=(object_nl)
680
- *
681
- * This string is put at the end of a line that holds a JSON object (or
682
- * Hash).
683
- */
684
- static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
685
- {
686
- GET_STATE(self);
687
- Check_Type(object_nl, T_STRING);
688
- return state->object_nl = object_nl;
689
- }
690
-
691
- /*
692
- * call-seq: array_nl()
693
- *
694
- * This string is put at the end of a line that holds a JSON array.
695
- */
696
- static VALUE cState_array_nl(VALUE self)
697
- {
698
- GET_STATE(self);
699
- return state->array_nl;
700
- }
701
-
702
- /*
703
- * call-seq: array_nl=(array_nl)
704
- *
705
- * This string is put at the end of a line that holds a JSON array.
706
- */
707
- static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
708
- {
709
- GET_STATE(self);
710
- Check_Type(array_nl, T_STRING);
711
- return state->array_nl = array_nl;
712
- }
713
-
714
- /*
715
- * call-seq: check_circular?
716
- *
717
- * Returns true, if circular data structures should be checked,
718
- * otherwise returns false.
719
- */
720
- static VALUE cState_check_circular_p(VALUE self)
721
- {
722
- GET_STATE(self);
723
- return state->check_circular ? Qtrue : Qfalse;
724
- }
725
-
726
- /*
727
- * call-seq: max_nesting
728
- *
729
- * This integer returns the maximum level of data structure nesting in
730
- * the generated JSON, max_nesting = 0 if no maximum is checked.
731
- */
732
- static VALUE cState_max_nesting(VALUE self)
733
- {
734
- GET_STATE(self);
735
- return LONG2FIX(state->max_nesting);
736
- }
737
-
738
- /*
739
- * call-seq: max_nesting=(depth)
740
- *
741
- * This sets the maximum level of data structure nesting in the generated JSON
742
- * to the integer depth, max_nesting = 0 if no maximum should be checked.
743
- */
744
- static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
745
- {
746
- GET_STATE(self);
747
- Check_Type(depth, T_FIXNUM);
748
- state->max_nesting = FIX2LONG(depth);
749
- return Qnil;
750
- }
751
-
752
- /*
753
- * call-seq: allow_nan?
754
- *
755
- * Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
756
- * returns false.
757
- */
758
- static VALUE cState_allow_nan_p(VALUE self)
759
- {
760
- GET_STATE(self);
761
- return state->allow_nan ? Qtrue : Qfalse;
762
- }
763
-
764
- /*
765
- * call-seq: seen?(object)
766
- *
767
- * Returns _true_, if _object_ was already seen during this generating run.
768
- */
769
- static VALUE cState_seen_p(VALUE self, VALUE object)
770
- {
771
- GET_STATE(self);
772
- return rb_hash_aref(state->seen, rb_obj_id(object));
773
- }
774
-
775
- /*
776
- * call-seq: remember(object)
777
- *
778
- * Remember _object_, to find out if it was already encountered (if a cyclic
779
- * data structure is rendered).
780
- */
781
- static VALUE cState_remember(VALUE self, VALUE object)
782
- {
783
- GET_STATE(self);
784
- return rb_hash_aset(state->seen, rb_obj_id(object), Qtrue);
785
- }
786
-
787
- /*
788
- * call-seq: forget(object)
789
- *
790
- * Forget _object_ for this generating run.
791
- */
792
- static VALUE cState_forget(VALUE self, VALUE object)
793
- {
794
- GET_STATE(self);
795
- return rb_hash_delete(state->seen, rb_obj_id(object));
796
- }
797
-
798
- /*
799
- *
800
- */
801
- void Init_generator()
802
- {
803
- rb_require("json/common");
804
- mJSON = rb_define_module("JSON");
805
- mExt = rb_define_module_under(mJSON, "Ext");
806
- mGenerator = rb_define_module_under(mExt, "Generator");
807
- eGeneratorError = rb_path2class("JSON::GeneratorError");
808
- eCircularDatastructure = rb_path2class("JSON::CircularDatastructure");
809
- eNestingError = rb_path2class("JSON::NestingError");
810
- cState = rb_define_class_under(mGenerator, "State", rb_cObject);
811
- rb_define_alloc_func(cState, cState_s_allocate);
812
- rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1);
813
- rb_define_method(cState, "initialize", cState_initialize, -1);
814
-
815
- rb_define_method(cState, "indent", cState_indent, 0);
816
- rb_define_method(cState, "indent=", cState_indent_set, 1);
817
- rb_define_method(cState, "space", cState_space, 0);
818
- rb_define_method(cState, "space=", cState_space_set, 1);
819
- rb_define_method(cState, "space_before", cState_space_before, 0);
820
- rb_define_method(cState, "space_before=", cState_space_before_set, 1);
821
- rb_define_method(cState, "object_nl", cState_object_nl, 0);
822
- rb_define_method(cState, "object_nl=", cState_object_nl_set, 1);
823
- rb_define_method(cState, "array_nl", cState_array_nl, 0);
824
- rb_define_method(cState, "array_nl=", cState_array_nl_set, 1);
825
- rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
826
- rb_define_method(cState, "max_nesting", cState_max_nesting, 0);
827
- rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1);
828
- rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
829
- rb_define_method(cState, "seen?", cState_seen_p, 1);
830
- rb_define_method(cState, "remember", cState_remember, 1);
831
- rb_define_method(cState, "forget", cState_forget, 1);
832
- rb_define_method(cState, "configure", cState_configure, 1);
833
- rb_define_method(cState, "to_h", cState_to_h, 0);
834
-
835
- mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
836
- mObject = rb_define_module_under(mGeneratorMethods, "Object");
837
- rb_define_method(mObject, "to_json", mObject_to_json, -1);
838
- mHash = rb_define_module_under(mGeneratorMethods, "Hash");
839
- rb_define_method(mHash, "to_json", mHash_to_json, -1);
840
- mArray = rb_define_module_under(mGeneratorMethods, "Array");
841
- rb_define_method(mArray, "to_json", mArray_to_json, -1);
842
- mInteger = rb_define_module_under(mGeneratorMethods, "Integer");
843
- rb_define_method(mInteger, "to_json", mInteger_to_json, -1);
844
- mFloat = rb_define_module_under(mGeneratorMethods, "Float");
845
- rb_define_method(mFloat, "to_json", mFloat_to_json, -1);
846
- mString = rb_define_module_under(mGeneratorMethods, "String");
847
- rb_define_singleton_method(mString, "included", mString_included_s, 1);
848
- rb_define_method(mString, "to_json", mString_to_json, -1);
849
- rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1);
850
- rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0);
851
- mString_Extend = rb_define_module_under(mString, "Extend");
852
- rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1);
853
- mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass");
854
- rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1);
855
- mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass");
856
- rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1);
857
- mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
858
- rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);
859
-
860
- i_to_s = rb_intern("to_s");
861
- i_to_json = rb_intern("to_json");
862
- i_new = rb_intern("new");
863
- i_indent = rb_intern("indent");
864
- i_space = rb_intern("space");
865
- i_space_before = rb_intern("space_before");
866
- i_object_nl = rb_intern("object_nl");
867
- i_array_nl = rb_intern("array_nl");
868
- i_check_circular = rb_intern("check_circular");
869
- i_max_nesting = rb_intern("max_nesting");
870
- i_allow_nan = rb_intern("allow_nan");
871
- i_pack = rb_intern("pack");
872
- i_unpack = rb_intern("unpack");
873
- i_create_id = rb_intern("create_id");
874
- i_extend = rb_intern("extend");
875
- }