navo 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,23 @@ module Navo
37
37
  end
38
38
  end
39
39
 
40
+ # Returns a hash of the contents of the given file/directory.
41
+ #
42
+ # @param path [String]
43
+ # @return [String, nil]
44
+ def path_hash(path)
45
+ if File.exist?(path)
46
+ %x{
47
+ { cd cookbooks;
48
+ export LC_ALL=C;
49
+ find #{path} -type f -exec md5sum {} + | sort; echo;
50
+ find #{path} -type d | sort;
51
+ find #{path} -type d | sort | md5sum;
52
+ } | md5sum
53
+ }.split(' ', 2).first
54
+ end
55
+ end
56
+
40
57
  # Convert string containing camel case or spaces into snake case.
41
58
  #
42
59
  # @see stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Navo
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: navo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2016-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: berkshelf
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.22'
41
+ - !ruby/object:Gem::Dependency
42
+ name: parallel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: thor
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -62,13 +76,16 @@ extra_rdoc_files: []
62
76
  files:
63
77
  - bin/navo
64
78
  - lib/navo.rb
79
+ - lib/navo/berksfile.rb
80
+ - lib/navo/chef_formatter.rb
65
81
  - lib/navo/cli.rb
66
82
  - lib/navo/configuration.rb
67
83
  - lib/navo/constants.rb
68
84
  - lib/navo/errors.rb
85
+ - lib/navo/logger.rb
69
86
  - lib/navo/sandbox.rb
87
+ - lib/navo/state_file.rb
70
88
  - lib/navo/suite.rb
71
- - lib/navo/suite_state.rb
72
89
  - lib/navo/utils.rb
73
90
  - lib/navo/version.rb
74
91
  homepage: https://github.com/sds/navo
@@ -1,59 +0,0 @@
1
- require 'fileutils'
2
- require 'yaml'
3
-
4
- module Navo
5
- # Stores persisted state about a test suite.
6
- #
7
- # This allows information to carry forward between different invocations of
8
- # the tool, e.g. remembering a previously-started Docker container.
9
- class SuiteState
10
- FILE_NAME = 'state.yaml'
11
-
12
- def initialize(suite:)
13
- @suite = suite
14
- end
15
-
16
- # Access the state as if it were a hash.
17
- #
18
- # @param key [String, Symbol]
19
- # @return [Array, Hash, Number, String]
20
- def [](key)
21
- @hash[key.to_s]
22
- end
23
-
24
- # Set the state as if it were a hash.
25
- #
26
- # @param key [String, Symbol]
27
- # @param value [Array, Hash, Number, String]
28
- def []=(key, value)
29
- @hash[key.to_s] = value
30
- end
31
-
32
- # Loads persisted state.
33
- def load
34
- @hash =
35
- if File.exist?(file_path) && yaml = YAML.load_file(file_path)
36
- yaml.to_hash
37
- else
38
- {} # Handle empty files
39
- end
40
- end
41
-
42
- # Persists state to disk.
43
- def save
44
- File.open(file_path, 'w') { |f| f.write(@hash.to_yaml) }
45
- end
46
-
47
- # Destroy persisted state.
48
- def destroy
49
- @hash = {}
50
- FileUtils.rm_f(file_path)
51
- end
52
-
53
- private
54
-
55
- def file_path
56
- File.join(@suite.storage_directory, FILE_NAME)
57
- end
58
- end
59
- end