snake-eyes 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 +22 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/lib/snake_eyes.rb +28 -0
- data/lib/snake_eyes/interface_changes.rb +15 -0
- data/lib/snake_eyes/version.rb +3 -0
- data/snake-eyes.gemspec +25 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a3b8ac620054f0262c47c6617f056a8122c2760
|
4
|
+
data.tar.gz: 75fc932a5aef91a619c192e56639f78c00be64dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7880881c2dd938db53560760f39194ad5860ed23ce34de463d2faaae174f162ab2e18ab87eaed77a681c4b3c93927698be4142a2119443518a1303da3aa4a6d5
|
7
|
+
data.tar.gz: b8275f03642adb3da8d393897728174998f78aac1ae971dbf1aa99e3e057077c2e511b5be78305a439be6397dcfff1779147d7a5370da0975e196f09c4540db1
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Aleck Greenham
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# SnakeEyes
|
2
|
+
|
3
|
+
Automatically convert between camel case APIs to snake case for your Rails code
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'snake-eyes'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
To use SnakeEyes, simply add the following to the top of any controller in which you wish to have snake case parameters. All controllers that inherit from it shall also have the behaviour
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
class Json_Controller < ApplicationController
|
21
|
+
snake_eyes_params
|
22
|
+
|
23
|
+
def show
|
24
|
+
#reference the params hash as normal
|
25
|
+
end
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
By default SnakeEyes logs the snake case parameters to the Rails console. You can prevent this behaviour by configuring the gem:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
SnakeEyes.configuration do |config|
|
35
|
+
config.log_snake_eyes_parameters = false
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it ( https://github.com/greena13/snake-eyes/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/snake_eyes.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "snake_eyes/version"
|
2
|
+
require "snake_eyes/interface_changes"
|
3
|
+
|
4
|
+
module SnakeEyes
|
5
|
+
class << self
|
6
|
+
attr_accessor :log_snake_eyes_parameters
|
7
|
+
|
8
|
+
def configuration
|
9
|
+
if block_given?
|
10
|
+
yield(SnakeEyes)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
alias :config :configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
@log_snake_eyes_parameters = true
|
18
|
+
end
|
19
|
+
|
20
|
+
module ActionController
|
21
|
+
class Base
|
22
|
+
class << self
|
23
|
+
def snake_eyes_params
|
24
|
+
include SnakeEyes::InterfaceChanges
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SnakeEyes
|
2
|
+
module InterfaceChanges
|
3
|
+
def params
|
4
|
+
unless defined? @snake_eyes_params
|
5
|
+
@snake_eyes_params = ActionController::Parameters.new(super.deep_transform_keys(&:underscore))
|
6
|
+
|
7
|
+
if SnakeEyes.log_snake_eyes_parameters
|
8
|
+
logger.info " SnakeEyes Parameters: #{@snake_eyes_params.except(:controller, :action).as_json}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
@snake_eyes_params
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/snake-eyes.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 'snake_eyes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "snake-eyes"
|
8
|
+
spec.version = SnakeEyes::VERSION
|
9
|
+
spec.authors = ["Aleck Greenham"]
|
10
|
+
spec.email = ["greenhama13@gmail.com"]
|
11
|
+
spec.summary = "Automatically convert params in your controllers from camel case to snake case"
|
12
|
+
spec.description = "Automatically convert params in your controllers from camel case to snake case in all or a select few controllers"
|
13
|
+
spec.homepage = "https://github.com/greena13/snake-eyes"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.required_ruby_version = ">= 1.9"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency 'rake', '~> 0'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: snake-eyes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aleck Greenham
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-04 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Automatically convert params in your controllers from camel case to snake
|
42
|
+
case in all or a select few controllers
|
43
|
+
email:
|
44
|
+
- greenhama13@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/snake_eyes.rb
|
55
|
+
- lib/snake_eyes/interface_changes.rb
|
56
|
+
- lib/snake_eyes/version.rb
|
57
|
+
- snake-eyes.gemspec
|
58
|
+
homepage: https://github.com/greena13/snake-eyes
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '1.9'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Automatically convert params in your controllers from camel case to snake
|
82
|
+
case
|
83
|
+
test_files: []
|