lono 4.2.3 → 4.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/bin/release +9 -0
- data/lib/lono/version.rb +1 -1
- data/vendor/plissken/Gemfile +14 -0
- data/vendor/plissken/LICENSE.txt +20 -0
- data/vendor/plissken/README.md +46 -0
- data/vendor/plissken/Rakefile +56 -0
- data/vendor/plissken/VERSION +1 -0
- data/vendor/plissken/lib/plissken.rb +1 -0
- data/vendor/plissken/lib/plissken/ext/hash/to_snake_keys.rb +45 -0
- data/vendor/plissken/plissken.gemspec +61 -0
- data/vendor/plissken/spec/lib/to_snake_keys_spec.rb +177 -0
- data/vendor/plissken/spec/spec_helper.rb +90 -0
- data/vendor/plissken/test/helper.rb +20 -0
- data/vendor/plissken/test/plissken/ext/hash/to_snake_keys_test.rb +184 -0
- data/vendor/plissken/test/test_plissken.rb +2 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9be32d1fc2006611399093aabc620ecbcea36c2c56c43f24b0e05b4f8d69324
|
4
|
+
data.tar.gz: aec055f691f563a7137c3b15b305b8fece46d5ed341ebc8f45de1c3c5b79756a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37aeb51abc1fb9f947bc669cd9310fbed48562844ffcc08f74d937ad0ec279973d8515a55e1acf97e0dbe70aa3b20247f82907ea7bcbd7e0feaf3e6fa9ed606c
|
7
|
+
data.tar.gz: a0eae309dce651d902361a7a404f57222fe63f99b893b503ae60bd9cc054fa36a23dafc7ba1ea5ee597e46c0b420af85b44ae0aa4affa2032af953008ee4edbf
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [4.2.4]
|
7
|
+
- bin/release wrapper script
|
8
|
+
|
6
9
|
## [4.2.3]
|
7
10
|
- hide type dot_clean check message
|
8
11
|
|
data/bin/release
ADDED
data/lib/lono/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
# gem 'debugger'
|
10
|
+
gem 'rspec', '~> 3.1'
|
11
|
+
gem 'rdoc', '~> 4.2'
|
12
|
+
gem 'bundler', '~> 1.6'
|
13
|
+
gem 'jeweler', '~> 2.3'
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Dave Hrycyszyn
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
=======
|
2
|
+
plissken
|
3
|
+
========
|
4
|
+
|
5
|
+
Have you ever needed to automatically convert JSON-style `camelBack` or `CamelCase` hash keys into more Rubyish `snake_case`?
|
6
|
+
|
7
|
+
Plissken to the rescue.
|
8
|
+
|
9
|
+
This gem recursively converts all camelBack or CamelCase keys in a hash structure to snake_case.
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'plissken'
|
15
|
+
my_hash = {"firstKey" => 1, "fooBars" => [{"bazBaz" => "value"}, {"blahBlah" => "value"}]}
|
16
|
+
snaked_hash = my_hash.to_snake_keys
|
17
|
+
# => {"first_key" => 1, "foo_bars" => [{"baz_baz" => "value"}, {"blah_blah" => "value"}]}
|
18
|
+
```
|
19
|
+
|
20
|
+
Plissken works on either string keys or symbolized keys. It has no dependencies, as it has its own `underscore` method lifted out of ActiveSupport.
|
21
|
+
|
22
|
+
## Limitations
|
23
|
+
|
24
|
+
* Your keys must be camelBack or CamelCase. The key "Foo Bar" will output as "foo bar".
|
25
|
+
* Unlike the original Snake Plissken in the seminal film [Escape from New York](http://en.wikipedia.org/wiki/Escape_from_New_York), the plissken gem is non-destructive. There is no `Hash#to_snake_keys!` form.
|
26
|
+
|
27
|
+
# Going the other way
|
28
|
+
|
29
|
+
If you've already got `snake_case` and need to `CamelCase` it, you are encouraged to try
|
30
|
+
the [Awrence](http://github.com/futurechimp/awrence) gem.
|
31
|
+
|
32
|
+
## Contributing to plissken
|
33
|
+
|
34
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
35
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
36
|
+
* Fork the project.
|
37
|
+
* Start a feature/bugfix branch.
|
38
|
+
* Commit and push until you are happy with your contribution.
|
39
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
40
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
41
|
+
|
42
|
+
== Copyright
|
43
|
+
|
44
|
+
Copyright (c) 2013 Dave Hrycyszyn. See LICENSE.txt for
|
45
|
+
further details.
|
46
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new('spec')
|
7
|
+
|
8
|
+
begin
|
9
|
+
Bundler.setup(:default, :development)
|
10
|
+
rescue Bundler::BundlerError => e
|
11
|
+
$stderr.puts e.message
|
12
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
+
exit e.status_code
|
14
|
+
end
|
15
|
+
require 'rake'
|
16
|
+
|
17
|
+
require 'jeweler'
|
18
|
+
Jeweler::Tasks.new do |gem|
|
19
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
20
|
+
gem.name = "plissken"
|
21
|
+
gem.homepage = "http://github.com/futurechimp/plissken"
|
22
|
+
gem.license = "MIT"
|
23
|
+
gem.summary = %Q{Snakify your camel keys when working with JSON APIs}
|
24
|
+
gem.description = %Q{
|
25
|
+
Have you ever needed to automatically convert JSON-style camelBack or
|
26
|
+
CamelCase hash keys into more Rubyish snake_case?
|
27
|
+
|
28
|
+
Plissken to the rescue.
|
29
|
+
|
30
|
+
This gem recursively converts all camelBack or CamelCase keys in a hash
|
31
|
+
structure to snake_case.
|
32
|
+
}
|
33
|
+
gem.email = "dave.hrycyszyn@headlondon.com"
|
34
|
+
gem.authors = ["Dave Hrycyszyn", "Michael Chrisco"]
|
35
|
+
# dependencies defined in Gemfile
|
36
|
+
end
|
37
|
+
Jeweler::RubygemsDotOrgTasks.new
|
38
|
+
|
39
|
+
require 'rake/testtask'
|
40
|
+
Rake::TestTask.new(:test) do |test|
|
41
|
+
test.libs << 'lib' << 'test'
|
42
|
+
test.pattern = 'test/**/test_*.rb'
|
43
|
+
test.verbose = true
|
44
|
+
end
|
45
|
+
|
46
|
+
task :default => :spec
|
47
|
+
|
48
|
+
require 'rdoc/task'
|
49
|
+
Rake::RDocTask.new do |rdoc|
|
50
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
51
|
+
|
52
|
+
rdoc.rdoc_dir = 'rdoc'
|
53
|
+
rdoc.title = "plissken #{version}"
|
54
|
+
rdoc.rdoc_files.include('README*')
|
55
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/plissken/ext/hash/to_snake_keys'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Hash.to_snake_keys
|
2
|
+
class Hash
|
3
|
+
# Recursively converts CamelCase and camelBack JSON-style hash keys to
|
4
|
+
# Rubyish snake_case, suitable for use during instantiation of Ruby
|
5
|
+
# model attributes.
|
6
|
+
#
|
7
|
+
def to_snake_keys(value = self)
|
8
|
+
case value
|
9
|
+
when Array
|
10
|
+
value.map { |v| to_snake_keys(v) }
|
11
|
+
when Hash
|
12
|
+
snake_hash(value)
|
13
|
+
else
|
14
|
+
value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def snake_hash(value)
|
21
|
+
Hash[value.map { |k, v| [underscore_key(k).to_sym, to_snake_keys(v)] }]
|
22
|
+
end
|
23
|
+
|
24
|
+
def underscore_key(k)
|
25
|
+
if k.is_a? Symbol
|
26
|
+
underscore(k.to_s).to_sym
|
27
|
+
elsif k.is_a? String
|
28
|
+
underscore(k)
|
29
|
+
else
|
30
|
+
k # Plissken can't snakify anything except strings and symbols
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def underscore(string)
|
35
|
+
@__memoize_underscore ||= {}
|
36
|
+
return @__memoize_underscore[string] if @__memoize_underscore[string]
|
37
|
+
@__memoize_underscore[string] =
|
38
|
+
string.gsub(/::/, '/')
|
39
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
40
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
41
|
+
.tr('-', '_')
|
42
|
+
.downcase
|
43
|
+
@__memoize_underscore[string]
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: plissken 0.3.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "plissken"
|
9
|
+
s.version = "0.3.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Dave Hrycyszyn", "Michael Chrisco"]
|
14
|
+
s.date = "2017-01-13"
|
15
|
+
s.description = "\n Have you ever needed to automatically convert JSON-style camelBack or\n CamelCase hash keys into more Rubyish snake_case?\n\n Plissken to the rescue.\n\n This gem recursively converts all camelBack or CamelCase keys in a hash\n structure to snake_case.\n "
|
16
|
+
s.email = "dave.hrycyszyn@headlondon.com"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
".rubocop.yml",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.md",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"lib/plissken.rb",
|
32
|
+
"lib/plissken/ext/hash/to_snake_keys.rb",
|
33
|
+
"plissken.gemspec",
|
34
|
+
"spec/lib/to_snake_keys_spec.rb",
|
35
|
+
"spec/spec_helper.rb",
|
36
|
+
"test/helper.rb",
|
37
|
+
"test/plissken/ext/hash/to_snake_keys_test.rb",
|
38
|
+
"test/test_plissken.rb"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/futurechimp/plissken"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.rubygems_version = "2.5.1"
|
43
|
+
s.summary = "Snakify your camel keys when working with JSON APIs"
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 4
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.1"])
|
50
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.6"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
53
|
+
s.add_dependency(%q<rdoc>, ["~> 4.2"])
|
54
|
+
s.add_dependency(%q<bundler>, ["~> 1.6"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.6"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../lib/plissken')
|
4
|
+
|
5
|
+
RSpec.describe 'A Hash' do
|
6
|
+
describe 'with camelBack keys' do
|
7
|
+
describe 'which are JSON-style strings' do
|
8
|
+
describe 'in the simplest case' do
|
9
|
+
let(:hash) { [{ 'firstKey' => 'fooBar' }] }
|
10
|
+
|
11
|
+
describe 'non-destructive snakification' do
|
12
|
+
let(:snaked) { hash.map(&:to_snake_keys) }
|
13
|
+
it 'snakifies the key' do
|
14
|
+
expect(snaked.first).to have_key(:first_key)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'leaves the key as a string' do
|
18
|
+
expect(snaked.first.keys).to eq([:first_key])
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'leaves the value untouched' do
|
22
|
+
expect(hash.first.values).to eq(['fooBar'])
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'leaves the original hash untouched' do
|
26
|
+
expect(hash.first.keys).to eq(['firstKey'])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'containing an array of other hashes' do
|
32
|
+
let(:hash) do
|
33
|
+
{
|
34
|
+
'appleType' => 'Granny Smith',
|
35
|
+
'vegetableTypes' => [
|
36
|
+
{ 'potatoType' => 'Golden delicious' },
|
37
|
+
{ 'otherTuberType' => 'peanut' },
|
38
|
+
{ 'peanutNamesAndSpouses' => [
|
39
|
+
{ 'billThePeanut' => 'sallyPeanut' },
|
40
|
+
{ 'sammyThePeanut' => 'jillPeanut' }
|
41
|
+
] }
|
42
|
+
] }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'non-destructive snakification' do
|
46
|
+
subject(:snaked) { hash.to_snake_keys }
|
47
|
+
#
|
48
|
+
it 'recursively snakifies the keys on the top level of the hash' do
|
49
|
+
expect(snaked.include?(:apple_type)).to be_truthy
|
50
|
+
expect(snaked.include?(:vegetable_types)).to be_truthy
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'leaves the values on the top level alone' do
|
54
|
+
expect(snaked[:apple_type]).to eq('Granny Smith')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'converts second-level keys' do
|
58
|
+
expect(snaked[:vegetable_types].first)
|
59
|
+
.to have_key(:potato_type)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'leaves second-level values alone' do
|
63
|
+
expect(snaked[:vegetable_types].first)
|
64
|
+
.to have_value('Golden delicious')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'converts third-level keys' do
|
68
|
+
expect(snaked[:vegetable_types].last[:peanut_names_and_spouses]
|
69
|
+
.last).to have_value('jillPeanut')
|
70
|
+
expect(snaked[:vegetable_types]
|
71
|
+
.last[:peanut_names_and_spouses]
|
72
|
+
.last).to have_key(:sammy_the_peanut)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'leaves third-level values alone' do
|
76
|
+
expect(snaked[:vegetable_types]
|
77
|
+
.last[:peanut_names_and_spouses]
|
78
|
+
.first[:bill_the_peanut]).to eq('sallyPeanut')
|
79
|
+
expect(snaked[:vegetable_types]
|
80
|
+
.last[:peanut_names_and_spouses]
|
81
|
+
.last[:sammy_the_peanut]).to eq('jillPeanut')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe 'which are symbols' do
|
88
|
+
describe 'in the simplest case' do
|
89
|
+
let(:hash) { { :firstKey => 'fooBar' } }
|
90
|
+
|
91
|
+
describe 'non-destructive snakification' do
|
92
|
+
subject(:snaked) { hash.to_snake_keys }
|
93
|
+
|
94
|
+
it 'snakifies the key' do
|
95
|
+
expect(snaked).to have_key(:first_key)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'leaves the key as a symbol' do
|
99
|
+
expect(:first_key).to eq(snaked.keys.first)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'leaves the value untouched' do
|
103
|
+
expect(snaked.values.first).to eq('fooBar')
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'leaves the original hash untouched' do
|
107
|
+
expect(hash).to have_key(:firstKey)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
#
|
112
|
+
describe 'containing an array of other hashes' do
|
113
|
+
let(:hash) do
|
114
|
+
{
|
115
|
+
:appleType => 'Granny Smith',
|
116
|
+
:vegetableTypes => [
|
117
|
+
{ :potatoType => 'Golden delicious' },
|
118
|
+
{ :otherTuberType => 'peanut' },
|
119
|
+
{ :peanutNamesAndSpouses => [
|
120
|
+
{ :billThePeanut => 'sallyPeanut' },
|
121
|
+
{ :sammyThePeanut => 'jillPeanut' }
|
122
|
+
] }
|
123
|
+
] }
|
124
|
+
end
|
125
|
+
#
|
126
|
+
describe 'non-destructive snakification' do
|
127
|
+
subject(:snaked) { hash.to_snake_keys }
|
128
|
+
#
|
129
|
+
it 'recursively snakifies the keys on the top level of the hash' do
|
130
|
+
expect(snaked.include?(:apple_type)).to be_truthy
|
131
|
+
expect(snaked.include?(:vegetable_types)).to be_truthy
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'leaves the values on the top level alone' do
|
135
|
+
expect(snaked[:apple_type]).to eq('Granny Smith')
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'converts second-level keys' do
|
139
|
+
expect(snaked[:vegetable_types].first)
|
140
|
+
.to have_key(:potato_type)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'leaves second-level values alone' do
|
144
|
+
expect(snaked[:vegetable_types].first)
|
145
|
+
.to have_value('Golden delicious')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'converts third-level keys' do
|
149
|
+
expect(snaked[:vegetable_types].last[:peanut_names_and_spouses]
|
150
|
+
.last).to have_value('jillPeanut')
|
151
|
+
expect(snaked[:vegetable_types]
|
152
|
+
.last[:peanut_names_and_spouses]
|
153
|
+
.last).to have_key(:sammy_the_peanut)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'leaves third-level values alone' do
|
157
|
+
expect(snaked[:vegetable_types]
|
158
|
+
.last[:peanut_names_and_spouses]
|
159
|
+
.first[:bill_the_peanut]).to eq('sallyPeanut')
|
160
|
+
expect(snaked[:vegetable_types]
|
161
|
+
.last[:peanut_names_and_spouses]
|
162
|
+
.last[:sammy_the_peanut]).to eq('jillPeanut')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe 'strings with spaces in them' do
|
170
|
+
let(:hash) { { 'With Spaces' => 'FooBar' } }
|
171
|
+
subject { hash.to_snake_keys }
|
172
|
+
|
173
|
+
it "doesn't get snaked, although it does get downcased" do
|
174
|
+
is_expected.to have_key(:'with spaces')
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper`
|
4
|
+
# which will cause this file to always be loaded,
|
5
|
+
# without a need to explicitly require it in any files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec
|
13
|
+
# files that actually need it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
# # These two settings work together to allow you to limit a spec run
|
46
|
+
# # to individual examples or groups you care about by tagging them with
|
47
|
+
# # `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
48
|
+
# # get run.
|
49
|
+
# config.filter_run :focus
|
50
|
+
# config.run_all_when_everything_filtered = true
|
51
|
+
#
|
52
|
+
# # Limits the available syntax to the non-monkey
|
53
|
+
# patched syntax that is recommended.
|
54
|
+
# # For more details, see:
|
55
|
+
#
|
56
|
+
# config.disable_monkey_patching!
|
57
|
+
#
|
58
|
+
# # This setting enables warnings. It's recommended, but in some cases may
|
59
|
+
# # be too noisy due to issues in dependencies.
|
60
|
+
# config.warnings = true
|
61
|
+
#
|
62
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
63
|
+
# # file, and it's useful to allow more verbose output when running an
|
64
|
+
# # individual spec file.
|
65
|
+
# if config.files_to_run.one?
|
66
|
+
# # Use the documentation formatter for detailed output,
|
67
|
+
# # unless a formatter has already been configured
|
68
|
+
# # (e.g. via a command-line flag).
|
69
|
+
# config.default_formatter = 'doc'
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# # Print the 10 slowest examples and example groups at the
|
73
|
+
# # end of the spec run, to help surface which specs are running
|
74
|
+
# # particularly slow.
|
75
|
+
# config.profile_examples = 10
|
76
|
+
#
|
77
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
78
|
+
# # order dependency and want to debug it,
|
79
|
+
# you can fix the order by providing
|
80
|
+
# # the seed, which is printed after each run.
|
81
|
+
# # --seed 1234
|
82
|
+
# config.order = :random
|
83
|
+
#
|
84
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
85
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
86
|
+
# # test failures related to randomization by
|
87
|
+
# # passing the same `--seed` value
|
88
|
+
# # as the one that triggered the failure.
|
89
|
+
# Kernel.srand config.seed
|
90
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'minitest/spec'
|
11
|
+
# require 'debugger'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
|
+
require 'plissken'
|
16
|
+
|
17
|
+
class MiniTest::Unit::TestCase
|
18
|
+
end
|
19
|
+
|
20
|
+
MiniTest::Unit.autorun
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_plissken.rb')
|
2
|
+
|
3
|
+
describe 'A Hash' do
|
4
|
+
describe 'with camelBack keys' do
|
5
|
+
describe 'which are JSON-style strings' do
|
6
|
+
describe 'in the simplest case' do
|
7
|
+
before do
|
8
|
+
@hash = { 'firstKey' => 'fooBar' }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'non-destructive snakification' do
|
12
|
+
before do
|
13
|
+
@snaked = @hash.to_snake_keys
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'snakifies the key' do
|
17
|
+
assert_equal(@snaked.keys.first, 'first_key')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'leaves the key as a string' do
|
21
|
+
assert_equal('first_key', @snaked.keys.first)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'leaves the value untouched' do
|
25
|
+
assert_equal(@snaked.values.first, 'fooBar')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'leaves the original hash untouched' do
|
29
|
+
assert_equal(@hash.keys.first, 'firstKey')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'containing an array of other hashes' do
|
35
|
+
before do
|
36
|
+
@hash = {
|
37
|
+
'appleType' => 'Granny Smith',
|
38
|
+
'vegetableTypes' => [
|
39
|
+
{ 'potatoType' => 'Golden delicious' },
|
40
|
+
{ 'otherTuberType' => 'peanut' },
|
41
|
+
{ 'peanutNamesAndSpouses' => [
|
42
|
+
{ 'billThePeanut' => 'sallyPeanut' },
|
43
|
+
{ 'sammyThePeanut' => 'jillPeanut' }
|
44
|
+
] }
|
45
|
+
] }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'non-destructive snakification' do
|
49
|
+
before do
|
50
|
+
@snaked = @hash.to_snake_keys
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'recursively snakifies the keys on the top level of the hash' do
|
54
|
+
assert @snaked.keys.include?('apple_type')
|
55
|
+
assert @snaked.keys.include?('vegetable_types')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'leaves the values on the top level alone' do
|
59
|
+
assert_equal(@snaked['apple_type'], 'Granny Smith')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'converts second-level keys' do
|
63
|
+
assert @snaked['vegetable_types'].first.key? 'potato_type'
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'leaves second-level values alone' do
|
67
|
+
assert @snaked['vegetable_types'].first.value? 'Golden delicious'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'converts third-level keys' do
|
71
|
+
assert @snaked['vegetable_types'].last['peanut_names_and_spouses']
|
72
|
+
.first.key?('bill_the_peanut')
|
73
|
+
assert @snaked['vegetable_types'].last['peanut_names_and_spouses']
|
74
|
+
.last.key?('sammy_the_peanut')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'leaves third-level values alone' do
|
78
|
+
assert_equal 'sallyPeanut', @snaked['vegetable_types']
|
79
|
+
.last['peanut_names_and_spouses']
|
80
|
+
.first['bill_the_peanut']
|
81
|
+
assert_equal 'jillPeanut', @snaked['vegetable_types']
|
82
|
+
.last['peanut_names_and_spouses']
|
83
|
+
.last['sammy_the_peanut']
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'which are symbols' do
|
90
|
+
describe 'in the simplest case' do
|
91
|
+
before do
|
92
|
+
@hash = { :firstKey => 'fooBar' }
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'non-destructive snakification' do
|
96
|
+
before do
|
97
|
+
@snaked = @hash.to_snake_keys
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'snakifies the key' do
|
101
|
+
assert_equal(@snaked.keys.first, :first_key)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'leaves the key as a symbol' do
|
105
|
+
assert_equal(:first_key, @snaked.keys.first)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'leaves the value untouched' do
|
109
|
+
assert_equal(@snaked.values.first, 'fooBar')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'leaves the original hash untouched' do
|
113
|
+
assert_equal(@hash.keys.first, :firstKey)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'containing an array of other hashes' do
|
119
|
+
before do
|
120
|
+
@hash = {
|
121
|
+
:appleType => 'Granny Smith',
|
122
|
+
:vegetableTypes => [
|
123
|
+
{ :potatoType => 'Golden delicious' },
|
124
|
+
{ :otherTuberType => 'peanut' },
|
125
|
+
{ :peanutNamesAndSpouses => [
|
126
|
+
{ :billThePeanut => 'sallyPeanut' },
|
127
|
+
{ :sammyThePeanut => 'jillPeanut' }
|
128
|
+
] }
|
129
|
+
] }
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'non-destructive snakification' do
|
133
|
+
before do
|
134
|
+
@snaked = @hash.to_snake_keys
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'recursively snakifies the keys on the top level of the hash' do
|
138
|
+
assert @snaked.keys.include?(:apple_type)
|
139
|
+
assert @snaked.keys.include?(:vegetable_types)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'leaves the values on the top level alone' do
|
143
|
+
assert_equal(@snaked[:apple_type], 'Granny Smith')
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'converts second-level keys' do
|
147
|
+
assert @snaked[:vegetable_types].first.key? :potato_type
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'leaves second-level values alone' do
|
151
|
+
assert @snaked[:vegetable_types].first.value? 'Golden delicious'
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'converts third-level keys' do
|
155
|
+
assert @snaked[:vegetable_types].last[:peanut_names_and_spouses]
|
156
|
+
.first.key?(:bill_the_peanut)
|
157
|
+
assert @snaked[:vegetable_types].last[:peanut_names_and_spouses]
|
158
|
+
.last.key?(:sammy_the_peanut)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'leaves third-level values alone' do
|
162
|
+
assert_equal 'sallyPeanut', @snaked[:vegetable_types]
|
163
|
+
.last[:peanut_names_and_spouses]
|
164
|
+
.first[:bill_the_peanut]
|
165
|
+
assert_equal 'jillPeanut', @snaked[:vegetable_types]
|
166
|
+
.last[:peanut_names_and_spouses]
|
167
|
+
.last[:sammy_the_peanut]
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe 'strings with spaces in them' do
|
175
|
+
before do
|
176
|
+
@hash = { 'With Spaces' => 'FooBar' }
|
177
|
+
@snaked = @hash.to_snake_keys
|
178
|
+
end
|
179
|
+
|
180
|
+
it "doesn't get snaked, although it does get downcased" do
|
181
|
+
assert @snaked.keys.include? 'with spaces'
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -324,6 +324,7 @@ files:
|
|
324
324
|
- LICENSE.txt
|
325
325
|
- README.md
|
326
326
|
- Rakefile
|
327
|
+
- bin/release
|
327
328
|
- exe/lono
|
328
329
|
- lib/lono.rb
|
329
330
|
- lib/lono/cfn.rb
|
@@ -439,6 +440,19 @@ files:
|
|
439
440
|
- lib/starter_projects/skeleton/config/settings.yml
|
440
441
|
- lib/starter_projects/skeleton/welcome.txt
|
441
442
|
- lono.gemspec
|
443
|
+
- vendor/plissken/Gemfile
|
444
|
+
- vendor/plissken/LICENSE.txt
|
445
|
+
- vendor/plissken/README.md
|
446
|
+
- vendor/plissken/Rakefile
|
447
|
+
- vendor/plissken/VERSION
|
448
|
+
- vendor/plissken/lib/plissken.rb
|
449
|
+
- vendor/plissken/lib/plissken/ext/hash/to_snake_keys.rb
|
450
|
+
- vendor/plissken/plissken.gemspec
|
451
|
+
- vendor/plissken/spec/lib/to_snake_keys_spec.rb
|
452
|
+
- vendor/plissken/spec/spec_helper.rb
|
453
|
+
- vendor/plissken/test/helper.rb
|
454
|
+
- vendor/plissken/test/plissken/ext/hash/to_snake_keys_test.rb
|
455
|
+
- vendor/plissken/test/test_plissken.rb
|
442
456
|
homepage: http://github.com/tongueroo/lono
|
443
457
|
licenses:
|
444
458
|
- MIT
|