lono 4.2.7 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/README.md +6 -0
- data/.cody/acceptance.sh +30 -0
- data/.cody/buildspec.yml +21 -0
- data/.cody/demo.rb +38 -0
- data/.cody/project.rb +12 -0
- data/.cody/role.rb +1 -0
- data/.gitignore +2 -0
- data/.gitmodules +6 -3
- data/.travis.yml +7 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -1
- data/LICENSE.txt +1 -22
- data/README.md +46 -55
- data/lib/lono.rb +20 -27
- data/lib/lono/app_file.rb +5 -0
- data/lib/lono/app_file/base.rb +19 -0
- data/lib/lono/app_file/build.rb +78 -0
- data/lib/lono/app_file/registry.rb +14 -0
- data/lib/lono/app_file/registry/item.rb +46 -0
- data/lib/lono/app_file/upload.rb +39 -0
- data/lib/lono/autoloader.rb +22 -0
- data/lib/lono/aws_services.rb +46 -0
- data/lib/lono/aws_services/util.rb +49 -0
- data/lib/lono/blueprint.rb +113 -0
- data/lib/lono/blueprint/find.rb +90 -0
- data/lib/lono/blueprint/helper.rb +18 -0
- data/lib/lono/blueprint/info.rb +10 -0
- data/lib/lono/blueprint/list.rb +14 -0
- data/lib/lono/blueprint/root.rb +43 -0
- data/lib/lono/cfn.rb +31 -19
- data/lib/lono/cfn/aws_service.rb +16 -0
- data/lib/lono/cfn/base.rb +244 -261
- data/lib/lono/cfn/create.rb +36 -32
- data/lib/lono/cfn/current.rb +1 -1
- data/lib/lono/cfn/delete.rb +2 -2
- data/lib/lono/cfn/deploy.rb +11 -0
- data/lib/lono/cfn/diff.rb +1 -1
- data/lib/lono/cfn/preview.rb +3 -3
- data/lib/lono/cfn/rollback.rb +26 -0
- data/lib/lono/cfn/status.rb +2 -203
- data/lib/lono/cfn/suffix.rb +67 -0
- data/lib/lono/cfn/update.rb +61 -53
- data/lib/lono/cli.rb +42 -23
- data/lib/lono/completer.rb +0 -2
- data/lib/lono/configure.rb +37 -0
- data/lib/lono/configure/aws_services.rb +18 -0
- data/lib/lono/configure/base.rb +94 -0
- data/lib/lono/configure/helpers.rb +128 -0
- data/lib/lono/conventions.rb +11 -0
- data/lib/lono/core.rb +42 -12
- data/lib/lono/core/config.rb +5 -4
- data/lib/lono/default/settings.yml +0 -11
- data/lib/lono/file_uploader.rb +9 -4
- data/lib/lono/help.rb +1 -2
- data/lib/lono/help/blueprint.md +46 -0
- data/lib/lono/help/cfn.md +5 -4
- data/lib/lono/help/cfn/create.md +14 -9
- data/lib/lono/help/cfn/deploy.md +92 -0
- data/lib/lono/help/cfn/diff.md +0 -1
- data/lib/lono/help/cfn/update.md +16 -15
- data/lib/lono/help/completion.md +3 -3
- data/lib/lono/help/generate.md +0 -1
- data/lib/lono/help/new.md +40 -34
- data/lib/lono/help/param.md +1 -1
- data/lib/lono/help/param/generate.md +1 -1
- data/lib/lono/help/template.md +2 -2
- data/lib/lono/help/xgraph.md +1 -1
- data/lib/lono/inspector.rb +1 -1
- data/lib/lono/inspector/base.rb +26 -10
- data/lib/lono/inspector/graph.rb +7 -3
- data/lib/lono/inspector/summary.rb +15 -3
- data/lib/lono/md5.rb +46 -0
- data/lib/lono/new.rb +40 -28
- data/lib/lono/new/helper.rb +2 -3
- data/lib/lono/param.rb +12 -11
- data/lib/lono/param/generator.rb +96 -42
- data/lib/lono/project_checker.rb +27 -8
- data/lib/lono/s3.rb +23 -0
- data/lib/lono/s3/bucket.rb +123 -0
- data/lib/lono/script.rb +4 -8
- data/lib/lono/script/base.rb +7 -2
- data/lib/lono/script/build.rb +7 -8
- data/lib/lono/script/upload.rb +4 -20
- data/lib/lono/sequence.rb +19 -16
- data/lib/lono/setting.rb +19 -27
- data/lib/lono/template.rb +22 -26
- data/lib/lono/template/base.rb +13 -0
- data/lib/lono/template/context.rb +4 -56
- data/lib/lono/template/context/loader.rb +70 -0
- data/lib/lono/template/dsl.rb +15 -151
- data/lib/lono/template/dsl/builder.rb +60 -0
- data/lib/lono/template/dsl/builder/base.rb +14 -0
- data/lib/lono/template/dsl/builder/condition.rb +26 -0
- data/lib/lono/template/dsl/builder/fn.rb +114 -0
- data/lib/lono/template/dsl/builder/helper.rb +64 -0
- data/lib/lono/template/dsl/builder/mapping.rb +24 -0
- data/lib/lono/template/dsl/builder/output.rb +37 -0
- data/lib/lono/template/dsl/builder/parameter.rb +39 -0
- data/lib/lono/template/dsl/builder/resource.rb +38 -0
- data/lib/lono/template/dsl/builder/section.rb +12 -0
- data/lib/lono/template/dsl/builder/syntax.rb +58 -0
- data/lib/lono/template/erb.rb +82 -0
- data/lib/lono/template/evaluate.rb +39 -0
- data/lib/lono/template/generator.rb +29 -0
- data/lib/lono/template/helper.rb +7 -29
- data/lib/lono/template/post_processor.rb +69 -0
- data/lib/lono/template/template.rb +4 -9
- data/lib/lono/template/upload.rb +103 -133
- data/lib/lono/template/util.rb +48 -0
- data/lib/lono/upgrade.rb +5 -3
- data/lib/lono/upgrade/upgrade5.rb +55 -0
- data/lib/lono/user_data.rb +4 -4
- data/lib/lono/version.rb +1 -1
- data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +44 -0
- data/lib/templates/blueprint/.gitignore +14 -0
- data/lib/templates/blueprint/.lono/config.yml.tt +3 -0
- data/lib/templates/blueprint/.meta/config.yml.tt +3 -0
- data/lib/templates/blueprint/CHANGELOG.md +7 -0
- data/lib/templates/blueprint/Gemfile +4 -0
- data/lib/templates/blueprint/README.md +37 -0
- data/lib/templates/blueprint/Rakefile +6 -0
- data/lib/templates/blueprint/setup/configs.rb +54 -0
- data/lib/templates/blueprint_configs/configs/%blueprint_name%/params/base.txt +2 -0
- data/lib/{starter_projects/skeleton/app/definitions/base.rb → templates/blueprint_configs/configs/%blueprint_name%/params/development.txt} +0 -0
- data/lib/templates/blueprint_configs/configs/%blueprint_name%/variables/base.rb +2 -0
- data/lib/templates/blueprint_configs/configs/%blueprint_name%/variables/development.rb +0 -0
- data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +37 -0
- data/lib/templates/blueprint_types/dsl/app/user_data/bootstrap.sh +2 -0
- data/lib/templates/blueprint_types/erb/app/definitions/base.rb.tt +1 -0
- data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +8 -0
- data/lib/{starter_projects/autoscaling → templates/skeleton}/.gitignore +1 -0
- data/lib/templates/skeleton/Gemfile +3 -0
- data/lib/{starter_projects/autoscaling → templates/skeleton}/Guardfile +2 -2
- data/lib/templates/skeleton/README.md +58 -0
- data/lib/templates/skeleton/configs/settings.yml +17 -0
- data/lib/templates/upgrade5/blueprints/main/.lono/config.yml +3 -0
- data/lib/templates/upgrade5/blueprints/main/.meta/config.yml +3 -0
- data/lono.gemspec +12 -8
- data/vendor/cfn-status/CHANGELOG.md +10 -0
- data/vendor/cfn-status/Gemfile +4 -0
- data/vendor/cfn-status/LICENSE.txt +21 -0
- data/vendor/cfn-status/README.md +56 -0
- data/vendor/cfn-status/Rakefile +6 -0
- data/vendor/cfn-status/bin/console +14 -0
- data/vendor/cfn-status/bin/setup +8 -0
- data/vendor/cfn-status/cfn-status.gemspec +30 -0
- data/vendor/cfn-status/lib/cfn-status.rb +1 -0
- data/vendor/cfn-status/lib/cfn/aws_service.rb +51 -0
- data/vendor/cfn-status/lib/cfn/status.rb +219 -0
- data/vendor/cfn-status/lib/cfn/status/version.rb +5 -0
- data/vendor/cfn-status/spec/cfn/status_spec.rb +81 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +1080 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +1080 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +1086 -0
- data/vendor/cfn-status/spec/spec_helper.rb +14 -0
- data/vendor/cfn_camelizer/CHANGELOG.md +20 -0
- data/vendor/cfn_camelizer/Gemfile +4 -0
- data/vendor/cfn_camelizer/LICENSE.txt +21 -0
- data/vendor/cfn_camelizer/README.md +40 -0
- data/vendor/cfn_camelizer/Rakefile +6 -0
- data/vendor/cfn_camelizer/bin/console +14 -0
- data/vendor/cfn_camelizer/bin/setup +8 -0
- data/vendor/cfn_camelizer/cfn_camelizer.gemspec +32 -0
- data/vendor/cfn_camelizer/lib/camelizer.yml +37 -0
- data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +94 -0
- data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +3 -0
- data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +86 -0
- data/vendor/cfn_camelizer/spec/spec_helper.rb +14 -0
- metadata +189 -62
- data/.circleci/bin/commit_docs.sh +0 -26
- data/.circleci/config.yml +0 -72
- data/bin/release +0 -9
- data/lib/lono/help/import.md +0 -54
- data/lib/lono/importer.rb +0 -134
- data/lib/lono/new/message.rb +0 -35
- data/lib/starter_projects/autoscaling/Gemfile +0 -3
- data/lib/starter_projects/autoscaling/README.md +0 -118
- data/lib/starter_projects/autoscaling/app/definitions/base.rb +0 -2
- data/lib/starter_projects/autoscaling/app/templates/autoscaling.yml +0 -682
- data/lib/starter_projects/autoscaling/config/params/base/autoscaling.txt +0 -6
- data/lib/starter_projects/autoscaling/config/settings.yml +0 -33
- data/lib/starter_projects/ec2/.gitignore +0 -2
- data/lib/starter_projects/ec2/Gemfile +0 -3
- data/lib/starter_projects/ec2/Guardfile +0 -12
- data/lib/starter_projects/ec2/README.md +0 -86
- data/lib/starter_projects/ec2/app/definitions/base.rb +0 -2
- data/lib/starter_projects/ec2/app/definitions/development.rb +0 -1
- data/lib/starter_projects/ec2/app/definitions/production.rb +0 -1
- data/lib/starter_projects/ec2/app/helpers/my_custom_helper.rb +0 -17
- data/lib/starter_projects/ec2/app/partials/user_data/bootstrap.sh +0 -4
- data/lib/starter_projects/ec2/app/templates/example.yml +0 -430
- data/lib/starter_projects/ec2/config/params/base/example.txt +0 -2
- data/lib/starter_projects/ec2/config/params/development/example.txt +0 -3
- data/lib/starter_projects/ec2/config/params/production/example.txt +0 -2
- data/lib/starter_projects/ec2/config/settings.yml +0 -33
- data/lib/starter_projects/ec2/config/variables/base.rb +0 -3
- data/lib/starter_projects/ec2/config/variables/development.rb +0 -2
- data/lib/starter_projects/ec2/config/variables/production.rb +0 -2
- data/lib/starter_projects/ec2/welcome.txt +0 -8
- data/lib/starter_projects/skeleton/.gitignore +0 -2
- data/lib/starter_projects/skeleton/Gemfile +0 -3
- data/lib/starter_projects/skeleton/Guardfile +0 -12
- data/lib/starter_projects/skeleton/README.md +0 -53
- data/lib/starter_projects/skeleton/config/settings.yml +0 -33
- data/lib/starter_projects/skeleton/welcome.txt +0 -7
- data/vendor/plissken/Gemfile +0 -14
- data/vendor/plissken/LICENSE.txt +0 -20
- data/vendor/plissken/README.md +0 -46
- data/vendor/plissken/Rakefile +0 -56
- data/vendor/plissken/VERSION +0 -1
- data/vendor/plissken/lib/plissken.rb +0 -1
- data/vendor/plissken/lib/plissken/ext/hash/to_snake_keys.rb +0 -45
- data/vendor/plissken/plissken.gemspec +0 -61
- data/vendor/plissken/spec/lib/to_snake_keys_spec.rb +0 -177
- data/vendor/plissken/spec/spec_helper.rb +0 -90
- data/vendor/plissken/test/helper.rb +0 -20
- data/vendor/plissken/test/plissken/ext/hash/to_snake_keys_test.rb +0 -184
- data/vendor/plissken/test/test_plissken.rb +0 -2
@@ -1,33 +0,0 @@
|
|
1
|
-
# More info: http://lono.cloud/docs/settings/
|
2
|
-
# The base config is specially treated. It gets included the other environments automatically.
|
3
|
-
# Yaml also directly supports merging with & and <<* syntax but doing it automatically
|
4
|
-
# for a cleaner syntax.
|
5
|
-
base:
|
6
|
-
# http://lono.cloud/docs/app-scripts/
|
7
|
-
# extract_scripts:
|
8
|
-
# to: "/opt"
|
9
|
-
# as: "ec2-user"
|
10
|
-
# If s3_folder is set then the generated templates and app/scripts will automatically
|
11
|
-
# be uploaded to s3.
|
12
|
-
# There are 2 formats for s3_folder:
|
13
|
-
# Format 1:
|
14
|
-
# s3_folder: mybucket/path/to/folder # simple string
|
15
|
-
# Format 2:
|
16
|
-
# s3_folder: # Hash options in order to support multiple AWS_PROFILEs
|
17
|
-
# default: mybucket/folder
|
18
|
-
# aws_profile1: mybucket/folder
|
19
|
-
# aws_profile2: another-bucket/storage/folder
|
20
|
-
# stack_name_suffix: random # tack on a 3 char random string at the end of the stack name for lono cfn create
|
21
|
-
|
22
|
-
|
23
|
-
development:
|
24
|
-
# When you have AWS_PROFILE set to one of these values, lono will switch to the desired
|
25
|
-
# environment. This prevents you from switching AWS_PROFILE, forgetting to
|
26
|
-
# also switch LONO_ENV, and accidentally deploying to production vs development.
|
27
|
-
# aws_profiles:
|
28
|
-
# - dev_profile1
|
29
|
-
# - dev_profile2
|
30
|
-
|
31
|
-
production:
|
32
|
-
# aws_profiles:
|
33
|
-
# - prod_profile
|
@@ -1,8 +0,0 @@
|
|
1
|
-
The example template uses a keypair named default. Be sure that keypair exists. Or you can adjust the KeyName parameter in config/params/base/example.txt. Here are contents of the file:
|
2
|
-
|
3
|
-
InstanceType=t2.micro
|
4
|
-
KeyName=default
|
5
|
-
|
6
|
-
To launch an example CloudFormation stack:
|
7
|
-
|
8
|
-
lono cfn create example
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
guard "lono" do
|
5
|
-
watch(%r{^config/lono.rb$})
|
6
|
-
watch(%r{^templates/.*$})
|
7
|
-
end
|
8
|
-
|
9
|
-
# Commented out due to CF rate limiting
|
10
|
-
# guard "cloudformation", templates_path: "output" do
|
11
|
-
# watch(%r{^output/.+\.yml$})
|
12
|
-
# end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# Lono CloudFormation Starter README
|
2
|
-
|
3
|
-
This folder contains the code that represents your infrastructure built with CloudFormation.
|
4
|
-
|
5
|
-
## Overview
|
6
|
-
|
7
|
-
The CloudFormations templates are generated by a tool called [lono](http://lono.cloud/).
|
8
|
-
|
9
|
-
## Updating the Infrastructure
|
10
|
-
|
11
|
-
The general steps to update the infrastructure:
|
12
|
-
|
13
|
-
1. Edit the files in this repo
|
14
|
-
2. Generate the CloudFormation templates
|
15
|
-
3. Update the stack with the changes
|
16
|
-
|
17
|
-
Steps 2-3 are automated with lono and performed together with:
|
18
|
-
|
19
|
-
```bash
|
20
|
-
lono cfn update STACK_NAME --iam --sure
|
21
|
-
```
|
22
|
-
|
23
|
-
## Generating the templates
|
24
|
-
|
25
|
-
If you would like to just generate the templates and not update the CloudFormation stack you can do so with:
|
26
|
-
|
27
|
-
```
|
28
|
-
lono generate
|
29
|
-
```
|
30
|
-
|
31
|
-
## Importing Templates
|
32
|
-
|
33
|
-
You can also get started quickly by importing other CloudFormration templates into lono. For example:
|
34
|
-
|
35
|
-
```
|
36
|
-
lono import https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/EC2InstanceWithSecurityGroupSample.template --name ec2
|
37
|
-
```
|
38
|
-
|
39
|
-
After importing edit the generated param file in the `config/params/base` folder. Then you can launch the stack:
|
40
|
-
|
41
|
-
```
|
42
|
-
lono cfn create ec2
|
43
|
-
```
|
44
|
-
|
45
|
-
## More help
|
46
|
-
|
47
|
-
You can get help by adding `-h` to the end of commands.
|
48
|
-
|
49
|
-
```sh
|
50
|
-
lono cfn update -h
|
51
|
-
```
|
52
|
-
|
53
|
-
Help is also provided in the [Lono Docs](http://lono.cloud/docs/directory-structure/).
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# More info: http://lono.cloud/docs/settings/
|
2
|
-
# The base config is specially treated. It gets included the other environments automatically.
|
3
|
-
# Yaml also directly supports merging with & and <<* syntax but doing it automatically
|
4
|
-
# for a cleaner syntax.
|
5
|
-
base:
|
6
|
-
# http://lono.cloud/docs/app-scripts/
|
7
|
-
# extract_scripts:
|
8
|
-
# to: "/opt"
|
9
|
-
# as: "ec2-user"
|
10
|
-
# If s3_folder is set then the generated templates and app/scripts will automatically
|
11
|
-
# be uploaded to s3.
|
12
|
-
# There are 2 formats for s3_folder:
|
13
|
-
# Format 1:
|
14
|
-
# s3_folder: mybucket/path/to/folder # simple string
|
15
|
-
# Format 2:
|
16
|
-
# s3_folder: # Hash options in order to support multiple AWS_PROFILEs
|
17
|
-
# default: mybucket/path
|
18
|
-
# aws_profile1: mybucket/path
|
19
|
-
# aws_profile2: another-bucket/storage/path
|
20
|
-
# stack_name_suffix: random # tack on a 3 char random string at the end of the stack name for lono cfn create
|
21
|
-
|
22
|
-
|
23
|
-
development:
|
24
|
-
# When you have AWS_PROFILE set to one of these values, lono will switch to the desired
|
25
|
-
# environment. This prevents you from switching AWS_PROFILE, forgetting to
|
26
|
-
# also switch LONO_ENV, and accidentally deploying to production vs development.
|
27
|
-
# aws_profiles:
|
28
|
-
# - dev_profile1
|
29
|
-
# - dev_profile2
|
30
|
-
|
31
|
-
production:
|
32
|
-
# aws_profiles:
|
33
|
-
# - prod_profile
|
@@ -1,7 +0,0 @@
|
|
1
|
-
Add and edit templates to your project. When you are ready to launch a CloudFormation stack run:
|
2
|
-
|
3
|
-
lono cfn create STACK_NAME
|
4
|
-
|
5
|
-
You can also get started quickly by importing other CloudFormration templates into lono. For example:
|
6
|
-
|
7
|
-
lono import https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/EC2InstanceWithSecurityGroupSample.template --name ec2
|
data/vendor/plissken/Gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
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
|
data/vendor/plissken/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
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.
|
data/vendor/plissken/README.md
DELETED
@@ -1,46 +0,0 @@
|
|
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
|
-
|
data/vendor/plissken/Rakefile
DELETED
@@ -1,56 +0,0 @@
|
|
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
|
data/vendor/plissken/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.0
|
@@ -1 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/plissken/ext/hash/to_snake_keys'
|
@@ -1,45 +0,0 @@
|
|
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
|
@@ -1,61 +0,0 @@
|
|
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
|
-
|