between_meals 0.0.12 → 0.0.13

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
  SHA256:
3
- metadata.gz: 21f7e5e4186f163af47afb9a74c9f877d12949c3a637232747eb1fbfd1e9b845
4
- data.tar.gz: 3e5e53f85e47ae60291c05c83e244e4d3414e4984443b9471ef4711aad36e937
3
+ metadata.gz: 514d9473b739b4589c6692a739cb10e7fbfa8d2d87fa86e975579d7e2756bc9c
4
+ data.tar.gz: f4984b471c7856b51f60f1fadf7b4b21f684482f2f123d9babab02445c87d102
5
5
  SHA512:
6
- metadata.gz: 0ae9b2b8ad9a02e11dbbbce04bd8fb9e240f2c9af5ae4aa6bd709cc8a18e5453705d3bb41729ac4dd699c016aebbd658b62f0021779af47202c54882554d3d25
7
- data.tar.gz: 138c9464b07cd6f797ac41fcb91bd360db357db3ca26a2ccca12b21f0d8afbabd99919e41129ae40a2f2b75e4ac1749822eeb291d126eb44172c42d39b109663
6
+ metadata.gz: a889b6ae00ddb079948b0e6a04cb2e2888ccff57e7fdf685facecc11baee5f0d7cd4bc8b4c730f4fdfdde924d0c358b5e06b06fb0ec5ad30d7edd793e16288f6
7
+ data.tar.gz: cbf64fb976eb7ed143b8024c7048595feec9967f65b37fb62c0b7195ee35db1a7a35f2c33715a36f5abbe88be0694fcee1edc64d4b3f98bccfe01410cd6a012a
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,12 +22,27 @@ module BetweenMeals
24
22
  module Changes
25
23
  # Common functionality
26
24
  class Change
25
+ # Since we either need to upload or delete, we only accept two statuses.
26
+ # VCSs will differentiate between various kinds of modifies, adds, etc.
27
+ # so instead of handling all possibilities here, we expect the caller to
28
+ # collapse them into `:modified` or `:deleted`.
29
+ ALLOWED_STATUSES = [:modified, :deleted].freeze #: Array[Symbol]
27
30
  @@logger = nil
28
- attr_accessor :name, :status
31
+ attr_accessor :name
32
+ attr_reader :status
33
+
34
+ #: () -> String
29
35
  def to_s
30
36
  @name
31
37
  end
32
38
 
39
+ def status=(value)
40
+ unless ALLOWED_STATUSES.include?(value)
41
+ fail "#{self.class} status attribute can only be one of #{ALLOWED_STATUSES} not #{value}"
42
+ end
43
+ @status = value
44
+ end
45
+
33
46
  # People who use us through find() can just pass in logger,
34
47
  # for everyone else, here's a setter
35
48
  def logger=(log)
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,7 +40,7 @@ module BetweenMeals
42
40
  # For each symlink get the source path, if any files have changed under
43
41
  # the source path, fake them as coming from the symlink path. This
44
42
  # allows the normal cookbook logic to just work.
45
- symlinks = {}
43
+ symlinks = {} #: Hash[String, Hash[String, String]]
46
44
  @cookbook_dirs.each do |dir|
47
45
  dir = File.join(@repo_dir, dir)
48
46
  # Find symlinks in each cookbook_dir
@@ -66,7 +64,7 @@ module BetweenMeals
66
64
  # Create the file hash expected for each file that is a link or coming
67
65
  # from a linked directory but fake the source path as a symlink path.
68
66
  # Hacky but works :)
69
- links_to_append = []
67
+ links_to_append = [] #: Array[untyped]
70
68
  symlinks.each_value do |lrp| # link_abs_path, link_relative_path
71
69
  files.each do |f|
72
70
  # a symlink will never have trailing '/', add one.
