rapid_runty 0.1.0 → 0.1.1

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: c50c57f021a6f19eb8749efdc40578a27dc298eb
4
- data.tar.gz: 36b934dd80ad325dc23e49850417bcff214c15ba
3
+ metadata.gz: 80540cdbd978fc8cfceeb6f123a03039219b87a2
4
+ data.tar.gz: 6e71cafc92d36bf244237b8c2fdbbc48f75820e6
5
5
  SHA512:
6
- metadata.gz: 0b335af20b67e10b172e4ba86a47104453c067ec0219416bdd98f43af67910eda3f44ed39e12af3d15d87890c469476930be82b4940eb395f08ce2b0239d5f97
7
- data.tar.gz: 6e85e1b35adba311aab34ff45d0196853bb65805e81b94b124091da5f36c276e0fabc40120bebbcd7ff8f7e19302ec77de622e601d34a9d48abef461692ed18a
6
+ metadata.gz: fb430ffbd7c1275e14664159401c419bfbf7f8d13a2b7f308d6e9bdbe1a822a0f697b86b954478da049480877d4fc7109bd3646f7b71e55b8179f1d21582608b
7
+ data.tar.gz: f614b09cf5e9e29574ed912ef2688352981f4c2e787c9f2467223954baf18f7f4b713ddb21f99fd99df83d2fa2fd35198118a3bdbefce74071e313d5e819812b
data/.hound.yml ADDED
@@ -0,0 +1,8 @@
1
+ javascript:
2
+ enabled: false
3
+ eslint:
4
+ enabled: false
5
+ scss:
6
+ enabled: false
7
+ ruby:
8
+ config_file: .rubocop.yml
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Rapid Runty
7
7
 
8
- [![Dependency Status](https://gemnasium.com/badges/bitbucket.org/habu_kagumba/rapid_runty.svg)](https://gemnasium.com/bitbucket.org/habu_kagumba/rapid_runty) [ ![Codeship Status for habu_kagumba/rapid_runty](https://codeship.com/projects/f506dfd0-3e2e-0134-298e-365d6082cf0e/status?branch=master) ](https://codeship.com/projects/167314) [![Coverage Status](https://coveralls.io/repos/bitbucket/habu_kagumba/rapid_runty/badge.svg?branch=master)](https://coveralls.io/bitbucket/habu_kagumba/rapid_runty?branch=master) [![codebeat badge](https://codebeat.co/badges/1c48e76c-c7c7-484a-a5d5-7c397b4fb429)](https://codebeat.co/projects/bitbucket-org-habu_kagumba-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/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)
9
9
 
10
10
  **Rapid Runty** is a minimal web framework to get your web project up and running in seconds.
11
11
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "coveralls/rake/task"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
6
+ Coveralls::RakeTask.new
5
7
 
6
8
  task default: :spec
@@ -1,15 +1,29 @@
1
+ require "rapid_runty/routing"
2
+ require "rapid_runty/controller"
3
+
1
4
  module RapidRunty
2
5
  # Main framework Application class. Entry point for all requests.
6
+ #
7
+ # Example:
8
+ #
9
+ # class Application < RapidRunty::Application
10
+ # end
3
11
  class Application
4
12
  ##
5
13
  # Returns a rack compatible response.
6
14
  #
15
+ # Retrieves the controller and action from request URL making a new
16
+ # controller and send it to the action.
17
+ #
18
+ # @param env [Hash] Rack environment Hash that includes CGI-like headers
19
+ #
7
20
  # @return [status, {headers}, [response]] array
8
21
  def call(env)
9
- @req = Rack::Request.new(env)
10
- path = @req.path_info
11
- return [500, {}, []] if path == "/favicon.ico"
12
- [200, { "Content-Type" => "text/html" }, ["Hello"]]
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]]
13
27
  end
14
28
  end
15
29
  end
@@ -0,0 +1,12 @@
1
+ module RapidRunty
2
+ # Application controller
3
+ #
4
+ # TODO: Just saves the env for now
5
+ class Controller
6
+ def initialize(env)
7
+ @env = env
8
+ end
9
+
10
+ attr_reader :env
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module RapidRunty
2
+ 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"
12
+
13
+ # Lookup controller constant name and return [controller, action]
14
+ [Object.const_get(controller), action]
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module RapidRunty
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  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.0
4
+ version: 0.1.1
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-06 00:00:00.000000000 Z
11
+ date: 2016-08-07 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
+ - ".hound.yml"
246
247
  - ".rspec"
247
248
  - ".rubocop.yml"
248
249
  - ".simplecov"
@@ -257,6 +258,8 @@ files:
257
258
  - gemify.sh
258
259
  - lib/rapid_runty.rb
259
260
  - lib/rapid_runty/application.rb
261
+ - lib/rapid_runty/controller.rb
262
+ - lib/rapid_runty/routing.rb
260
263
  - lib/rapid_runty/version.rb
261
264
  - rapid_runty.gemspec
262
265
  homepage: https://github.com/andela-hkagumba/rapid_runty