rapid_runty 0.1.1 → 0.1.2

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: 80540cdbd978fc8cfceeb6f123a03039219b87a2
4
- data.tar.gz: 6e71cafc92d36bf244237b8c2fdbbc48f75820e6
3
+ metadata.gz: 45302d9a8dbbf57572216e3d7decd9a79504fa51
4
+ data.tar.gz: 71527a5d37ac8a023a374bfb5b354738f8f61b7a
5
5
  SHA512:
6
- metadata.gz: fb430ffbd7c1275e14664159401c419bfbf7f8d13a2b7f308d6e9bdbe1a822a0f697b86b954478da049480877d4fc7109bd3646f7b71e55b8179f1d21582608b
7
- data.tar.gz: f614b09cf5e9e29574ed912ef2688352981f4c2e787c9f2467223954baf18f7f4b713ddb21f99fd99df83d2fa2fd35198118a3bdbefce74071e313d5e819812b
6
+ metadata.gz: b0b02e994bb9479b459d5f15aba669b263887508d74cf71c2ba7a08dfe5f7fe707132f1110e21ea981f50515c85f4ee6103afd6904e55333ef68791ee1d713f5
7
+ data.tar.gz: 7d63588dc32c587faed2722be2f2bf547c6990c3d33d22b135f6b9b7d4a693ab9c7d11c1f242cc3db3f4095225c724ad62b6294a43f2486ac6fb53a5eda0eb3c
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "todoList"]
2
+ path = spec/support/todoList
3
+ url = https://github.com/Habu-Kagumba/todoList.git
data/.rubocop.yml CHANGED
@@ -1,243 +1,13 @@
1
1
  AllCops:
2
- Include:
3
- - "**/*.gemspec"
4
- - "**/*.rake"
5
- - "**/Gemfile"
6
- - "**/Rakefile"
7
- - "**/Guardfile"
8
- - "**/Thorfile"
9
- - "**/Vagrantfile"
10
2
  Exclude:
11
- - "vendor/**/*"
12
- - "db/schema.rb"
13
- Rails:
14
- enabled: false
3
+ - "db/schema.rb"
4
+ - "Gemfile"
5
+ - "spec/**/*"
15
6
  UseCache: false
