snorlax 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b53bab2423a46c274206d57459abb78a811d3dd5
4
- data.tar.gz: 9dbc6d8173b431936797bbdbe9979148fe02d125
3
+ metadata.gz: d6d01c9be95a6a09f2b95508b9a7bd95a7df93a2
4
+ data.tar.gz: 4ca7cea8aa4a0113e8ef3384591c6e0af7ff6a73
5
5
  SHA512:
6
- metadata.gz: eb4a29d12a68529cf4335bd74026f10ed818db84f644447741770fb52016eac3c68dff54339d0533b5a4b2c94e888dbc40d605368ed46696bc370487c8257d4d
7
- data.tar.gz: 569aebf4ea57664c9fa7e958eaeb0663e9ddf211d77eaa363648d975d080eab097af7e034aa99c022a5aef132d755afe6b24cf2fedbee9aa8c1a815b76ea2589
6
+ metadata.gz: cecf771da9bcd04f93d194be38584813941bfd7bbd38f2b96e3dd7877c9ff4a705de4896762c1c87e1c00605f42245fd8ee4efb45a5d458b9a496c11614dd52f
7
+ data.tar.gz: 175f940f1daacce9d660aeaa2fc03314b717bde28d7036dfc695a0d1e6ea0f81b91906e57d16e92d5292eda78373d5294c0bbc1650c0a66f87a3c1cca6766d28
data/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # Snorlax
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/restful_controller`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ ![](http://img3.wikia.nocookie.net/__cb20140924022259/pokemon/images/9/9f/143Snorlax_OS_anime.png)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Snorlax is an opinionated, flexible, and well-RESTed gem for building Rails APIs. It's designed to Do The Right Thing™ by default, but allow you to customize where necessary.
6
+
7
+ It's been extracted from [Loomio](www.github.com/loomio/loomio).
6
8
 
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
10
12
 
11
13
  ```ruby
12
- gem 'restful_controller'
14
+ gem 'snorlax'
13
15
  ```
14
16
 
15
17
  And then execute:
@@ -18,22 +20,47 @@ And then execute:
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install restful_controller
23
+ $ gem install snorlax
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ There are two primary ways to use Snorlax. The easier way is to inherit from it:
26
28
 
27
- ## Development
29
+ ```
30
+ class MyController < Snorlax::Base
31
+ end
32
+ ```
28
33
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+ But, if you're already inheriting from something else, Snorlax makes it easy to simply apply itself to your controller without being a parent, by calling `snorlax_used_rest!` like so:
30
35
 
31
- 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).
36
+ ```
37
+ class MyController < SomeOtherController
38
+ snorlax_used_rest!
39
+ end
40
+ ```
32
41
 
33
- ## Contributing
42
+ Once you've got it installed, you're good to go!
43
+
44
+ TODO:
45
+ - Expand on show action
46
+ - - respond_with_resource
47
+ - explanation of side-loading
48
+ - Expand on index action
49
+ - - accessible and public records (required)
50
+ - - default page size
51
+ - From, to, per, since, until, timeframe_for parameters
52
+ - Toggling pagination / timeframing
53
+ - Customizing the serializer options
54
+ - Expand on create / update action
55
+ - create_action, update_action overriding
56
+ - respond_with_resource
57
+ - Expand on destroy action [destroy_action]
58
+ - destroy_action overriding
59
+ - Explain the respond_with_errors behaviour
34
60
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/restful_controller. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
61
+ ## Contributing
36
62
 
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gdpelican/snorlax. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
64
 
38
65
  ## License
39
66
 
@@ -157,7 +157,7 @@ module Snorlax
157
157
  end
158
158
 
159
159
  def respond_with_errors
160
- render json: {errors: resource.errors.as_json()}, root: false, status: 422
160
+ render json: {errors: resource.errors.as_json}, root: false, status: 422
161
161
  end
162
162
 
163
163
  def serializer_root
@@ -1,3 +1,3 @@
1
1
  module Snorlax
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/snorlax.rb CHANGED
@@ -8,6 +8,6 @@ class ActionController::Base
8
8
  # Method to allow controllers to apply Snorlax to themselves
9
9
  # (g@nked from Inherited resources: https://github.com/josevalim/inherited_resources/blob/master/lib/inherited_resources.rb)
10
10
  def self.snorlax_used_rest!
11
- RestfulController::Base.snorlax_used_rest!(self)
11
+ Snorlax::Base.snorlax_used_rest!(self)
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snorlax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Kiesel (gdpelican)