scaleway_data 0.1.1

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
+ SHA256:
3
+ metadata.gz: 677a1c198e572ddae053eb18d139e07fa548264eb94eecde8ae4c59640d5564c
4
+ data.tar.gz: 6a939a946bd65092700d74028a7b81245ec3b304d279dc6a7572dad4c82eccdd
5
+ SHA512:
6
+ metadata.gz: 128cb689ce3fee721cd786fad6f186f7d05fd4c5e189b6ef8e2d1bbc13f1e1b208be184a8351086ec322eb0c104877964cb68c3b8330f4c15efbc561a402c865
7
+ data.tar.gz: 68b3e4c3010b34613a93c1bbe65ed587684a1b47dbe2de890b80f32da0c740612588b753d72369c34e3456c2db532cd4fd582b1a768e1ceaa7e6e6b244b3c9d3
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## [0.1.0]
7
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in scaleway_data.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Tung Nguyen
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,52 @@
1
+ # ScalewayData
2
+
3
+ Simple library to get current scaleway data like project and region.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'scaleway_data'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install scaleway_data
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ ScalewayData.organization
25
+ ScalewayData.project
26
+ ScalewayData.region
27
+ ScalewayData.zone
28
+ ```
29
+
30
+ ## Precedence
31
+
32
+ This library will return project, region and zone info using different sources with this precedence:
33
+
34
+ 1. Environment variables: SCW_DEFAULT_ORGANIZATION_ID, SCW_DEFAULT_PROJECT_ID, SCW_DEFAULT_REGION, SCW_DEFAULT_ZONE
35
+ 2. Defaults: region=fr-par and zone=fr-par-1
36
+
37
+ ### 1. Environment variables
38
+
39
+ The environment variables take the highest precedence:
40
+
41
+ SCW_DEFAULT_ORGANIZATION_ID, SCW_DEFAULT_PROJECT_ID, SCW_DEFAULT_REGION, SCW_DEFAULT_ZONE
42
+
43
+ ### 2. Defaults
44
+
45
+ The library will fallback to default values when it's unable to lookup the region and zone. The default values are:
46
+
47
+ region=fr-par
48
+ zone=fr-par-1
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/synalabs/scaleway_data.
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 "scaleway_data"
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,29 @@
1
+ require "json"
2
+ require "memoist"
3
+
4
+ module ScalewayData
5
+ class Error < StandardError; end
6
+ extend Memoist
7
+
8
+ def organization
9
+ ENV['SCW_DEFAULT_ORGANIZATION_ID'] || raise("Unable to look up scaleway organization_id")
10
+ end
11
+ memoize :organization
12
+
13
+ def project
14
+ ENV['SCW_DEFAULT_PROJECT_ID'] || raise("Unable to look up scaleway project_id")
15
+ end
16
+ memoize :project
17
+
18
+ def region
19
+ ENV['SCW_DEFAULT_REGION'] || 'fr-par'
20
+ end
21
+ memoize :region
22
+
23
+ def zone
24
+ ENV['SCW_DEFAULT_ZONE'] || 'fr-par-1'
25
+ end
26
+ memoize :zone
27
+
28
+ extend self
29
+ end
@@ -0,0 +1,3 @@
1
+ module ScalewayData
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'lib/scaleway_data/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "scaleway_data"
5
+ spec.version = ScalewayData::VERSION
6
+ spec.authors = ["Francois Baligant"]
7
+ spec.email = ["fbaligant@synalabs.com"]
8
+
9
+ spec.summary = "Simple module to get current scaleway data project and region"
10
+ spec.homepage = "https://github.com/synalabs/scaleway_data"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "memoist"
26
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scaleway_data
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Francois Baligant
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: memoist
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - fbaligant@synalabs.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - CHANGELOG.md
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - bin/console
43
+ - bin/setup
44
+ - lib/scaleway_data.rb
45
+ - lib/scaleway_data/version.rb
46
+ - scaleway_data.gemspec
47
+ homepage: https://github.com/synalabs/scaleway_data
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ homepage_uri: https://github.com/synalabs/scaleway_data
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.3.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.1.4
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Simple module to get current scaleway data project and region
71
+ test_files: []