pup 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 216a768ae07ccc09169ed291813cdd36af0a2d97
4
+ data.tar.gz: 5c56d82f63271e5c9aeb04e1baae497610564894
5
+ SHA512:
6
+ metadata.gz: 05995ed8f1fa52ef8836065bc1a5574f668e1baf22a96c21180c29b5cabbe713cb18bcb8cdb069a09ec47fe674121a35f0b1f2e0a25429ec46aba83119467535
7
+ data.tar.gz: aa4390a7d063b57173e63236c5194d4b45250cbe6438a7cfcc4ca0ccccd0c43bbfc75fa2dbb8c78deb1cdc71782aa5145d6eb9dd3c6acefb5d7633a567d776c9
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: dsZmx9QZxorOwQIHuNpirKNgDD4gH61gU
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
3
+ javascript:
4
+ config_file: .javascript-style.json
5
+ ignore_file: .javascript-ignore
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,242 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ Exclude:
4
+ - "vendor/**/*"
5
+ - "db/schema.rb"
6
+ UseCache: false
7
+ Style/CollectionMethods:
8
+ Description: Preferred collection methods.
9
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
10
+ Enabled: true
11
+ PreferredMethods:
12
+ collect: map
13
+ collect!: map!
14
+ find: detect
15
+ find_all: select
16
+ reduce: inject
17
+ Style/DotPosition:
18
+ Description: Checks the position of the dot in multi-line method calls.
19
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
20
+ Enabled: true
21
+ EnforcedStyle: trailing
22
+ SupportedStyles:
23
+ - leading
24
+ - trailing
25
+ Style/FileName:
26
+ Description: Use snake_case for source file names.
27
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
28
+ Enabled: false
29
+ Exclude: []
30
+ Style/GuardClause:
31
+ Description: Check for conditionals that can be replaced with guard clauses
32
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
33
+ Enabled: false
34
+ MinBodyLength: 1
35
+ Style/IfUnlessModifier:
36
+ Description: Favor modifier if/unless usage when you have a single-line body.
37
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
38
+ Enabled: false
39
+ MaxLineLength: 80
40
+ Style/OptionHash:
41
+ Description: Don't use option hashes when you can use keyword arguments.
42
+ Enabled: false
43
+ Style/PercentLiteralDelimiters:
44
+ Description: Use `%`-literal delimiters consistently
45
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
46
+ Enabled: false
47
+ PreferredDelimiters:
48
+ "%": "()"
49
+ "%i": "()"
50
+ "%q": "()"
51
+ "%Q": "()"
52
+ "%r": "{}"
53
+ "%s": "()"
54
+ "%w": "()"
55
+ "%W": "()"
56
+ "%x": "()"
57
+ Style/PredicateName:
58
+ Description: Check the names of predicate methods.
59
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
60
+ Enabled: true
61
+ NamePrefix:
62
+ - is_
63
+ - has_
64
+ - have_
65
+ NamePrefixBlacklist:
66
+ - is_
67
+ Exclude:
68
+ - spec/**/*
69
+ Style/RaiseArgs:
70
+ Description: Checks the arguments passed to raise/fail.
71
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
72
+ Enabled: false
73
+ EnforcedStyle: exploded
74
+ SupportedStyles:
75
+ - compact
76
+ - exploded
77
+ Style/SignalException:
78
+ Description: Checks for proper usage of fail and raise.
79
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
80
+ Enabled: false
81
+ EnforcedStyle: semantic
82
+ SupportedStyles:
83
+ - only_raise
84
+ - only_fail
85
+ - semantic
86
+ Style/SingleLineBlockParams:
87
+ Description: Enforces the names of some block params.
88
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
89
+ Enabled: false
90
+ Methods:
91
+ - reduce:
92
+ - a
93
+ - e
94
+ - inject:
95
+ - a
96
+ - e
97
+ Style/SingleLineMethods:
98
+ Description: Avoid single-line methods.
99
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
100
+ Enabled: false
101
+ AllowIfMethodIsEmpty: true
102
+ Style/StringLiterals:
103
+ Description: Checks if uses of quotes match the configured preference.
104
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
105
+ Enabled: true
106
+ EnforcedStyle: double_quotes
107
+ SupportedStyles:
108
+ - single_quotes
109
+ - double_quotes
110
+ Style/StringLiteralsInInterpolation:
111
+ Description: Checks if uses of quotes inside expressions in interpolated strings
112
+ match the configured preference.
113
+ Enabled: true
114
+ EnforcedStyle: single_quotes
115
+ SupportedStyles:
116
+ - single_quotes
117
+ - double_quotes
118
+ Style/TrailingCommaInLiteral:
119
+ Description: Checks for trailing comma in parameter lists and literals.
120
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
121
+ Enabled: false
122
+ EnforcedStyleForMultiline: no_comma
123
+ SupportedStyles:
124
+ - comma
125
+ - no_comma
126
+ Style/TrailingCommaInArguments:
127
+ Description: Checks for trailing comma in parameter lists and literals.
128
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
129
+ Enabled: false
130
+ EnforcedStyleForMultiline: no_comma
131
+ SupportedStyles:
132
+ - comma
133
+ - no_comma
134
+ Metrics/AbcSize:
135
+ Description: A calculated magnitude based on number of assignments, branches, and
136
+ conditions.
137
+ Enabled: false
138
+ Max: 15
139
+ Metrics/ClassLength:
140
+ Description: Avoid classes longer than 100 lines of code.
141
+ Enabled: false
142
+ CountComments: false
143
+ Max: 100
144
+ Metrics/ModuleLength:
145
+ CountComments: false
146
+ Max: 100
147
+ Description: Avoid modules longer than 100 lines of code.
148
+ Enabled: false
149
+ Metrics/CyclomaticComplexity:
150
+ Description: A complexity metric that is strongly correlated to the number of test
151
+ cases needed to validate a method.
152
+ Enabled: false
153
+ Max: 6
154
+ Metrics/MethodLength:
155
+ Description: Avoid methods longer than 10 lines of code.
156
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
157
+ Enabled: false
158
+ CountComments: false
159
+ Max: 10
160
+ Metrics/ParameterLists:
161
+ Description: Avoid parameter lists longer than three or four parameters.
162
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
163
+ Enabled: false
164
+ Max: 5
165
+ CountKeywordArgs: true
166
+ Metrics/PerceivedComplexity:
167
+ Description: A complexity metric geared towards measuring complexity for a human
168
+ reader.
169
+ Enabled: false
170
+ Max: 7
171
+ Lint/AssignmentInCondition:
172
+ Description: Don't use assignment in conditions.
173
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
174
+ Enabled: false
175
+ AllowSafeAssignment: true
176
+ Style/InlineComment:
177
+ Description: Avoid inline comments.
178
+ Enabled: false
179
+ Style/AccessorMethodName:
180
+ Description: Check the naming of accessor methods for get_/set_.
181
+ Enabled: false
182
+ Style/Alias:
183
+ Description: Use alias_method instead of alias.
184
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
185
+ Enabled: false
186
+ Style/Documentation:
187
+ Description: Document classes and non-namespace modules.
188
+ Enabled: false
189
+ Style/DoubleNegation:
190
+ Description: Checks for uses of double negation (!!).
191
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
192
+ Enabled: false
193
+ Style/EachWithObject:
194
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
195
+ Enabled: false
196
+ Style/EmptyLiteral:
197
+ Description: Prefer literals to Array.new/Hash.new/String.new.
198
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
199
+ Enabled: false
200
+ Style/ModuleFunction:
201
+ Description: Checks for usage of `extend self` in modules.
202
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
203
+ Enabled: false
204
+ Style/OneLineConditional:
205
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
206
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
207
+ Enabled: false
208
+ Style/PerlBackrefs:
209
+ Description: Avoid Perl-style regex back references.
210
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
211
+ Enabled: false
212
+ Style/Send:
213
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
214
+ may overlap with existing methods.
215
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
216
+ Enabled: false
217
+ Style/SpecialGlobalVars:
218
+ Description: Avoid Perl-style global variables.
219
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
220
+ Enabled: false
221
+ Style/VariableInterpolation:
222
+ Description: Don't interpolate global, instance and class variables directly in
223
+ strings.
224
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
225
+ Enabled: false
226
+ Style/WhenThen:
227
+ Description: Use when x then ... for one-line cases.
228
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
229
+ Enabled: false
230
+ Lint/EachWithObjectArgument:
231
+ Description: Check for immutable argument given to each_with_object.
232
+ Enabled: true
233
+ Lint/HandleExceptions:
234
+ Description: Don't suppress exception.
235
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
236
+ Enabled: false
237
+ Lint/LiteralInCondition:
238
+ Description: Checks of literals used in conditions.
239
+ Enabled: false
240
+ Lint/LiteralInInterpolation:
241
+ Description: Checks for literals used in interpolation.
242
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
5
+ CODECLIMATE_REPO_TOKEN: fcc1b5ada9fef6202a5c7296432925dde35949c7c0fab7cdbfaa8f34ad1014cc
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "2.2.3"
4
+ # Specify your gem's dependencies in pup.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Emmanuel Chigbo
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,174 @@
1
+ # Pup
2
+
3
+ [![Build Status](https://travis-ci.org/andela-echigbo/pup.svg?branch=master)](https://travis-ci.org/andela-echigbo/pup) [![Coverage Status](https://coveralls.io/repos/github/andela-echigbo/pup/badge.svg?branch=master)](https://coveralls.io/github/andela-echigbo/pup?branch=master) [![Test Coverage](https://codeclimate.com/github/andela-echigbo/pup/badges/coverage.svg)](https://codeclimate.com/github/andela-echigbo/pup/coverage) [![Code Climate](https://codeclimate.com/github/andela-echigbo/pup/badges/gpa.svg)](https://codeclimate.com/github/andela-echigbo/pup)
4
+
5
+
6
+ **Pup** is a micro framework target built on Ruby and Rack. The motive of building this framework was not to compete with Rails, but to create my own implemtnation of the MVC framework to help me and other programmers like me(that might want to read and/or contribute to this project) understand what actually happens behind the scene in rails and other awesome MVC frameworks.
7
+
8
+ Pup is recommended for begginers who might want to work with a simpler framework, understand the besics of MVC framework and to build a non-complex application.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'pup'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install pup
25
+
26
+ ## Usage
27
+
28
+ Creating a **Pup** application is very simple, however, a few things need to be setup and a few rules adhered to. Pup follows the same folder structure as a typical rails app with all of the `model`, `view` and `controller` code packed inside of an `app` folder, configuration based code and `routing` system placed inside a `config` folder and the main database file in a db folder. [Here](https://github.com/andela-echigbo/pup-notebook) is a link to a `Note Keeping` application app built using Pup with the correct folder setup, it can be forked, cloned and edited to suit other purposes.
29
+
30
+ ### Setup
31
+
32
+ In order to run a Pup app, it is expected that a `config.ru` file exists in the root directory of your project and all the needed files have been required here.
33
+
34
+ Example `config.ru` file:
35
+
36
+ * Note that the `APP_ROOT` constant is required and must point to the current file directory as the gem uses this internally to find and link folders.
37
+
38
+ ```ruby
39
+ APP_ROOT ||= __dir__
40
+
41
+ require File.expand_path("../config/application", __FILE__)
42
+
43
+ PupApplication ||= NoteBook::Application.new
44
+ require_relative "config/routes.rb"
45
+
46
+ app ||= Rack::Builder.new do
47
+ use Rack::Reloader
48
+ use Rack::Static, urls: ["/stylesheets", "/images", "/javascripts"],
49
+ root: "app/assets"
50
+
51
+ run PupApplication
52
+ end
53
+
54
+ run app
55
+
56
+ ```
57
+
58
+ ### Routes
59
+
60
+ The route file should be required in the config.ru file after the application has been initialized and before the rack 'run' command is called.
61
+
62
+ Example route file:
63
+
64
+ ```ruby
65
+ PupApplication.routes.create do
66
+ resources "notes"
67
+ root "pages#index"
68
+ get "/about", to: "pages#about"
69
+ post "/contact", to: "pages#contact"
70
+ end
71
+
72
+ ```
73
+
74
+ ### Models
75
+
76
+ Pup implements a lightweight orm that makes it easy to query the database using ruby objects. It supports only sqlite3. Models are placed inside the `app/models` folder.
77
+
78
+ Example model file:
79
+
80
+ ```ruby
81
+ class Note < Pup::Model
82
+ to_table :notes
83
+ property :title, type: :varchar, nullable: false
84
+ property :category, type: :varchar, default: "unclassified"
85
+ property :content, type: :text
86
+ property :created_at, type: :datetime
87
+ property :updated_at, type: :datetime
88
+
89
+ create_table
90
+ end
91
+
92
+ ```
93
+
94
+ ### Controllers
95
+
96
+ Controllers are placed inside the `app/controllers` folder.
97
+
98
+ Example controller file:
99
+
100
+ ```ruby
101
+ class NotesController < ApplicationController
102
+ def index
103
+ @notes = Note.all
104
+ end
105
+
106
+ def new
107
+ @note = Note.new
108
+ end
109
+ end
110
+
111
+ ```
112
+
113
+ Note that the `ApplicationController` itself should be define in the controllers directory and it inherits from `Pup::BaseController`.
114
+
115
+ ### Views
116
+
117
+ View templates are mapped to controller actions and must assume the same nomenclature as their respective actions. Erbuis is used as the templating engine and the views that are rendered are required to have the `.erb` file extension. Views are placed inside the `app/views` folder.
118
+
119
+ Example view file:
120
+
121
+ ```erb
122
+ <!DOCTYPE html>
123
+ <html lang="en">
124
+ <head>
125
+ <meta charset="UTF-8">
126
+ <meta name="viewport" content="width=device-width, initial-scale=1">
127
+ <title>My Notes App</title>
128
+ </head>
129
+ <body>
130
+ html content of the site here
131
+ <%= @title %> to interpolate a variable from the controller
132
+ </body>
133
+ </html>
134
+ ```
135
+ ## Running the tests
136
+
137
+ Test files are placed inside the spec folder including the unit tests and the integration tests. You can run the tests from your command line client by typing `rspec spec`
138
+
139
+ ## Limitation
140
+
141
+ **Pup** is still in an evolving stage, but is targeted at being one of the most used micro framework for developing simple web application for the web. However, there is still a long way to go and we are calling on you to bring it closer to it's target. The following are yet to be implemented in Pup.
142
+
143
+ * Migration - Managing your database status separately
144
+ * Executables - Scripts that can perform operations in application _(start server, run migrations, etc)_
145
+ * Supports for other templating engine
146
+ * Support for other database managment systems
147
+ * ...and more
148
+
149
+
150
+ ## Development
151
+
152
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
153
+
154
+ ## License
155
+
156
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
157
+
158
+
159
+
160
+ ## Contributing
161
+
162
+ Bug reports and pull requests are welcome on GitHub at https://github.com/andela-echigbo/pup. This project is intended to be a safe and welcoming space for collaboration. To contribute to this work:
163
+
164
+ 1. Fork it ( https://github.com/[andela-echigbo]/pup/fork )
165
+
166
+ 2. Create your feature branch (`git checkout -b my-new-awesome-feature`)
167
+
168
+ 3. Commit your changes (`git commit -am 'Add some awesome feature'`)
169
+
170
+ 4. Push to the branch (`git push origin my-new-awesome-feature`)
171
+
172
+ 5. Create a new Pull Request
173
+
174
+ 6. Wait