rack-app 0.9.0 → 0.9.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: dde5ac113879f10a79548e3c815ce6df2ce1c1f4
4
- data.tar.gz: 737dce792b8d47068228ff468e6a25db9224e377
3
+ metadata.gz: 6e9e97fcff12d6ec6e33b8b73bb3a2858cfdb028
4
+ data.tar.gz: d40cb38798d131f0905d31f3682b1ff500ab0421
5
5
  SHA512:
6
- metadata.gz: 3749bd9e51a5da2eead8467043088bfaa73d25952128366a098c09e24449691eed5771f2976e3bce79b481637d6e10dc92bb6af8aef686996c93ab722c99f5ca
7
- data.tar.gz: abd365ac5e50dc6780a7171ae2e47bab25de55339fe92d7d61475d5ec8d6b4279d41b42dd996fa5ef5c08998e602f946e277a028503d9de9ba66a8556a04c7e5
6
+ metadata.gz: b8ed888abbdc3e27359e19bba5b00285ab44515d4958b0b7364f37bb1f9cdbcc92cbda0a4dbd4e110e6631cc126ef1921d1922112b8e75a553c75a08cad464b8
7
+ data.tar.gz: 3e1000a744087c86caa8eccd83d2ae333f7a471adbd7271c0f6d443e341e111afca9408560f489ad4caa4f6e17162e6c992b5005d71ef7c915f255b6dbe92a22
@@ -0,0 +1,27 @@
1
+ language: ruby
2
+ script: rspec spec
3
+
4
+ rvm:
5
+ - 1.8
6
+ - 1.9
7
+ - 2.0
8
+ - 2.1
9
+ - jruby-18mode
10
+ - jruby-19mode
11
+ - ree
12
+
13
+ - ruby-head
14
+ - jruby-head
15
+
16
+ env:
17
+ global:
18
+ - VERBOSE=true
19
+ - TIMEOUT=1
20
+
21
+ branches:
22
+ only:
23
+ - master
24
+
25
+ notifications:
26
+ email:
27
+ - adamluzsi@gmail.com
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # Rack::App
1
+ # Rack::Appi [![Build Status][travis-image]][travis-link]
2
+
3
+ [travis-image]: https://secure.travis-ci.org/adamluzsi/rack-app.rb.png?branch=master
4
+ [travis-link]: http://travis-ci.org/adamluzsi/rack-app.rb
5
+ [travis-home]: http://travis-ci.org/
2
6
 
3
7
  Your next favourite rack based micro framework that is totally addition free!
4
8
  Have a cup of awesomeness with your performance designed framework!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
@@ -14,7 +14,6 @@ class Rack::App
14
14
  require 'rack/app/request_configurator'
15
15
 
16
16
  require 'rack/app/file'
17
- require 'rack/app/view'
18
17
 
19
18
  class << self
20
19
 
@@ -78,9 +77,9 @@ class Rack::App
78
77
  def add_route(request_method, request_path, &block)
79
78
 
80
79
  endpoint_properties = {
81
- request_method: request_method,
82
- request_path: request_path,
83
- description: @last_description
80
+ :request_method => request_method,
81
+ :request_path => request_path,
82
+ :description => @last_description
84
83
  }
85
84
 
86
85
  endpoint = Rack::App::Endpoint.new(self, endpoint_properties, &block)
@@ -4,23 +4,29 @@ module Rack::App::Test
4
4
 
5
5
  # magic ;)
6
6
  def self.included(klass)
7
+ class << klass
7
8
 
8
- klass.define_singleton_method :rack_app do |rack_app_class=nil, &constructor|
9
+ define_method(:rack_app) do |*args, &constructor|
9
10
 
10
- subject_app = rack_app_class.is_a?(Class) ? rack_app_class : Class.new(Rack::App)
11
- subject_app.class_eval(&constructor) unless constructor.nil?
11
+ rack_app_class = args.shift
12
+ subject_app = rack_app_class.is_a?(Class) ? rack_app_class : Class.new(Rack::App)
13
+ subject_app.class_eval(&constructor) unless constructor.nil?
14
+
15
+ define_method(:rack_app) do
16
+ subject_app
17
+ end
12
18
 
13
- klass.__send__ :define_method, :rack_app do
14
- @rack_app = subject_app
15
19
  end
16
20
 
17
21
  end
18
-
19
22
  end
20
23
 
21
24
  [:get, :post, :put, :delete, :options].each do |request_method|
22
- define_method(request_method) do |url, properties={}|
23
- rack_app.call(request_env_by(request_method, url, properties)).last
25
+ define_method(request_method) do |properties|
26
+ properties ||= Hash.new
27
+ url = properties.delete(:url)
28
+ request_env = request_env_by(request_method, url, properties)
29
+ rack_app.call(request_env).last
24
30
  end
25
31
  end
26
32
 
@@ -35,9 +41,7 @@ module Rack::App::Test
35
41
  def request_env_by(request_method, url, raw_properties)
36
42
 
37
43
  properties = format_properties(raw_properties)
