bundler-ecology 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 714aaccc033cc2dca2a5f8f0561eb12388f5bce641213ced430862bd0d7b3fcc
4
- data.tar.gz: 81b122b07b2f4f630126d209977f804365673a580cbf90f1a47cbbf4c729a51b
3
+ metadata.gz: 2783cee897240df4b61c014b1c75fb35b4bd4f00527ad92e60c6b8bc43ec59df
4
+ data.tar.gz: 27159bfaf73cec10747446ac6f037ce0aa5d446d01459a1484ca4be6d78563e1
5
5
  SHA512:
6
- metadata.gz: 1389bd9c14f4987c0263aa23244f7fcb3b8d4f1455dd2016fca10fa6b53eca59aaed80942f7b5bdf7f0f922bcaa631dfe21b115763badd0d9bb027c6ce289904
7
- data.tar.gz: 0626f1b3e6191fa5159f41ae2b2c27bdce880757436c8daf75b15ba2b2732a763fca44a0d428f13522974313e9f0bd0f1b48c17384cacab384aef1fd5e54336a
6
+ metadata.gz: b530048337c5cfb8ca5d462fcdac0b1c25480c9f3ebd68fb644aa321002da72f52d788f864d30661f52efeab7fd5ec2cdb3871ac3af5c23b83cb2e119fd9e578
7
+ data.tar.gz: 31d41d1c48578a516c3a9af1712b817ce58b142a7cfa553d76c313d4a8214bb44cb4a32729bc7e8b6ade8f3db4e320d181d60f3c5561a2ce4ceb97e2bfa47bbf
@@ -0,0 +1,6 @@
1
+ # 0.1.1 (2018-01-06)
2
+
3
+ ## Fixed
4
+ - Do not fail when config file does not exist
5
+
6
+ # 0.1.0 (2018-01-05) The first release
data/README.md CHANGED
@@ -19,6 +19,10 @@ plugin 'bundler-ecology'
19
19
  And then execute:
20
20
 
21
21
  $ bundle
22
+
23
+ Or install it globally as a plugin:
24
+
25
+ $ bundler install bundler-ecology
22
26
 
23
27
  ## Usage
24
28
 
@@ -1,21 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bundler/ecology/handlers/before_install'
3
4
  require 'bundler/ecology/version'
4
- require 'yaml'
5
5
 
6
6
  module Bundler
7
7
  module Ecology
8
8
  def self.register
9
- config_file_content = File.read('.bundler-ecology.yml')
10
- config = YAML.safe_load(config_file_content, symbolize_names: true)
11
- @gem_names = config[:disallowed].map { |item| item[:name] }
9
+ before_install_handler = Handlers::BeforeInstall.new(config)
12
10
 
13
11
  Bundler::Plugin.add_hook('before-install') do |dependency|
14
- next unless @gem_names.include?(dependency.name)
15
-
16
- raise Bundler::PluginError,
17
- "Gemfile contains a disallowed dependency: #{dependency.name}"
12
+ before_install_handler.call(dependency)
18
13
  end
19
14
  end
15
+
16
+ def self.config
17
+ config_file_name = '.bundler-ecology.yml'
18
+ return { disallowed: [] } unless File.exist?(config_file_name)
19
+
20
+ config_file_content = File.read(config_file_name)
21
+ YAML.safe_load(config_file_content, symbolize_names: true)
22
+ end
20
23
  end
21
24
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Bundler
6
+ module Ecology
7
+ module Handlers
8
+ class BeforeInstall
9
+ def initialize(config)
10
+ @gem_names = config.fetch(:disallowed, []).map { |item| item[:name] }
11
+ end
12
+
13
+ def call(dependency)
14
+ return unless @gem_names.include?(dependency.name)
15
+
16
+ raise Bundler::PluginError,
17
+ "Gemfile contains a disallowed dependency: #{dependency.name}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bundler
4
4
  module Ecology
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-ecology
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Kolesnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-05 00:00:00.000000000 Z
11
+ date: 2019-01-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: No unwanted gems more in your Gemfile.lock
14
14
  email:
@@ -17,8 +17,10 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - CHANGELOG.md
20
21
  - README.md
21
22
  - lib/bundler/ecology.rb
23
+ - lib/bundler/ecology/handlers/before_install.rb
22
24
  - lib/bundler/ecology/version.rb
23
25
  - plugins.rb
24
26
  homepage: https://github.com/eco-rb/bundler-ecology