16
- Style/CollectionMethods:
17
- Description: Preferred collection methods.
18
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
19
- Enabled: true
20
- PreferredMethods:
21
- collect: map
22
- collect!: map!
23
- find: detect
24
- find_all: select
25
- reduce: inject
26
- Style/DotPosition:
27
- Description: Checks the position of the dot in multi-line method calls.
28
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
29
- Enabled: true
30
- EnforcedStyle: trailing
31
- SupportedStyles:
32
- - leading
33
- - trailing
34
- Style/FileName:
35
- Description: Use snake_case for source file names.
36
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
37
- Enabled: false
38
- Exclude: []
39
- Style/GuardClause:
40
- Description: Check for conditionals that can be replaced with guard clauses
41
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
42
- Enabled: false
43
- MinBodyLength: 1
44
- Style/IfUnlessModifier:
45
- Description: Favor modifier if/unless usage when you have a single-line body.
46
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
47
- Enabled: false
48
- MaxLineLength: 80
49
- Style/OptionHash:
50
- Description: Don't use option hashes when you can use keyword arguments.
51
- Enabled: false
52
- Style/PercentLiteralDelimiters:
53
- Description: Use `%`-literal delimiters consistently
54
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
55
- Enabled: false
56
- PreferredDelimiters:
57
- "%": "()"
58
- "%i": "()"
59
- "%q": "()"
60
- "%Q": "()"
61
- "%r": "{}"
62
- "%s": "()"
63
- "%w": "()"
64
- "%W": "()"
65
- "%x": "()"
66
- Style/PredicateName:
67
- Description: Check the names of predicate methods.
68
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
69
- Enabled: true
70
- NamePrefix:
71
- - is_
72
- - has_
73
- - have_
74
- NamePrefixBlacklist:
75
- - is_
76
- Exclude:
77
- - spec/**/*
78
- Style/RaiseArgs:
79
- Description: Checks the arguments passed to raise/fail.
80
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
81
- Enabled: false
82
- EnforcedStyle: exploded
83
- SupportedStyles:
84
- - compact
85
- - exploded
86
- Style/SignalException:
87
- Description: Checks for proper usage of fail and raise.
88
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
89
- Enabled: false
90
- EnforcedStyle: semantic
91
- SupportedStyles:
92
- - only_raise
93
- - only_fail
94
- - semantic
95
- Style/SingleLineBlockParams:
96
- Description: Enforces the names of some block params.
97
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
98
- Enabled: false
99
- Methods:
100
- - reduce:
101
- - a
102
- - e
103
- - inject:
104
- - a
105
- - e
106
- Style/SingleLineMethods:
107
- Description: Avoid single-line methods.
108
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
109
- Enabled: false
110
- AllowIfMethodIsEmpty: true
111
- Style/StringLiterals:
112
- Description: Checks if uses of quotes match the configured preference.
113
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
114
- Enabled: true
115
- EnforcedStyle: double_quotes
116
- SupportedStyles:
117
- - single_quotes
118
- - double_quotes
119
- Style/StringLiteralsInInterpolation:
120
- Description: Checks if uses of quotes inside expressions in interpolated strings
121
- match the configured preference.
122
- Enabled: true
123
- EnforcedStyle: single_quotes
124
- SupportedStyles:
125
- - single_quotes
126
- - double_quotes
127
- Style/TrailingCommaInLiteral:
128
- Description: Checks for trailing comma in parameter lists and literals.
129
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
130
- Enabled: false
131
- EnforcedStyleForMultiline: no_comma
132
- SupportedStyles:
133
- - comma
134
- - no_comma
135
7
  Metrics/AbcSize:
136
- Description: A calculated magnitude based on number of assignments, branches, and
137
- conditions.
138
- Enabled: false
139
- Max: 15
140
- Metrics/ClassLength:
141
- Description: Avoid classes longer than 100 lines of code.
142
- Enabled: false
143
- CountComments: false
144
- Max: 100
145
- Metrics/ModuleLength:
146
- CountComments: false
147
- Max: 100
148
- Description: Avoid modules longer than 100 lines of code.
149
- Enabled: false
150
- Metrics/CyclomaticComplexity:
151
- Description: A complexity metric that is strongly correlated to the number of test
152
- cases needed to validate a method.
153
- Enabled: false
154
- Max: 6
155
- Metrics/MethodLength:
156
- Description: Avoid methods longer than 10 lines of code.
157
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
158
- Enabled: false
159
- CountComments: false
160
- Max: 10
161
- Metrics/ParameterLists:
162
- Description: Avoid parameter lists longer than three or four parameters.
163
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
164
- Enabled: false
165
- Max: 5
166
- CountKeywordArgs: true
167
- Metrics/PerceivedComplexity:
168
- Description: A complexity metric geared towards measuring complexity for a human
169
- reader.
170
- Enabled: false
171
- Max: 7
172
- Lint/AssignmentInCondition:
173
- Description: Don't use assignment in conditions.
174
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
175
8
  Enabled: false
176
- AllowSafeAssignment: true
177
- Style/InlineComment:
178
- Description: Avoid inline comments.
179
- Enabled: false
180
- Style/AccessorMethodName:
181
- Description: Check the naming of accessor methods for get_/set_.
182
- Enabled: false
183
- Style/Alias:
184
- Description: Use alias_method instead of alias.
185
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
9
+ Metrics/LineLength:
186
10
  Enabled: false
187
11
  Style/Documentation:
