Skip to content

Commit f4d6356

Browse files
committed
initial commit
1 parent a51004a commit f4d6356

26 files changed

+946
-0
lines changed

.codeclimate.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This is a sample .codeclimate.yml configured for Engine analysis on Code
2+
# Climate Platform. For an overview of the Code Climate Platform, see here:
3+
# http://docs.codeclimate.com/article/300-the-codeclimate-platform
4+
5+
# Under the engines key, you can configure which engines will analyze your repo.
6+
# Each key is an engine name. For each value, you need to specify enabled: true
7+
# to enable the engine as well as any other engines-specific configuration.
8+
9+
# For more details, see here:
10+
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
11+
12+
# For a list of all available engines, see here:
13+
# http://docs.codeclimate.com/article/296-engines-available-engines
14+
15+
engines:
16+
# to turn on an engine, add it here and set enabled to `true`
17+
# to turn off an engine, set enabled to `false` or remove it
18+
rubocop:
19+
enabled: true
20+
# golint:
21+
# enabled: true
22+
# gofmt:
23+
# enabled: true
24+
# eslint:
25+
# enabled: true
26+
# csslint:
27+
# enabled: true
28+
29+
# Engines can analyze files and report issues on them, but you can separately
30+
# decide which files will receive ratings based on those issues. This is
31+
# specified by path patterns under the ratings key.
32+
33+
# For more details see here:
34+
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
35+
36+
# Note: If the ratings key is not specified, this will result in a 0.0 GPA on your dashboard.
37+
38+
ratings:
39+
paths:
40+
- lib/**
41+
# - app/**
42+
# - "**.rb"
43+
# - "**.go"
44+
45+
# You can globally exclude files from being analyzed by any engine using the
46+
# exclude_paths key.
47+
48+
exclude_paths:
49+
- spec/**/*
50+
- vendor/**/*

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--color --format doc

.rubocop.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
AllCops:
2+
Exclude:
3+
- config/initializers/forbidden_yaml.rb
4+
- !ruby/regexp /(vendor|bundle|bin|db|tmp)\/.*/
5+
DisplayCopNames: true
6+
DisplayStyleGuide: true
7+
8+
Lint/NestedMethodDefinition:
9+
Enabled: false
10+
Exclude:
11+
- test/action_controller/serialization_test.rb
12+
13+
Style/StringLiterals:
14+
EnforcedStyle: single_quotes
15+
16+
Metrics/AbcSize:
17+
Max: 35 # TODO: Lower to 15
18+
19+
Metrics/ClassLength:
20+
Max: 261 # TODO: Lower to 100
21+
Exclude:
22+
- test/**/*.rb
23+
24+
Metrics/CyclomaticComplexity:
25+
Max: 7 # TODO: Lower to 6
26+
27+
Metrics/LineLength:
28+
Max: 110 # TODO: Lower to 80
29+
30+
Metrics/MethodLength:
31+
Max: 25
32+
33+
Metrics/PerceivedComplexity:
34+
Max: 9 # TODO: Lower to 7
35+
36+
Style/AlignParameters:
37+
EnforcedStyle: with_fixed_indentation
38+
39+
Style/ClassAndModuleChildren:
40+
EnforcedStyle: nested
41+
42+
Style/Documentation:
43+
Enabled: false
44+
45+
Style/MissingElse:
46+
Enabled: false # TODO: maybe enable this?
47+
EnforcedStyle: case
48+
49+
Style/EmptyElse:
50+
EnforcedStyle: empty
51+
52+
Style/MultilineOperationIndentation:
53+
EnforcedStyle: indented
54+
55+
Style/BlockDelimiters:
56+
Enabled: true
57+
EnforcedStyle: line_count_based
58+
59+
Style/PredicateName:
60+
Enabled: false # TODO: enable with correct prefixes
61+
62+
Style/ClassVars:
63+
Enabled: false

.travis.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: ruby
2+
bundler_args: --without guard
3+
rvm:
4+
- "2.0"
5+
- "2.1"
6+
- "2.2"
7+
- ruby-head
8+
script: "bundle exec rspec"
9+
addons:
10+
code_climate:
11+
repo_token: ''
12+
branches:
13+
only: master
14+
notifications:
15+
email: false
16+
17+
matrix:
18+
fast_finish: true
19+
allow_failures:
20+
- rvm: ruby-head

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in authorizable.gemspec
4+
gemspec

