arn_parse 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/arn_parse.gemspec +29 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/arn_parse.rb +32 -0
- data/lib/arn_parse/version.rb +3 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d2b8b9273642e093b96fed5bc3615f045b5871a7
|
4
|
+
data.tar.gz: 1331a6a3600a6ec520c6c95563799a296ae3978e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f88c0993a5723637936d982a40b321c9534fd399edef798ab0ed9519e6a71befb354228ad05933082a2b929aeda6832dda0f1b45d4b2059ac3e466053b115cb6
|
7
|
+
data.tar.gz: 8046d4d3935e3108a6f6f54c015928a3a81ea1bffbab705992ba6dd8b53d8cccaa58d262da01365d54b352632f05ac3ceeddbe21daa2cef4935fdb2029134a12
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Ryan Porter
|
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,37 @@
|
|
1
|
+
# ArnParse
|
2
|
+
|
3
|
+
I needed to parse an AWS ARN with Ruby. I couldn't find a Ruby gem that provided that funcionality (do the AWS SDK gems?) but I did find this Gist: https://gist.github.com/RulerOf/b9f5dd00a9911aba8271b57d3d269d7a
|
4
|
+
|
5
|
+
So I packaged that Gist as a Ruby gem. Thanks, Andrew!
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'arn_parse'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install arn_parse
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
$ bundle exec irb
|
26
|
+
2.4.0 :001 > require 'arn_parse'
|
27
|
+
=> true
|
28
|
+
2.4.0 :002 > ArnParse::Arn.parse('arn:aws:s3:::serverless-url-screenshot.development.files')
|
29
|
+
=> #<ArnParse::Arn:0x007fa0d9a701d0 @partition="aws", @service="s3", @region="", @account="", @resource="serverless-url-screenshot.development.files">
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/arn_parse.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/arn_parse.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "arn_parse/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "arn_parse"
|
8
|
+
spec.version = ArnParse::VERSION
|
9
|
+
spec.authors = ["Ryan Porter"]
|
10
|
+
spec.email = ["rap@endymion.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Parse an AWS ARN and get its various sections.}
|
13
|
+
spec.description = %q{Based on https://gist.github.com/RulerOf/b9f5dd00a9911aba8271b57d3d269d7a}
|
14
|
+
spec.homepage = "https://github.com/endymion/arn_parse"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "arn_parse"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/lib/arn_parse.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "arn_parse/version"
|
2
|
+
|
3
|
+
module ArnParse
|
4
|
+
class Arn
|
5
|
+
attr_accessor :partition
|
6
|
+
attr_accessor :service
|
7
|
+
attr_accessor :region
|
8
|
+
attr_accessor :account
|
9
|
+
attr_accessor :resource
|
10
|
+
|
11
|
+
def initialize(partition, service, region, account, resource)
|
12
|
+
@partition = partition
|
13
|
+
@service = service
|
14
|
+
@region = region
|
15
|
+
@account = account
|
16
|
+
@resource = resource
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parse(arn)
|
20
|
+
raise TypeError, 'ARN must be supplied as a string' unless arn.is_a?(String)
|
21
|
+
|
22
|
+
arn_components = arn.split(':', 6)
|
23
|
+
raise ArgumentError, 'Could not parse ARN' if arn_components.length < 6
|
24
|
+
|
25
|
+
Arn.new arn_components[1],
|
26
|
+
arn_components[2],
|
27
|
+
arn_components[3],
|
28
|
+
arn_components[4],
|
29
|
+
arn_components[5]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arn_parse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Porter
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-19 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Based on https://gist.github.com/RulerOf/b9f5dd00a9911aba8271b57d3d269d7a
|
56
|
+
email:
|
57
|
+
- rap@endymion.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- arn_parse.gemspec
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/arn_parse.rb
|
73
|
+
- lib/arn_parse/version.rb
|
74
|
+
homepage: https://github.com/endymion/arn_parse
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.6.12
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Parse an AWS ARN and get its various sections.
|
98
|
+
test_files: []
|