188
- Description: Document classes and non-namespace modules.
189
- Enabled: false
190
- Style/DoubleNegation:
191
- Description: Checks for uses of double negation (!!).
192
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
193
- Enabled: false
194
- Style/EachWithObject:
195
- Description: Prefer `each_with_object` over `inject` or `reduce`.
196
- Enabled: false
197
- Style/EmptyLiteral:
198
- Description: Prefer literals to Array.new/Hash.new/String.new.
199
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
200
- Enabled: false
201
- Style/ModuleFunction:
202
- Description: Checks for usage of `extend self` in modules.
203
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
204
- Enabled: false
205
- Style/OneLineConditional:
206
- Description: Favor the ternary operator(?:) over if/then/else/end constructs.
207
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
208
- Enabled: false
209
- Style/PerlBackrefs:
210
- Description: Avoid Perl-style regex back references.
211
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
212
- Enabled: false
213
- Style/Send:
214
- Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
215
- may overlap with existing methods.
216
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
217
- Enabled: false
218
- Style/SpecialGlobalVars:
219
- Description: Avoid Perl-style global variables.
220
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
221
- Enabled: false
222
- Style/VariableInterpolation:
223
- Description: Don't interpolate global, instance and class variables directly in
224
- strings.
225
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
226
- Enabled: false
227
- Style/WhenThen:
228
- Description: Use when x then ... for one-line cases.
229
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
230
- Enabled: false
231
- Lint/EachWithObjectArgument:
232
- Description: Check for immutable argument given to each_with_object.
233
- Enabled: true
234
- Lint/HandleExceptions:
235
- Description: Don't suppress exception.
236
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
237
- Enabled: false
238
- Lint/LiteralInCondition:
239
- Description: Checks of literals used in conditions.
240
- Enabled: false
241
- Lint/LiteralInInterpolation:
242
- Description: Checks for literals used in interpolation.
243
- Enabled: false
12
+ Exclude:
13
+ - 'lib/**/*'
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
5
  group :development, :test do
6
- gem "poltergeist", git: "git://github.com/teampoltergeist/poltergeist.git"
6
+ gem 'poltergeist', git: 'git://github.com/teampoltergeist/poltergeist.git'
7
7
  end
data/Guardfile CHANGED
@@ -1,5 +1,5 @@
1
- guard :rspec, cmd: "bundle exec rspec" do
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/rapid_runty/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch("spec/spec_helper.rb") { "spec" }
4
+ watch('spec/spec_helper.rb') { 'spec' }
5
5
  end
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Rapid Runty
7
7
 
