sys_lib_detector 0.1.1

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: 021ed26b0412910307df6c158d9311de498ff518
4
+ data.tar.gz: 79c5851f9c6e2457f6b58813b4ee1279bf289d3b
5
+ SHA512:
6
+ metadata.gz: 878ddd8ac643df79238ec2a46a9c8c234d36dda067982dd06a5c4a78a166c66d4623d08a5a7532cbf301c1f24c2af69f1fca25456185c9f49892a7cd828747a4
7
+ data.tar.gz: a37cbe9f2d39fcc59ab2505f643d86acc4b0409f703c5eaf3d4f7d82e49acaaaddfee141fdc65272385bf74279d3f1a1d22b1dfe6bdf494458f63a405f539733
data/.document ADDED
@@ -0,0 +1,4 @@
1
+ lib/**/*.rb
2
+ -
3
+ features/**/*.feature
4
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+ .DS_Store
11
+
12
+ # rspec failure tracking
13
+ .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,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hussein.abumash@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [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 sys_lib_detector.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
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,39 @@
1
+ # SysLibDetector
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/sys_lib_detector`. 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 'sys_lib_detector'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install sys_lib_detector
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/HusseinReda/sys_lib_detector.
36
+
37
+ ## License
38
+
39
+ 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,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 "sys_lib_detector"
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,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'sys_lib_detector/cli'
3
+
4
+ SysLibDetector::Cli.start
@@ -0,0 +1,63 @@
1
+ require "thor"
2
+ require "sys_lib_detector"
3
+
4
+ module SysLibDetector
5
+ # The command-line interface class, responsible for the commands of running
6
+ # the gem's funcionalities, using Thor's gem
7
+ class Cli < Thor
8
+
9
+ desc "list_all_gems", "Listing all the local gems existing in the porject"
10
+ # Listing the local gems existing in the porject
11
+ def list_all_gems
12
+ gems = get_gems
13
+ if gems.empty?
14
+ puts "You don't have any gems installed"
15
+ else
16
+ puts gems
17
+ end
18
+ end
19
+
20
+ desc "list_sys_libs", "Retrieving gems' dependant system libraries "
21
+ # Retrieving the required system libraries for the project's local gems via
22
+ # sending the retrieval request to the web-service, and then displaying
23
+ # it in a friendly way using the Displayer class
24
+ def list_sys_libs
25
+ gems = get_gems
26
+ os = get_os_name
27
+ begin
28
+ web_service_handler = get_web_service_handler
29
+ response = web_service_handler.retrieve_sys_libraries(gems, os)
30
+
31
+ response = clean_response(response)
32
+
33
+ Displayer::diplay_list_sys_libs(response, gems)
34
+ rescue Exception::NoInternetConnection
35
+ abort "Please check your internet connectivity"
36
+ end
37
+ end
38
+
39
+ private
40
+ # private method for getting the project's local gems
41
+ def get_gems
42
+ return GemsCollector.get_all
43
+ end
44
+
45
+ # private method for getting the running operating system's name
46
+ def get_os_name
47
+ return SystemDetector.get_os_name
48
+ end
49
+
50
+ # private method for initializing a new handler for the web-service
51
+ def get_web_service_handler
52
+ return WebServiceCommunicator.new
53
+ end
54
+
55
+ # private method for cleaning up the web-service's response from empty
56
+ # values, for gems that exist in the web-service but doesn't have
57
+ # libraries attached yet
58
+ # @param json_object [Json] The json response of web-service
59
+ def clean_response(json_object)
60
+ return json_object.delete_if {|key, value| value.nil? || value.empty?}
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,53 @@
1
+ module SysLibDetector
2
+ # Class responsible for displaying the results of the
3
+ # command line interface class
4
+ class Displayer
5
+ # Displaying the system libraries retrieved
6
+ # @param response [Json] The json response of web-service
7
+ # in format { gem_1: [a,b,c], gem_2: [x,y,z] }
8
+ # @param gems [Array] The current project's gems' names
9
+ def self.diplay_list_sys_libs(response, gems)
10
+ display_header(response, gems)
11
+
12
+ response.each do |gemm, libraries|
13
+ puts "#{gemm}:"
14
+ libraries.each do |library|
15
+ puts " #{library}"
16
+ end
17
+ end
18
+
19
+ # display_footer if response.count > 0
20
+ end
21
+
22
+ private
23
+
24
+ def self.gems_with_libraries_count(response)
25
+ return response.keys.count
26
+ end
27
+
28
+ # Displaying the header message after recieving the web-service response
29
+ # @param response [Json] The json response of web-service
30
+ # in format { gem_1: [a,b,c], gem_2: [x,y,z] }
31
+ # @param gems [Array] The current project's gems' names
32
+ def self.display_header(response, gems)
33
+ gems_found_count = gems_with_libraries_count(response)
34
+ all_found = gems_found_count == gems.count
35
+
36
+ if(gems_found_count == 0)
37
+ puts "No system libraries found for your gems, you can contribute by adding libraries!"
38
+ puts "For more details check https://github.com/HusseinReda/SysLibDetectorGem#contributing"
39
+ return
40
+ end
41
+
42
+ if(all_found)
43
+ puts "Required system libraries found for all your gems!"
44
+ else
45
+ puts "Required system libraries found for gems: #{response.keys.join(", ")}"
46
+ end
47
+ end
48
+
49
+ # def self.display_footer
50
+ # puts "\nTo install the required system libraries listed, run 'sys-lib-detector install-sys-libs'"
51
+ # end
52
+ end
53
+ end
@@ -0,0 +1,12 @@
1
+ module SysLibDetector
2
+ # Namespace for the exceptions classes
3
+ module Exception
4
+ # Standard error exception
5
+ class Error < StandardError
6
+ end
7
+
8
+ # No internet connectivity exception
9
+ class NoInternetConnection < Error
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # Namespace for classes handling the whole process of the gem
2
+ # from collecting the projects' gem, going through system libraries retrieval,
3
+ # till displaying the results or installing the required system libraries
4
+
5
+ module SysLibDetector
6
+ # Class responsible for collecting the projects' local gems
7
+ class GemsCollector
8
+ # Getting all the projects' local gems
9
+ def self.get_all
10
+ Bundler.load.specs.map(&:name)
11
+ end
12
+ end
13
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ require 'system'
2
+
3
+ module SysLibDetector
4
+ # Class responsible for getting information about the current system
5
+ class SystemDetector
6
+ # Getting the running operating system's name
7
+ def self.get_os_name
8
+ return System::OS.name
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module SysLibDetector
2
+ # current version of the gem
3
+ VERSION = "0.1.1"
4
+ end
@@ -0,0 +1,48 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module SysLibDetector
5
+ # Handler for the communication with the web-service for retrieving
6
+ # the required system libraries
7
+ class WebServiceCommunicator
8
+ # Url for the web-service libraries retrieval endpoint
9
+ SERVICE_URL = "https://sys-libraries.herokuapp.com/libraries"
10
+
11
+ # Initializing the handler object, with a check for internet connectivity
12
+ def initialize
13
+ # checking internet connectivity
14
+ raise Exception::NoInternetConnection if ping != :pong
15
+
16
+ @url = SERVICE_URL
17
+ end
18
+
19
+ # Retrieving the required system libraries by sending a get request
20
+ # to the web-service with the gems' names and running operating system
21
+ # @param gems_names [Array] The current project's gems' names
22
+ # @param os_name [String] The operating system's name as a symbol (:linux, :osx, :windows)
23
+ # @return [Json] The web-services's response,
24
+ # in format { gem_1: [a,b,c], gem_2: [x,y,z] }
25
+ def retrieve_sys_libraries(gems_names, os_name)
26
+ params = {
27
+ gems: gems_names,
28
+ os: os_name
29
+ }
30
+ response = JSON.parse(RestClient.get(@url, {params: params}))
31
+ end
32
+
33
+ private
34
+
35
+ # Pinging google.com for checking the internet connectivity, by
36
+ # making a simple get request to www.google.com
37
+ def ping
38
+ begin
39
+ RestClient.get("https://www.google.com")
40
+ return :pong
41
+ rescue SocketError => e
42
+ return e
43
+ rescue Errno::ECONNREFUSED => e
44
+ return e
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ require "sys_lib_detector/version"
2
+ require "sys_lib_detector/gems_collector"
3
+ require "sys_lib_detector/system_detector"
4
+ require "sys_lib_detector/web_service_communicator"
5
+ require "sys_lib_detector/displayer"
6
+ require "sys_lib_detector/installer"
7
+ require "sys_lib_detector/exceptions"
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "sys_lib_detector/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sys_lib_detector"
8
+ spec.version = SysLibDetector::VERSION
9
+ spec.authors = ["Hussein Abu Maash"]
10
+ spec.email = ["hussein.abumaash@gmail.com"]
11
+
12
+ spec.summary = "Listing and installing gems' system libraries"
13
+ spec.description = "SysLibDetector lists and installs all the gems' system libraries and native dependencies"
14
+ spec.homepage = "https://github.com/HusseinReda/SysLibDetectorGem"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ # spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_dependency "system", "~> 0.1"
28
+ spec.add_dependency "rest-client", "~> 2.0"
29
+ spec.add_dependency "json", "~> 2.1"
30
+ spec.add_dependency "thor"
31
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sys_lib_detector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Hussein Abu Maash
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-09 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: system
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
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: SysLibDetector lists and installs all the gems' system libraries and
112
+ native dependencies
113
+ email:
114
+ - hussein.abumaash@gmail.com
115
+ executables:
116
+ - console
117
+ - setup
118
+ - sys-lib-detector
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - ".document"
123
+ - ".gitignore"
124
+ - ".rspec"
125
+ - ".travis.yml"
126
+ - CODE_OF_CONDUCT.md
127
+ - Gemfile
128
+ - LICENSE.txt
129
+ - README.md
130
+ - Rakefile
131
+ - bin/console
132
+ - bin/setup
133
+ - bin/sys-lib-detector
134
+ - lib/sys_lib_detector.rb
135
+ - lib/sys_lib_detector/cli.rb
136
+ - lib/sys_lib_detector/displayer.rb
137
+ - lib/sys_lib_detector/exceptions.rb
138
+ - lib/sys_lib_detector/gems_collector.rb
139
+ - lib/sys_lib_detector/installer.rb
140
+ - lib/sys_lib_detector/system_detector.rb
141
+ - lib/sys_lib_detector/version.rb
142
+ - lib/sys_lib_detector/web_service_communicator.rb
143
+ - sys-lib-detector.gemspec
144
+ homepage: https://github.com/HusseinReda/SysLibDetectorGem
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.6.14
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: Listing and installing gems' system libraries
168
+ test_files: []