racket-mvc 0.0.5 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2780584b9d4ab769bd0e1aef25544d15aee4eab
4
- data.tar.gz: 391cf9ae48c6ed99634b0d224f3351c0b0b9c1a9
3
+ metadata.gz: 297c59402186821841ac8b3d9ec1585ebd19a9d4
4
+ data.tar.gz: acd9b707fa7aa9d7e249e818454fb2045367b5ef
5
5
  SHA512:
6
- metadata.gz: 97cacd90e6986b5a0946cfbcb018c993521696aa54e654dc2d593eaf01129554e446ad9c3e4b4709c1186a7443f8ab24c7d9ef209e8c6f760561132b0131d01f
7
- data.tar.gz: dd360e6ff448e1216008453962ccb8b091dee5c0c01804263b4e7495bd48802d39d546978aa64ee40a269fe6da23afa4083245f3c166316ac6a7053c3b1f00e4
6
+ metadata.gz: a0a346641c4c8f09872051634660c1270edaa0c6ca34ee4f9fd13e69736d24c58bb976b45df94cbc4208443204ad0198ab0ef7d1cfbb57b47d9c27995ac81a01
7
+ data.tar.gz: 0cfa26fb63e2750dd4b3ab3bb1472fefbbc589f24d29fcacfbeb13ea55b787cd46f0b249b57b5f0fa5706786dc6b72cfd67da64e2feff86a40eb11ba18e1728c
data/README.md CHANGED
@@ -20,18 +20,27 @@ Yes. Writing Rack frameworks is easy! And since I am able to decide exactly what
20
20
  need to adopt to a large ecosystem of concepts I do not like.
21
21
 
22
22
  ## So, is it any good?
23
- Probably not. At the moment it is good _enough_ for my needs, but I plan to add more features/make stuff faster
24
- as I start porting more of my old apps from Ramaze.
23
+ Let us just say it is good _enough_ for my needs at the moment. I plan to add more features/make stuff faster
24
+ whenever I am finished porting most of my old apps from Ramaze.
25
25
 
26
26
  ## Where are the tests?
