idlc-sdk-core 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10455e548fa2eaf8df4e5cbf5dc8459f6efd77d9
4
+ data.tar.gz: b08b51eb7a144d1a9a01327350cbd345d98ef274
5
+ SHA512:
6
+ metadata.gz: a662f684953c900d24bfb9905e93855df0ffb42b053f12226bf8fd3e66f5f9d5cb5defc55780b0e116184394da7085c932a061fc39e8e4800f5aaa70c59c2260
7
+ data.tar.gz: 82ed306383719f7f591836f71c850d8610d3cc29fbfbe583876f134640cfd77354abe4445d7e10ecf2ed4657c847cc99b49df727ef052e65956a2a264bc00757
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.4
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: IGztrc71SZ6X3uMHT+RkrqRaHGihyq8Ikt80FfQEfC7CEsIJQtScOr8+Edqs0GRJfDBhV2WikUdUvMVvq9hZeiO0bJf4QMVTbh5cUIq5A+IP2T6nDwQZvlTO03vxMGunnCaF9MDqSTtA39VtIQJUlV5S3J2pv8oShBGB9CMffaB+LdzTw49fdKBc1TfBo6du8X1ELJPxx2ZmT0+0XAqxD0+lJ1x08T2XOfb2/iLmD/Yhg5+EPOuDY2ePO+PqSTJuiyKsFLxxKgjI1eVRwfvqKeSuFeFMxrj+CqA2+9aF8M28J4FIXac3U5obJYgPxmZznmqlPlh8fLamBZ2yZ/AVRfJIwSeYgAzTbo8te+bOpwwAk/+lMOzxkz82yK3bf2R9cnKY09lH2Uht3hkBWE5IUijfl4j34mvQl7JJJP6ZQHGg1v2pcAgXRlRQw60M2v4v8XFxOhdO39lMymyRXol1Raq3N4eY8AcxPa/GVPfR2/H4u9JDA1dUqsYxTO3LcfIZjs68q801Z3ddxLhOECOH0b8VfvCTibnVUOj8XpP/E0VUoXyjQ8mPancblfsy5BL9c8HB9Vim1ZcdmZ3FKbJ2Ud/dVxQmbMRW9doVL7dZMDbfxIuPEVfqTsssGucJByNeSXJzc+fMej5HCrCTpuOztOIgsT/JbxJQ6/e0IVL5F18=
10
+ gem: idlc-sdk-core
11
+ on:
12
+ tags: true
13
+ repo: NathanTCz/idlc-sdk-core
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ -m markdown
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in idlc-sdk-core.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Nathan Cazell
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
+ # Idlc::Sdk::Core
2
+
3
+ Provides core libraries for idlc-sdk. This gem is part of the IDLC SDK
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'idlc-sdk-core'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install idlc-sdk-core
20
+
21
+ ## Usage
22
+
23
+ require 'idlc-sdk-core'
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nathantcz/idlc-sdk-core.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "idlc-sdk-core"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'idlc-sdk-core/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'idlc-sdk-core'
9
+ spec.version = Idlc::VERSION
10
+ spec.authors = ['Nathan Cazell']
11
+ spec.email = ['nathan.cazell@imageapi.com']
12
+
13
+ spec.summary = 'IDLC SDK for AWS resources - Core'
14
+ spec.description = 'Provides core libraries for idlc-sdk. This gem is part of the IDLC SDK'
15
+ spec.homepage = 'https://github.com/nathantcz/idlc-sdk'
16
+ spec.license = 'MIT'
17
+
18
+ spec.metadata = {
19
+ 'source_code_uri' => 'https://github.com/nathantcz/idlc-sdk-core'
20
+ }
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.15'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'rubocop', '0.48.1'
32
+ spec.add_development_dependency 'pry'
33
+ spec.add_development_dependency 'yard'
34
+
35
+ spec.add_runtime_dependency 'rubyzip'
36
+ end
@@ -0,0 +1,34 @@
1
+ module Idlc
2
+ module Helpers
3
+ module_function
4
+
5
+ #
6
+ # Runs given commands using mixlib-shellout
7
+ #
8
+ def system_command(*command_args)
9
+ cmd = Mixlib::ShellOut.new(*command_args)
10
+ cmd.run_command
11
+ cmd
12
+ end
13
+
14
+ def err(message)
15
+ stderr.print("#{message}\n")
16
+ end
17
+
18
+ def msg(message)
19
+ stdout.print("#{message}\n")
20
+ end
21
+
22
+ def debug(message)
23
+ stdout.print("#{message}\n") if ENV['DEBUG']
24
+ end
25
+
26
+ def stdout
27
+ $stdout
28
+ end
29
+
30
+ def stderr
31
+ $stderr
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,44 @@
1
+ module Idlc
2
+ module Utility
3
+ include Helpers
4
+
5
+ class MissingCredentials < StandardError; end
6
+ class MissingVersionFile < StandardError; end
7
+
8
+ class << self
9
+ def check_for_creds
10
+ creds_fmt = {
11
+ 'AWS_ACCESS_ID' => 'AWS_ACCESS_KEY_ID',
12
+ 'AWS_SECRET_KEY' => 'AWS_SECRET_ACCESS_KEY'
13
+ }
14
+ creds_fmt.each do |old_fmt, new_fmt|
15
+ if ENV.include? new_fmt
16
+ next
17
+ elsif ENV.include?(old_fmt) && !ENV.include?(new_fmt)
18
+ ENV[new_fmt] = ENV[old_fmt]
19
+ elsif !ENV.include?(old_fmt) || !ENV.include?(new_fmt)
20
+ raise MissingCredentials, "#{new_fmt} is not set."
21
+ end
22
+ end
23
+ end
24
+
25
+ def set_global_version(filename)
26
+ filename = ENV['VERSION_FILE'] if ENV.include? 'VERSION_FILE'
27
+ Idlc::Helpers.debug('WARNING: Not using a global version file') unless File.exist? filename
28
+ YAML.load_file(filename)['version'] if File.exist? filename
29
+ end
30
+
31
+ def major_minor_patch(version)
32
+ # Strip build number from version number. The migration scripts only include
33
+ # major.minor.patch
34
+ version.split('.')[0..2].join('.')
35
+ end
36
+
37
+ def major_minor(version)
38
+ # Strip build number from version number. The migration scripts only include
39
+ # major.minor.patch
40
+ version.split('.')[0..1].join('.')
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module Idlc
2
+ VERSION = '1.0.0.rc2'.freeze
3
+ end
@@ -0,0 +1,46 @@
1
+ module Idlc
2
+ class Workspace
3
+ include Helpers
4
+
5
+ class << self
6
+ def zip_folder(src, out)
7
+ zf = ZipFileGenerator.new(src, out)
8
+ zf.write
9
+ end
10
+ end
11
+
12
+ attr_accessor :tmp_dir
13
+
14
+ def initialize
15
+ @tmp_dir = Dir.mktmpdir('ws-temp')
16
+ end
17
+
18
+ def empty?
19
+ !Dir.exist? @tmp_dir
20
+ end
21
+
22
+ def cleanup
23
+ debug("keeping directory: #{@tmp_dir} for dubugging")
24
+ return if ENV['DEBUG']
25
+
26
+ FileUtils.rm_rf(@tmp_dir)
27
+ end
28
+
29
+ def flatten(base_path, file_ext)
30
+ Dir["#{base_path}/**/*.#{file_ext}"].each do |file|
31
+ # get the filename and parent dir
32
+ filename = file.tr('/', '-')
33
+
34
+ # copy the files to a single temp directory.
35
+ debug("copying #{file} to #{@tmp_dir}/#{filename} ...")
36
+ FileUtils.cp(file, "#{@tmp_dir}/#{filename}")
37
+ end
38
+ end
39
+
40
+ def add(path)
41
+ parent_dir = path.split('/')[0..-2].join('/')
42
+ FileUtils.mkdir_p("#{@tmp_dir}/#{parent_dir}")
43
+ FileUtils.cp_r(path, "#{@tmp_dir}/#{path}")
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,40 @@
1
+ module Idlc
2
+ class ZipFileGenerator
3
+ include Helpers
4
+
5
+ # Initialize with the directory to zip and the location of the output archive.
6
+ def initialize(inputDir, outputFile)
7
+ @inputDir = inputDir
8
+ @outputFile = outputFile
9
+ end
10
+
11
+ # Zip the input directory.
12
+ def write()
13
+ entries = Dir.entries(@inputDir); entries.delete("."); entries.delete("..")
14
+ io = Zip::File.open(@outputFile, Zip::File::CREATE);
15
+
16
+ writeEntries(entries, "", io)
17
+ io.close();
18
+ end
19
+
20
+ # A helper method to make the recursion work.
21
+ private
22
+ def writeEntries(entries, path, io)
23
+
24
+ entries.each { |e|
25
+ zipFilePath = path == "" ? e : File.join(path, e)
26
+ diskFilePath = File.join(@inputDir, zipFilePath)
27
+
28
+ debug("Deflating " + diskFilePath)
29
+
30
+ if File.directory?(diskFilePath)
31
+ io.mkdir(zipFilePath)
32
+ subdir =Dir.entries(diskFilePath); subdir.delete("."); subdir.delete("..")
33
+ writeEntries(subdir, zipFilePath, io)
34
+ else
35
+ io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read())}
36
+ end
37
+ }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,12 @@
1
+ require 'tmpdir'
2
+ require 'zip'
3
+
4
+ require 'idlc-sdk-core/version'
5
+ require 'idlc-sdk-core/helpers'
6
+ require 'idlc-sdk-core/utility'
7
+ require 'idlc-sdk-core/workspace'
8
+ require 'idlc-sdk-core/zip'
9
+
10
+ module Idlc
11
+ # ...
12
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: idlc-sdk-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc2
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Cazell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-08 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.48.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.48.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubyzip
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Provides core libraries for idlc-sdk. This gem is part of the IDLC SDK
112
+ email:
113
+ - nathan.cazell@imageapi.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - ".yardopts"
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - idlc-sdk-core.gemspec
129
+ - lib/idlc-sdk-core.rb
130
+ - lib/idlc-sdk-core/helpers.rb
131
+ - lib/idlc-sdk-core/utility.rb
132
+ - lib/idlc-sdk-core/version.rb
133
+ - lib/idlc-sdk-core/workspace.rb
134
+ - lib/idlc-sdk-core/zip.rb
135
+ homepage: https://github.com/nathantcz/idlc-sdk
136
+ licenses:
137
+ - MIT
138
+ metadata:
139
+ source_code_uri: https://github.com/nathantcz/idlc-sdk-core
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">"
152
+ - !ruby/object:Gem::Version
153
+ version: 1.3.1
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.6.11
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: IDLC SDK for AWS resources - Core
160
+ test_files: []