Gemfile.lock

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
PATH
2+
remote: .
3+
specs:
4+
skinny_controllers (0.1)
5+
activesupport
6+
7+
GEM
8+
remote: https://rubygems.org/
9+
specs:
10+
actionmailer (4.2.5)
11+
actionpack (= 4.2.5)
12+
actionview (= 4.2.5)
13+
activejob (= 4.2.5)
14+
mail (~> 2.5, >= 2.5.4)
15+
rails-dom-testing (~> 1.0, >= 1.0.5)
16+
actionpack (4.2.5)
17+
actionview (= 4.2.5)
18+
activesupport (= 4.2.5)
19+
rack (~> 1.6)
20+
rack-test (~> 0.6.2)
21+
rails-dom-testing (~> 1.0, >= 1.0.5)
22+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
23+
actionview (4.2.5)
24+
activesupport (= 4.2.5)
25+
builder (~> 3.1)
26+
erubis (~> 2.7.0)
27+
rails-dom-testing (~> 1.0, >= 1.0.5)
28+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
29+
activejob (4.2.5)
30+
activesupport (= 4.2.5)
31+
globalid (>= 0.3.0)
32+
activemodel (4.2.5)
33+
activesupport (= 4.2.5)
34+
builder (~> 3.1)
35+
activerecord (4.2.5)
36+
activemodel (= 4.2.5)
37+
activesupport (= 4.2.5)
38+
arel (~> 6.0)
39+
activesupport (4.2.5)
40+
i18n (~> 0.7)
41+
json (~> 1.7, >= 1.7.7)
42+
minitest (~> 5.1)
43+
thread_safe (~> 0.3, >= 0.3.4)
44+
tzinfo (~> 1.1)
45+
arel (6.0.3)
46+
ast (2.1.0)
47+
astrolabe (1.3.1)
48+
parser (~> 2.2)
49+
awesome_print (1.6.1)
50+
builder (3.2.2)
51+
byebug (8.2.0)
52+
codeclimate-test-reporter (0.4.8)
53+
simplecov (>= 0.7.1, < 1.0.0)
54+
coderay (1.1.0)
55+
diff-lcs (1.2.5)
56+
docile (1.1.5)
57+
erubis (2.7.0)
58+
globalid (0.3.6)
59+
activesupport (>= 4.1.0)
60+
i18n (0.7.0)
61+
json (1.8.3)
62+
loofah (2.0.3)
63+
nokogiri (>= 1.5.9)
64+
mail (2.6.3)
65+
mime-types (>= 1.16, < 3)
66+
method_source (0.8.2)
67+
mime-types (2.6.2)
68+
mini_portile (0.6.2)
69+
minitest (5.8.2)
70+
nokogiri (1.6.6.2)
71+
mini_portile (~> 0.6.0)
72+
parser (2.2.3.0)
73+
ast (>= 1.1, < 3.0)
74+
powerpack (0.1.1)
75+
pry (0.10.3)
76+
coderay (~> 1.1.0)
77+
method_source (~> 0.8.1)
78+
slop (~> 3.4)
79+
pry-byebug (3.3.0)
80+
byebug (~> 8.0)
81+
pry (~> 0.10)
82+
rack (1.6.4)
83+
rack-test (0.6.3)
84+
rack (>= 1.0)
85+
rails (4.2.5)
86+
actionmailer (= 4.2.5)
87+
actionpack (= 4.2.5)
88+
actionview (= 4.2.5)
89+
activejob (= 4.2.5)
90+
activemodel (= 4.2.5)
91+
activerecord (= 4.2.5)
92+
activesupport (= 4.2.5)
93+
bundler (>= 1.3.0, < 2.0)
94+
railties (= 4.2.5)
95+
sprockets-rails
96+
rails-deprecated_sanitizer (1.0.3)
97+
activesupport (>= 4.2.0.alpha)
98+
rails-dom-testing (1.0.7)
99+
activesupport (>= 4.2.0.beta, < 5.0)
100+
nokogiri (~> 1.6.0)
101+
rails-deprecated_sanitizer (>= 1.0.1)
102+
rails-html-sanitizer (1.0.2)
103+
loofah (~> 2.0)
104+
railties (4.2.5)
105+
actionpack (= 4.2.5)
106+
activesupport (= 4.2.5)
107+
rake (>= 0.8.7)
108+
thor (>= 0.18.1, < 2.0)
109+
rainbow (2.0.0)
110+
rake (10.4.2)
111+
rspec (3.4.0)
112+
rspec-core (~> 3.4.0)
113+
rspec-expectations (~> 3.4.0)
114+
rspec-mocks (~> 3.4.0)
115+
rspec-core (3.4.0)
116+
rspec-support (~> 3.4.0)
117+
rspec-expectations (3.4.0)
118+
diff-lcs (>= 1.2.0, < 2.0)
119+
rspec-support (~> 3.4.0)
120+
rspec-mocks (3.4.0)
121+
diff-lcs (>= 1.2.0, < 2.0)
122+
rspec-support (~> 3.4.0)
123+
rspec-support (3.4.0)
124+
rubocop (0.35.1)
125+
astrolabe (~> 1.3)
126+
parser (>= 2.2.3.0, < 3.0)
127+
powerpack (~> 0.1)
128+
rainbow (>= 1.99.1, < 3.0)
129+
ruby-progressbar (~> 1.7)
130+
tins (<= 1.6.0)
131+
ruby-progressbar (1.7.5)
132+
simplecov (0.10.0)
133+
docile (~> 1.1.0)
134+
json (~> 1.8)
135+
simplecov-html (~> 0.10.0)
136+
simplecov-html (0.10.0)
137+
slop (3.6.0)
138+
sprockets (3.4.0)
139+
rack (> 1, < 3)
140+
sprockets-rails (2.3.3)
141+
actionpack (>= 3.0)
142+
activesupport (>= 3.0)
143+
sprockets (>= 2.8, < 4.0)
144+
thor (0.19.1)
145+
thread_safe (0.3.5)
146+
tins (1.6.0)
147+
tzinfo (1.2.2)
148+
thread_safe (~> 0.1)
149+
150+
PLATFORMS
151+
ruby
152+
153+
DEPENDENCIES
154+
awesome_print
155+
codeclimate-test-reporter
156+
pry-byebug
157+
rails
158+
rspec
159+
rubocop
160+
skinny_controllers!
161+
162+
BUNDLED WITH
163+
1.10.6

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# skinny-controllers
2+
[![Gem Version](http://img.shields.io/gem/v/skinny_controllers.svg?style=flat-square)](http://badge.fury.io/rb/skinny_controllers)
3+
[![Build Status](http://img.shields.io/travis/NullVoxPopuli/skinny_controllers.svg?style=flat-square)](https://travis-ci.org/NullVoxPopuli/skinny_controllers)
4+
[![Code Climate](http://img.shields.io/codeclimate/github/NullVoxPopuli/skinny_controllers.svg?style=flat-square)](https://codeclimate.com/github/NullVoxPopuli/skinny_controllers)
5+
[![Test Coverage](http://img.shields.io/codeclimate/coverage/github/NullVoxPopuli/skinny_controllers.svg?style=flat-square)](https://codeclimate.com/github/NullVoxPopuli/skinny_controllers)
6+
[![Dependency Status](http://img.shields.io/gemnasium/NullVoxPopuli/skinny_controllers.svg?style=flat-square)](https://gemnasium.com/NullVoxPopuli/skinny_controllers)
7+
28
An implementation of role-based policies and operations to help controllers lose weight.
9+
10+
The goal of this project is to help API apps be more slim, and separate logic as much as possible.
11+
12+
# Installation
13+
14+
```ruby
15+
gem 'skinny_controllers'
16+
```
17+
or
18+
19+
`gem install skinny_controllers`
20+
21+
# Usage
22+
23+
TODO: this section

Rakefile

Whitespace-only changes.

lib/skinny_controllers.rb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# required gems
2+
require 'active_support'
3+
require 'active_support/core_ext/class'
4+
require 'active_support/core_ext/object/blank'
5+
require 'active_support/core_ext/object/try'
6+
require 'active_support/core_ext/string/inflections'
7+
8+
# files for this gem
9+
require 'skinny_controllers/default_verbs'
10+
require 'skinny_controllers/policy/base'
11+
require 'skinny_controllers/operation/base'
12+
require 'skinny_controllers/operation/default'
13+
require 'skinny_controllers/diet'
14+
require 'skinny_controllers/version'
15+
16+
module SkinnyControllers
17+
18+
# Tells the Diet what namespace of the controller
19+
# isn't going to be part of the model name
20+
#
21+
# @example
22+
# # config/initializers/skinny_controllers.rb
23+
# SkinnyControllers.controller_namespace = 'API'
24+
# # 'API::' would be removed from 'API::Namespace::ObjectNamesController'
25+
cattr_accessor :controller_namespace
26+
27+
#
28+
cattr_accessor :operation_namespace do
29+
'Operation'.freeze
30+
end
31+
32+
cattr_accessor :allow_by_default do
33+
true
34+
end
35+
36+
# the diet uses ActionController::Base's
37+
# `action_name` method to get the current action.
38+
# From that action, we map what verb we want to use for our operation
39+
#
40+
# If an action is not be listed, the action name will be
41+
# manipulated to fit the verb naming convention.
42+
#
43+
# @example POST controller#send_receipt will use 'SendReceipt' for the verb
44+
cattr_accessor :action_map do
45+
{
46+
'default'.freeze => DefaultVerbs::Read,
47+
'create'.freeze => DefaultVerbs::Create,
48+
'index'.freeze => DefaultVerbs::ReadAll,
49+
'destroy'.freeze => DefaultVerbs::Delete,
50+
'update'.freeze => DefaultVerbs::Update
51+
}
52+
end
53+
54+
end

0 commit comments

Comments
 (0)