rasti-web 0.1.0 → 0.1.1

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: 999b0e5bcb54088a41c56b17277f32713ad9731c
4
- data.tar.gz: 38afef4e73a96bc749c9b09082880c5d2c2b0098
3
+ metadata.gz: 831a4d1eeebc387c8e40196939035027bb83f63e
4
+ data.tar.gz: 2e0f0a273055f0d863d008744f2a22d48e885731
5
5
  SHA512:
6
- metadata.gz: 9f1bbc842a4ffe459a6c1288df422fa11b7d8a61faa753ea97b5ebcbb8a2225ece830d97b72cbeb00041f6c9645ab4e8730a32028523b0e66fddbc567ff79fd2
7
- data.tar.gz: 161c0a4f55c947accbd829d63640cad6bc24359bd8668c198d6f6cd1840420fbdce3df3860700ee2f88abac93cb48e49677b4587fa82af5d0fb749aa8f347c71
6
+ metadata.gz: 7316d529b5ac6595603cb9f26bec14dcf5e70ece674987f99a27bf7388fbd22dfeeb05e8d0c08c0d7bf37a7df02318eff0c6672858291c7761139d9ddad4930f
7
+ data.tar.gz: ff916df63a04677a72dab94f3f0cec2ef4ea5f0324f7461833ca93b0331da9df9e40c6b6be184cfe7a6f185d7ef53ec025b4bcf9584b32e52ad232dd82485af0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0
1
+ ruby-2.3.0
data/.travis.yml CHANGED
@@ -4,6 +4,7 @@ rvm:
4
4
  - 2.0
5
5
  - 2.1
6
6
  - 2.2
7
+ - 2.3.0
7
8
  - jruby
8
9
  before_install:
