unleash-admin 0.1.0

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: c83cc5b1c1ab2e784cafa1192f10f62cdbde1b9bb6ec7427eb711ea39d8b228b
4
+ data.tar.gz: a3cacb91a840f0134bd4f2b4872854e27f88e9231215ecf9f0f201d84d919193
5
+ SHA512:
6
+ metadata.gz: 654b59d996ed09bb889864b5aedfbfbfb742610ab65c79ea6c9bee81ed46a5f9ec4690b4fd40266937e0607a0fec9acdedb242673d2d91b5a990fef94bfc1195
7
+ data.tar.gz: 6e0253a7b24d7fe07ad9ed57ac3e5ad4c91d9cb57064a51197a69c28eef6be2273feacfaadca87071758081fb42e57df9c09aea9deb46cc40e9dc324acc37c24
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 doew
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,35 @@
1
+ # Unleash::Admin
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/unleash/admin`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ 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.
26
+
27
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/unleash-admin.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,45 @@
1
+ require "uri"
2
+ require "net/http"
3
+ require "json"
4
+ # frozen_string_literal: true
5
+
6
+ module Unleash
7
+ module Admin
8
+ class Client
9
+ def initialize(config = Unleash::Admin.configuration)
10
+ @config = config
11
+ end
12
+
13
+ def get_features
14
+ api_call(:get, "/api/admin/projects/#{@config.project}/features")
15
+ end
16
+
17
+ def api_call(method, path, body = nil)
18
+ url = URI.parse(@config.server_url + path)
19
+ case method
20
+ when :get
21
+ request = Net::HTTP::Get.new(url)
22
+ when :post
23
+ request = Net::HTTP::Post.new(url)
24
+ when :put
25
+ request = Net::HTTP::Put.new(url)
26
+ when :delete
27
+ request = Net::HTTP::Delete.new(url)
28
+ end
29
+ request["Accept"] = "application/json"
30
+ request["Authorization"] = @config.admin_api_key
31
+ request.body = body if body
32
+ use_ssl = url.scheme == "https"
33
+ response = Net::HTTP.start(url.hostname, url.port, use_ssl: use_ssl) do |http|
34
+ http.request(request)
35
+ end
36
+
37
+ raise NotFoundError if response.code == "404"
38
+
39
+ [response.code, JSON.parse(response.body)]
40
+ end
41
+
42
+ class NotFoundError < StandardError; end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unleash
4
+ module Admin
5
+ class Configuration
6
+ attr_accessor :admin_api_key, :server_url, :project, :environment
7
+
8
+ def initialize
9
+ @admin_api_key = ENV.key?('UNLEASH_ADMIN_API_KEY') ? ENV['UNLEASH_ADMIN_API_KEY'] : 'dummy'
10
+ @server_url = ENV.key?('UNLEASH_SERVER_URL') ? ENV['UNLEASH_SERVER_URL'] : 'http://localhost:4242'
11
+ @project = ENV.key?('UNLEASH_PROJECT_NAME') ? ENV['UNLEASH_PROJECT_NAME'] : 'default'
12
+ @environment = ENV.key?('UNLEASH_ENVIRONMENT') ? ENV['UNLEASH_ENVIRONMENT'] : 'development'
13
+
14
+ yield(self) if block_given?
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unleash
4
+ module Admin
5
+ class Environment
6
+ def initialize
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unleash
4
+ module Admin
5
+ class Feature
6
+ attr_accessor :name, :description, :project, :enabled, :stale, :favorite, :impression_data, :created_at, :archived_at
7
+
8
+ def initialize(name, description, project, enabled, stale, favorite, impression_data, created_at, archived_at)
9
+ @name = name
10
+ @description = description
11
+ @project = project
12
+ @enabled = enabled
13
+ @stale = stale
14
+ @favorite = favorite
15
+ @impression_data = impression_data
16
+ @created_at = created_at
17
+ @archived_at = archived_at
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unleash
4
+ module Admin
5
+ class Project
6
+ def get_features
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ require 'zeitwerk'
2
+ # frozen_string_literal: true
3
+
4
+ module Unleash
5
+ module Admin
6
+ VERSION = "0.1.0"
7
+ end
8
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zeitwerk"
4
+ loader = Zeitwerk::Loader.new
5
+ loader.push_dir(__dir__+"/../")
6
+ loader.setup
7
+
8
+ module Unleash
9
+ module Admin
10
+ class << self
11
+ def configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def configure
16
+ self.configuration ||= Configuration.new
17
+ yield(configuration)
18
+ end
19
+ end
20
+ class Error < StandardError; end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ module Unleash
2
+ module Admin
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unleash-admin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - doew
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: zeitwerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ description: Unleash Admin api client gem.
28
+ email:
29
+ - git@doew.jp
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".rubocop.yml"
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/unleash/admin.rb
40
+ - lib/unleash/admin/client.rb
41
+ - lib/unleash/admin/configuration.rb
42
+ - lib/unleash/admin/environtment.rb
43
+ - lib/unleash/admin/feature.rb
44
+ - lib/unleash/admin/project.rb
45
+ - lib/unleash/admin/version.rb
46
+ - sig/unleash/admin.rbs
47
+ homepage: https://github.com/doew/unleash-admin-gem
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ allowed_push_host: https://rubygems.org/
52
+ homepage_uri: https://github.com/doew/unleash-admin-gem
53
+ source_code_uri: https://github.com/doew/unleash-admin-gem
54
+ changelog_uri: https://github.com/doew/unleash-admin-gem/releases
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.6.0
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.4.22
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Unleash Admin api client gem.
74
+ test_files: []