jason 0.1.0
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.
- data/.autotest +9 -0
- data/.gitignore +19 -0
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +93 -0
- data/LICENSE +20 -0
- data/README.md +59 -0
- data/Rakefile +20 -0
- data/jason.gemspec +29 -0
- data/lib/jason.rb +35 -0
- data/lib/jason/rails_template_handler.rb +21 -0
- data/lib/jason/version.rb +4 -0
- data/test/rails/.autotest +5 -0
- data/test/rails/.gitignore +17 -0
- data/test/rails/Gemfile +11 -0
- data/test/rails/Gemfile.lock +87 -0
- data/test/rails/README.md +1 -0
- data/test/rails/Rakefile +4 -0
- data/test/rails/app/controllers/application_controller.rb +2 -0
- data/test/rails/app/controllers/test_controller.rb +6 -0
- data/test/rails/app/views/test/index.jason +2 -0
- data/test/rails/config.ru +4 -0
- data/test/rails/config/application.rb +15 -0
- data/test/rails/config/boot.rb +6 -0
- data/test/rails/config/environment.rb +5 -0
- data/test/rails/config/environments/development.rb +9 -0
- data/test/rails/config/environments/production.rb +9 -0
- data/test/rails/config/environments/test.rb +9 -0
- data/test/rails/config/initializers/secret_token.rb +1 -0
- data/test/rails/config/initializers/session_store.rb +1 -0
- data/test/rails/config/routes.rb +3 -0
- data/test/rails/public/404.html +26 -0
- data/test/rails/public/422.html +26 -0
- data/test/rails/public/500.html +26 -0
- data/test/rails/public/favicon.ico +0 -0
- data/test/rails/public/robots.txt +5 -0
- data/test/rails/script/rails +6 -0
- data/test/rails/test/integration/jason_test.rb +8 -0
- data/test/rails/test/test_helper.rb +3 -0
- data/test/test_helper.rb +7 -0
- data/test/test_jason.rb +32 -0
- metadata +201 -0
data/.autotest
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
jason (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: http://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ZenTest (4.5.0)
|
|
10
|
+
abstract (1.0.0)
|
|
11
|
+
actionmailer (3.0.5)
|
|
12
|
+
actionpack (= 3.0.5)
|
|
13
|
+
mail (~> 2.2.15)
|
|
14
|
+
actionpack (3.0.5)
|
|
15
|
+
activemodel (= 3.0.5)
|
|
16
|
+
activesupport (= 3.0.5)
|
|
17
|
+
builder (~> 2.1.2)
|
|
18
|
+
erubis (~> 2.6.6)
|
|
19
|
+
i18n (~> 0.4)
|
|
20
|
+
rack (~> 1.2.1)
|
|
21
|
+
rack-mount (~> 0.6.13)
|
|
22
|
+
rack-test (~> 0.5.7)
|
|
23
|
+
tzinfo (~> 0.3.23)
|
|
24
|
+
activemodel (3.0.5)
|
|
25
|
+
activesupport (= 3.0.5)
|
|
26
|
+
builder (~> 2.1.2)
|
|
27
|
+
i18n (~> 0.4)
|
|
28
|
+
activerecord (3.0.5)
|
|
29
|
+
activemodel (= 3.0.5)
|
|
30
|
+
activesupport (= 3.0.5)
|
|
31
|
+
arel (~> 2.0.2)
|
|
32
|
+
tzinfo (~> 0.3.23)
|
|
33
|
+
activeresource (3.0.5)
|
|
34
|
+
activemodel (= 3.0.5)
|
|
35
|
+
activesupport (= 3.0.5)
|
|
36
|
+
activesupport (3.0.5)
|
|
37
|
+
arel (2.0.9)
|
|
38
|
+
autotest (4.4.6)
|
|
39
|
+
ZenTest (>= 4.4.1)
|
|
40
|
+
builder (2.1.2)
|
|
41
|
+
erubis (2.6.6)
|
|
42
|
+
abstract (>= 1.0.0)
|
|
43
|
+
i18n (0.5.0)
|
|
44
|
+
json (1.5.1)
|
|
45
|
+
mail (2.2.17)
|
|
46
|
+
activesupport (>= 2.3.6)
|
|
47
|
+
i18n (>= 0.4.0)
|
|
48
|
+
mime-types (~> 1.16)
|
|
49
|
+
treetop (~> 1.4.8)
|
|
50
|
+
maruku (0.6.0)
|
|
51
|
+
syntax (>= 1.0.0)
|
|
52
|
+
mime-types (1.16)
|
|
53
|
+
minitest (2.1.0)
|
|
54
|
+
mocha (0.9.12)
|
|
55
|
+
polyglot (0.3.1)
|
|
56
|
+
rack (1.2.2)
|
|
57
|
+
rack-mount (0.6.14)
|
|
58
|
+
rack (>= 1.0.0)
|
|
59
|
+
rack-test (0.5.7)
|
|
60
|
+
rack (>= 1.0)
|
|
61
|
+
rails (3.0.5)
|
|
62
|
+
actionmailer (= 3.0.5)
|
|
63
|
+
actionpack (= 3.0.5)
|
|
64
|
+
activerecord (= 3.0.5)
|
|
65
|
+
activeresource (= 3.0.5)
|
|
66
|
+
activesupport (= 3.0.5)
|
|
67
|
+
bundler (~> 1.0)
|
|
68
|
+
railties (= 3.0.5)
|
|
69
|
+
railties (3.0.5)
|
|
70
|
+
actionpack (= 3.0.5)
|
|
71
|
+
activesupport (= 3.0.5)
|
|
72
|
+
rake (>= 0.8.7)
|
|
73
|
+
thor (~> 0.14.4)
|
|
74
|
+
rake (0.8.7)
|
|
75
|
+
syntax (1.0.0)
|
|
76
|
+
thor (0.14.6)
|
|
77
|
+
treetop (1.4.9)
|
|
78
|
+
polyglot (>= 0.3.1)
|
|
79
|
+
tzinfo (0.3.26)
|
|
80
|
+
yard (0.6.8)
|
|
81
|
+
|
|
82
|
+
PLATFORMS
|
|
83
|
+
ruby
|
|
84
|
+
|
|
85
|
+
DEPENDENCIES
|
|
86
|
+
autotest (~> 4.4)
|
|
87
|
+
jason!
|
|
88
|
+
json (~> 1.5)
|
|
89
|
+
maruku (~> 0.6)
|
|
90
|
+
minitest (~> 2.0)
|
|
91
|
+
mocha (~> 0.9)
|
|
92
|
+
rails (= 3.0.5)
|
|
93
|
+
yard (~> 0.6)
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 Alexander Kern
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# jason - insanely simple JSON templates [](http://stillmaintained.com/CapnKernul/jason) [](http://travis-ci.org/CapnKernul/jason) #
|
|
2
|
+
|
|
3
|
+
## Problem ##
|
|
4
|
+
|
|
5
|
+
There's no easy way to create JSON templates in Ruby.
|
|
6
|
+
|
|
7
|
+
## Solution ##
|
|
8
|
+
|
|
9
|
+
Use YAML and ERb to make the simplest thing that could possibly work.
|
|
10
|
+
|
|
11
|
+
## Installation ##
|
|
12
|
+
|
|
13
|
+
Without bundler:
|
|
14
|
+
|
|
15
|
+
gem install jason
|
|
16
|
+
|
|
17
|
+
With bundler:
|
|
18
|
+
|
|
19
|
+
gem 'jason'
|
|
20
|
+
|
|
21
|
+
## Usage ##
|
|
22
|
+
|
|
23
|
+
You write jason templates in plain YAML and ERb. Jason will take care of the
|
|
24
|
+
(ultra-simple) conversion to JSON.
|
|
25
|
+
|
|
26
|
+
Jason.render("foo: bar") # => '{"foo": "bar"}'
|
|
27
|
+
|
|
28
|
+
That's it.
|
|
29
|
+
|
|
30
|
+
## Usage with Rails ##
|
|
31
|
+
|
|
32
|
+
Name your view template with the extension `jason`. Everything else is the same.
|
|
33
|
+
|
|
34
|
+
# in view_name.jason
|
|
35
|
+
foo: bar
|
|
36
|
+
baz:
|
|
37
|
+
<% unless @we_started_the_fire %>
|
|
38
|
+
- quz
|
|
39
|
+
- quuz
|
|
40
|
+
<% end %>
|
|
41
|
+
|
|
42
|
+
# Renders: {"foo": "bar", "baz": ["quz", "quuz"]}
|
|
43
|
+
|
|
44
|
+
## Note on Patches/Pull Requests ##
|
|
45
|
+
|
|
46
|
+
* Fork the project.
|
|
47
|
+
* Make your feature addition or bug fix.
|
|
48
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
49
|
+
* Commit, but do not mess with the `Rakefile`. If you want to have your own version, that is fine but bump the version in a commit by itself in another branch so I can ignore it when I pull.
|
|
50
|
+
* Send me a pull request. Bonus points for git flow feature branches.
|
|
51
|
+
|
|
52
|
+
## Resources ##
|
|
53
|
+
|
|
54
|
+
* [GitHub Repository](https://github.com/CapnKernul/jason)
|
|
55
|
+
* [Documentation](http://rubydoc.info/github/CapnKernul/jason)
|
|
56
|
+
|
|
57
|
+
## License ##
|
|
58
|
+
|
|
59
|
+
Jason is licensed under the MIT License. See `LICENSE` for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
task :default => 'test:unit'
|
|
5
|
+
|
|
6
|
+
task :test => ['test:unit', 'test:rails']
|
|
7
|
+
|
|
8
|
+
require 'rake/testtask'
|
|
9
|
+
Rake::TestTask.new('test:unit') do |t|
|
|
10
|
+
t.ruby_opts += ['-rubygems']
|
|
11
|
+
t.libs << 'test'
|
|
12
|
+
t.pattern = 'test/test_*.rb'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
task 'test:rails' do
|
|
16
|
+
sh <<-CMD
|
|
17
|
+
cd test/rails
|
|
18
|
+
rake
|
|
19
|
+
CMD
|
|
20
|
+
end
|
data/jason.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'jason/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'jason'
|
|
7
|
+
s.version = Jason::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ['Alexander Kern']
|
|
10
|
+
s.email = ['alex@kernul.com']
|
|
11
|
+
s.homepage = 'https://github.com/CapnKernul/jason'
|
|
12
|
+
s.summary = %q{Insanely simple JSON templates}
|
|
13
|
+
s.description = %q{Create JSON templates using YAML and ERb}
|
|
14
|
+
|
|
15
|
+
s.rubyforge_project = 'jason'
|
|
16
|
+
|
|
17
|
+
s.files = `git ls-files`.split("\n")
|
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
20
|
+
s.require_paths = ['lib']
|
|
21
|
+
|
|
22
|
+
s.add_development_dependency 'minitest', '~> 2.0'
|
|
23
|
+
s.add_development_dependency 'mocha', '~> 0.9'
|
|
24
|
+
s.add_development_dependency 'autotest', '~> 4.4'
|
|
25
|
+
s.add_development_dependency 'rails', '3.0.5'
|
|
26
|
+
s.add_development_dependency 'json', '~> 1.5'
|
|
27
|
+
s.add_development_dependency 'yard', '~> 0.6'
|
|
28
|
+
s.add_development_dependency 'maruku', '~> 0.6'
|
|
29
|
+
end
|
data/lib/jason.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
# Renders and compiles Jason templates.
|
|
6
|
+
module Jason
|
|
7
|
+
# Render a template.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Jason.render('foo: bar') # => '{"foo": "bar"}'
|
|
11
|
+
#
|
|
12
|
+
# @param template [String] the template to render
|
|
13
|
+
# @param binding [Binding] the binding to render the template in
|
|
14
|
+
# @return [String] the rendered template
|
|
15
|
+
def self.render(template, binding = nil)
|
|
16
|
+
yaml = ERB.new(template).result(binding)
|
|
17
|
+
YAML::load(yaml).to_json
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Compile a template.
|
|
21
|
+
#
|
|
22
|
+
# Eval the returned value to render the template within the current binding.
|
|
23
|
+
#
|
|
24
|
+
# @param template [String] the template to compile
|
|
25
|
+
# @return [String] the compiled template
|
|
26
|
+
def self.compile(template)
|
|
27
|
+
"#{ERB.new(template).src}; YAML::load(_erbout).to_json"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
require 'jason/version'
|
|
32
|
+
|
|
33
|
+
if defined? ActionView::Template
|
|
34
|
+
require 'jason/rails_template_handler'
|
|
35
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Jason
|
|
2
|
+
# Rails plugin for using Jason as a template handler.
|
|
3
|
+
#
|
|
4
|
+
# Name your view templates like so: `view_name.jason`.
|
|
5
|
+
#
|
|
6
|
+
# Jason loads this module only if it can find `ActionView`.
|
|
7
|
+
class RailsTemplateHandler
|
|
8
|
+
class_attribute :default_format
|
|
9
|
+
self.default_format = Mime::JSON
|
|
10
|
+
|
|
11
|
+
# Compile the Rails template.
|
|
12
|
+
#
|
|
13
|
+
# @param template [Class] the Rails template class
|
|
14
|
+
# @return [String] the compiled template
|
|
15
|
+
def call(template)
|
|
16
|
+
Jason.compile(template.source)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
ActionView::Template.register_template_handler(:jason, Jason::RailsTemplateHandler.new)
|
data/test/rails/Gemfile
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../../
|
|
3
|
+
specs:
|
|
4
|
+
jason (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: http://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ZenTest (4.5.0)
|
|
10
|
+
abstract (1.0.0)
|
|
11
|
+
actionmailer (3.0.5)
|
|
12
|
+
actionpack (= 3.0.5)
|
|
13
|
+
mail (~> 2.2.15)
|
|
14
|
+
actionpack (3.0.5)
|
|
15
|
+
activemodel (= 3.0.5)
|
|
16
|
+
activesupport (= 3.0.5)
|
|
17
|
+
builder (~> 2.1.2)
|
|
18
|
+
erubis (~> 2.6.6)
|
|
19
|
+
i18n (~> 0.4)
|
|
20
|
+
rack (~> 1.2.1)
|
|
21
|
+
rack-mount (~> 0.6.13)
|
|
22
|
+
rack-test (~> 0.5.7)
|
|
23
|
+
tzinfo (~> 0.3.23)
|
|
24
|
+
activemodel (3.0.5)
|
|
25
|
+
activesupport (= 3.0.5)
|
|
26
|
+
builder (~> 2.1.2)
|
|
27
|
+
i18n (~> 0.4)
|
|
28
|
+
activerecord (3.0.5)
|
|
29
|
+
activemodel (= 3.0.5)
|
|
30
|
+
activesupport (= 3.0.5)
|
|
31
|
+
arel (~> 2.0.2)
|
|
32
|
+
tzinfo (~> 0.3.23)
|
|
33
|
+
activeresource (3.0.5)
|
|
34
|
+
activemodel (= 3.0.5)
|
|
35
|
+
activesupport (= 3.0.5)
|
|
36
|
+
activesupport (3.0.5)
|
|
37
|
+
arel (2.0.9)
|
|
38
|
+
autotest (4.4.6)
|
|
39
|
+
ZenTest (>= 4.4.1)
|
|
40
|
+
builder (2.1.2)
|
|
41
|
+
erubis (2.6.6)
|
|
42
|
+
abstract (>= 1.0.0)
|
|
43
|
+
i18n (0.5.0)
|
|
44
|
+
json (1.5.1)
|
|
45
|
+
mail (2.2.15)
|
|
46
|
+
activesupport (>= 2.3.6)
|
|
47
|
+
i18n (>= 0.4.0)
|
|
48
|
+
mime-types (~> 1.16)
|
|
49
|
+
treetop (~> 1.4.8)
|
|
50
|
+
mime-types (1.16)
|
|
51
|
+
minitest (2.1.0)
|
|
52
|
+
mocha (0.9.12)
|
|
53
|
+
polyglot (0.3.1)
|
|
54
|
+
rack (1.2.2)
|
|
55
|
+
rack-mount (0.6.13)
|
|
56
|
+
rack (>= 1.0.0)
|
|
57
|
+
rack-test (0.5.7)
|
|
58
|
+
rack (>= 1.0)
|
|
59
|
+
rails (3.0.5)
|
|
60
|
+
actionmailer (= 3.0.5)
|
|
61
|
+
actionpack (= 3.0.5)
|
|
62
|
+
activerecord (= 3.0.5)
|
|
63
|
+
activeresource (= 3.0.5)
|
|
64
|
+
activesupport (= 3.0.5)
|
|
65
|
+
bundler (~> 1.0)
|
|
66
|
+
railties (= 3.0.5)
|
|
67
|
+
railties (3.0.5)
|
|
68
|
+
actionpack (= 3.0.5)
|
|
69
|
+
activesupport (= 3.0.5)
|
|
70
|
+
rake (>= 0.8.7)
|
|
71
|
+
thor (~> 0.14.4)
|
|
72
|
+
rake (0.8.7)
|
|
73
|
+
thor (0.14.6)
|
|
74
|
+
treetop (1.4.9)
|
|
75
|
+
polyglot (>= 0.3.1)
|
|
76
|
+
tzinfo (0.3.25)
|
|
77
|
+
|
|
78
|
+
PLATFORMS
|
|
79
|
+
ruby
|
|
80
|
+
|
|
81
|
+
DEPENDENCIES
|
|
82
|
+
autotest (~> 4.4)
|
|
83
|
+
jason!
|
|
84
|
+
json (~> 1.5)
|
|
85
|
+
minitest (~> 2.0)
|
|
86
|
+
mocha (~> 0.9)
|
|
87
|
+
rails (= 3.0.5)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Bare-bones Rails 3 application for testing Jason.
|
data/test/rails/Rakefile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'action_controller/railtie'
|
|
4
|
+
require 'rails/test_unit/railtie'
|
|
5
|
+
|
|
6
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
|
7
|
+
# you've limited to :test, :development, or :production.
|
|
8
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
|
9
|
+
|
|
10
|
+
module JasonApp
|
|
11
|
+
class Application < Rails::Application
|
|
12
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
13
|
+
config.encoding = 'utf-8'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
JasonApp::Application.configure do
|
|
2
|
+
config.cache_classes = false
|
|
3
|
+
config.whiny_nils = true
|
|
4
|
+
config.consider_all_requests_local = true
|
|
5
|
+
config.action_view.debug_rjs = true
|
|
6
|
+
config.action_controller.perform_caching = false
|
|
7
|
+
config.active_support.deprecation = :log
|
|
8
|
+
config.action_dispatch.best_standards_support = :builtin
|
|
9
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
JasonApp::Application.configure do
|
|
2
|
+
config.cache_classes = true
|
|
3
|
+
config.consider_all_requests_local = false
|
|
4
|
+
config.action_controller.perform_caching = true
|
|
5
|
+
config.action_dispatch.x_sendfile_header = 'X-Sendfile'
|
|
6
|
+
config.serve_static_assets = false
|
|
7
|
+
config.i18n.fallbacks = true
|
|
8
|
+
config.active_support.deprecation = :notify
|
|
9
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
JasonApp::Application.configure do
|
|
2
|
+
config.cache_classes = true
|
|
3
|
+
config.whiny_nils = true
|
|
4
|
+
config.consider_all_requests_local = true
|
|
5
|
+
config.action_controller.perform_caching = false
|
|
6
|
+
config.action_dispatch.show_exceptions = false
|
|
7
|
+
config.action_controller.allow_forgery_protection = false
|
|
8
|
+
config.active_support.deprecation = :stderr
|
|
9
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
JasonApp::Application.config.secret_token = '5ddfeaf6267d5da9a3409c06628538253d49c742d72b512724abc93a89df4f37ae8dc9bafaeb4ebd0b40be6eb13ca47e4bcaedbf423ed8c6774d61de1abe51eb'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
JasonApp::Application.config.session_store :cookie_store, :key => '_jason_app_session'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/404.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/422.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/500.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
+
require 'rails/commands'
|
data/test/test_helper.rb
ADDED
data/test/test_jason.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class TestJason < MiniTest::Unit::TestCase
|
|
4
|
+
def test_render_without_binding
|
|
5
|
+
template = <<-EOF
|
|
6
|
+
foo: bar
|
|
7
|
+
baz:
|
|
8
|
+
- quz
|
|
9
|
+
- quuz
|
|
10
|
+
EOF
|
|
11
|
+
|
|
12
|
+
assert_equal({'foo' => 'bar', 'baz' => ['quz', 'quuz']}, JSON.parse(Jason.render(template)))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_render_with_binding
|
|
16
|
+
test_string = 'bar'
|
|
17
|
+
template = <<-EOF
|
|
18
|
+
foo: <%= test_string %>
|
|
19
|
+
EOF
|
|
20
|
+
|
|
21
|
+
assert_equal({'foo' => 'bar' }, JSON.parse(Jason.render(template, binding)))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_compile
|
|
25
|
+
test_string = 'bar'
|
|
26
|
+
template = <<-EOF
|
|
27
|
+
foo: <%= test_string %>
|
|
28
|
+
EOF
|
|
29
|
+
|
|
30
|
+
assert_equal({'foo' => 'bar' }, JSON.parse(eval(Jason.compile(template))))
|
|
31
|
+
end
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jason
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease:
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Alexander Kern
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2011-04-19 00:00:00 -07:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: minitest
|
|
18
|
+
prerelease: false
|
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
20
|
+
none: false
|
|
21
|
+
requirements:
|
|
22
|
+
- - ~>
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: "2.0"
|
|
25
|
+
type: :development
|
|
26
|
+
version_requirements: *id001
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: mocha
|
|
29
|
+
prerelease: false
|
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
31
|
+
none: false
|
|
32
|
+
requirements:
|
|
33
|
+
- - ~>
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: "0.9"
|
|
36
|
+
type: :development
|
|
37
|
+
version_requirements: *id002
|
|
38
|
+
- !ruby/object:Gem::Dependency
|
|
39
|
+
name: autotest
|
|
40
|
+
prerelease: false
|
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
42
|
+
none: false
|
|
43
|
+
requirements:
|
|
44
|
+
- - ~>
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: "4.4"
|
|
47
|
+
type: :development
|
|
48
|
+
version_requirements: *id003
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: rails
|
|
51
|
+
prerelease: false
|
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
53
|
+
none: false
|
|
54
|
+
requirements:
|
|
55
|
+
- - "="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: 3.0.5
|
|
58
|
+
type: :development
|
|
59
|
+
version_requirements: *id004
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: json
|
|
62
|
+
prerelease: false
|
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
64
|
+
none: false
|
|
65
|
+
requirements:
|
|
66
|
+
- - ~>
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: "1.5"
|
|
69
|
+
type: :development
|
|
70
|
+
version_requirements: *id005
|
|
71
|
+
- !ruby/object:Gem::Dependency
|
|
72
|
+
name: yard
|
|
73
|
+
prerelease: false
|
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
75
|
+
none: false
|
|
76
|
+
requirements:
|
|
77
|
+
- - ~>
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: "0.6"
|
|
80
|
+
type: :development
|
|
81
|
+
version_requirements: *id006
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: maruku
|
|
84
|
+
prerelease: false
|
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
86
|
+
none: false
|
|
87
|
+
requirements:
|
|
88
|
+
- - ~>
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: "0.6"
|
|
91
|
+
type: :development
|
|
92
|
+
version_requirements: *id007
|
|
93
|
+
description: Create JSON templates using YAML and ERb
|
|
94
|
+
email:
|
|
95
|
+
- alex@kernul.com
|
|
96
|
+
executables: []
|
|
97
|
+
|
|
98
|
+
extensions: []
|
|
99
|
+
|
|
100
|
+
extra_rdoc_files: []
|
|
101
|
+
|
|
102
|
+
files:
|
|
103
|
+
- .autotest
|
|
104
|
+
- .gitignore
|
|
105
|
+
- .travis.yml
|
|
106
|
+
- Gemfile
|
|
107
|
+
- Gemfile.lock
|
|
108
|
+
- LICENSE
|
|
109
|
+
- README.md
|
|
110
|
+
- Rakefile
|
|
111
|
+
- jason.gemspec
|
|
112
|
+
- lib/jason.rb
|
|
113
|
+
- lib/jason/rails_template_handler.rb
|
|
114
|
+
- lib/jason/version.rb
|
|
115
|
+
- test/rails/.autotest
|
|
116
|
+
- test/rails/.gitignore
|
|
117
|
+
- test/rails/Gemfile
|
|
118
|
+
- test/rails/Gemfile.lock
|
|
119
|
+
- test/rails/README.md
|
|
120
|
+
- test/rails/Rakefile
|
|
121
|
+
- test/rails/app/controllers/application_controller.rb
|
|
122
|
+
- test/rails/app/controllers/test_controller.rb
|
|
123
|
+
- test/rails/app/views/test/index.jason
|
|
124
|
+
- test/rails/config.ru
|
|
125
|
+
- test/rails/config/application.rb
|
|
126
|
+
- test/rails/config/boot.rb
|
|
127
|
+
- test/rails/config/environment.rb
|
|
128
|
+
- test/rails/config/environments/development.rb
|
|
129
|
+
- test/rails/config/environments/production.rb
|
|
130
|
+
- test/rails/config/environments/test.rb
|
|
131
|
+
- test/rails/config/initializers/secret_token.rb
|
|
132
|
+
- test/rails/config/initializers/session_store.rb
|
|
133
|
+
- test/rails/config/routes.rb
|
|
134
|
+
- test/rails/public/404.html
|
|
135
|
+
- test/rails/public/422.html
|
|
136
|
+
- test/rails/public/500.html
|
|
137
|
+
- test/rails/public/favicon.ico
|
|
138
|
+
- test/rails/public/robots.txt
|
|
139
|
+
- test/rails/script/rails
|
|
140
|
+
- test/rails/test/integration/jason_test.rb
|
|
141
|
+
- test/rails/test/test_helper.rb
|
|
142
|
+
- test/test_helper.rb
|
|
143
|
+
- test/test_jason.rb
|
|
144
|
+
has_rdoc: true
|
|
145
|
+
homepage: https://github.com/CapnKernul/jason
|
|
146
|
+
licenses: []
|
|
147
|
+
|
|
148
|
+
post_install_message:
|
|
149
|
+
rdoc_options: []
|
|
150
|
+
|
|
151
|
+
require_paths:
|
|
152
|
+
- lib
|
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
|
+
none: false
|
|
155
|
+
requirements:
|
|
156
|
+
- - ">="
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: "0"
|
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
|
+
none: false
|
|
161
|
+
requirements:
|
|
162
|
+
- - ">="
|
|
163
|
+
- !ruby/object:Gem::Version
|
|
164
|
+
version: "0"
|
|
165
|
+
requirements: []
|
|
166
|
+
|
|
167
|
+
rubyforge_project: jason
|
|
168
|
+
rubygems_version: 1.6.2
|
|
169
|
+
signing_key:
|
|
170
|
+
specification_version: 3
|
|
171
|
+
summary: Insanely simple JSON templates
|
|
172
|
+
test_files:
|
|
173
|
+
- test/rails/.autotest
|
|
174
|
+
- test/rails/.gitignore
|
|
175
|
+
- test/rails/Gemfile
|
|
176
|
+
- test/rails/Gemfile.lock
|
|
177
|
+
- test/rails/README.md
|
|
178
|
+
- test/rails/Rakefile
|
|
179
|
+
- test/rails/app/controllers/application_controller.rb
|
|
180
|
+
- test/rails/app/controllers/test_controller.rb
|
|
181
|
+
- test/rails/app/views/test/index.jason
|
|
182
|
+
- test/rails/config.ru
|
|
183
|
+
- test/rails/config/application.rb
|
|
184
|
+
- test/rails/config/boot.rb
|
|
185
|
+
- test/rails/config/environment.rb
|
|
186
|
+
- test/rails/config/environments/development.rb
|
|
187
|
+
- test/rails/config/environments/production.rb
|
|
188
|
+
- test/rails/config/environments/test.rb
|
|
189
|
+
- test/rails/config/initializers/secret_token.rb
|
|
190
|
+
- test/rails/config/initializers/session_store.rb
|
|
191
|
+
- test/rails/config/routes.rb
|
|
192
|
+
- test/rails/public/404.html
|
|
193
|
+
- test/rails/public/422.html
|
|
194
|
+
- test/rails/public/500.html
|
|
195
|
+
- test/rails/public/favicon.ico
|
|
196
|
+
- test/rails/public/robots.txt
|
|
197
|
+
- test/rails/script/rails
|
|
198
|
+
- test/rails/test/integration/jason_test.rb
|
|
199
|
+
- test/rails/test/test_helper.rb
|
|
200
|
+
- test/test_helper.rb
|
|
201
|
+
- test/test_jason.rb
|