27
- Have a look in the `spec` directory. The code base have tests covering 100 per cent of the code and I am planning on keeping it that way. At the moment the code is tested using ruby 2.0, ruby 2.1.6 and 2.2.2, but more versions might be added later.
27
+ Have a look in the `spec` directory. The code base have tests covering 100 per cent of the code and I am planning on keeping it that way. At the moment the code is tested on the following platforms (using [Travis CI](https://travis-ci.org/)):
28
28
 
29
- I am using [bacon](https://github.com/chneukirchen/bacon) and [rack-test](https://github.com/brynary/rack-test) for testing. Run the tests by typing `bacon spec/racket.rb`in the root directory. Code coverage reports are provided by [simplecov](https://rubygems.org/gems/simplecov). After the tests have run the an HTML report can be found in the `coverage` directory. If you are not interested in running the tests yourself you could also have a look at the test status at [Travis CI](https://travis-ci.org/lasso/racket) and the code coverage at [Codecov](https://codecov.io/github/lasso/racket). Their stats get updated on every commit.
29
+ - ruby 1.9.3
30
+ - ruby 2.0
31
+ - ruby 2.1.6
32
+ - ruby 2.2.2
33
+ - jruby (latest version, 1.9 mode only)
34
+ - rbx-2 (latest version)
35
+
36
+ I am using [bacon](https://github.com/chneukirchen/bacon) and [rack-test](https://github.com/brynary/rack-test) for testing. Run the tests by typing `rake test`in the root directory. Code coverage reports are provided by [simplecov](https://rubygems.org/gems/simplecov). After the tests have run the an HTML report can be found in the `coverage` directory.
37
+
38
+ If you are not interested in running the tests yourself you could have a look at the test status at [Travis CI](https://travis-ci.org/lasso/racket) and the code coverage at [Codecov](https://codecov.io/github/lasso/racket). Their stats get updated on every commit.
30
39
 
31
40
  ## Alright, I want to try using this stuff. Where are the docs?
32
- Unfortunately there aren't any docs yet. The main reason is that most things are not finished yet, I am still
33
- moving stuff around like crazy. There **will** be a wiki later and I also plan on documenting the code itself heavily
34
- (using [Yard](http://yardoc.org/)).
41
+ At the moment there is not much documentation available, but I have started working on the [wiki](https://github.com/lasso/racket/wiki).
42
+
43
+ The code itself is documented using [Yard](http://yardoc.org/). The docs are not generated automatically, you need to run `rake doc` in the root directory to generate them. After running the rake task the documentation will be available in the `doc` directory.
35
44
 
36
45
  ## Why is the code licenced under the GNU Affero General Public License? I want a more liberal licence!
37
46
  Because I think it is a Good Thing™ to share code. The
@@ -38,11 +38,7 @@ module Racket
38
38
  instance.options[:middleware].each do |middleware|
39
39
  klass, opts = middleware
40
40
  instance.inform_dev("Loading middleware #{klass} with options #{opts}.")
41
- if opts
42
- use klass, opts
43
- else
44
- use klass
45
- end
41
+ use *middleware
46
42
  end
47
43
  run lambda { |env|
48
44
  static_result = instance.serve_static_file(env)
data/lib/racket/router.rb CHANGED
@@ -41,8 +41,7 @@ module Racket
41
41
  actions.merge(current.instance_methods(false))
42
42
  current = current.superclass
43
43
  end
44
- @actions_by_controller[controller] = actions.to_a
45
- nil
44
+ (@actions_by_controller[controller] = actions.to_a) && nil
46
45
  end
47
46
 
48
47
  # Returns a route to the specified controller/action/parameter combination.
@@ -71,8 +70,7 @@ module Racket
71
70
  Application.inform_dev("Mapping #{controller} to #{controller_base_path}.")
72
71
  @router.add("#{path}(/*params)").to(controller)
73
72
  @routes_by_controller[controller] = controller_base_path
74
- cache_actions(controller)
75
- nil
73
+ cache_actions(controller) && nil
76
74
  end
77
75
 
78
76
  # @todo: Allow the user to set custom handlers for different errors
@@ -105,12 +103,13 @@ module Racket
105
103
  # Check if action is available on target
106
104
  return render_error(404) unless @actions_by_controller[target_klass].include?(action)
107
105
 
108
- # Initialize target
106
+ # Rewrite PATH_INFO to reflect that we split out the parameters
107
+ env['PATH_INFO'] = env['PATH_INFO']
108
+ .split('/')[0...-params.count]
109
+ .join('/') unless params.empty?
110
+
111
+ # Initialize and render target
109
112
  target = target_klass.new
110
- # @fixme: File.dirname should not be used on urls!
111
- 1.upto(params.count) do
112
- env['PATH_INFO'] = File.dirname(env['PATH_INFO'])
113
- end
114
113
  target.extend(Current.init(env, action, params))
115
114
  target.render(action)
116
115
  else
@@ -121,6 +120,5 @@ module Racket
121
120
  render_error(500, err)
122
121
  end
123
122
  end
124
-
125
123
  end
126
124
  end
data/lib/racket/utils.rb CHANGED
@@ -1,3 +1,23 @@
1
+ =begin
2
+ Racket - The noisy Rack MVC framework
3
+ Copyright (C) 2015 Lars Olsson <lasso@lassoweb.se>
4
+
5
+ This file is part of Racket.
6
+
7
+ Racket is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU Affero General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ Racket is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU Affero General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Affero General Public License
18
+ along with Racket. If not, see <http://www.gnu.org/licenses/>.
19
+ =end
20
+
1
21
  module Racket
2
22
  # Collects utilities needed by different objects in Racket.
3
23
  class Utils
@@ -25,15 +25,18 @@ module Racket
25
25
  # Major version
26
26
  MAJOR = 0
27
27
  # Minor version
28
- MINOR = 0
28
+ MINOR = 1
29
29
  # Teeny version
30
- TEENY = 5
30
+ TEENY = 0
31
+ # Prerelease ?
32
+ PRERELEASE = false
31
33
 
32
34
  # Returns the current version of Racket as a string.
33
35
  #
34
36
  # @return [String]
35
37
  def current
36
- [MAJOR, MINOR, TEENY].join('.')
38
+ current = [MAJOR, MINOR, TEENY]
39
+ ((current.push('pre') if PRERELEASE) || current).join('.')
37
40
  end
38
41
 
39
42
  module_function :current
data/spec/racket.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'simplecov'
2
2
  require 'stringio'
3
+ require 'tilt/erb'
3
4
 
4
5
  SimpleCov.start do
5
6
  add_filter 'spec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: racket-mvc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Olsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-13 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http_router
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description: Racket is a small MVC framework built atop of rack.
139
+ description: Racket is a small MVC framework built on top of rack.
140
140
  email: lasso@lassoweb.se
141
141
  executables: []
142
142
  extensions: []
@@ -186,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - ">="
188
188
  - !ruby/object:Gem::Version
189
- version: 2.0.0
189
+ version: 1.9.3
190
190
  required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ">="