algernon 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2fbc850ffd9b51fb9ff4b62e9d76e994f10138ba
4
+ data.tar.gz: 8deabc2abc86f49371db3af3114bc0b25539d1e9
5
+ SHA512:
6
+ metadata.gz: c087fdddef2a72607b181d05b69575aa62deca236693f72cb23d9323a56b09f6cba949c99338db45bf8a447fb34c33514b845fbae9265b05eb659f76c28a1e52
7
+ data.tar.gz: be56d536db6ef22d62fa96f515349b183bcd3a18a25e5bec0c1ef1a06312a8a32b4fc3640f01f40519ebda47bc7e49d58de54d1181889ed1ac1a090a3e57b9fd
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: j2rQsY7YJdXfxQtYAZkKYb7Zl3yIc4SSP
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ algernon-0.1.0.gem
11
+ notes
12
+ /database/data.sqlite
data/.hound.yml ADDED
@@ -0,0 +1,4 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
3
+
4
+ fail_on_violations: true
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --backtrace
data/.rubocop.yml ADDED
@@ -0,0 +1,233 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ UseCache: false
4
+ Style/BracesAroundHashParameters:
5
+ EnforcedStyle: context_dependent
6
+ Style/CollectionMethods:
7
+ Description: Preferred collection methods.
8
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
9
+ Enabled: true
10
+ PreferredMethods:
11
+ collect: map
12
+ collect!: map!
13
+ find: detect
14
+ find_all: select
15
+ reduce: inject
16
+ Style/DotPosition:
17
+ Description: Checks the position of the dot in multi-line method calls.
18
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
19
+ Enabled: true
20
+ EnforcedStyle: trailing
21
+ SupportedStyles:
22
+ - leading
23
+ - trailing
24
+ Style/FileName:
25
+ Description: Use snake_case for source file names.
26
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
27
+ Enabled: false
28
+ Exclude: []
29
+ Style/GuardClause:
30
+ Description: Check for conditionals that can be replaced with guard clauses
31
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
32
+ Enabled: false
33
+ MinBodyLength: 1
34
+ Style/IfUnlessModifier:
35
+ Description: Favor modifier if/unless usage when you have a single-line body.
36
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
37
+ Enabled: false
38
+ MaxLineLength: 80
39
+ Style/OptionHash:
40
+ Description: Don't use option hashes when you can use keyword arguments.
41
+ Enabled: false
42
+ Style/PercentLiteralDelimiters:
43
+ Description: Use `%`-literal delimiters consistently
44
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
45
+ Enabled: false
46
+ PreferredDelimiters:
47
+ "%": "()"
48
+ "%i": "()"
49
+ "%q": "()"
50
+ "%Q": "()"
51
+ "%r": "{}"
52
+ "%s": "()"
53
+ "%w": "()"
54
+ "%W": "()"
55
+ "%x": "()"
56
+ Style/PredicateName:
57
+ Description: Check the names of predicate methods.
58
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
59
+ Enabled: true
60
+ NamePrefix:
61
+ - is_
62
+ - has_
63
+ - have_
64
+ NamePrefixBlacklist:
65
+ - is_
66
+ Exclude:
67
+ - spec/**/*
68
+ Style/RaiseArgs:
69
+ Description: Checks the arguments passed to raise/fail.
70
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
71
+ Enabled: false
72
+ EnforcedStyle: exploded
73
+ SupportedStyles:
74
+ - compact
75
+ - exploded
76
+ Style/SignalException:
77
+ Description: Checks for proper usage of fail and raise.
78
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
79
+ Enabled: false
80
+ EnforcedStyle: semantic
81
+ SupportedStyles:
82
+ - only_raise
83
+ - only_fail
84
+ - semantic
85
+ Style/SingleLineBlockParams:
86
+ Description: Enforces the names of some block params.
87
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
88
+ Enabled: false
89
+ Methods:
90
+ - reduce:
91
+ - a
92
+ - e
93
+ - inject:
94
+ - a
95
+ - e
96
+ Style/SingleLineMethods:
97
+ Description: Avoid single-line methods.
98
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
99
+ Enabled: false
100
+ AllowIfMethodIsEmpty: true
101
+ Style/StringLiterals:
102
+ Description: Checks if uses of quotes match the configured preference.
103
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
104
+ Enabled: true
105
+ EnforcedStyle: double_quotes
106
+ SupportedStyles:
107
+ - single_quotes
108
+ - double_quotes
109
+ Style/StringLiteralsInInterpolation:
110
+ Description: Checks if uses of quotes inside expressions in interpolated strings
111
+ match the configured preference.
112
+ Enabled: true
113
+ EnforcedStyle: single_quotes
114
+ SupportedStyles:
115
+ - single_quotes
116
+ - double_quotes
117
+ Style/TrailingCommaInLiteral:
118
+ Description: Checks for trailing comma in parameter lists and literals.
119
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
120
+ Enabled: false
121
+ EnforcedStyleForMultiline: no_comma
122
+ SupportedStyles:
123
+ - comma
124
+ - no_comma
125
+ Metrics/AbcSize:
126
+ Description: A calculated magnitude based on number of assignments, branches, and
127
+ conditions.
128
+ Enabled: false
129
+ Max: 15
130
+ Metrics/ClassLength:
131
+ Description: Avoid classes longer than 100 lines of code.
132
+ Enabled: false
133
+ CountComments: false
134
+ Max: 100
135
+ Metrics/ModuleLength:
136
+ CountComments: false
137
+ Max: 100
138
+ Description: Avoid modules longer than 100 lines of code.
139
+ Enabled: false
140
+ Metrics/CyclomaticComplexity:
141
+ Description: A complexity metric that is strongly correlated to the number of test
142
+ cases needed to validate a method.
143
+ Enabled: false
144
+ Max: 6
145
+ Metrics/MethodLength:
146
+ Description: Avoid methods longer than 10 lines of code.
147
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
148
+ Enabled: false
149
+ CountComments: false
150
+ Max: 10
151
+ Metrics/ParameterLists:
152
+ Description: Avoid parameter lists longer than three or four parameters.
153
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
154
+ Enabled: false
155
+ Max: 5
156
+ CountKeywordArgs: true
157
+ Metrics/PerceivedComplexity:
158
+ Description: A complexity metric geared towards measuring complexity for a human
159
+ reader.
160
+ Enabled: false
161
+ Max: 7
162
+ Lint/AssignmentInCondition:
163
+ Description: Don't use assignment in conditions.
164
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
165
+ Enabled: false
166
+ AllowSafeAssignment: true
167
+ Style/InlineComment:
168
+ Description: Avoid inline comments.
169
+ Enabled: false
170
+ Style/AccessorMethodName:
171
+ Description: Check the naming of accessor methods for get_/set_.
172
+ Enabled: false
173
+ Style/Alias:
174
+ Description: Use alias_method instead of alias.
175
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
176
+ Enabled: false
177
+ Style/Documentation:
178
+ Description: Document classes and non-namespace modules.
179
+ Enabled: false
180
+ Style/DoubleNegation:
181
+ Description: Checks for uses of double negation (!!).
182
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
183
+ Enabled: false
184
+ Style/EachWithObject:
185
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
186
+ Enabled: false
187
+ Style/EmptyLiteral:
188
+ Description: Prefer literals to Array.new/Hash.new/String.new.
189
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
190
+ Enabled: false
191
+ Style/ModuleFunction:
192
+ Description: Checks for usage of `extend self` in modules.
193
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
194
+ Enabled: false
195
+ Style/OneLineConditional:
196
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
197
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
198
+ Enabled: false
199
+ Style/PerlBackrefs:
200
+ Description: Avoid Perl-style regex back references.
201
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
202
+ Enabled: false
203
+ Style/Send:
204
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
205
+ may overlap with existing methods.
206
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
207
+ Enabled: false
208
+ Style/SpecialGlobalVars:
209
+ Description: Avoid Perl-style global variables.
210
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
211
+ Enabled: false
212
+ Style/VariableInterpolation:
213
+ Description: Don't interpolate global, instance and class variables directly in
214
+ strings.
215
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
216
+ Enabled: false
217
+ Style/WhenThen:
218
+ Description: Use when x then ... for one-line cases.
219
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
220
+ Enabled: false
221
+ Lint/EachWithObjectArgument:
222
+ Description: Check for immutable argument given to each_with_object.
223
+ Enabled: true
224
+ Lint/HandleExceptions:
225
+ Description: Don't suppress exception.
226
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
227
+ Enabled: false
228
+ Lint/LiteralInCondition:
229
+ Description: Checks of literals used in conditions.
230
+ Enabled: false
231
+ Lint/LiteralInInterpolation:
232
+ Description: Checks for literals used in interpolation.
233
+ Enabled: false
data/.swp ADDED
Binary file
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at yusuf.daniju@andela.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "2.2.3"
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Yusuf Daniju
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,273 @@
1
+ #Algernon
2
+
3
+ [![Coverage Status](https://coveralls.io/repos/github/andela-ydaniju/algernon/badge.svg?branch=master)](https://coveralls.io/github/andela-ydaniju/algernon?branch=master) [![Build Status](https://travis-ci.org/andela-ydaniju/algernon.svg?branch=master)](https://travis-ci.org/andela-ydaniju/algernon) [![Code Climate](https://codeclimate.com/github/andela-ydaniju/algernon/badges/gpa.svg)](https://codeclimate.com/github/andela-ydaniju/algernon)
4
+
5
+ Algernon is a Ruby MVC web framework.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'algernon'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install algernon
22
+
23
+ ## Usage
24
+
25
+ Algernon is a tiny framewok built using the Rails way. It follows an MVC pattern. Models, Views and Controllers (MVC) are all systematically arranged in respective directories under the app directory.
26
+
27
+ ```
28
+ Algernon Application
29
+
30
+ └───app
31
+ | └───assets
32
+ | └───controllers
33
+ | └───models
34
+ | └───views
35
+ └───config
36
+ | └─── routes.rb
37
+ | └───application.rb
38
+ └───database
39
+ | └───data.sqlite3
40
+ └───config.ru
41
+ ```
42
+
43
+ At the moment, the only database supported is SQLite3.
44
+
45
+ ## Initial Setup
46
+ Algernon is built using Rack - a simple interface between webservers that support Ruby and Ruby frameworks. Thus, web apps built with the framework are initialized same way Rack apps are initlialized - through a `config.ru` file, which is parsed to determine appropriate configuration settings. A sample `config.ru` is:
47
+
48
+ ```ruby
49
+ APP_ROOT ||= __dir__
50
+
51
+ require File.expand_path("../config/application", __FILE__)
52
+
53
+ LapisTodoApp = LapisTodo::Application.new
54
+ require_relative "config/routes.rb"
55
+
56
+ app ||= Rack::Builder.new do
57
+ use Rack::Reloader
58
+ use Rack::Static, urls: ["/css", "/font-awesome", "/js", "/fonts", "/img"],
59
+ root: "app/assets"
60
+
61
+ run LapisTodoApp
62
+ end
63
+
64
+ run app
65
+ ```
66
+ Algernon
67
+
68
+ The first line of the sample config file requires the Algernon framework.
69
+
70
+ The second line sets a constant used by the framework in searching for important files. This is required in order to map locations of important components in the web application. Thus it should be set by apps built on top of Algernon.
71
+
72
+ A sample Application class which inherits from the Algernon::Application class is then declared and initialized. This sample class is used to start up the web server, and inherits methods from the BaseApplication class to provide a rack-compatible response to requests. The declaration for the Application class could be moved into a separate class and then required in the config file.
73
+
74
+ On instantiating the Application class, routes need to be set. In the ```routes.rb``` in the config direectory. A block with the route methods called appropriately is passed to the prepare method exposed by the application. This block is evaluated, and routes are saved for processing.
75
+
76
+ On the last line of the config file, the application is passed to the run method, which is evaluated by Rack to start up the web application on the default port - 9292.
77
+
78
+ ## Key Features
79
+
80
+ ### Routing
81
+ Routing with Algernon deals with directing requests to the appropriate controllers. A sample route file is:
82
+
83
+ ```ruby
84
+ LapisTodoApp.routes.draw do
85
+ resources "tasks"
86
+ root "tasks#index"
87
+ end
88
+ ```
89
+
90
+ Algernon supports GET, DELETE, PATCH, POST, PUT requests.
91
+
92
+ In the sample config file, the second line indicates that GET requests to the root path of the application should be handled by the `index action of the TasksController`.
93
+
94
+ Thus an appropriate view named index.html.erb in the fellows folder is expected in the views folder. Instance variables set in the index action of the controller are passed to the Erubis template engine which renders the view.
95
+
96
+ Resources creates a REST-compatible set of routes which handles CRUD requests dealing with fellows. The declaration is equivalent to writing these set of routes:
97
+
98
+ ```ruby
99
+ get "/tasks", to: "tasks#index"
100
+ get "/tasks/new", to: "tasks#new"
101
+ post "/tasks", to: "tasks#create"
102
+ get "/tasks/:id", to: "tasks#show"
103
+ get "/tasks/:id/edit", to: "tasks#edit"
104
+ patch "/tasks/:id", to: "tasks#update"
105
+ put "/tasks/:id", to: "tasks#update"
106
+ delete "/tasks/:id", to: "tasks#destroy"
107
+ ```
108
+
109
+
110
+ ### Models
111
+ All models to be used with the Algernon framework are to inherit from the BaseRecord class provided by Algernon, in order to access the rich ORM functionalities provided. Although not as succinct as ActiveRecord, the BaseRecord class acts as an interface between the model class and its database representation. A sample model file is provided below:
112
+
113
+ ```ruby
114
+ class Task < Algernon::Model
115
+ to_table :tasks
116
+
117
+ property :title, type: :varchar, nullable: false
118
+ property :description, type: :text
119
+ property :created_at, type: :datetime
120
+ property :updated_at, type: :datetime
121
+
122
+ create_table
123
+ end
124
+ ```
125
+ The `to_table` method provided stores the table name used while creating the table record in the database.
126
+
127
+ The `property` method is provided to declare table columns, and their attributes. The first argument to `property` is the column name, while subsequent hash arguments are used to provide information about attributes.
128
+
129
+ The `type` argument represents the data type of the column. Supported data types by Algernon are:
130
+
131
+ * integer (for numeric values)
132
+ * boolean (for boolean values [true or false])
133
+ * text (for alphanumeric values)
134
+
135
+ The `primary_key` argument is used to specify that the column should be used as the primary key of the table. If this is an integer, the value is auto-incremented by the database.
136
+
137
+ The `nullable` argument is used to specify whether a column should have null values, or not.
138
+
139
+ While creating models, the id property declaration is optional. If this is is not provided, the Algernon ORM adds it automatically, and sets it as the primary key. Thus, it should only be set if you'd like to use a different type as the primary key.
140
+
141
+ On passing in the table name, and its properties, a call should be made to the `create_table` method to persist the model to database by creating the table.
142
+
143
+
144
+ ### Controllers
145
+ Controllers are key to the MVC structure, as they handle receiving requests, interacting with the database, and providing responses. Controllers are placed in the controllers folder, which is nested in the app folder.
146
+
147
+ All controllers should inherit from the BaseController class provided by Algernon to inherit methods which simplify accessing request parameters and returning responses by rendering views.
148
+
149
+ A sample structure for a controller file is:
150
+
151
+ ```ruby
152
+ class TasksController < ApplicationController
153
+ def index
154
+ @tasks = Task.all
155
+ end
156
+
157
+ def new
158
+ @task = Task.new
159
+ end
160
+
161
+ def create
162
+ task = Task.create(task_params)
163
+ redirect_to "/tasks/#{task.id}"
164
+ end
165
+
166
+ def show
167
+ @task = Task.find(params[:id].to_i)
168
+ end
169
+
170
+ def edit
171
+ @task = Task.find(params[:id].to_i)
172
+ end
173
+
174
+ def update
175
+ @task = Task.find(params[:id].to_i)
176
+ @task.update(task_params)
177
+ redirect_to "/tasks/#{@task.id}"
178
+ end
179
+
180
+ def destroy
181
+ Task.destroy(params[:id].to_i)
182
+ redirect_to "/tasks"
183
+ end
184
+
185
+ def task_params
186
+ parameters = {
187
+ title: params[:title],
188
+ description: params[:description],
189
+ updated_at: Time.now.to_s
190
+ }
191
+ parameters[:created_at] = Time.now.to_s if params[:id].nil?
192
+ parameters
193
+ end
194
+ end
195
+ ```
196
+
197
+ Instance variables set by the controllers are passed to the routes while rendering responses.
198
+
199
+ Explicitly calling `render` to render template files is optional. If it's not called by the controller action, then it's done automatically by the framework with an argument that's the same name as the action. Thus, you can decide to call `render` explicitly when you want to render a view with a name different from the action.
200
+
201
+
202
+ ### Views
203
+ Currently, view templates are handled with the Erubis template engine. See https://rubygems.org/gems/erubis for more details.
204
+
205
+ Views are mapped to actions in controllers. Thus the folder structure for storing views depends on the location of the controller/action. A view to be rendered for the new action in the TasksController for example is saved as `new.html.erb` in the tasks folder, nested in the views folder. A sample structure for a view file is:
206
+
207
+ ```erb
208
+ <div class = "form-part container-fluid">
209
+ <div class = "form-part-in row">
210
+ <div class="col-xs-4">&nbsp;</div>
211
+ <div class="">
212
+ <h2 class="form-tag">Create Task</h2>
213
+ <form class="" action="/tasks" method="post">
214
+ <label for="title" class="sr-only">Title</label>
215
+ <input type="text" id="title" class="form-control" placeholder="Title" name="title">
216
+ <label for="description" class="sr-only">Description</label>
217
+ <input type="text" id="description" class="form-control" placeholder="Description" name="description">
218
+ </div>
219
+ <input class="btn btn-lg btn-primary btn-block" type="submit" value="Create Task"/>
220
+ </form>
221
+ </div>
222
+ <div class="col-xs-4">&nbsp;</div>
223
+ </div>
224
+ </div>
225
+ ```
226
+
227
+ ### External Dependencies
228
+ The Algernon framework has a few dependencies. These are listed below, with links to source pages for each.
229
+
230
+ * sqlite3 - https://github.com/sparklemotion/sqlite3-ruby
231
+ * erubis - https://rubygems.org/gems/erubis
232
+ * bundler - https://github.com/bundler/bundler
233
+ * rake - https://github.com/ruby/rake
234
+ * rack - https://github.com/rack/rack
235
+ * rack-test - https://github.com/brynary/rack-test
236
+
237
+ ## Testing
238
+
239
+ Before running tests, run the following command to install dependencies
240
+
241
+ $ bundle install
242
+
243
+ To test the web framework, run the following command to carry out all tests:
244
+
245
+ $ bundle exec rake
246
+
247
+ ## Contributing
248
+
249
+ 1. Fork it by visiting - https://github.com/andela-ydaniju/algernon/fork
250
+
251
+ 2. Create your feature branch
252
+
253
+ $ git checkout -b new_feature
254
+
255
+ 3. Contribute to code
256
+
257
+ 4. Commit changes made
258
+
259
+ $ git commit -a -m 'descriptive_message_about_change'
260
+
261
+ 5. Push to branch created
262
+
263
+ $ git push origin new_feature
264
+
265
+ 6. Then, create a new Pull Request
266
+
267
+ ## License
268
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
269
+
270
+
271
+
272
+
273
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/algernon.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "algernon/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "algernon"
8
+ spec.version = Algernon::VERSION
9
+ spec.authors = ["andela-ydaniju"]
10
+ spec.email = ["yusuf.daniju@andela.com"]
11
+
12
+ spec.summary = "Algernon is a mini MVC framework built on Ruby."
13
+ spec.description = "Algernon is a mini MVC framework built on Ruby."
14
+ spec.homepage = "https://github.com/andela-ydaniju/algernon."
15
+ spec.license = "MIT"
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against"\
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.11"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "rack-test", "~> 0.6"
35
+ spec.add_development_dependency "coveralls"
36
+ spec.add_development_dependency "capybara"
37
+ spec.add_runtime_dependency "poltergeist"
38
+ spec.add_runtime_dependency "pry"
39
+
40
+ spec.add_runtime_dependency "rack", "~> 1.6.4"
41
+ spec.add_runtime_dependency "erubis"
42
+ spec.add_runtime_dependency "sqlite3"
43
+ spec.add_runtime_dependency "activesupport"
44
+ end