9
10
  - gem install bundler
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rasti-web.gemspec
4
- gemspec
5
-
6
- gem 'coveralls', require: false
4
+ gemspec
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Rasti::Web
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/rasti-web.png)](https://rubygems.org/gems/rasti-web)
4
- [![Build Status](https://travis-ci.org/gabynaiman/rasti-web.png?branch=master)](https://travis-ci.org/gabynaiman/rasti-web)
5
- [![Coverage Status](https://coveralls.io/repos/gabynaiman/rasti-web/badge.png?branch=master)](https://coveralls.io/r/gabynaiman/rasti-web?branch=master)
6
- [![Code Climate](https://codeclimate.com/github/gabynaiman/rasti-web.png)](https://codeclimate.com/github/gabynaiman/rasti-web)
7
- [![Dependency Status](https://gemnasium.com/gabynaiman/rasti-web.png)](https://gemnasium.com/gabynaiman/rasti-web)
3
+ [![Gem Version](https://badge.fury.io/rb/rasti-web.svg)](https://rubygems.org/gems/rasti-web)
4
+ [![Build Status](https://travis-ci.org/gabynaiman/rasti-web.svg?branch=master)](https://travis-ci.org/gabynaiman/rasti-web)
5
+ [![Coverage Status](https://coveralls.io/repos/gabynaiman/rasti-web/badge.svg?branch=master)](https://coveralls.io/r/gabynaiman/rasti-web?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/gabynaiman/rasti-web.svg)](https://codeclimate.com/github/gabynaiman/rasti-web)
7
+ [![Dependency Status](https://gemnasium.com/gabynaiman/rasti-web.svg)](https://gemnasium.com/gabynaiman/rasti-web)
8
8
 
9
9
  Web blocks to build robust applications
10
10
 
@@ -24,7 +24,43 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- TODO: Write usage instructions here
27
+ ### Routing
28
+
29
+ ```ruby
30
+ # app.rb
31
+ class WebApp < Rasti::Web::Application
32
+
33
+ use SomeMiddleware
34
+
35
+ get '/hello' do |request, response, render|
36
+ render.text 'world'
37
+ end
38
+
39
+ put '/users/:id', UsersController >> :update
40
+
41
+ end
42
+
43
+ # configu.ru
44
+ require_relative 'app'
45
+ run WebApp
46
+ ```
47
+
48
+ ### Controllers
49
+
50
+ ```ruby
51
+ class UsersController < Rasti::Web::Controller
52
+
53
+ def update
54
+ user = User.find(params[:id])
55
+ if user.update_attributes(params[:user])
56
+ render.view 'users/list', users: User.all
57
+ else
58
+ render.view 'users/edit', user: user
59
+ end
60
+ end
61
+
62
+ end
63
+ ```
28
64
 
29
65
  ## Contributing
30
66
 
data/Rakefile CHANGED
@@ -5,6 +5,12 @@ Rake::TestTask.new(:spec) do |t|
5
5
  t.libs << 'spec'
6
6
  t.pattern = 'spec/**/*_spec.rb'
7
7
  t.verbose = false
8
+ t.warning = false
9
+ t.loader = nil if ENV['TEST']
10
+ ENV['TEST'], ENV['LINE'] = ENV['TEST'].split(':') if ENV['TEST'] && !ENV['LINE']
11
+ t.options = ''
12
+ t.options << "--name=/#{ENV['NAME']}/ " if ENV['NAME']
13
+ t.options << "-l #{ENV['LINE']} " if ENV['LINE'] && ENV['TEST']
8
14
  end
9
15
 
10
16
  task default: :spec
@@ -20,7 +20,9 @@ module Rasti
20
20
  end
21
21
 
22
22
  def json?
23
- content_type == 'application/json'
23
+ content_type && ContentType.parse(content_type).mime_type == 'application/json'
24
+ rescue
25
+ false
24
26
  end
25
27
 
26
28
  end
@@ -1,5 +1,5 @@
1
1
  module Rasti
2
2
  module Web
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
data/lib/rasti/web.rb CHANGED
@@ -2,6 +2,7 @@ require 'rack'
2
2
  require 'tilt'
3
3
  require 'json'
4
4
  require 'mime-types'
5
+ require 'content-type'
5
6
  require 'class_config'
6
7
  require 'forwardable'
7
8
  require 'logger'
data/rasti-web.gemspec CHANGED
@@ -23,12 +23,21 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'mime-types', '~> 2.0'
24
24
  spec.add_dependency 'class_config', '~> 0.0.2'
25
25
  spec.add_dependency 'hash_ext', '~> 0.1'
26
+ spec.add_dependency 'content-type', '~> 0.0'
26
27
 
27
- spec.add_development_dependency 'bundler', '~> 1.6'
28
- spec.add_development_dependency 'rake'
29
- spec.add_development_dependency 'minitest', '~> 4.7'
30
- spec.add_development_dependency 'turn', '~> 0.9'
31
- spec.add_development_dependency 'simplecov'
32
- spec.add_development_dependency 'pry-nav'
28
+ spec.add_development_dependency 'bundler', '~> 1.12'
29
+ spec.add_development_dependency 'rake', '~> 11.0'
30
+ spec.add_development_dependency 'minitest', '~> 5.0'
31
+ spec.add_development_dependency 'minitest-colorin', '~> 0.1'
32
+ spec.add_development_dependency 'minitest-line', '~> 0.6'
33
+ spec.add_development_dependency 'simplecov', '~> 0.12'
34
+ spec.add_development_dependency 'coveralls', '~> 0.8'
35
+ spec.add_development_dependency 'pry-nav', '~> 0.2'
33
36
  spec.add_development_dependency 'rack-test'
37
+
38
+ if RUBY_VERSION < '2'
39
+ spec.add_development_dependency 'term-ansicolor', '~> 1.3.0'
40
+ spec.add_development_dependency 'tins', '~> 1.6.0'
41
+ spec.add_development_dependency 'json', '~> 1.8'
42
+ end
34
43
  end
@@ -1,8 +1,5 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
3
 
4
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
- SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
7
- ]
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
8
5
  SimpleCov.start
@@ -1,16 +1,10 @@
1
1
  require 'coverage_helper'
2
2
  require 'rasti-web'
3
3
  require 'minitest/autorun'
4
- require 'turn'
4
+ require 'minitest/colorin'
5
5
  require 'rack/test'
6
6
  require 'pry-nav'
7
7
 
8
- Turn.config do |c|
9
- c.format = :pretty
10
- c.natural = true
11
- c.ansi = true
12
- end
13
-
14
8
  module ContextMethodHelper
15
9
  def page_header(text)
16
10
  "<h1>#{text}</h1>"
metadata CHANGED
@@ -1,181 +1,223 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasti-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-27 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tilt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mime-types
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: class_config
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.0.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.0.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hash_ext
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: content-type
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ~>
101
+ - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '1.6'
103
+ version: '1.12'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ~>
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '1.6'
110
+ version: '1.12'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - '>='
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '0'
117
+ version: '11.0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - '>='
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '0'
124
+ version: '11.0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: minitest
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ~>
129
+ - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '4.7'
131
+ version: '5.0'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - ~>
136
+ - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '4.7'
138
+ version: '5.0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: turn
140
+ name: minitest-colorin
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - ~>
143
+ - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '0.9'
145
+ version: '0.1'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - ~>
150
+ - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '0.9'
152
+ version: '0.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: minitest-line
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.6'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.6'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: simplecov
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
- - - '>='
171
+ - - "~>"
144
172
  - !ruby/object:Gem::Version
145
- version: '0'
173
+ version: '0.12'
146
174
  type: :development
147
175
  prerelease: false
148
176
  version_requirements: !ruby/object:Gem::Requirement
149
177
  requirements:
150
- - - '>='
178
+ - - "~>"
151
179
  - !ruby/object:Gem::Version
152
- version: '0'
180
+ version: '0.12'
181
+ - !ruby/object:Gem::Dependency
182
+ name: coveralls
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.8'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.8'
153
195
  - !ruby/object:Gem::Dependency
154
196
  name: pry-nav
155
197
  requirement: !ruby/object:Gem::Requirement
156
198
  requirements:
157
- - - '>='
199
+ - - "~>"
158
200
  - !ruby/object:Gem::Version
159
- version: '0'
201
+ version: '0.2'
160
202
  type: :development
161
203
  prerelease: false
162
204
  version_requirements: !ruby/object:Gem::Requirement
163
205
  requirements:
164
- - - '>='
206
+ - - "~>"
165
207
  - !ruby/object:Gem::Version
166
- version: '0'
208
+ version: '0.2'
167
209
  - !ruby/object:Gem::Dependency
168
210
  name: rack-test
169
211
  requirement: !ruby/object:Gem::Requirement
170
212
  requirements:
171
- - - '>='
213
+ - - ">="
172
214
  - !ruby/object:Gem::Version
173
215
  version: '0'
174
216
  type: :development
175
217
  prerelease: false
176
218
  version_requirements: !ruby/object:Gem::Requirement
177
219
  requirements:
178
- - - '>='
220
+ - - ">="
179
221
  - !ruby/object:Gem::Version
180
222
  version: '0'
181
223
  description: Web blocks to build robust applications
@@ -185,11 +227,11 @@ executables: []
185
227
  extensions: []
186
228
  extra_rdoc_files: []
187
229
  files:
188
- - .coveralls.yml
189
- - .gitignore
190
- - .ruby-gemset
191
- - .ruby-version
192
- - .travis.yml
230
+ - ".coveralls.yml"
231
+ - ".gitignore"
232
+ - ".ruby-gemset"
233
+ - ".ruby-version"
234
+ - ".travis.yml"
193
235
  - Gemfile
194
236
  - LICENSE.txt
195
237
  - README.md
@@ -238,17 +280,17 @@ require_paths:
238
280
  - lib
239
281
  required_ruby_version: !ruby/object:Gem::Requirement
240
282
  requirements:
241
- - - '>='
283
+ - - ">="
242
284
  - !ruby/object:Gem::Version
243
285
  version: '0'
244
286
  required_rubygems_version: !ruby/object:Gem::Requirement
245
287
  requirements:
246
- - - '>='
288
+ - - ">="
247
289
  - !ruby/object:Gem::Version
248
290
  version: '0'
249
291
  requirements: []
250
292
  rubyforge_project:
251
- rubygems_version: 2.4.8
293
+ rubygems_version: 2.5.1
252
294
  signing_key:
253
295
  specification_version: 4
254
296
  summary: Web blocks to build robust applications