38
- URI.encode_www_form(properties[:params].to_a)
39
-
40
- additional_headers = properties[:headers].reduce({}) { |m,(k, v)| m.merge("HTTP_#{k.to_s.gsub('-', '_').upcase}" => v.to_s) }
44
+ additional_headers = properties[:headers].reduce({}) { |m, (k, v)| m.merge("HTTP_#{k.to_s.gsub('-', '_').upcase}" => v.to_s) }
41
45
 
42
46
  {
43
47
  "REMOTE_ADDR" => "192.168.56.1",
@@ -49,7 +53,7 @@ module Rack::App::Test
49
53
  "CONTENT_TYPE" => "application/x-www-form-urlencoded",
50
54
  "SERVER_NAME" => "hds-dev.ett.local",
51
55
  "SERVER_PORT" => "80",
52
- "QUERY_STRING" => URI.encode_www_form(properties[:params].to_a),
56
+ "QUERY_STRING" => encode_www_form(properties[:params].to_a),
53
57
  "HTTP_VERSION" => "HTTP/1.1",
54
58
  "HTTP_USER_AGENT" => "spec",
55
59
  "HTTP_HOST" => "spec.local",
@@ -60,4 +64,51 @@ module Rack::App::Test
60
64
 
61
65
  end
62
66
 
67
+ def encode_www_form(enum)
68
+ enum.map do |k, v|
69
+ if v.nil?
70
+ encode_www_form_component(k)
71
+ elsif v.respond_to?(:to_ary)
72
+ v.to_ary.map do |w|
73
+ str = encode_www_form_component(k)
74
+ unless w.nil?
75
+ str << '='
76
+ str << encode_www_form_component(w)
77
+ end
78
+ end.join('&')
79
+ else
80
+ str = encode_www_form_component(k)
81
+ str << '='
82
+ str << encode_www_form_component(v)
83
+ end
84
+ end.join('&')
85
+ end
86
+
87
+ TBLENCWWWCOMP_ = {} # :nodoc:
88
+ 256.times do |i|
89
+ TBLENCWWWCOMP_['%%%02X' % i] = i.chr
90
+ end
91
+ TBLENCWWWCOMP_[' '] = '+'
92
+ TBLENCWWWCOMP_.freeze
93
+ TBLDECWWWCOMP = {} # :nodoc:
94
+ 256.times do |i|
95
+ h, l = i>>4, i&15
96
+ TBLDECWWWCOMP[i.chr]= '%%%X%X' % [h, l]
97
+ TBLDECWWWCOMP[i.chr]= '%%%X%X' % [h, l]
98
+ TBLDECWWWCOMP[i.chr]= '%%%x%X' % [h, l]
99
+ TBLDECWWWCOMP[i.chr]= '%%%X%x' % [h, l]
100
+ TBLDECWWWCOMP[i.chr]= '%%%x%x' % [h, l]
101
+ end
102
+ TBLDECWWWCOMP['+'] = ' '
103
+ TBLDECWWWCOMP.freeze
104
+
105
+ def encode_www_form_component(str)
106
+ str = str.to_s.dup
107
+
108
+ TBLENCWWWCOMP_.each do |from,to|
109
+ str.gsub!(from,to)
110
+ end
111
+ str
112
+ end
113
+
63
114
  end
@@ -1,3 +1,2 @@
1
- Rack ||= Module.new
2
- Rack::App ||= Class.new
1
+ require 'rack/app'
3
2
  Rack::App::VERSION = File.read(File.join(File.dirname(__FILE__), '..', '..', '..', 'VERSION')).strip
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rack/app/version'
2
+ # lib = File.expand_path('../lib', __FILE__)
3
+ # $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ # require 'rack/app/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
 
8
8
  spec.name = "rack-app"
9
- spec.version = Rack::App::VERSION
9
+ spec.version = File.read(File.join(File.dirname(__FILE__), 'VERSION')).strip
10
10
  spec.authors = ["Adam Luzsi"]
11
11
  spec.email = ["adamluzsi@gmail.com"]
12
12
 
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.license = 'GNU General Public License v3'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.10"
25
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "rspec"
27
27
 
28
28
  spec.add_dependency "rack"
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
+ - ".travis.yml"
79
80
  - CODE_OF_CONDUCT.md
80
81
  - Gemfile
81
82
  - LICENSE
@@ -103,7 +104,6 @@ files:
103
104
  - lib/rack/app/test.rb
104
105
  - lib/rack/app/utils.rb
105
106
  - lib/rack/app/version.rb
106
- - lib/rack/app/view.rb
107
107
  - rack-app.gemspec
108
108
  - spike/routing_time.rb
109
109
  homepage: https://github.com/adamluzsi/rack-app.rb
@@ -1,14 +0,0 @@
1
- class Rack::App::View
2
-
3
- extend Rack::App::File::Parser::Factory
4
-
5
- def render(view_file_basename)
6
- file_path = File.join(class_current_folder, view_file_basename)
7
- self.class.find_file_parser_class_for(File.extname(file_path)).new(self).parse(file_path).to_a.join("\n")
8
- end
9
-
10
- def class_current_folder
11
- method(:call).source_location.first.sub(/.rb$/,'')
12
- end
13
-
14
- end