@@ -119,9 +117,9 @@ module BetweenMeals
119
117
  %{^(#{cookbook_dirs.join('|')})/[^/]+/metadata\.(rb|json)$},
120
118
  )
121
119
  end.none?
122
- @status = :deleted
120
+ self.status = :deleted
123
121
  else
124
- @status = :modified
122
+ self.status = :modified
125
123
  end
126
124
  end
127
125
 
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,6 +17,7 @@ module BetweenMeals
19
17
  # Changeset aware databag
20
18
  class Databag < Change
21
19
  attr_accessor :item
20
+
22
21
  def self.name_from_path(path, databag_dir)
23
22
  re = %r{^#{databag_dir}/([^/]+)/([^/]+)\.json}
24
23
  debug("[databag] Matching #{path} against #{re}")
@@ -31,8 +30,8 @@ module BetweenMeals
31
30
  end
32
31
 
33
32
  def initialize(file, databag_dir)
34
- @status = file[:status]
35
- @name, @item = self.class.name_from_path(file[:path], databag_dir)
33
+ self.status = file[:status] == :deleted ? :deleted : :modified
34
+ self.name, self.item = self.class.name_from_path(file[:path], databag_dir)
36
35
  end
37
36
 
38
37
  def self.find(list, databag_dir, logger)
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,8 +28,8 @@ module BetweenMeals
30
28
  end
31
29
 
32
30
  def initialize(file, role_dir)
33
- @status = file[:status] == :deleted ? :deleted : :modified
34
- @name = self.class.name_from_path(file[:path], role_dir)
31
+ self.status = file[:status] == :deleted ? :deleted : :modified
32
+ self.name = self.class.name_from_path(file[:path], role_dir)
35
33
  end
36
34
 
37
35
  # Given a list of changed files
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,6 +27,7 @@ module BetweenMeals
29
27
  class Changeset
30
28
  class ReferenceError < RuntimeError
31
29
  end
30
+
32
31
  # rubocop:disable Metrics/ParameterLists
33
32
  def initialize(
34
33
  logger, repo, start_ref, end_ref, locations, track_symlinks = false
@@ -43,7 +42,7 @@ module BetweenMeals
43
42
  # Figure out which files changed if refs provided
44
43
  # or return all files (full upload) otherwise
45
44
  if start_ref
46
- @files = []
45
+ @files = [] #: Array[untyped]
47
46
  @repo.changes(start_ref, end_ref).each do |file|
48
47
  @files << file
49
48
  end
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -261,8 +259,10 @@ IAMAEpsWX2s2A6phgMCx7kH6wMmoZn3hb7Thh9+PfR8Jtp2/7k+ibCeF4gEWUCs5
261
259
 
262
260
  def create_databag_if_missing(databag)
263
261
  s = Mixlib::ShellOut.new("#{@knife} data bag list" +
264
- " --format json #{@knife_verb_option} " +
262
+ ' --format json ' +
265
263
  "-c #{@config}").run_command
264
+
265
+ s.stdout.gsub!(/^[A-Z].*\n/, '')
266
266
  s.error!
267
267
  db = JSON.parse(s.stdout)
268
268
  unless db.include?(databag)
@@ -272,7 +272,7 @@ IAMAEpsWX2s2A6phgMCx7kH6wMmoZn3hb7Thh9+PfR8Jtp2/7k+ibCeF4gEWUCs5
272
272
  end
273
273
 
274
274
  def delete_databag_if_empty(databag)
275
- s = Mixlib::ShellOut.new("#{@knife} data bag show #{databag}" +
275
+ s = Mixlib::ShellOut.new("#{@knife} data bag show #{databag}" + # steep:ignore
276
276
  " --format json #{@knife_verb_option} " +
277
277
  "-c #{@config}").run_command
278
278
  s.error!
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,8 +16,8 @@ require 'between_meals/cmd'
18
16
 
19
17
  module BetweenMeals
20
18
  class Repo
21
- class Git < BetweenMeals::Repo
22
- class Cmd < BetweenMeals::Cmd
19
+ class Git < ::BetweenMeals::Repo
20
+ class Cmd < ::BetweenMeals::Cmd
23
21
  def config(key)
24
22
  s = cmd("config #{key}", nil, true)
25
23
  unless [0, 1].include?(s.exitstatus)
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +26,7 @@ module BetweenMeals
28
26
  def setup
29
27
  if File.exist?(File.expand_path(@repo_path))
30
28
  begin
31
- @repo = Rugged::Repository.new(File.expand_path(@repo_path))
29
+ @repo = Rugged::Repository.new(File.expand_path(@repo_path)) # steep:ignore
32
30
  rescue StandardError
33
31
  @repo = nil
34
32
  end
@@ -82,7 +80,7 @@ module BetweenMeals
82
80
 
83
81
  def checkout(url)
84
82
  @cmd.clone(url, @repo_path)
85
- @repo = Rugged::Repository.new(File.expand_path(@repo_path))
83
+ @repo = Rugged::Repository.new(File.expand_path(@repo_path)) # steep:ignore
86
84
  end
87
85
 
88
86
  # Return files changed between two revisions
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,8 +17,8 @@ require 'tempfile'
19
17
 
20
18
  module BetweenMeals
21
19
  class Repo
22
- class Hg < BetweenMeals::Repo
23
- class Cmd < BetweenMeals::Cmd
20
+ class Hg < ::BetweenMeals::Repo
21
+ class Cmd < ::BetweenMeals::Cmd
24
22
  def rev(rev)
25
23
  cmd("log -r #{rev}")
26
24
  end
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,8 +15,8 @@
17
15
  require 'between_meals/cmd'
18
16
  module BetweenMeals
19
17
  class Repo
20
- class Svn < BetweenMeals::Repo
21
- class Cmd < BetweenMeals::Cmd
18
+ class Svn < ::BetweenMeals::Repo
19
+ class Cmd < ::BetweenMeals::Cmd
22
20
  def diff(start_ref, end_ref, repo_path)
23
21
  cmd("diff -r #{start_ref}:#{end_ref} --summarize #{repo_path}")
24
22
  end
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,7 +67,7 @@ module BetweenMeals
69
67
  'Something went wrong. Please report this output.',
70
68
  )
71
69
  @logger.error(e)
72
- stdout.lines.each do |line|
70
+ changes.lines.each do |line|
73
71
  @logger.error(line.strip)
74
72
  end
75
73
  exit(1)
@@ -105,7 +103,7 @@ module BetweenMeals
105
103
  when /^([\w ])\w?\s+(.+)$/
106
104
  {
107
105
  :status => Regexp.last_match(1) == 'D' ? :deleted : :modified,
108
- :path => Regexp.last_match(2).sub("#{@repo_path}/", ''),
106
+ :path => Regexp.last_match(2).to_s.sub("#{@repo_path}/", ''),
109
107
  }
110
108
  else
111
109
  fail 'Failed to parse repo diff line.'
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,35 +38,33 @@ module BetweenMeals
40
38
  exit(1)
41
39
  end
42
40
  logger.info('Trying to detect repo type')
43
- require 'between_meals/repo/git'
44
- require 'between_meals/repo/hg'
45
- require 'between_meals/repo/svn'
46
- [
47
- BetweenMeals::Repo::Git,
48
- BetweenMeals::Repo::Hg,
49
- BetweenMeals::Repo::Svn,
50
- ].each do |klass|
51
- begin
52
- r = klass.new(repo_path, logger)
53
- if r.exists?
54
- logger.info("Repo found to be #{klass.to_s.split('::').last}")
55
- return r
56
- end
57
- rescue StandardError
58
- logger.debug("Skipping #{klass}")
41
+ {
42
+ 'Hg' => 'between_meals/repo/hg',
43
+ 'Svn' => 'between_meals/repo/svn',
44
+ 'Git' => 'between_meals/repo/git',
45
+ }.each do |klass_name, req|
46
+ require req
47
+ klass = BetweenMeals::Repo.const_get(klass_name)
48
+ r = klass.new(repo_path, logger)
49
+ if r.exists?
50
+ logger.info("Repo found to be #{klass.to_s.split('::').last}")
51
+ return r
59
52
  end
53
+ rescue StandardError
54
+ logger.debug("Skipping #{klass}")
55
+
60
56
  end
61
57
  logger.warn("Failed detecting repo type at #{repo_path}")
62
58
  exit(1)
59
+ when 'hg'
60
+ require 'between_meals/repo/hg'
61
+ BetweenMeals::Repo::Hg.new(repo_path, logger)
63
62
  when 'svn'
64
63
  require 'between_meals/repo/svn'
65
64
  BetweenMeals::Repo::Svn.new(repo_path, logger)
66
65
  when 'git'
67
66
  require 'between_meals/repo/git'
68
67
  BetweenMeals::Repo::Git.new(repo_path, logger)
69
- when 'hg'
70
- require 'between_meals/repo/hg'
71
- BetweenMeals::Repo::Hg.new(repo_path, logger)
72
68
  else
73
69
  fail "Do not know repo type #{type}"
74
70
  end
@@ -1,5 +1,3 @@
1
- # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
2
-
3
1
  # Copyright 2013-present Facebook
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +32,7 @@ module BetweenMeals
34
32
  def time(logger = nil)
35
33
  @@logger = logger if logger
36
34
  t0 = Time.now
37
- yield
35
+ yield # steep:ignore
38
36
  info("Executed in #{format('%.2f', Time.now - t0)}s")
39
37
  end
40
38
 
@@ -60,7 +58,7 @@ module BetweenMeals
60
58
 
61
59
  def execute(command, stream)
62
60
  info("Running: #{command}")
63
- c = Mixlib::ShellOut.new(command, :live_stream => stream)
61
+ c = Mixlib::ShellOut.new(command, :live_stream => stream) # steep:ignore
64
62
  c.run_command
65
63
  c.stdout.lines.each do |line|
66
64
  info("STDOUT: #{line.strip}")
@@ -73,38 +71,38 @@ module BetweenMeals
73
71
 
74
72
  def port_open?(port)
75
73
  ips = Socket.ip_address_list
76
- ips.map!(&:ip_address)
74
+ ips = ips.map { |i| i.ip_address.to_s }
77
75
  ips.each do |ip|
78
- begin
79
- Timeout.timeout(1) do
80
- begin
81
- s = TCPSocket.new(ip, port)
82
- s.close
83
- return true
84
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
85
- next
86
- end
87
- end
88
- rescue Timeout::Error
76
+
77
+ Timeout.timeout(1) do
78
+
79
+ s = TCPSocket.new(ip, port)
80
+ s.close
81
+ return true
82
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
89
83
  next
84
+
90
85
  end
86
+ rescue Timeout::Error
87
+ next
88
+
91
89
  end
92
90
  return false
93
91
  end
94
92
 
95
93
  def chef_zero_running?(port, use_ssl)
96
94
  Timeout.timeout(1) do
97
- begin
98
- http = Net::HTTP.new('localhost', port)
99
- if use_ssl
100
- http.use_ssl = true
101
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
102
- end
103
- res = http.get('/')
104
- return res['Server'] == 'chef-zero'
105
- rescue StandardError
106
- return false
95
+
96
+ http = Net::HTTP.new('localhost', port)
97
+ if use_ssl
98
+ http.use_ssl = true
99
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
107
100
  end
101
+ res = http.get('/')
102
+ return res['Server'] == 'chef-zero'
103
+ rescue StandardError
104
+ return false
105
+
108
106
  end
109
107
  rescue Timeout::Error
110
108
  return false
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: between_meals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Dibowitz
8
8
  - Marcin Sawicki
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-21 00:00:00.000000000 Z
12
+ date: 2026-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -39,22 +39,8 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: rugged
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
42
  description: Library for calculating Chef differences between revisions
57
- email:
43
+ email:
58
44
  executables: []
59
45
  extensions: []
60
46
  extra_rdoc_files:
@@ -82,7 +68,7 @@ homepage: https://github.com/facebook/between-meals
82
68
  licenses:
83
69
  - Apache-2.0
84
70
  metadata: {}
85
- post_install_message:
71
+ post_install_message:
86
72
  rdoc_options: []
87
73
  require_paths:
88
74
  - lib
@@ -90,15 +76,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
76
  requirements:
91
77
  - - ">="
92
78
  - !ruby/object:Gem::Version
93
- version: '0'
79
+ version: 2.7.0
94
80
  required_rubygems_version: !ruby/object:Gem::Requirement
95
81
  requirements:
96
82
  - - ">="
97
83
  - !ruby/object:Gem::Version
98
84
  version: '0'
99
85
  requirements: []
100
- rubygems_version: 3.1.2
101
- signing_key:
86
+ rubygems_version: 3.5.22
87
+ signing_key:
102
88
  specification_version: 4
103
89
  summary: Between Meals
104
90
  test_files: []