ecs_bundler 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 48edd71d441cbac1968e1199612072a07fbaed03
4
+ data.tar.gz: a7ec8e166289e4d786a4fcf81ded2b222f0d62da
5
+ SHA512:
6
+ metadata.gz: 8a32235e2f1d067c22d6cfffffee77f5ed631130bf954a844a1365de0ade3d2c8353633d03c693e8e031c0cd640746db3ff0ae49da88b62db1fab4a1e6c29272
7
+ data.tar.gz: bac2b0c485cb774ddaf8aaf1a349ba5db77a243591a81db80b1c635c9720023c23a4a359cb70bb22bccbaf200717bd6fc95c6ca04b7b7c92f1a916d21797181c
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.ecsrc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "project": "Ruby test",
3
+ "userName": "prizrack13@mail.ru",
4
+ "apiKey": "d8cb326a-9964-46dc-a086-beae9d5b9e9e"
5
+ }
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.15.0
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+ gem 'bundler', '~> 1.0'
3
+ gem 'cli', '~> 1.3.1'
4
+ gem 'rest-client', '~> 2.0.2'
5
+
6
+ group :development do
7
+ gem 'jeweler', '~> 2.3.5'
8
+ gem 'rdoc', '~> 5.1.0'
9
+ gem 'rspec', '~> 3.4'
10
+ gem 'rspec-mocks'
11
+ gem 'rubocop'
12
+ gem 'shoulda', '>= 0'
13
+ gem 'simplecov', '>= 0'
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,139 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (5.1.1)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (~> 0.7)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ addressable (2.5.1)
10
+ public_suffix (~> 2.0, >= 2.0.2)
11
+ ast (2.3.0)
12
+ builder (3.2.3)
13
+ cli (1.3.1)
14
+ concurrent-ruby (1.0.5)
15
+ descendants_tracker (0.0.4)
16
+ thread_safe (~> 0.3, >= 0.3.1)
17
+ diff-lcs (1.3)
18
+ docile (1.1.5)
19
+ domain_name (0.5.20170404)
20
+ unf (>= 0.0.5, < 1.0.0)
21
+ faraday (0.9.2)
22
+ multipart-post (>= 1.2, < 3)
23
+ git (1.3.0)
24
+ github_api (0.11.3)
25
+ addressable (~> 2.3)
26
+ descendants_tracker (~> 0.0.1)
27
+ faraday (~> 0.8, < 0.10)
28
+ hashie (>= 1.2)
29
+ multi_json (>= 1.7.5, < 2.0)
30
+ nokogiri (~> 1.6.0)
31
+ oauth2
32
+ hashie (3.5.5)
33
+ highline (1.7.8)
34
+ http-cookie (1.0.3)
35
+ domain_name (~> 0.5)
36
+ i18n (0.8.4)
37
+ jeweler (2.3.5)
38
+ builder
39
+ bundler (>= 1.0)
40
+ git (>= 1.2.5)
41
+ github_api (~> 0.11.0)
42
+ highline (>= 1.6.15)
43
+ nokogiri (>= 1.5.10)
44
+ psych (~> 2.2)
45
+ rake
46
+ rdoc
47
+ semver2
48
+ json (2.1.0)
49
+ jwt (1.5.6)
50
+ mime-types (3.1)
51
+ mime-types-data (~> 3.2015)
52
+ mime-types-data (3.2016.0521)
53
+ mini_portile2 (2.1.0)
54
+ minitest (5.10.2)
55
+ multi_json (1.12.1)
56
+ multi_xml (0.6.0)
57
+ multipart-post (2.0.0)
58
+ netrc (0.11.0)
59
+ nokogiri (1.6.8.1)
60
+ mini_portile2 (~> 2.1.0)
61
+ oauth2 (1.3.1)
62
+ faraday (>= 0.8, < 0.12)
63
+ jwt (~> 1.0)
64
+ multi_json (~> 1.3)
65
+ multi_xml (~> 0.5)
66
+ rack (>= 1.2, < 3)
67
+ parallel (1.11.2)
68
+ parser (2.4.0.0)
69
+ ast (~> 2.2)
70
+ powerpack (0.1.1)
71
+ psych (2.2.2)
72
+ public_suffix (2.0.5)
73
+ rack (2.0.3)
74
+ rainbow (2.2.2)
75
+ rake
76
+ rake (12.0.0)
77
+ rdoc (5.1.0)
78
+ rest-client (2.0.2)
79
+ http-cookie (>= 1.0.2, < 2.0)
80
+ mime-types (>= 1.16, < 4.0)
81
+ netrc (~> 0.8)
82
+ rspec (3.6.0)
83
+ rspec-core (~> 3.6.0)
84
+ rspec-expectations (~> 3.6.0)
85
+ rspec-mocks (~> 3.6.0)
86
+ rspec-core (3.6.0)
87
+ rspec-support (~> 3.6.0)
88
+ rspec-expectations (3.6.0)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.6.0)
91
+ rspec-mocks (3.6.0)
92
+ diff-lcs (>= 1.2.0, < 2.0)
93
+ rspec-support (~> 3.6.0)
94
+ rspec-support (3.6.0)
95
+ rubocop (0.49.1)
96
+ parallel (~> 1.10)
97
+ parser (>= 2.3.3.1, < 3.0)
98
+ powerpack (~> 0.1)
99
+ rainbow (>= 1.99.1, < 3.0)
100
+ ruby-progressbar (~> 1.7)
101
+ unicode-display_width (~> 1.0, >= 1.0.1)
102
+ ruby-progressbar (1.8.1)
103
+ semver2 (3.4.2)
104
+ shoulda (3.5.0)
105
+ shoulda-context (~> 1.0, >= 1.0.1)
106
+ shoulda-matchers (>= 1.4.1, < 3.0)
107
+ shoulda-context (1.2.2)
108
+ shoulda-matchers (2.8.0)
109
+ activesupport (>= 3.0.0)
110
+ simplecov (0.14.1)
111
+ docile (~> 1.1.0)
112
+ json (>= 1.8, < 3)
113
+ simplecov-html (~> 0.10.0)
114
+ simplecov-html (0.10.1)
115
+ thread_safe (0.3.6)
116
+ tzinfo (1.2.3)
117
+ thread_safe (~> 0.1)
118
+ unf (0.1.4)
119
+ unf_ext
120
+ unf_ext (0.0.7.4)
121
+ unicode-display_width (1.2.1)
122
+
123
+ PLATFORMS
124
+ ruby
125
+
126
+ DEPENDENCIES
127
+ bundler (~> 1.0)
128
+ cli (~> 1.3.1)
129
+ jeweler (~> 2.3.5)
130
+ rdoc (~> 5.1.0)
131
+ rest-client (~> 2.0.2)
132
+ rspec (~> 3.4)
133
+ rspec-mocks
134
+ rubocop
135
+ shoulda
136
+ simplecov
137
+
138
+ BUNDLED WITH
139
+ 1.15.0
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017 Anatoliy Varanitsa
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # ECS Bundler
2
+ [![Gem Version](https://badge.fury.io/rb/ecs_bundler.svg)](https://badge.fury.io/rb/ecs_bundler)
3
+
4
+ Composer module to transfer dependency information to our ECS server. Find the solution at https://ecs-app.eacg.de
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'ecs_bundler'
12
+ ```
13
+
14
+ And then execute:
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```
21
+ $ gem install ecs_bundler
22
+ ```
23
+
24
+ To store your credentials for automated transfer you may create `.ecsrc.json` in your project directory or in your home directory to set credentials globally (not recommended!)
25
+
26
+ `.ecsrc.json` example:
27
+
28
+ ```json
29
+ {
30
+ "userName": "UserName",
31
+ "apiKey": "apiKey",
32
+ "url": "url",
33
+ "project": "Project Description"
34
+ }
35
+
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ You also may initiate transfer to ECS server manually by executing following command via terminal:
41
+
42
+ ```
43
+ ecs_bundler
44
+ ecs_bundler -u userName -k apiKey -p Project
45
+ ecs_bundler -c config.json
46
+ ```
47
+ ```
48
+ Usage: ecs_bundler [switches|options]
49
+ Switches:
50
+ --help (-h) - display this help message
51
+ --version - display version string
52
+ Options:
53
+ --apiKey (-k) - api key
54
+ --userName (-u) - user name
55
+ --url - Base url
56
+ --project (-p) - Project name
57
+ --config (-c) - Config path
58
+ ```
59
+ You also may initiate transfer to ECS server manually by executing following command in rake task or any other place:
60
+ ```ruby
61
+ ECSBundler.run
62
+ ```
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification...
17
+ # see http://guides.rubygems.org/specification-reference/ for more options
18
+ gem.name = 'ecs_bundler'
19
+ gem.homepage = 'http://github.com/eacg-gmbh/ecs-bundler'
20
+ gem.license = 'MIT'
21
+ gem.summary = %(Module for Bundler allowing the transfer of package dependencies to ECS)
22
+ gem.description = %(Module for Bundler allowing the transfer of package dependencies to ECS for further legal and vulnerability analysis. See https://ecs.eacg.de for a detailed service description.)
23
+ gem.email = 'prizrack13@mail.ru'
24
+ gem.authors = ['Anatolii Varanytsia']
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ desc 'Code coverage detail'
30
+ task :simplecov do
31
+ ENV['COVERAGE'] = 'true'
32
+ Rake::Task['test'].execute
33
+ end
34
+
35
+ require 'rspec/core/rake_task'
36
+ RSpec::Core::RakeTask.new(:spec)
37
+
38
+ task default: :spec
39
+
40
+ require 'rdoc/task'
41
+ Rake::RDocTask.new do |rdoc|
42
+ version = File.exist?('VERSION') ? File.read('VERSION') : ''
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "ecs-bundler #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/bin/ecs_bundler ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ if RUBY_VERSION >= '1.9.2'
5
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
6
+
7
+ require 'ecs_bundler'
8
+ ECSBundler.run_cli
9
+
10
+ exit 0
11
+ else
12
+ puts 'ECSBundler supports only Ruby 1.9.2+'
13
+ exit(-1)
14
+ end
@@ -0,0 +1,98 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ # stub: ecs_bundler 1.0.0 ruby lib
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = 'ecs_bundler'.freeze
10
+ s.version = '1.0.0'
11
+
12
+ s.required_rubygems_version = Gem::Requirement.new('>= 0'.freeze) if s.respond_to? :required_rubygems_version=
13
+ s.require_paths = ['lib'.freeze]
14
+ s.authors = ['Anatolii Varanytsia'.freeze]
15
+ s.date = '2017-06-07'
16
+ s.description = 'Module for Bundler allowing the transfer of package dependencies to ECS for further legal and vulnerability analysis. See https://ecs.eacg.de for a detailed service description.'.freeze
17
+ s.email = 'prizrack13@mail.ru'.freeze
18
+ s.executables = ['ecs_bundler'.freeze]
19
+ s.extra_rdoc_files = [
20
+ 'LICENSE.txt',
21
+ 'README.md'
22
+ ]
23
+ s.files = [
24
+ '.document',
25
+ '.ecsrc.json',
26
+ '.rspec',
27
+ '.travis.yml',
28
+ 'Gemfile',
29
+ 'Gemfile.lock',
30
+ 'LICENSE.txt',
31
+ 'README.md',
32
+ 'Rakefile',
33
+ 'VERSION',
34
+ 'bin/ecs_bundler',
35
+ 'ecs_bundler.gemspec',
36
+ 'lib/ecs_bundler.rb',
37
+ 'lib/ecs_bundler/bundler_scanner.rb',
38
+ 'lib/ecs_bundler/bundler_scanner/repository_finder.rb',
39
+ 'lib/ecs_bundler/config.rb',
40
+ 'lib/ecs_bundler/project_specification.rb',
41
+ 'lib/ecs_bundler/rest_client.rb',
42
+ 'lib/ecs_bundler/scan.rb',
43
+ 'lib/ecs_bundler/version.rb',
44
+ 'spec/fixtures/.ecsrc.json',
45
+ 'spec/fixtures/config.json',
46
+ 'spec/lib/ecs_bundler/bundler_scanner/repository_finder_spec.rb',
47
+ 'spec/lib/ecs_bundler/bundler_scanner_spec.rb',
48
+ 'spec/lib/ecs_bundler/config_spec.rb',
49
+ 'spec/lib/ecs_bundler/project_specification_spec.rb',
50
+ 'spec/lib/ecs_bundler/rest_client_spec.rb',
51
+ 'spec/lib/ecs_bundler/scan_spec.rb',
52
+ 'spec/lib/ecs_bundler_spec.rb',
53
+ 'spec/spec_helper.rb'
54
+ ]
55
+ s.homepage = 'http://github.com/eacg-gmbh/ecs-bundler'.freeze
56
+ s.licenses = ['MIT'.freeze]
57
+ s.rubygems_version = '2.6.9'.freeze
58
+ s.summary = 'Module for Bundler allowing the transfer of package dependencies to ECS'.freeze
59
+
60
+ if s.respond_to? :specification_version
61
+ s.specification_version = 4
62
+
63
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0')
64
+ s.add_runtime_dependency('bundler'.freeze, ['~> 1.0'])
65
+ s.add_runtime_dependency('cli'.freeze, ['~> 1.3.1'])
66
+ s.add_runtime_dependency('rest-client'.freeze, ['~> 2.0.2'])
67
+ s.add_development_dependency('jeweler'.freeze, ['~> 2.3.5'])
68
+ s.add_development_dependency('rdoc'.freeze, ['~> 5.1.0'])
69
+ s.add_development_dependency('rspec'.freeze, ['~> 3.4'])
70
+ s.add_development_dependency('rspec-mocks'.freeze, ['>= 0'])
71
+ s.add_development_dependency('rubocop'.freeze, ['>= 0'])
72
+ s.add_development_dependency('shoulda'.freeze, ['>= 0'])
73
+ s.add_development_dependency('simplecov'.freeze, ['>= 0'])
74
+ else
75
+ s.add_dependency('bundler'.freeze, ['~> 1.0'])
76
+ s.add_dependency('cli'.freeze, ['~> 1.3.1'])
77
+ s.add_dependency('rest-client'.freeze, ['~> 2.0.2'])
78
+ s.add_dependency('jeweler'.freeze, ['~> 2.3.5'])
79
+ s.add_dependency('rdoc'.freeze, ['~> 5.1.0'])
80
+ s.add_dependency('rspec'.freeze, ['~> 3.4'])
81
+ s.add_dependency('rspec-mocks'.freeze, ['>= 0'])
82
+ s.add_dependency('rubocop'.freeze, ['>= 0'])
83
+ s.add_dependency('shoulda'.freeze, ['>= 0'])
84
+ s.add_dependency('simplecov'.freeze, ['>= 0'])
85
+ end
86
+ else
87
+ s.add_dependency('bundler'.freeze, ['~> 1.0'])
88
+ s.add_dependency('cli'.freeze, ['~> 1.3.1'])
89
+ s.add_dependency('rest-client'.freeze, ['~> 2.0.2'])
90
+ s.add_dependency('jeweler'.freeze, ['~> 2.3.5'])
91
+ s.add_dependency('rdoc'.freeze, ['~> 5.1.0'])
92
+ s.add_dependency('rspec'.freeze, ['~> 3.4'])
93
+ s.add_dependency('rspec-mocks'.freeze, ['>= 0'])
94
+ s.add_dependency('rubocop'.freeze, ['>= 0'])
95
+ s.add_dependency('shoulda'.freeze, ['>= 0'])
96
+ s.add_dependency('simplecov'.freeze, ['>= 0'])
97
+ end
98
+ end
@@ -0,0 +1,75 @@
1
+ module ECSBundler::BundlerScanner::RepositoryFinder
2
+ GITHUB_REPO_REGEX = %r{(https?):\/\/(www.)?github\.com\/([\w.%-]*)\/([\w.%-]*)}
3
+
4
+ # rails builds several gems that are not individual projects
5
+ # some repos move and the old repo page still exists
6
+ # some repos are not mostly ruby so the github search doesn't find them
7
+ REPO_EXCEPTIONS =
8
+ {
9
+ actioncable: 'rails/rails',
10
+ actionmailer: 'rails/rails',
11
+ actionpack: 'rails/rails',
12
+ actionview: 'rails/rails',
13
+ activejob: 'rails/rails',
14
+ activemodel: 'rails/rails',
15
+ activerecord: 'rails/rails',
16
+ activesupport: 'rails/rails',
17
+ bluepill: 'bluepill-rb/bluepill',
18
+ chunky_png: 'wvanbergen/chunky_png',
19
+ :"color-schemer" => 'at-import/color-schemer',
20
+ delayed_job: 'collectiveidea/delayed_job',
21
+ execjs: 'rails/execjs',
22
+ faraday_middleware: 'lostisland/faraday_middleware',
23
+ flamegraph: 'SamSaffron/flamegraph',
24
+ ffi: 'ffi/ffi',
25
+ :"foundation-rails" => 'zurb/foundation-rails',
26
+ googleauth: 'google/google-auth-library-ruby',
27
+ gosu: 'jlnr/gosu',
28
+ :"guard-livereload" => 'guard/guard-livereload',
29
+ :"jquery-ujs" => 'rails/jquery-ujs',
30
+ json: 'flori/json',
31
+ kaminari: 'kaminari/kaminari',
32
+ :"kaminari-actionview" => 'kaminari/kaminari',
33
+ :"kaminari-activerecord" => 'kaminari/kaminari',
34
+ :"kaminari-core" => 'kaminari/kaminari',
35
+ :"modular-scale" => 'modularscale/modularscale-sass',
36
+ :"net-ssh-gateway" => 'net-ssh/net-ssh-gateway',
37
+ newrelic_rpm: 'newrelic/rpm',
38
+ nokogiri: 'sparklemotion/nokogiri',
39
+ nokogumbo: 'rubys/nokogumbo',
40
+ oauth: 'oauth-xx/oauth-ruby',
41
+ oj: 'ohler55/oj',
42
+ passenger: 'phusion/passenger',
43
+ pg: 'ged/ruby-pg',
44
+ :"pry-doc" => 'pry/pry-doc',
45
+ rails: 'rails/rails',
46
+ railties: 'rails/rails',
47
+ rake: 'ruby/rake',
48
+ resque: 'resque/resque',
49
+ :"resque-multi-job-forks" => 'stulentsev/resque-multi-job-forks',
50
+ representable: 'trailblazer/representable',
51
+ rr: 'rr/rr',
52
+ SassyLists: 'at-import/SassyLists',
53
+ :"Sassy-Maps" => 'at-import/Sassy-Maps',
54
+ :"sassy-math" => 'at-import/Sassy-math',
55
+ settingslogic: 'settingslogic/settingslogic',
56
+ sinatra: 'sinatra/sinatra',
57
+ stripe: 'stripe/stripe-ruby',
58
+ thread_safe: 'ruby-concurrency/thread_safe',
59
+ tolk: 'tolk/tolk',
60
+ toolkit: 'at-import/tookit',
61
+ :"trailblazer-cells" => 'trailblazer/trailblazer-cells',
62
+ turbolinks: 'turbolinks/turbolinks',
63
+ :"twitter-text" => 'twitter/twitter-text',
64
+ zeus: 'burke/zeus'
65
+ }.freeze
66
+
67
+ class << self
68
+ def url(spec)
69
+ return "https://github.com/#{REPO_EXCEPTIONS[spec.name.to_sym]}" unless REPO_EXCEPTIONS[spec.name.to_sym].nil?
70
+ return spec.homepage if spec.homepage =~ GITHUB_REPO_REGEX
71
+ match = spec.description.to_s.match(GITHUB_REPO_REGEX)
72
+ match && match[0]
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ECSBundler
4
+ class BundlerScanner
5
+ class << self
6
+ def run
7
+ project_specification = ProjectSpecification.new
8
+ {
9
+ project: ECSBundler.config[:project],
10
+ module: project_specification.name,
11
+ moduleId: "bundler:#{project_specification.name}",
12
+ dependencies: [specification_to_h(project_specification)]
13
+ }
14
+ end
15
+
16
+ private
17
+
18
+ def specification_to_h(spec)
19
+ {
20
+ name: spec.name,
21
+ key: "bundler:#{spec.name}",
22
+ description: spec.description,
23
+ private: true,
24
+ licenses: spec.license ? [{ name: spec.license }] : [],
25
+ homepageUrl: spec.homepage,
26
+ repoUrl: RepositoryFinder.url(spec),
27
+ versions: [spec.version.to_s].compact,
28
+ dependencies: spec.runtime_dependencies.map { |dependency| specification_to_h(dependency.to_spec) }
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module ECSBundler
6
+ class Config
7
+ FILE_NAME = '/.ecsrc.json'.freeze
8
+ URL = 'https://ecs-app.eacg.de'.freeze
9
+ attr_reader :data
10
+
11
+ def initialize
12
+ @data = get_default_options
13
+ end
14
+
15
+ def load(path = nil)
16
+ path = [path, Dir.pwd, ENV['HOME']].flatten.compact.map do |path|
17
+ if File.directory?(path) && File.exist?("#{path}#{FILE_NAME}")
18
+ "#{path}#{FILE_NAME}"
19
+ elsif File.file?(path) && File.exist?(path)
20
+ path
21
+ end
22
+ end.compact.first
23
+ @data = get_default_options.merge(::JSON.parse(File.read(path)).map { |k, v| [k.to_sym, v] }.to_h) if path
24
+ rescue
25
+ end
26
+
27
+ def [](key)
28
+ @data[key]
29
+ end
30
+
31
+ private
32
+
33
+ def get_default_options
34
+ { url: URL, project: '', apiKey: '', userName: '', userAgent: "#{ECSBundler.name}/#{VERSION}" }
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler'
3
+
4
+ module ECSBundler
5
+ class ProjectSpecification
6
+ def name
7
+ return Rails.application.class.parent.name if defined?(Rails)
8
+ ECSBundler.config[:project].gsub(/[^a-zA-Z]+/, '-')
9
+ end
10
+
11
+ def description; end
12
+
13
+ def license; end
14
+
15
+ def homepage; end
16
+
17
+ def version
18
+ path = [
19
+ (Rails.root.join('VERSION') if defined?(Rails)),
20
+ "#{Dir.pwd}/VERSION"
21
+ ].compact.find { |path| File.exist?(path) }
22
+ path ? File.read(path) : nil
23
+ end
24
+
25
+ def runtime_dependencies
26
+ Bundler.load.current_dependencies
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ module ECSBundler
7
+ # Wrapper under rest-client with authorization headers
8
+ class RestClient
9
+ attr_reader :options
10
+
11
+ def initialize(options = {})
12
+ @options = options
13
+ end
14
+
15
+ def headers
16
+ {
17
+ content_type: :json,
18
+ accept: :json,
19
+ 'User-Agent' => options[:userAgent],
20
+ 'X-ApiKey' => options[:apiKey],
21
+ 'X-User' => options[:userName]
22
+ }
23
+ end
24
+
25
+ def respond_to?(name)
26
+ return true if %i[get delete head options post patch put].include?(name)
27
+ super(name)
28
+ end
29
+
30
+ # get delete head options post patch put methods
31
+ def method_missing(name, *args)
32
+ if %i[get delete head options post patch put].include?(name)
33
+ if %i[get delete head options].include?(name)
34
+ path, headers = args
35
+ payload = nil
36
+ else
37
+ path, payload, headers = args
38
+ end
39
+ return ::RestClient::Request.execute(
40
+ method: name,
41
+ url: "#{options[:url]}#{path}",
42
+ payload: payload ? payload.to_json : payload,
43
+ headers: self.headers.merge(headers || {})
44
+ ) do |response|
45
+ parsed_response = JSON.parse(response.body) rescue {}
46
+ message = [
47
+ "#{response.code} #{::RestClient::STATUSES[response.code]}",
48
+ parsed_response['info'],
49
+ (parsed_response['messages'] || []).map { |message| message['message'] }
50
+ ].compact.join(', ')
51
+ yield(response, parsed_response, message) if block_given?
52
+ response
53
+ end
54
+ end
55
+ super(name, *args)
56
+ end
57
+ end
58
+ end