panda_frwk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ffb651a9be9b190e8935a4fe2d98d5715c416953
4
+ data.tar.gz: 60cd7c9a260bf2cfc441d5cec6fa3164ec562fbc
5
+ SHA512:
6
+ metadata.gz: 572d826ca01413892843c95e7f79f46287eaeab3b46ca1bc535e5ab47f67f36608bad7c4b7593ee80c5f1bad941694d8282e1257189ddf0d161f6170684bb000
7
+ data.tar.gz: 7392abf9be646ea8d19713926633985d2436ec70a6706c521142477623620acfcb83bf8efc220867d0186e8619da8ba3bfa4fef9e7e5f76d81c2e3ee89b92325
@@ -0,0 +1,12 @@
1
+ ruby:
2
+ version:
3
+ 2.3.0
4
+
5
+ dependencies:
6
+ pre:
7
+ - gem uninstall bundler # use a custom version of bundler
8
+
9
+ test:
10
+ override:
11
+ - bundle install: # note ':' here
12
+ timeout: 180 # fail if command has no output for 3 minutes
@@ -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
+ /coverage/
@@ -0,0 +1,3 @@
1
+ [submodule "spec/support/panda_todo"]
2
+ path = spec/support/panda_todo
3
+ url = https://github.com/andela-akabiru/panda_todo
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,238 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "Gemfile"
4
+ - "Rakefile"
5
+ - "panda.gemspec"
6
+ - "spec/panda_spec.rb"
7
+ - "spec/spec_helper.rb"
8
+ UseCache: false
9
+ Style/CollectionMethods:
10
+ Description: Preferred collection methods.
11
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
12
+ Enabled: true
13
+ PreferredMethods:
14
+ collect: map
15
+ collect!: map!
16
+ find: detect
17
+ find_all: select
18
+ reduce: inject
19
+ Style/DotPosition:
20
+ Description: Checks the position of the dot in multi-line method calls.
21
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
22
+ Enabled: true
23
+ EnforcedStyle: trailing
24
+ SupportedStyles:
25
+ - leading
26
+ - trailing
27
+ Style/FileName:
28
+ Description: Use snake_case for source file names.
29
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
30
+ Enabled: false
31
+ Exclude: []
32
+ Style/GuardClause:
33
+ Description: Check for conditionals that can be replaced with guard clauses
34
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
35
+ Enabled: false
36
+ MinBodyLength: 1
37
+ Style/IfUnlessModifier:
38
+ Description: Favor modifier if/unless usage when you have a single-line body.
39
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
40
+ Enabled: false
41
+ MaxLineLength: 80
42
+ Style/OptionHash:
43
+ Description: Don't use option hashes when you can use keyword arguments.
44
+ Enabled: false
45
+ Style/PercentLiteralDelimiters:
46
+ Description: Use `%`-literal delimiters consistently
47
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
48
+ Enabled: false
49
+ PreferredDelimiters:
50
+ "%": "()"
51
+ "%i": "()"
52
+ "%q": "()"
53
+ "%Q": "()"
54
+ "%r": "{}"
55
+ "%s": "()"
56
+ "%w": "()"
57
+ "%W": "()"
58
+ "%x": "()"
59
+ Style/PredicateName:
60
+ Description: Check the names of predicate methods.
61
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
62
+ Enabled: true
63
+ NamePrefix:
64
+ - is_
65
+ - has_
66
+ - have_
67
+ NamePrefixBlacklist:
68
+ - is_
69
+ Exclude:
70
+ - spec/**/*
71
+ Style/RaiseArgs:
72
+ Description: Checks the arguments passed to raise/fail.
73
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
74
+ Enabled: false
75
+ EnforcedStyle: exploded
76
+ SupportedStyles:
77
+ - compact
78
+ - exploded
79
+ Style/SignalException:
80
+ Description: Checks for proper usage of fail and raise.
81
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
82
+ Enabled: false
83
+ EnforcedStyle: semantic
84
+ SupportedStyles:
85
+ - only_raise
86
+ - only_fail
87
+ - semantic
88
+ Style/SingleLineBlockParams:
89
+ Description: Enforces the names of some block params.
90
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
91
+ Enabled: false
92
+ Methods:
93
+ - reduce:
94
+ - a
95
+ - e
96
+ - inject:
97
+ - a
98
+ - e
99
+ Style/SingleLineMethods:
100
+ Description: Avoid single-line methods.
101
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
102
+ Enabled: false
103
+ AllowIfMethodIsEmpty: true
104
+ Style/StringLiterals:
105
+ Description: Checks if uses of quotes match the configured preference.
106
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
107
+ Enabled: true
108
+ EnforcedStyle: double_quotes
109
+ SupportedStyles:
110
+ - single_quotes
111
+ - double_quotes
112
+ Style/StringLiteralsInInterpolation:
113
+ Description: Checks if uses of quotes inside expressions in interpolated strings
114
+ match the configured preference.
115
+ Enabled: true
116
+ EnforcedStyle: single_quotes
117
+ SupportedStyles:
118
+ - single_quotes
119
+ - double_quotes
120
+ Style/TrailingCommaInLiteral:
121
+ Description: Checks for trailing comma in parameter lists and literals.
122
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
123
+ Enabled: false
124
+ EnforcedStyleForMultiline: no_comma
125
+ SupportedStyles:
126
+ - comma
127
+ - no_comma
128
+ Metrics/AbcSize:
129
+ Description: A calculated magnitude based on number of assignments, branches, and
130
+ conditions.
131
+ Enabled: false
132
+ Max: 15
133
+ Metrics/ClassLength:
134
+ Description: Avoid classes longer than 100 lines of code.
135
+ Enabled: false
136
+ CountComments: false
137
+ Max: 100
138
+ Metrics/ModuleLength:
139
+ CountComments: false
140
+ Max: 100
141
+ Description: Avoid modules longer than 100 lines of code.
142
+ Enabled: false
143
+ Metrics/CyclomaticComplexity:
144
+ Description: A complexity metric that is strongly correlated to the number of test
145
+ cases needed to validate a method.
146
+ Enabled: false
147
+ Max: 6
148
+ Metrics/MethodLength:
149
+ Description: Avoid methods longer than 10 lines of code.
150
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
151
+ Enabled: false
152
+ CountComments: false
153
+ Max: 10
154
+ Metrics/ParameterLists:
155
+ Description: Avoid parameter lists longer than three or four parameters.
156
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
157
+ Enabled: false
158
+ Max: 5
159
+ CountKeywordArgs: true
160
+ Metrics/PerceivedComplexity:
161
+ Description: A complexity metric geared towards measuring complexity for a human
162
+ reader.
163
+ Enabled: false
164
+ Max: 7
165
+ Lint/AssignmentInCondition:
166
+ Description: Don't use assignment in conditions.
167
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
168
+ Enabled: false
169
+ AllowSafeAssignment: true
170
+ Style/InlineComment:
171
+ Description: Avoid inline comments.
172
+ Enabled: false
173
+ Style/AccessorMethodName:
174
+ Description: Check the naming of accessor methods for get_/set_.
175
+ Enabled: false
176
+ Style/Alias:
177
+ Description: Use alias_method instead of alias.
178
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
179
+ Enabled: false
180
+ Style/Documentation:
181
+ Description: Document classes and non-namespace modules.
182
+ Enabled: false
183
+ Style/DoubleNegation:
184
+ Description: Checks for uses of double negation (!!).
185
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
186
+ Enabled: false
187
+ Style/EachWithObject:
188
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
189
+ Enabled: false
190
+ Style/EmptyLiteral:
191
+ Description: Prefer literals to Array.new/Hash.new/String.new.
192
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
193
+ Enabled: false
194
+ Style/ModuleFunction:
195
+ Description: Checks for usage of `extend self` in modules.
196
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
197
+ Enabled: false
198
+ Style/OneLineConditional:
199
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
200
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
201
+ Enabled: false
202
+ Style/PerlBackrefs:
203
+ Description: Avoid Perl-style regex back references.
204
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
205
+ Enabled: false
206
+ Style/Send:
207
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
208
+ may overlap with existing methods.
209
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
210
+ Enabled: false
211
+ Style/SpecialGlobalVars:
212
+ Description: Avoid Perl-style global variables.
213
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
214
+ Enabled: false
215
+ Style/VariableInterpolation:
216
+ Description: Don't interpolate global, instance and class variables directly in
217
+ strings.
218
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
219
+ Enabled: false
220
+ Style/WhenThen:
221
+ Description: Use when x then ... for one-line cases.
222
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
223
+ Enabled: false
224
+ Style/FrozenStringLiteralComment:
225
+ Enabled: false
226
+ Lint/EachWithObjectArgument:
227
+ Description: Check for immutable argument given to each_with_object.
228
+ Enabled: true
229
+ Lint/HandleExceptions:
230
+ Description: Don't suppress exception.
231
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
232
+ Enabled: false
233
+ Lint/LiteralInCondition:
234
+ Description: Checks of literals used in conditions.
235
+ Enabled: false
236
+ Lint/LiteralInInterpolation:
237
+ Description: Checks for literals used in interpolation.
238
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.3.0
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
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 austin.kabiru@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
+ # Specify your gem's dependencies in panda.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Austin Kabiru
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.
@@ -0,0 +1,245 @@
1
+ ![](https://www.dropbox.com/s/yfhnvtjd7iei1e4/panda.png?raw=1)
2
+
3
+ [![Code Climate](https://codeclimate.com/github/andela-akabiru/panda/badges/gpa.svg)](https://codeclimate.com/github/andela-akabiru/panda) [![Coverage Status](https://coveralls.io/repos/github/andela-akabiru/panda/badge.svg?branch=master)](https://coveralls.io/github/andela-akabiru/panda?branch=master) [![Issue Count](https://codeclimate.com/github/andela-akabiru/panda/badges/issue_count.svg)](https://codeclimate.com/github/andela-akabiru/panda) [![Build Status](https://travis-ci.org/akabiru/panda.svg?branch=master)](https://travis-ci.org/akabiru/panda)
4
+
5
+ # Panda
6
+
7
+ Panda is an mvc framework built with Ruby for building web applications.
8
+
9
+ ## Getting started
10
+
11
+ Clone Panda
12
+
13
+ $ git clone https://github.com/andela-akabiru/panda
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'panda', path: 'path_to_panda'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ ## Usage
26
+
27
+ Panda uses the mvc pattern. Thus your application structure should be as follows:
28
+
29
+ .
30
+ ├── app
31
+ │   ├── controllers
32
+ │   │   └── todo_controller.rb
33
+ │   ├── models
34
+ │   │   └── todo.rb
35
+ │   └── views
36
+ │   ├── layouts
37
+ │   │   └── application.html.erb
38
+ │   └── todo
39
+ │   ├── edit.html.erb
40
+ │   ├── index.html.erb
41
+ │   ├── new.html.erb
42
+ │   └── show.html.erb
43
+ ├── config
44
+ │   ├── application.rb
45
+ │   └── routes.rb
46
+ ├── config.ru
47
+ ├── db
48
+ │   └── app.db
49
+ ├── Gemfile
50
+ ├── Gemfile.lock
51
+ └── README.md
52
+
53
+
54
+
55
+ ### Routes
56
+
57
+ Your routes should be defined in `config/routes.rb` file. Here's an example.
58
+
59
+ ```ruby
60
+ TodoApplication.routes.draw do
61
+ root "todo#index"
62
+ get "/todo", to: "todo#index"
63
+ get "/todo/new", to: "todo#new"
64
+ get "/todo/:id", to: "todo#show"
65
+ get "/todo/:id/edit", to: "todo#edit"
66
+ post "/todo", to: "todo#create"
67
+ put "/todo/:id", to: "todo#update"
68
+ delete "/todo/:id", to: "todo#destroy"
69
+ end
70
+ ```
71
+
72
+ ### Models
73
+
74
+ Models are defined in `app/models` folder. Here's an example model
75
+
76
+ ```ruby
77
+ class Todo < Panda::Record::Base
78
+ to_table :todos
79
+ property :id, type: :integer, primary_key: true
80
+ property :title, type: :text, nullable: false
81
+ property :body, type: :text, nullable: false
82
+ property :status, type: :text, nullable: false
83
+ property :created_at, type: :text, nullable: false
84
+ create_table
85
+ end
86
+ ```
87
+
88
+ ### Controllers
89
+
90
+ Controllers are defined in `app/controllers`. Here's an example controller.
91
+
92
+ ```ruby
93
+ class TodoController < Panda::BaseController
94
+ def index
95
+ @todos = Todo.all
96
+ end
97
+
98
+ def show
99
+ @todo = Todo.find(params["id"])
100
+ end
101
+
102
+ def new
103
+ end
104
+
105
+ def edit
106
+ @todo = Todo.find(params["id"])
107
+ end
108
+
109
+ def update
110
+ todo = Todo.find(params["id"])
111
+ todo.update(
112
+ title: params["title"],
113
+ body: params["body"],
114
+ status: params["status"]
115
+ )
116
+ redirect_to "/todo/#{todo.id}"
117
+ end
118
+
119
+ def create
120
+ Todo.create(
121
+ title: params["title"],
122
+ body: params["body"],
123
+ status: params["status"],
124
+ created_at: Time.now.to_s
125
+ )
126
+ redirect_to "/todo"
127
+ end
128
+
129
+ def destroy
130
+ todo = Todo.find(params["id"])
131
+ todo.destroy
132
+ redirect_to "/todo"
133
+ end
134
+ end
135
+ ```
136
+
137
+ ### Views
138
+
139
+ Views are mapped to the controller actions. E.g if You have a `TodoController`, views for that controller should be defined in `app/views/todos/action_name.erb`. Panda depends on [Tilt](https://github.com/rtomayko/tilt) gem and thus supports embedded ruby in the views. Instance variables defined in the controller actions can be accessed in the corresponding view.
140
+
141
+ Here's an example usage:
142
+
143
+ Controller `app/controllers/todo_controller.rb`
144
+
145
+ ```ruby
146
+ [...]
147
+ def index
148
+ @todos = Todo.all
149
+ end
150
+ [...]
151
+ ```
152
+
153
+ View `app/views/index.html.erb`
154
+
155
+ ```html
156
+ <h1>My Todos</h1>
157
+
158
+ <% @todos.each do |todo| %>
159
+ <p><strong><%= todo.title %></strong> <em><%= todo.status %></em>
160
+ <a href="/todo/<%= todo.id %>" id="todo_<%= todo.id %>">Show</a> | <a href="/todo/<%= todo.id %>/edit">Edit</a>
161
+ </p>
162
+ <% end %>
163
+
164
+ <p><a href="/todo/new">New Todo</a></p>
165
+ ```
166
+
167
+
168
+ Note that there's an layout file `app/views/layouts/application.html.erb`. Here you can define your general view layout. Other views will be rendered inside the file.
169
+
170
+ Here's a sample layout file:
171
+
172
+ ```html
173
+ <!DOCTYPE html>
174
+ <html>
175
+ <head>
176
+ <title><%= title %></title>
177
+ </head>
178
+ <body>
179
+ <%= yield %>
180
+ </body>
181
+ </html>
182
+ ```
183
+
184
+ ### Configuration
185
+
186
+ I bet you've noticed that there's a `config.ru` file. This file that gets called when we run our panda application. However, there're some few things to take note of:
187
+
188
+ Set the `APP_ROOT` to the current directory since panda uses that constant to find templates.
189
+
190
+ ```ruby
191
+ APP_ROOT = __dir__
192
+ ```
193
+
194
+ Require `config/appliaction`
195
+
196
+ ```ruby
197
+ require_relative './config/application.rb'
198
+ ```
199
+
200
+ Add method override middleware. This masks put and delete request as post requests.
201
+
202
+ ```ruby
203
+ use Rack::MethodOverride
204
+ ```
205
+
206
+ After this what's left is initialising the panda application, locading the routes and running it.
207
+
208
+ To run the application run
209
+
210
+ $ bundle exec rackup
211
+
212
+ at the root of your application.
213
+
214
+
215
+ ### Tests
216
+
217
+ Panda is well tested with a sample application for integration tests and unit specs for the base model. To run the specs run
218
+
219
+ $ bundle exec rake
220
+
221
+ Or
222
+
223
+ $ bundle exec rspec -fd
224
+
225
+ ## Application Limitations
226
+
227
+ * Panda does not have a generator for file structures.
228
+ * Panda does not support model relationships at the moment
229
+
230
+ ## Dependencies
231
+ 1. [Ruby](https://github.com/rbenv/rbenv)
232
+ 2. [SQlite3](https://github.com/sparklemotion/sqlite3-ruby)
233
+ 3. [Bundler](https://github.com/bundler/bundler)
234
+ 4. [Rack](https://github.com/rack/rack)
235
+ 5. [Rack Test](https://github.com/brynary/rack-test)
236
+ 6. [Rspec](https://github.com/rspec/rspec)
237
+
238
+ ## Contributing
239
+
240
+ Bug reports and pull requests are welcome on GitHub at https://github.com/andela-akabiru/panda. 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.
241
+
242
+
243
+ ## License
244
+
245
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).