deplist 0.5.22 → 0.5.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0db14dcdd798403f475c287835b702863dbc6b1
4
- data.tar.gz: ef359967710c291572fb5d16d8d70eee0a25c465
3
+ metadata.gz: cf7f0d364f2762c4402a752ad09f36f7da3e2b3b
4
+ data.tar.gz: c292908171bf9f0f647a6f8b829e1a5d55af8045
5
5
  SHA512:
6
- metadata.gz: 02dc074528c4f20aa59918311afa89431c2ef599217ec288c7764b44b2d8c15fe37362a4c1feae583e8b3a2a285415d118dd169dd46fbdd9cde80259db4487d4
7
- data.tar.gz: d4749698630760755042b2a8148fbfecd4f79a51c521a363d1e6f0f556b4b5754fe81c9b845150349442135e1416685c5c9f77d671a9f104bdf701de883bea9d
6
+ metadata.gz: 898e14fdb99d4c5583ac7729dfe4a2f6a74219e46b9e24eaed5fd443c1184ca4b7959278716703da55f4e6bdc3729c5a28b673827e725967916fa92131e88626
7
+ data.tar.gz: 0085eb92d5b96476390ddf36e71255fa61b813df88ebab8b152cbb7d4289339daaddbebb98bdad47c88e2d132c93ecb4f7e8c0d8276046009c5af5c7dff0d85e
data/.gitignore CHANGED
@@ -7,5 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ log/
11
+ /log/
10
12
  /.overcommit
11
13
  .overcommit
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-11-19 17:02:27 +0200 using RuboCop version 0.45.0.
3
+ # on 2016-11-20 01:19:07 +0200 using RuboCop version 0.45.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 6
9
+ # Offense count: 7
10
10
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
11
11
  # URISchemes: http, https
12
12
  Metrics/LineLength:
@@ -15,4 +15,9 @@ Metrics/LineLength:
15
15
  # Offense count: 2
16
16
  # Configuration parameters: CountComments.
17
17
  Metrics/MethodLength:
18
- Max: 11
18
+ Max: 13
19
+
20
+ # Offense count: 1
21
+ Style/ClassVars:
22
+ Exclude:
23
+ - 'lib/deplist/dep_logger.rb'
data/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  Collects the project dependencies and operating system information, sends them to the web service, and displays the required system libraries to install and ask to install them.
4
4
 
5
+ ## How DepList works:
6
+
7
+ DepList detects missing system dependencies of gems you are using in your Rails project. It sends them to an external API which responds with a list of dependencies that your system needs to be able to run your project. DepList also asks you to add a list of dependencies for gems that it could not identify, and sends them back to the external API to populate its knowledge base.
8
+
9
+ NOTE: DepList will not ask you to install system packages you already have. In case DepList fails to install any packages, it will let you know the name of the packages so you can configure them manually. DepList keeps a log of all its operations in `log/deplist.log`.
10
+
5
11
  ## Installation
6
12
 
7
13
  Add this line to your application's Gemfile:
@@ -22,7 +28,7 @@ Or install it yourself as:
22
28
 
23
29
  Show all system library needed to be able to run your rails application and ask you to install missing dependencies.
24
30
 
25
- $ rake system_dependencies:show
31
+ $ rake deplist:show
26
32
 
27
33
  ## Contributing
28
34
 
@@ -32,4 +38,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/adham9
32
38
  ## License
33
39
 
34
40
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
35
-
@@ -1,7 +1,8 @@
1
1
  require 'deplist/version'
2
+ require 'deplist/dep_logger'
3
+ require 'deplist/os_detector'
2
4
  require 'deplist/gemlist_server'
3
5
  require 'deplist/installer'
4
- require 'deplist/os_detector'
5
6
 
6
7
  module Deplist
7
8
  require 'deplist/railtie.rb' if defined?(Rails)
@@ -0,0 +1,26 @@
1
+ require 'logger'
2
+
3
+ class DepLogger
4
+ LOG_DIR = 'log'.freeze
5
+ LOG_FILE = "#{LOG_DIR}/deplist.log".freeze
6
+
7
+ class << self
8
+ def error(msg)
9
+ logger.error(msg)
10
+ end
11
+
12
+ def info(msg)
13
+ logger.info(msg)
14
+ end
15
+
16
+ private
17
+
18
+ def logger
19
+ FileUtils.mkdir_p(LOG_DIR)
20
+
21
+ @@logger ||= begin
22
+ Logger.new(LOG_FILE)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,6 +3,7 @@ require 'json'
3
3
 
4
4
  class GemListServer
5
5
  include HTTParty
6
+
6
7
  base_uri 'https://gemdep.herokuapp.com'
7
8
  # base_uri 'http://localhost:3000'
8
9
 
@@ -11,17 +12,14 @@ class GemListServer
11
12
  @packages = load_packages(@options)
12
13
  end
13
14
 
14
- def create(unknown_gem, dependencies)
15
+ def self.create(unknown_gem, dependencies)
15
16
  options = { body: { gem: unknown_gem, dependencies: dependencies, os: OsDetector.current_os } }
16
17
 
17
18
  self.class.post('/system_lib', options)
18
19
  end
19
20
 
20
21
  def dependencies
21
- system_dependencies = @packages['dependencies'].select { |pkg| !pkg_exists?(pkg) }
22
- system('clear')
23
-
24
- system_dependencies
22
+ @packages['dependencies'].reject { |pkg| pkg_exists?(pkg) }
25
23
  end
