yade-common 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: 526eb2936e6f41cd8a7466ce4474c6b59f8ef884cfb5c56ac36aefa1c03377d7
4
+ data.tar.gz: e7d4523c64c7404c614e182c118452ae7825c9dc9b5b9da0904c7632f62ff0ac
5
+ SHA512:
6
+ metadata.gz: e4a2deb5b2d4e2f26f44644fe327e420d07cf53a987b18d13108d7ddf39c8cfe6a3ac1e67107bb77d36a972748a54a0b9d28bcb70388d30a0aa33198f294e8fa
7
+ data.tar.gz: 43f6c45d5e0ac94f6817f689a507f7c623b65bd33dee60423cfa25830bcac3a52f1ec25ca76fc299f790f783dd7041af2942639d8f91b518982ce7ac365005c2
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .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,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.4
7
+ before_install: gem install bundler -v 1.16.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at seba1403@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
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 yade-common.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yade-common (0.1.1)
5
+ activemodel (~> 5.2)
6
+ httparty (~> 0.15)
7
+ settingslogic (~> 2.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activemodel (5.2.1)
13
+ activesupport (= 5.2.1)
14
+ activesupport (5.2.1)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ ast (2.4.0)
20
+ concurrent-ruby (1.0.5)
21
+ diff-lcs (1.3)
22
+ httparty (0.16.2)
23
+ multi_xml (>= 0.5.2)
24
+ i18n (1.1.0)
25
+ concurrent-ruby (~> 1.0)
26
+ jaro_winkler (1.5.1)
27
+ minitest (5.11.3)
28
+ multi_xml (0.6.0)
29
+ parallel (1.12.1)
30
+ parser (2.5.1.2)
31
+ ast (~> 2.4.0)
32
+ powerpack (0.1.2)
33
+ rainbow (3.0.0)
34
+ rake (10.5.0)
35
+ rspec (3.8.0)
36
+ rspec-core (~> 3.8.0)
37
+ rspec-expectations (~> 3.8.0)
38
+ rspec-mocks (~> 3.8.0)
39
+ rspec-core (3.8.0)
40
+ rspec-support (~> 3.8.0)
41
+ rspec-expectations (3.8.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.8.0)
44
+ rspec-json_expectations (2.1.0)
45
+ rspec-mocks (3.8.0)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.8.0)
48
+ rspec-support (3.8.0)
49
+ rubocop (0.58.2)
50
+ jaro_winkler (~> 1.5.1)
51
+ parallel (~> 1.10)
52
+ parser (>= 2.5, != 2.5.1.1)
53
+ powerpack (~> 0.1)
54
+ rainbow (>= 2.2.2, < 4.0)
55
+ ruby-progressbar (~> 1.7)
56
+ unicode-display_width (~> 1.0, >= 1.0.1)
57
+ ruby-progressbar (1.10.0)
58
+ settingslogic (2.0.9)
59
+ thread_safe (0.3.6)
60
+ tzinfo (1.2.5)
61
+ thread_safe (~> 0.1)
62
+ unicode-display_width (1.4.0)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ bundler (~> 1.16)
69
+ rake (~> 10.0)
70
+ rspec (~> 3.0)
71
+ rspec-json_expectations (~> 2.1)
72
+ rubocop (~> 0.58.0)
73
+ yade-common!
74
+
75
+ BUNDLED WITH
76
+ 1.16.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Sebastian Freund
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,43 @@
1
+ # Yade::Project::Common
2
+
3
+ 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/yade/common`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'yade-common'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install yade-common
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yade-common. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Yade::Project::Common project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/yade-common/blob/master/CODE_OF_CONDUCT.md).
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 "yade/common"
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,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+ require 'base64'
5
+
6
+ # yadecli cli
7
+ module Yade
8
+ module Common
9
+ module Client
10
+ # authentication client
11
+ class AuthenticationClient
12
+ include HTTParty
13
+ include Yade::Common::Config
14
+
15
+ #
16
+ def initialize
17
+ client_id = 'web_app'
18
+ client_secret = 'changeit'
19
+
20
+ # Basic d2ViX2FwcDpjaGFuZ2VpdA==
21
+ # The BASE64 encoded value of your 'clientId + ":" + clientSecret'
22
+ @authorization = "Basic #{Base64.encode64("#{client_id}:#{client_secret}")}"
23
+ end
24
+
25
+ # login
26
+ def login(auth_url, auth_username, auth_password)
27
+ response = request_token(auth_url, auth_username, auth_password)
28
+
29
+ parsed_response = response.parsed_response
30
+
31
+ access_token = parsed_response['access_token']
32
+ refresh_token = parsed_response['refresh_token']
33
+ expiration_time = Time.now + parsed_response['expires_in']
34
+
35
+ authentication = Yade::Common::Model::Authentication.new(auth_url: auth_url,
36
+ auth_username: auth_username,
37
+ auth_password: auth_password,
38
+ access_token: access_token,
39
+ refresh_token: refresh_token,
40
+ expiration_time: expiration_time)
41
+
42
+ authentication.write
43
+
44
+ authentication
45
+ end
46
+
47
+ # logout
48
+ def logout
49
+ authentication = Yade::Common::Model::Authentication.new(auth_url: '',
50
+ auth_username: '',
51
+ auth_password: '',
52
+ access_token: '',
53
+ refresh_token: '',
54
+ expiration_time: '')
55
+
56
+ authentication.write
57
+ end
58
+
59
+ def access_token
60
+ authentication = Yade::Common::Model::Authentication.new
61
+
62
+ authentication.read
63
+
64
+ if Time.now > Time.parse(authentication.expiration_time)
65
+ response = refresh_token(authentication.auth_url, authentication.refresh_token)
66
+
67
+ if response.code == 200
68
+ authentication.access_token = response['access_token']
69
+ else
70
+ response = request_token(authentication.auth_url, authentication.auth_username,
71
+ authentication.auth_password)
72
+ authentication.access_token = response['access_token']
73
+ authentication.refresh_token = response['refresh_token']
74
+ authentication.expiration_time = Time.now + response['expires_in']
75
+ end
76
+
77
+ authentication.write
78
+ end
79
+
80
+ authentication.access_token
81
+ end
82
+
83
+ private
84
+
85
+ # request token
86
+ def request_token(auth_url, auth_username, auth_password)
87
+ options = { headers: { Accept: 'application/json', Authorization: @authorization } }
88
+
89
+ self.class.base_uri auth_url
90
+
91
+ self.class.post("/oauth/token?username=#{auth_username}&password=#{auth_password}&grant_type=password", options)
92
+ end
93
+
94
+ # refresh token
95
+ def refresh_token(auth_url, refresh_token)
96
+ # curl -X POST -H 'Authorization: Basic d2ViX2FwcDpjaGFuZ2VpdA==' \
97
+ # -d "refresh_token=${...}&grant_type=refresh_token" \
98
+ # 'http://host.com:9999/oauth/token'
99
+ options = {
100
+ headers: { Accept: 'application/json', Authorization: @authorization },
101
+ body: { refresh_token: refresh_token, grant_type: 'refresh_token' }
102
+ }
103
+
104
+ self.class.base_uri auth_url
105
+
106
+ self.class.post('/oauth/token', options)
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ # yadecli cli
4
+ module Yade
5
+ module Common
6
+ module Client
7
+ # base client
8
+ class BaseClient
9
+ # initialize
10
+ # prepare options hash with authorization header for httpparty requests
11
+ def initialize(microservice, resource_name, model_class)
12
+ @microservice = microservice
13
+ @resource_name = resource_name
14
+ @model_class = model_class
15
+
16
+ @authentication_client = Yade::Common::Client::AuthenticationClient.new
17
+ @options = { headers: { Authorization: "Bearer #{@authentication_client.access_token}", 'Content-Type' => 'application/json' } }
18
+ end
19
+
20
+ # list all
21
+ def list
22
+ response = self.class.get(base_path, @options)
23
+
24
+ response.parsed_response.map do |p|
25
+ create_instance.new(p)
26
+ end
27
+ end
28
+
29
+ # get by id
30
+ def get(id)
31
+ response = get_request("#{id}")
32
+
33
+ if response.success?
34
+ create_instance.new(response.parsed_response)
35
+ else
36
+ raise "Unable to make get request. Response code was #{response.code}"
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def get_request(path = nil)
43
+ self.class.get(full_path(path), @options)
44
+ end
45
+
46
+ def full_path(path = nil)
47
+ full_path = base_path
48
+ full_path += "/#{path}" if path != nil
49
+
50
+ full_path
51
+ end
52
+
53
+ def base_path
54
+ if @resource_name.end_with? 's'
55
+ "/#{@microservice}/api/#{@resource_name}"
56
+ else
57
+ "/#{@microservice}/api/#{@resource_name}s"
58
+ end
59
+ end
60
+
61
+ def create_instance
62
+ Object.const_get(@model_class)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yade/common/version'
4
+
5
+ require 'yade/common/config/app_config'
6
+ require 'yade/common/config/composer_config'
7
+
8
+ require 'yade/common/model/authentication'
9
+
10
+ require 'yade/common/client/authentication_client'
11
+ require 'yade/common/client/base_client'
12
+
13
+ module Yade
14
+ module Common
15
+ # Your code goes here...
16
+ end
17
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'settingslogic'
4
+
5
+ module Yade
6
+ module Common
7
+ module Config
8
+ class AppConfig < Settingslogic
9
+ @@yade_home = File.join(File.expand_path('~'), '.yade')
10
+ @@config_path = File.join(@@yade_home, 'yade-config.yml')
11
+
12
+ @@project_home = File.join(File.expand_path('~'), 'yade', 'projects')
13
+
14
+ source File.join(@@config_path)
15
+
16
+ class << self
17
+ attr_accessor :yade_home, :config_path, :project_home
18
+ end
19
+
20
+ def self.load!
21
+ if no_config_file?
22
+ $stderr.puts <<-HELP
23
+ ******** You haven't set up your Yade settings file. **********
24
+ Please do the following:
25
+ 1. Create the yade base directory and download the yade-config.yml example:
26
+ mkdir -p ~/.yade
27
+ cd ~/.yade
28
+ curl --header 'PRIVATE-TOKEN: <your token>' \
29
+ 'http://gitlab.dzbw.de/client/v4/projects/366/repository/files/yade-config%2Eyml%2Eexample/raw?ref=master' \
30
+ -o yade-config.yml
31
+ 2. Have a look at the settings in that file and change it according to your needs.
32
+ HELP
33
+ Process.exit(1)
34
+ end
35
+
36
+ super
37
+
38
+ end
39
+
40
+ # no config
41
+ def self.no_config_file?
42
+ !File.exists?(@source)
43
+ end
44
+
45
+ load!
46
+
47
+ def self.[](key)
48
+ return @@yade_home if key == :yade_home
49
+ return @@config_path if key == :config_path
50
+ return @@project_home if key == :project_home
51
+
52
+ super
53
+ end
54
+
55
+ def self.write!
56
+ d = YAML.load_file(@@config_path)
57
+
58
+ d['yade_url'] = self.yade_url
59
+
60
+ File.open(@@config_path, 'w') { |f| f.write d.to_yaml }
61
+ end
62
+
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'settingslogic'
4
+
5
+ module Yade
6
+ module Common
7
+ module Config
8
+ class ComposerConfig < Settingslogic
9
+ @@yade_home = File.join(File.expand_path('~'), '.yade')
10
+ @@config_path = File.join(@@yade_home, 'yade-composer-config.yml')
11
+
12
+ @@composer_home = File.join(File.expand_path('~'), 'yade', 'composer')
13
+
14
+ source File.join(@@config_path)
15
+
16
+ class << self
17
+ attr_accessor :yade_home, :config_path, :composer_home
18
+ end
19
+
20
+ def self.load!
21
+ if no_config_file?
22
+ $stderr.puts <<-HELP
23
+ ******** You haven't set up your Yade Composer settings file. **********
24
+ Please do the following:
25
+ 1. Create the yade base directory and download the yade-composer-config.yml example:
26
+ mkdir -p ~/.yade
27
+ cd ~/.yade
28
+ curl --header 'PRIVATE-TOKEN: <your token>' \
29
+ 'http://gitlab.dzbw.de/client/v4/projects/366/repository/files/yade-composer-config%2Eyml%2Eexample/raw?ref=master' \
30
+ -o yade-composer-config.yml
31
+ 2. Have a look at the settings in that file and change it according to your needs.
32
+ HELP
33
+ Process.exit(1)
34
+ end
35
+
36
+ super
37
+
38
+ end
39
+
40
+ # no config
41
+ def self.no_config_file?
42
+ !File.exists?(@source)
43
+ end
44
+
45
+ load!
46
+
47
+ def self.[](key)
48
+ return @@yade_home if key == :yade_home
49
+ return @@config_path if key == :config_path
50
+ return @@composer_home if key == :composer_home
51
+
52
+ super
53
+ end
54
+
55
+ def self.write!
56
+ d = YAML.load_file(@@config_path)
57
+
58
+ d['git_api_url'] = self.git_api_url
59
+ d['git_username'] = self.git_username
60
+ d['git_password'] = self.git_password
61
+ d['git_token'] = self.git_token
62
+ d['docker_registry_url'] = self.docker_registry_url
63
+ d['docker_registry_username'] = self.docker_registry_username
64
+ d['docker_registry_password'] = self.docker_registry_password
65
+
66
+ File.open(@@config_path, 'w') { |f| f.write d.to_yaml }
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+ require 'json'
5
+
6
+ module Yade
7
+ module Common
8
+ module Model
9
+ # authentication
10
+ class Authentication
11
+ include ActiveModel::Model
12
+ include ActiveModel::Validations
13
+ include ActiveModel::Serializers::JSON
14
+
15
+ attr_accessor :auth_url, :auth_username, :auth_password, :access_token,
16
+ :refresh_token, :expiration_time
17
+
18
+ validates_presence_of 'auth_url', 'auth_username', 'auth_password', 'access_token', 'refresh_token',
19
+ 'expiration_time'
20
+
21
+ def attributes
22
+ instance_values
23
+ end
24
+
25
+ # write
26
+ def write
27
+ json = as_json.to_json
28
+
29
+ File.open("#{ENV['HOME']}/.yade/authentication.json", 'w') do |f|
30
+ f.write(json)
31
+ end
32
+ end
33
+
34
+ # read
35
+ def read
36
+ from_json(File.read("#{ENV['HOME']}/.yade/authentication.json"))
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # yadecli cli
4
+ module Yade
5
+ module Common
6
+ module Service
7
+ # base service
8
+ class BaseService
9
+ # initialize
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # list all
15
+ def list
16
+ @client.list
17
+ end
18
+
19
+ # get by id
20
+ def get(id)
21
+ @client.get(id)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yade
4
+ module Common
5
+ VERSION = '0.1.1'
6
+ end
7
+ end
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yade/common/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'yade-common'
8
+ spec.version = Yade::Common::VERSION
9
+ spec.authors = ['Sebastian Freund']
10
+ spec.email = ['seba1403@gmail.com']
11
+
12
+ spec.summary = 'Yade Common'
13
+ spec.description = 'Yade Common'
14
+ spec.homepage = 'https://gitlab.com/yadedev/yade-common'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
23
+ # end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ['lib']
33
+
34
+ spec.add_dependency 'settingslogic', '~> 2.0'
35
+ spec.add_dependency 'httparty', '~> 0.15'
36
+ spec.add_dependency 'activemodel', '~> 5.2'
37
+
38
+ spec.add_development_dependency 'bundler', '~> 1.16'
39
+ spec.add_development_dependency 'rake', '~> 10.0'
40
+ spec.add_development_dependency 'rspec', '~> 3.0'
41
+ spec.add_development_dependency 'rspec-json_expectations', '~> 2.1'
42
+ spec.add_development_dependency 'rubocop', '~> 0.58.0'
43
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yade-common
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian Freund
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: settingslogic
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activemodel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-json_expectations
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.58.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.58.0
125
+ description: Yade Common
126
+ email:
127
+ - seba1403@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".travis.yml"
135
+ - CODE_OF_CONDUCT.md
136
+ - Gemfile
137
+ - Gemfile.lock
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - bin/console
142
+ - bin/setup
143
+ - lib/yade/common/client/authentication_client.rb
144
+ - lib/yade/common/client/base_client.rb
145
+ - lib/yade/common/common.rb
146
+ - lib/yade/common/config/app_config.rb
147
+ - lib/yade/common/config/composer_config.rb
148
+ - lib/yade/common/model/authentication.rb
149
+ - lib/yade/common/service/base_service.rb
150
+ - lib/yade/common/version.rb
151
+ - yade-common.gemspec
152
+ homepage: https://gitlab.com/yadedev/yade-common
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.7.7
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Yade Common
176
+ test_files: []