bcupgrade 0.9.1 → 0.9.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e1ba7a4c41f23f3847b3d796af45417d2549e73
4
- data.tar.gz: 2baf0fe4c779ce6bc0e19ec82333671def99559a
3
+ metadata.gz: 9b87f6da66f77ed4aa3c25152ecded951be8f1cf
4
+ data.tar.gz: d8a5dbd8f95d17baba2cc2014fb09d16d60de1fe
5
5
  SHA512:
6
- metadata.gz: 99f770aa03f908d7a5d1c7a557c5370ed039324f9dbdecb2a08a5a8f365a007abcaffe93c6b8e45c31c601fd132ef8542f39ff3761490ed64eff0cc2a39995e0
7
- data.tar.gz: b156cbb648afd5595fc435b66938b532bf3f1a7bd5d54cb0057f3a511bce66ede11c25ff5b01785281db7b3ab776934d7702ba03f77f5c937305dccd1baf4a01
6
+ metadata.gz: 4a7b72bb99b04e2c8e846900a72f3861bbcade80d47333b5e53aa7029aa5c521a3f6e5c9f898e3d32d9ec704c55b260fd6c28ab22a60aacb5e82e584e8e15e57
7
+ data.tar.gz: 24870992624b64013c6379c52846264143df4501b09047212845ca5050ecb28c1ac95250d7f49aa67f265ecec2bc2bce66eefa369f7a391302433281d681b6eb
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-01-06 13:26:21 +0900 using RuboCop version 0.52.1.
3
+ # on 2018-01-07 18:51:23 +0900 using RuboCop version 0.52.1.
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
@@ -9,9 +9,9 @@
9
9
  # Offense count: 1
10
10
  # Configuration parameters: CountComments.
11
11
  Metrics/MethodLength:
12
- Max: 15
12
+ Max: 13
13
13
 
14
- # Offense count: 3
14
+ # Offense count: 4
15
15
  Style/Documentation:
16
16
  Exclude:
17
17
  - 'spec/**/*'
@@ -19,3 +19,4 @@ Style/Documentation:
19
19
  - 'lib/bcupgrade.rb'
20
20
  - 'lib/bcupgrade/brew_cask.rb'
21
21
  - 'lib/bcupgrade/cask.rb'
22
+ - 'lib/bcupgrade/config_file.rb'
@@ -6,6 +6,8 @@ require 'optparse'
6
6
  require 'readline'
7
7
 
8
8
  OptionParser.new do |opt|
9
+ config = Bcupgrade::ConfigFile.new
10
+
9
11
  begin
10
12
  opt.program_name = File.basename($PROGRAM_NAME)
11
13
  opt.banner = "Usage: #{opt.program_name} [options] [cask1 cask2...]"
@@ -24,7 +26,7 @@ OptionParser.new do |opt|
24
26
 
25
27
  args = opt.parse!(ARGV)
26
28
 
27
- Bcupgrade.run(options, args)
29
+ Bcupgrade.run(options, args, config)
28
30
  rescue StandardError => e
29
31
  puts "Error: #{e}.\nSee #{opt}"
30
32
  exit
@@ -3,22 +3,23 @@
3
3
  require_relative 'bcupgrade/version'
4
4
  require_relative 'bcupgrade/brew_cask'
5
5
  require_relative 'bcupgrade/cask'
6
+ require_relative 'bcupgrade/config_file'
6
7
 
7
8
  module Bcupgrade
8
- def self.run(options, args)
9
- cask = Cask.new(options, args)
9
+ def self.run(options, args, config)
10
+ cask = Cask.new(options, args, config)
10
11
 
11
12
  unless cask.args.any?
12
13
  puts "\n==> Outdated cask...\n"
13
14
  BrewCask.output_outdated
14
15
 
15
- ignore = cask.config['ignore']
16
- puts "\nNot upgrading pinned package:\n#{ignore}" if ignore
16
+ ignore = cask.list_ignore
17
+ puts "\nNot upgrading pinned package:\n#{ignore}" unless ignore.empty?
17
18
  end
18
19
 
19
- update_casks = cask.target
20
+ update_casks = cask.upgrade_target
20
21
  if update_casks.any?
21
- cask.upgrade_version(update_casks)
22
+ cask.upgrade(update_casks)
22
23
  else
23
24
  puts "\nAlready up-to-date."
24
25
  end
@@ -4,16 +4,16 @@ require 'yaml'
4
4
 
5
5
  module Bcupgrade
6
6
  class Cask
7
- attr_reader :config, :args, :target
7
+ attr_reader :args
8
8
 
9
- def initialize(options, args)
10
- @config = load_config
11
- @options = options
12
- @args = args.uniq
13
- @target = upgrade_target
9
+ def initialize(options, args, config)
10
+ @config = config
11
+ @options = options
12
+ @args = args.uniq
13
+ @outdated = BrewCask.outdated.split(/\n/)
14
14
  end
15
15
 
16
- def upgrade_version(casks)
16
+ def upgrade(casks)
17
17
  return if @options[:dry_run]
18
18
 
19
19
  casks.each do |cask|
@@ -24,33 +24,22 @@ module Bcupgrade
24
24
  end
25
25
  end
26
26
 
27
- private
28
-
29
- def load_config
30
- file = File.join(ENV['HOME'], '.bcupgrade')
31
- if File.exist?(file)
32
- YAML.load_file(file)
33
- else
34
- ''
35
- end
27
+ def list_ignore
28
+ @config.ignore.join(' ')
36
29
  end
37
30
 
38
31
  def upgrade_target
39
32
  if @args.any?
40
33
  @args
41
34
  else
42
- outdated = BrewCask.outdated.split(/\n/)
43
- exclude_ignore_casks(outdated)
35
+ exclude_ignore_casks(@outdated)
44
36
  end
45
37
  end
46
38
 
39
+ private
40
+
47
41
  def exclude_ignore_casks(casks)
48
- if @config.nil?
49
- casks
50
- else
51
- ignore = Array(@config['ignore'])
52
- casks - ignore
53
- end
42
+ casks - @config.ignore
54
43
  end
55
44
 
56
45
  def prompt_answer_yes?(cask)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Bcupgrade
6
+ class ConfigFile
7
+ def initialize
8
+ @file = File.join(ENV['HOME'], '.bcupgrade')
9
+ end
10
+
11
+ def load
12
+ if File.exist?(@file)
13
+ YAML.load_file(@file)
14
+ else
15
+ { 'ignore' => [''] }
16
+ end
17
+ end
18
+
19
+ def ignore
20
+ load['ignore'].map { |e| e ? e : '' }
21
+ rescue StandardError
22
+ ['']
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bcupgrade
4
- VERSION = '0.9.1'
4
+ VERSION = '0.9.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcupgrade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DriftwoodJP
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-06 00:00:00.000000000 Z
11
+ date: 2018-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -134,6 +134,7 @@ files:
134
134
  - lib/bcupgrade.rb
135
135
  - lib/bcupgrade/brew_cask.rb
136
136
  - lib/bcupgrade/cask.rb
137
+ - lib/bcupgrade/config_file.rb
137
138
  - lib/bcupgrade/version.rb
138
139
  homepage: https://github.com/DriftwoodJP/bcupgrade
139
140
  licenses: