yaks-sinatra 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28c35c58ace4346a97002a21dfaed0511727f9ff
4
+ data.tar.gz: 73530e6769357b55adbcfa83e9a46e5cbda2f6c3
5
+ SHA512:
6
+ metadata.gz: 64937f85fc62289840d67532d72a02caa28e5847a48548b4c8a0d2673be3e4ab8e710172734131c13ec93c45fa51c4ae030ba4a824549c8931839099b4846a37
7
+ data.tar.gz: 9fe45f75c8d256e1334330f91e1d6888f4727cc59c661a3e9c3d90a37aa5338bec0629253a86852cf04f20e69cd66f921a19d92919e0b7472657219efb6ff10c
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ Provide basic integration for using Yaks in sinatra. It gives you a top level `configure_yaks` method, and a `yaks` helper for use in routes.
2
+
3
+ This will register all media types known to Yaks, make sure the right one is picked based on the `Accept` header, and it will put the correct `Content-Type` header on the response.
4
+
5
+
6
+ ``` ruby
7
+ require 'yaks-sinatra'
8
+
9
+ configure_yaks do
10
+ # Yaks configuration as used in Yaks.new do ; ... ; end
11
+ end
12
+
13
+ class RootMapper < Yaks::Mapper
14
+ link :self, '/
15
+ link :posts, '/posts'
16
+ end
17
+
18
+ class PostMapper < Yaks::Mapper
19
+ attributes :title, :body, :date
20
+ has_one :author
21
+ end
22
+
23
+ get '/' do
24
+ yaks nil, mapper: RootMapper
25
+ end
26
+
27
+ get '/posts' do
28
+ yaks Post.all
29
+ end
30
+ ```
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ load '../rakelib/shared.rake'
2
+
3
+ gem_tasks(:"yaks-sinatra")
@@ -0,0 +1,31 @@
1
+ require 'sinatra/base'
2
+ require 'yaks'
3
+
4
+ module Sinatra
5
+ module Yaks
6
+ class << self
7
+ attr_accessor :yaks_config
8
+ end
9
+
10
+ def configure_yaks(&block)
11
+ Yaks.yaks_config = ::Yaks.new(&block)
12
+
13
+ configure do
14
+ ::Yaks::Format.all.each do |format|
15
+ mime_type format.format_name, format.mime_type
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ module YaksHelpers
22
+ def yaks(*args)
23
+ runner = Yaks.yaks_config.runner(*args, env: env)
24
+ content_type runner.format
25
+ runner.result
26
+ end
27
+ end
28
+
29
+ register Yaks
30
+ helpers YaksHelpers
31
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../yaks/lib/yaks/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'yaks-sinatra'
7
+ gem.version = Yaks::VERSION
8
+ gem.authors = [ 'Arne Brasseur' ]
9
+ gem.email = [ 'arne@arnebrasseur.net' ]
10
+ gem.description = 'Sinatra integration for Yaks'
11
+ gem.summary = gem.description
12
+ gem.homepage = 'https://github.com/plexus/yaks'
13
+ gem.license = 'MIT'
14
+
15
+ gem.require_paths = %w[lib]
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.test_files = gem.files.grep(/^spec/)
18
+ gem.extra_rdoc_files = %w[README.md]
19
+
20
+ gem.add_runtime_dependency 'yaks', Yaks::VERSION
21
+ gem.add_runtime_dependency 'sinatra', '~> 1.4'
22
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yaks-sinatra
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ platform: ruby
6
+ authors:
7
+ - Arne Brasseur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yaks
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.7.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ description: Sinatra integration for Yaks
42
+ email:
43
+ - arne@arnebrasseur.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files:
47
+ - README.md
48
+ files:
49
+ - README.md
50
+ - Rakefile
51
+ - lib/yaks-sinatra.rb
52
+ - yaks-sinatra.gemspec
53
+ homepage: https://github.com/plexus/yaks
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Sinatra integration for Yaks
77
+ test_files: []