api_monkey 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTE.md +88 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +6 -0
- data/api_monkey.gemspec +25 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/api_monkey/filter_scopes.rb +11 -0
- data/lib/api_monkey/filterable.rb +14 -0
- data/lib/api_monkey/version.rb +3 -0
- data/lib/api_monkey.rb +9 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 14630a35b125ccf8d2107cb54a0d4be4f16d8031
|
4
|
+
data.tar.gz: e7fd94d3f82f6c99b4eba34f769422f1cba993e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db3fdc5d3e2a09e81a6fcafd0bfdbfa70e9fa884a728b3709c0a3ef96320c63e26f6e29edace93dd46b9a432eddfcf790d44adbb6d48c2e27f5256b1ce5271be
|
7
|
+
data.tar.gz: 018ded42e99d237e7ff8cc40b239c7849f3dd28eae26cf88d84ab43caf051b161de50e58bdeaa1c32d7cc477554fd647938167462b2105214b315afd228541ab
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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/CONTRIBUTE.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# CONTRIBUTE
|
2
|
+
|
3
|
+
This is the contribute.md of our project. Great to have you here. Here
|
4
|
+
are a few ways you can help make this project better!
|
5
|
+
|
6
|
+
## Adding new features
|
7
|
+
|
8
|
+
This section includes advice on how to build new features for the
|
9
|
+
project & what kind of process it includes.
|
10
|
+
|
11
|
+
* This is how we like people to add new features:
|
12
|
+
* Here are some specifics on the coding style we prefer:
|
13
|
+
* This is how you send your pull request:
|
14
|
+
* You should include the following tests:
|
15
|
+
|
16
|
+
# Bug triage
|
17
|
+
|
18
|
+
This sections explains how bug triaging is done for your project. Help
|
19
|
+
beginners by including examples to good bug reports and providing them
|
20
|
+
questions they should look to answer.
|
21
|
+
|
22
|
+
* You can help report bugs by filing them here:
|
23
|
+
* You can look through the existing bugs here:
|
24
|
+
|
25
|
+
* You can help us diagnose and fix existing bugs by asking and providing
|
26
|
+
answers for the following:
|
27
|
+
|
28
|
+
* Is the bug reproducible as explained?
|
29
|
+
* Is it reproducible in other environments (for instance, on different
|
30
|
+
browsers or devices)?
|
31
|
+
* Are the steps to reproduce the bug clear? If not, can you describe
|
32
|
+
how you might reproduce it?
|
33
|
+
* What tags should the bug have?
|
34
|
+
* Is this bug something you have run into? Would you appreciate it
|
35
|
+
being looked into faster?
|
36
|
+
|
37
|
+
* You can close fixed bugs by testing old tickets to see if they are
|
38
|
+
still happening.
|
39
|
+
* You can update our changelog here:
|
40
|
+
* You can remove duplicate bug reports by:
|
41
|
+
|
42
|
+
|
43
|
+
# Beta testing
|
44
|
+
|
45
|
+
This section explains if your project needs beta testing. Explain why
|
46
|
+
early releases require heavy testing and how they can help with
|
47
|
+
specially across browsers and on different hardware.
|
48
|
+
|
49
|
+
* For our project you can find the roadmap and features that require
|
50
|
+
testing from here:
|
51
|
+
|
52
|
+
# Translations
|
53
|
+
|
54
|
+
This section includes any instructions or translation needs your project
|
55
|
+
has.
|
56
|
+
|
57
|
+
* You can help us translate our project here:
|
58
|
+
|
59
|
+
# Documentation
|
60
|
+
|
61
|
+
This section includes any help you need with the documentation and where
|
62
|
+
it can be found. Code needs explanation, and sometimes those who know
|
63
|
+
the code well have trouble explaining it to someone just getting into
|
64
|
+
it.
|
65
|
+
|
66
|
+
* Help us with documentation here
|
67
|
+
|
68
|
+
# Community
|
69
|
+
This section includes ideas on how non-developers can help with the
|
70
|
+
project. Here's a few examples:
|
71
|
+
|
72
|
+
* You can help us answer questions our users have here:
|
73
|
+
* You can help build and design our website here:
|
74
|
+
* You can help write blog posts about the project by:
|
75
|
+
* You can help with newsletters and internal communications by:
|
76
|
+
|
77
|
+
* Create an example of the project in real world by building something
|
78
|
+
or
|
79
|
+
showing what others have built.
|
80
|
+
* Write about other people’s projects based on this project. Show how
|
81
|
+
it’s used in daily life. Take screenshots and make videos!
|
82
|
+
|
83
|
+
|
84
|
+
# Your first bugfix
|
85
|
+
This section should help a person get started with their very first bug
|
86
|
+
fix and thinking through the problem.
|
87
|
+
|
88
|
+
* If you have further questions, contact:
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Michael Kelly
|
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,62 @@
|
|
1
|
+
# ApiMonkey
|
2
|
+
Makes building data-driven APIs in Rails a breeze by providing an easy to use DSL for declaring API resources.
|
3
|
+
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'api_monkey'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
Once you have ApiMonkey installed, declare your model as an ApiMonkey model:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
# app/models/product.rb
|
22
|
+
|
23
|
+
class Product < ActiveRecord::Base
|
24
|
+
include ApiMonkey
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
### Filter Params
|
29
|
+
Filter params provide a clean and easy way to add request-based
|
30
|
+
filtering of your active record models:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# app/controllers/products_controller.rb
|
34
|
+
|
35
|
+
class ProductsController < ApplicationController
|
36
|
+
def index
|
37
|
+
@products = Product.filter(filter_params)
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def filter_params
|
43
|
+
params.slice(:active, :price, :code)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
51
|
+
|
52
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/michaelkelly322/api_resource. Guidelines and suggestion can be found in our [CONTRIBUTE.md file](https://github.com/michaelkelly322/api_monkey/blob/master/CONTRIBUTE.md). 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.
|
57
|
+
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
62
|
+
|
data/Rakefile
ADDED
data/api_monkey.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'api_monkey/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "api_monkey"
|
8
|
+
spec.version = ApiMonkey::VERSION
|
9
|
+
spec.authors = ["Michael Kelly"]
|
10
|
+
spec.email = ["michaelkelly322@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Makes building data-driven APIs in Rails a breeze"
|
13
|
+
spec.description = "Makes building data-driven APIs in Rails a breeze by providing an easy to use DSL for declaring API resources"
|
14
|
+
spec.homepage = "https://github.com/michaelkelly322/api_monkey"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "api_resource"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module ApiMonkey::Filterable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
define_singleton_method :filter do |filtering_params|
|
6
|
+
results = self.where(nil)
|
7
|
+
filtering_params.each do |key, value|
|
8
|
+
results = results.public_send("filter_#{key}", value) if value.present?
|
9
|
+
end
|
10
|
+
results
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
data/lib/api_monkey.rb
ADDED
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: api_monkey
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Kelly
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Makes building data-driven APIs in Rails a breeze by providing an easy
|
56
|
+
to use DSL for declaring API resources
|
57
|
+
email:
|
58
|
+
- michaelkelly322@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- CONTRIBUTE.md
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- api_monkey.gemspec
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
|
+
- lib/api_monkey.rb
|
76
|
+
- lib/api_monkey/filter_scopes.rb
|
77
|
+
- lib/api_monkey/filterable.rb
|
78
|
+
- lib/api_monkey/version.rb
|
79
|
+
homepage: https://github.com/michaelkelly322/api_monkey
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.4.6
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Makes building data-driven APIs in Rails a breeze
|
103
|
+
test_files: []
|