8
- [![Gem Version](https://badge.fury.io/rb/rapid_runty.svg)](https://badge.fury.io/rb/rapid_runty) [![Dependency Status](https://gemnasium.com/badges/github.com/andela-hkagumba/rapid_runty.svg)](https://gemnasium.com/github.com/andela-hkagumba/rapid_runty) [![Codeship Status for andela-hkagumba/rapid_runty](https://codeship.com/projects/c6f3c4d0-3efd-0134-9b91-6a8ca46930c1/status?branch=master) ](https://codeship.com/projects/167383) [![Coverage Status](https://coveralls.io/repos/github/andela-hkagumba/rapid_runty/badge.svg?branch=master)](https://coveralls.io/github/andela-hkagumba/rapid_runty?branch=master) [![codebeat badge](https://codebeat.co/badges/e5fef576-c696-4d14-9ca0-2ace5b758642)](https://codebeat.co/projects/github-com-andela-hkagumba-rapid_runty)
8
+ [![Gem Version](https://badge.fury.io/rb/rapid_runty.svg)](https://badge.fury.io/rb/rapid_runty) [![Dependency Status](https://gemnasium.com/badges/github.com/Habu-Kagumba/rapid_runty.svg)](https://gemnasium.com/github.com/Habu-Kagumba/rapid_runty) [![Codeship Status for Habu-Kagumba/rapid_runty](https://codeship.com/projects/c6f3c4d0-3efd-0134-9b91-6a8ca46930c1/status?branch=master) ](https://codeship.com/projects/167383) [![Coverage Status](https://coveralls.io/repos/github/Habu-Kagumba/rapid_runty/badge.svg?branch=master)](https://coveralls.io/github/Habu-Kagumba/rapid_runty?branch=master) [![codebeat badge](https://codebeat.co/badges/e5fef576-c696-4d14-9ca0-2ace5b758642)](https://codebeat.co/projects/github-com-habu-kagumba-rapid_runty) [![Inline docs](http://inch-ci.org/github/Habu-Kagumba/rapid_runty.svg?branch=master&style=flat-square)](http://inch-ci.org/github/Habu-Kagumba/rapid_runty)
9
9
 
10
10
  **Rapid Runty** is a minimal web framework to get your web project up and running in seconds.
11
11
 
@@ -41,7 +41,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
41
41
 
42
42
  ## Contributing
43
43
 
44
- Bug reports and pull requests are welcome on GitHub at https://github.com/andela-hkagumba/rapid_runty. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Habu-Kagumba/rapid_runty. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
45
45
 
46
46
 
47
47
  ## License
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "coveralls/rake/task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'coveralls/rake/task'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  Coveralls::RakeTask.new
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "rapid_runty"
3
+ require 'bundler/setup'
4
+ require 'rapid_runty'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "rapid_runty"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
@@ -1,7 +1,8 @@
1
- require "rapid_runty/routing"
2
- require "rapid_runty/controller"
1
+ require 'rapid_runty/routing'
2
+ require 'rapid_runty/controller'
3
3
 
4
4
  module RapidRunty
5
+ ##
5
6
  # Main framework Application class. Entry point for all requests.
6
7
  #
7
8
  # Example:
@@ -19,11 +20,19 @@ module RapidRunty
19
20
  #
20
21
  # @return [status, {headers}, [response]] array
21
22
  def call(env)
22
- return [500, {}, []] if env["PATH_INFO"] == "/favicon.ico"
23
- controller_class, action = get_controller_action(env)
24
- controller = controller_class.new(env)
25
- response = controller.send(action)
26
- [200, { "Content-Type" => "text/html" }, [response]]
23
+ request = Rack::Request.new(env)
24
+
25
+ verb = request.request_method.downcase.to_sym
26
+ path = Rack::Utils.unescape(request.path_info)
27
+
28
+ return [500, {}, []] if path == '/favicon.ico'
29
+
30
+ route = routes.match(verb, path)
31
+ if route.nil?
32
+ [404, { 'Content-Type' => 'text/html' }, '404 not found']
33
+ else
34
+ [200, { 'Content-Type' => 'text/html' }, ["Hello RapidRunty"]]
35
+ end
27
36
  end
28
37
  end
29
38
  end
@@ -0,0 +1,8 @@
1
+ # Override Object.const_missing
2
+ class Object
3
+ # Convert Constants to snake_case and try to autoload them
4
+ def self.const_missing(c)
5
+ require c.to_s.snake_case
6
+ Object.const_get(c)
7
+ end
8
+ end
@@ -0,0 +1,110 @@
1
+ require 'pathname'
2
+
3
+ module RapidRunty
4
+ module Router
5
+ ##
6
+ # Matches passed in path with array of application paths
7
+ module Matcher
8
+ def self.match(*args)
9
+ Base.match(*args)
10
+ end
11
+
12
+ class Base
13
+ ##
14
+ # Defines the route that matches the path
15
+ #
16
+ # Example:
17
+ #
18
+ # RapidRunty::Router::Matcher.match("/foo", [{url: "/", to: "root#index"}, {url: "/bar", to: "bar#index"}, {url: "/foo", to: "foo#index"}]) #=> ["/foo", [], { controller: "foo", action: "index" }]
19
+ # RapidRunty::Router::Matcher.match("/04/01/01", [{url: "/:day/:month/:year", to: "date#find"}]) #=> ["/", ["04", "01", "01"], { controller: "date", action: "find" }]
20
+ # @param path [String] path from ENV["PATH_INFO"]
21
+ # @param application routes [Array] Array of Hash application defined routes
22
+ #
23
+ # Currently only supporting ":to" options which defines the "controller#action"
24
+ #
25
+ # @return [matching_route, matched_placeholders, matched_controller_action] array
26
+ #
27
+ def self.match(path, routes)
28
+ path = Path.new(path)
29
+ url_patterns = routes.map { |route| URLPattern.new(route) }
30
+
31
+ url_patterns.each do |pattern|
32
+ return [
33
+ pattern.to_s,
34
+ pattern.placeholders,
35
+ ControllerSetup.controller_action(pattern.options)
36
+ ] if pattern == path
37
+ end
38
+
39
+ [nil, [], {}]
40
+ end
41
+ end
42
+
43
+ class Path
44
+ attr_accessor :parts, :ext, :options
45
+
46
+ def initialize(path)
47
+ path = Pathname(path)
48
+ self.parts, self.ext = split_path(path)
49
+ rescue TypeError
50
+ self.parts, self.ext = split_path(path[:url])
51
+ self.options = path[:to]
52
+ end
53
+
54
+ def to_s
55
+ '/' + parts.join('/') + ext
56
+ end
57
+
58
+ private
59
+
60
+ def split_path(path)
61
+ path = path.to_s
62
+ ext = Pathname(path).extname
63
+ path = path.sub(/#{ext}$/, '')
64
+ parts = path.split('/').reject(&:empty?)
65
+ parts = [''] if path == '/'
66
+ [parts, ext]
67
+ end
68
+ end
69
+
70
+ class URLPattern < Path
71
+ def placeholders
72
+ return [] unless @match
73
+
74
+ vars = []
75
+ parts.each_with_index do |part, i|
76
+ vars << @match.parts[i] if part[0] == ':'
77
+ end
78
+ vars
79
+ end
80
+
81
+ def ==(other)
82
+ is_match = size_match?(other) && parts_match?(other)
83
+ @match = other if is_match
84
+ is_match
85
+ end
86
+
87
+ private
88
+
89
+ def size_match?(path)
90
+ parts.size == path.parts.size
91
+ end
92
+
93
+ def parts_match?(path)
94
+ parts.each_with_index do |part, i|
95
+ return true if part[0] == ':' || path.parts[i] == part
96
+ end
97
+ false
98
+ end
99
+ end
100
+
101
+ class ControllerSetup
102
+ def self.controller_action(options)
103
+ Hash[
104
+ %w(controller action).zip options.split('#')
105
+ ]
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,80 @@
1
+ require 'rapid_runty/routes/matcher'
2
+
3
+ module RapidRunty
4
+ module Router
5
+ ##
6
+ # This class registers all routes defined by the draw method.
7
+ class Routes < Array
8
+ def add(*args)
9
+ self << Route.new(*args)
10
+ end
11
+
12
+ ##
13
+ # Match incoming paths from env to existing routes
14
+ #
15
+ # @param verb [String] HTTP verb extracted from Rack env
16
+ # @param path [String] the url path extracted from Rack env
17
+ #
18
+ # @return A RapidRunty::Router::Route Instance:
19
+ #
20
+ # Example:
21
+ # RapidRunty::Router::Routes.match("GET", "/foo/4") = #<RapidRunty::Router::Route options={"controller"=>"foo", "action"=>"bar"}, path="/foo/:id", placeholders=[], verb=:get
22
+ def match(verb, path)
23
+ return nil if empty?
24
+
25
+ verb = verb.to_s.downcase.strip.to_sym
26
+
27
+ routes = select { |route| route.verb == verb }
28
+ paths = routes.map { |route| { url: route.path }.merge route.options }
29
+
30
+ path, places, action = RapidRunty::Router::Matcher.match(path, paths)
31
+ return nil if path.nil?
32
+
33
+ route = routes.detect { |router| router.path == path }.clone
34
+ route.placeholders = places
35
+ route.options = action
36
+ route
37
+ end
38
+
39
+ ##
40
+ # Provides familiar DSL to defining routes
41
+ #
42
+ # Example:
43
+ # DemoApplication.routes.draw do
44
+ # root "demo#index"
45
+ # get "/demo", to: "demo#index"
46
+ # get "/demo/new", to: "demo#new"
47
+ # get "/demo/:id", to: "demo#show"
48
+ # get "/demo/:id/edit", to: "demo#edit"
49
+ # post "/demo/", to: "demo#create"
50
+ # put "/demo/:id", to: "demo#update"
51
+ # patch "/demo/:id", to: "demo#update"
52
+ # delete "/demo/:id", to: "demo#destroy"
53
+ # end
54
+ def draw(&block)
55
+ instance_eval(&block)
56
+ end
57
+
58
+ def root(controller)
59
+ get '/', to: controller
60
+ end
61
+
62
+ %w(get post put patch delete).each do |method_name|
63
+ define_method(method_name) do |path, options|
64
+ add(method_name.to_sym, path, options)
65
+ end
66
+ end
67
+ end
68
+
69
+ class Route
70
+ attr_accessor :verb, :path, :options, :placeholders
71
+
72
+ def initialize(verb, path, options)
73
+ self.verb = verb
74
+ self.path = path
75
+ self.options = options
76
+ self.placeholders = nil
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,17 +1,11 @@
1
+ require 'rapid_runty/routes/route'
2
+
1
3
  module RapidRunty
2
4
  class Application
3
- # Retrieve the controller and action method from the URL
4
- #
5
- # @param env [Hash] Rack environment Hash that includes CGI-like headers
6
- #
7
- # @return [Controller, Action] array
8
- def get_controller_action(env)
9
- _, controller, action, _other = env["PATH_INFO"].split("/", 4)
10
- controller = controller.capitalize
11
- controller += "Controller"
5
+ attr_reader :routes
12
6
 
13
- # Lookup controller constant name and return [controller, action]
14
- [Object.const_get(controller), action]
7
+ def initialize
8
+ @routes = RapidRunty::Router::Routes.new
15
9
  end
16
10
  end
17
11
  end
@@ -0,0 +1,17 @@
1
+ # Extend the Ruby String class
2
+ class String
3
+ ##
4
+ # Returns the snake_case version of a word
5
+ #
6
+ # Example:
7
+ #
8
+ # "IndexController".snake_case = "index_controller"
9
+ def snake_case
10
+ gsub!(/::/, '/')
11
+ gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
12
+ gsub!(/([a-z\d])([A-Z])/, '\1_\2')
13
+ tr!('-', '_')
14
+ downcase!
15
+ self
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module RapidRunty
2
- VERSION = "0.1.1".freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/rapid_runty.rb CHANGED
@@ -1,5 +1,7 @@
1
- require "rapid_runty/application"
2
- require "rapid_runty/version"
1
+ require 'rapid_runty/application'
2
+ require 'rapid_runty/version'
3
+ require 'rapid_runty/util'
4
+ require 'rapid_runty/dependencies'
3
5
 
4
6
  module RapidRunty
5
7
  end
data/rapid_runty.gemspec CHANGED
@@ -1,45 +1,45 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "rapid_runty/version"
4
+ require 'rapid_runty/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "rapid_runty"
7
+ spec.name = 'rapid_runty'
8
8
  spec.version = RapidRunty::VERSION
9
- spec.authors = ["Herbert Kagumba"]
10
- spec.email = ["herbert.kagumba@andela.com"]
9
+ spec.authors = ['Herbert Kagumba']
10
+ spec.email = ['herbert.kagumba@andela.com']
11
11
 
12
- spec.summary = "A minimal web framework"
13
- spec.description = "A minimal web framework to get your web project up "\
14
- "and running in seconds."
15
- spec.homepage = "https://github.com/andela-hkagumba/rapid_runty"
16
- spec.license = "MIT"
12
+ spec.summary = 'A minimal web framework'
13
+ spec.description = 'A minimal web framework to get your web project up '\
14
+ 'and running in seconds.'
15
+ spec.homepage = 'https://github.com/Habu-Kagumb/rapid_runty'
16
+ spec.license = 'MIT'
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
19
  f.match(%r{^(test|spec|features)/})
20
20
  end
21
- spec.bindir = "exe"
21
+ spec.bindir = 'exe'
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
24
24
 
25
- spec.add_development_dependency "pry", "~> 0.10"
25
+ spec.add_development_dependency 'pry', '~> 0.10'
26
26
 
27
- spec.add_development_dependency "rspec", "~> 3.0"
28
- spec.add_development_dependency "rack-test", "~> 0.6"
29
- spec.add_development_dependency "simplecov", "~> 0.12"
30
- spec.add_development_dependency "capybara", "~> 2.7"
31
- spec.add_development_dependency "coveralls", "~> 0.8"
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'rack-test', '~> 0.6'
29
+ spec.add_development_dependency 'simplecov', '~> 0.12'
30
+ spec.add_development_dependency 'capybara', '~> 2.7'
31
+ spec.add_development_dependency 'coveralls', '~> 0.8'
32
32
 
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "guard", "~> 2.14"
35
- spec.add_development_dependency "guard-rspec", "~> 4.7"
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'guard', '~> 2.14'
35
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
36
36
 
37
- spec.add_development_dependency "yard", "~> 0.9"
38
- spec.add_development_dependency "rubocop", "~> 0.42"
39
- spec.add_development_dependency "brakeman", "~> 3.3"
40
- spec.add_development_dependency "rubycritic", "~> 2.9"
37
+ spec.add_development_dependency 'yard', '~> 0.9'
38
+ spec.add_development_dependency 'rubocop', '~> 0.42'
39
+ spec.add_development_dependency 'brakeman', '~> 3.3'
40
+ spec.add_development_dependency 'rubycritic', '~> 2.9'
41
41
 
42
- spec.add_dependency "rack", "~> 2.0"
43
- spec.add_dependency "bundler", "~> 1.12"
44
- spec.add_dependency "thor", "~> 0.19"
42
+ spec.add_dependency 'rack', '~> 2.0'
43
+ spec.add_dependency 'bundler', '~> 1.12'
44
+ spec.add_dependency 'thor', '~> 0.19'
45
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapid_runty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herbert Kagumba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-07 00:00:00.000000000 Z
11
+ date: 2016-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -243,6 +243,7 @@ extra_rdoc_files: []
243
243
  files:
244
244
  - ".github/PULL_REQUEST_TEMPLATE.md"
245
245
  - ".gitignore"
246
+ - ".gitmodules"
246
247
  - ".hound.yml"
247
248
  - ".rspec"
248
249
  - ".rubocop.yml"
@@ -259,10 +260,14 @@ files:
259
260
  - lib/rapid_runty.rb
260
261
  - lib/rapid_runty/application.rb
261
262
  - lib/rapid_runty/controller.rb
263
+ - lib/rapid_runty/dependencies.rb
264
+ - lib/rapid_runty/routes/matcher.rb
265
+ - lib/rapid_runty/routes/route.rb
262
266
  - lib/rapid_runty/routing.rb
267
+ - lib/rapid_runty/util.rb
263
268
  - lib/rapid_runty/version.rb
264
269
  - rapid_runty.gemspec
265
- homepage: https://github.com/andela-hkagumba/rapid_runty
270
+ homepage: https://github.com/Habu-Kagumb/rapid_runty
266
271
  licenses:
267
272
  - MIT
268
273
  metadata: {}