26
24
 
27
25
  def unknown_gems
@@ -36,6 +34,6 @@ class GemListServer
36
34
  end
37
35
 
38
36
  def pkg_exists?(pkg)
39
- system("which #{pkg}")
37
+ system("which #{pkg} >/dev/null 2>&1")
40
38
  end
41
39
  end
@@ -14,9 +14,12 @@ class Installer
14
14
 
15
15
  packages.each do |pkg|
16
16
  status = send("#{os}_install", pkg)
17
- if status == true
17
+
18
+ if status
19
+ DepLogger.info("Succeeded to install: #{pkg}")
18
20
  success_list << pkg
19
21
  else
22
+ DepLogger.error("Failed to install: #{pkg}")
20
23
  fail_list << pkg
21
24
  end
22
25
  end
@@ -30,8 +33,7 @@ class Installer
30
33
  end
31
34
 
32
35
  def macosx_install(pkg)
33
- # TODO: esc confirmation
34
- system("sudo bower install #{pkg} --no-interactive")
36
+ system("bower install #{pkg} --no-interactive")
35
37
  end
36
38
  end
37
39
  end
@@ -1,6 +1,7 @@
1
1
  require 'deplist'
2
2
  require 'rails'
3
- module YourGem
3
+
4
+ module Deplist
4
5
  class Railtie < Rails::Railtie
5
6
  rake_tasks do
6
7
  load 'tasks/show_dep.rake'
@@ -1,3 +1,3 @@
1
1
  module Deplist
2
- VERSION = '0.5.22'.freeze
2
+ VERSION = '0.5.23'.freeze
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require 'bundler'
2
2
  require 'colorize'
3
3
 
4
- namespace :system_dependencies do
5
- desc 'TODO'
4
+ namespace :deplist do
5
+ desc 'List system dependencies'
6
6
  task show: :environment do
7
7
  # get a list of project gems
8
8
  gems = Bundler.load.specs.map(&:name)
@@ -10,24 +10,24 @@ namespace :system_dependencies do
10
10
  packages = server.dependencies
11
11
  unknown_gems = server.unknown_gems
12
12
 
13
- unless unknown_gems.empty?
13
+ if unknown_gems.any?
14
14
  # TODO: change this message
15
15
  puts "I don't know this gems can you tell"\
16
- 'me what dependencies they need if you know(y/n)?'.yellow
16
+ 'me what dependencies they need if you know? (y/n)'.yellow
17
17
  puts unknown_gems.join(', ').red
18
18
 
19
19
  if user_input
20
20
  puts 'To abort type exit.'.yellow
21
- puts 'To add multiple dependencies use ex(pkg1,pkg2).'.yellow
21
+ puts 'To add multiple dependencies use e.g. pkg1,pkg2,...,pkgn.'.yellow
22
22
  unknown_gems.each do |unknown_gem|
23
- # TODO: Change this message
24
23
  print "What about (#{unknown_gem}): ".yellow
25
24
  STDOUT.flush
26
25
  dependencies = STDIN.gets.chomp.split(/[\s,]+/)
26
+
27
27
  break if dependencies == ['exit']
28
28
  next if dependencies.empty?
29
29
 
30
- server.create(unknown_gem, dependencies)
30
+ GemListServer.create(unknown_gem, dependencies)
31
31
  packages = packages.concat(dependencies)
32
32
  end
33
33
  end
@@ -35,24 +35,23 @@ namespace :system_dependencies do
35
35
 
36
36
  abort 'Life is good ;D'.green if packages.empty?
37
37
 
38
- puts 'Your system need to have this packages'\
39
- ' to be able to run your rails project:'.yellow
38
+ puts 'Your system needs to have these packages'\
39
+ ' to be able to run your Rails project:'.yellow
40
40
  puts packages.join(', ').red
41
- puts 'Do you want to install missing dependencies(y/n)?'.blue
41
+ puts 'Do you want to install missing dependencies? (y/n)'.blue
42
42
 
43
43
  begin
44
44
  if user_input
45
45
  status = Installer.install(packages)
46
- system('clear')
47
46
 
48
- unless status[:success].empty?
49
- puts 'I have installed this packages for you :)'.yellow
47
+ if status[:success].present?
48
+ puts 'I have installed these packages for you :)'.yellow
50
49
  puts status[:success].join(', ').green
51
50
  puts
52
51
  end
53
52
 
54
- unless status[:fail].empty?
55
- puts "I'm sorry i can't install this packages :(".yellow
53
+ if status[:fail].present?
54
+ puts "I'm sorry, I can't install these packages :(".yellow
56
55
  abort status[:fail].join(', ').red
57
56
  end
58
57
 
@@ -71,7 +70,7 @@ namespace :system_dependencies do
71
70
  when 'Y', 'y', "\r"
72
71
  return true
73
72
  else
74
- puts 'Bye Bye My Friend'
73
+ puts 'Goodbye my friend'
75
74
  return false
76
75
  end
77
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deplist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.22
4
+ version: 0.5.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - adham90
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-19 00:00:00.000000000 Z
11
+ date: 2016-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,6 +118,7 @@ files:
118
118
  - bin/setup
119
119
  - deplist.gemspec
120
120
  - lib/deplist.rb
121
+ - lib/deplist/dep_logger.rb
121
122
  - lib/deplist/gemlist_server.rb
122
123
  - lib/deplist/installer.rb
123
124
  - lib/deplist/os_detector.rb