jsonify 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/jsonify.gemspec +1 -0
- data/lib/jsonify/version.rb +1 -1
- data/lib/tilt/jsonify_template.rb +42 -0
- data/spec/hello_world.jsonify +1 -0
- data/spec/jsonify_template_spec.rb +10 -0
- data/spec/spec_helper.rb +1 -0
- metadata +34 -18
data/jsonify.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency 'json' unless RUBY_VERSION =~ /^1.9/
|
23
23
|
|
24
24
|
s.add_development_dependency 'bundler'
|
25
|
+
s.add_development_dependency 'tilt'
|
25
26
|
s.add_development_dependency 'rake'
|
26
27
|
s.add_development_dependency 'rspec'
|
27
28
|
s.add_development_dependency 'autotest'
|
data/lib/jsonify/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'tilt/template'
|
3
|
+
|
4
|
+
module Tilt
|
5
|
+
# Builder template implementation. See:
|
6
|
+
# http://builder.rubyforge.org/
|
7
|
+
class JsonifyTemplate < Template
|
8
|
+
self.default_mime_type = 'application/json'
|
9
|
+
|
10
|
+
def self.engine_initialized?
|
11
|
+
defined? ::Jsonify
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize_engine
|
15
|
+
require_template_library 'jsonify'
|
16
|
+
end
|
17
|
+
|
18
|
+
def prepare; end
|
19
|
+
|
20
|
+
def evaluate(scope, locals, &block)
|
21
|
+
return super(scope, locals, &block) if data.respond_to?(:to_str)
|
22
|
+
json = ::Jsonify::Builder.new
|
23
|
+
data.call(json)
|
24
|
+
json.compile!
|
25
|
+
end
|
26
|
+
|
27
|
+
def precompiled_preamble(locals)
|
28
|
+
return super if locals.include? :json
|
29
|
+
"json = ::Jsonify::Builder.new\n#{super}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def precompiled_postamble(locals)
|
33
|
+
"json.compile!"
|
34
|
+
end
|
35
|
+
|
36
|
+
def precompiled_template(locals)
|
37
|
+
data.to_str
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Tilt.register Tilt::JsonifyTemplate, 'jsonify'
|
@@ -0,0 +1 @@
|
|
1
|
+
json.hello 'world'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
describe Tilt::JsonifyTemplate do
|
2
|
+
it 'should be associated with .jsonify files' do
|
3
|
+
template = Tilt.new('spec/hello_world.jsonify')
|
4
|
+
template.should be_a_kind_of(Tilt::JsonifyTemplate)
|
5
|
+
end
|
6
|
+
it 'should render the template' do
|
7
|
+
template = Tilt.new('spec/hello_world.jsonify')
|
8
|
+
template.render.should == "{\"hello\":\"world\"}"
|
9
|
+
end
|
10
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70196253538200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,21 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70196253538200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: tilt
|
27
|
+
requirement: &70196253537140 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70196253537140
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rake
|
27
|
-
requirement: &
|
38
|
+
requirement: &70196253536220 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70196253536220
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rspec
|
38
|
-
requirement: &
|
49
|
+
requirement: &70196253535660 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: '0'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70196253535660
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: autotest
|
49
|
-
requirement: &
|
60
|
+
requirement: &70196253534820 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70196253534820
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: yard
|
60
|
-
requirement: &
|
71
|
+
requirement: &70196253531360 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,10 +76,10 @@ dependencies:
|
|
65
76
|
version: '0'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70196253531360
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: rdiscount
|
71
|
-
requirement: &
|
82
|
+
requirement: &70196253530520 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,10 +87,10 @@ dependencies:
|
|
76
87
|
version: '0'
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70196253530520
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: ruby-prof
|
82
|
-
requirement: &
|
93
|
+
requirement: &70196253529760 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,7 +98,7 @@ dependencies:
|
|
87
98
|
version: '0'
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *70196253529760
|
91
102
|
description: Turn Ruby objects into JSON -- correctly!
|
92
103
|
email:
|
93
104
|
- bsiggelkow@me.com
|
@@ -108,12 +119,15 @@ files:
|
|
108
119
|
- lib/jsonify/generate.rb
|
109
120
|
- lib/jsonify/json_value.rb
|
110
121
|
- lib/jsonify/version.rb
|
122
|
+
- lib/tilt/jsonify_template.rb
|
111
123
|
- performance/profile.rb
|
112
124
|
- performance/speed.rb
|
113
125
|
- spec/builder_spec.rb
|
114
126
|
- spec/generate_spec.rb
|
127
|
+
- spec/hello_world.jsonify
|
115
128
|
- spec/json_value_spec.rb
|
116
129
|
- spec/jsonify_spec.rb
|
130
|
+
- spec/jsonify_template_spec.rb
|
117
131
|
- spec/spec_helper.rb
|
118
132
|
homepage: http://github.com/bsiggelkow/jsonify
|
119
133
|
licenses: []
|
@@ -129,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
143
|
version: '0'
|
130
144
|
segments:
|
131
145
|
- 0
|
132
|
-
hash:
|
146
|
+
hash: 1862892832760024132
|
133
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
148
|
none: false
|
135
149
|
requirements:
|
@@ -138,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
152
|
version: '0'
|
139
153
|
segments:
|
140
154
|
- 0
|
141
|
-
hash:
|
155
|
+
hash: 1862892832760024132
|
142
156
|
requirements: []
|
143
157
|
rubyforge_project: jsonify
|
144
158
|
rubygems_version: 1.8.6
|
@@ -150,6 +164,8 @@ test_files:
|
|
150
164
|
- performance/speed.rb
|
151
165
|
- spec/builder_spec.rb
|
152
166
|
- spec/generate_spec.rb
|
167
|
+
- spec/hello_world.jsonify
|
153
168
|
- spec/json_value_spec.rb
|
154
169
|
- spec/jsonify_spec.rb
|
170
|
+
- spec/jsonify_template_spec.rb
|
155
171
|
- spec/spec_helper.rb
|