update_repo 0.2.0 → 0.3.0

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: 3c8f69a7896ee9033c3795a0f5fb64bdc4ad203b
4
- data.tar.gz: 5e2d5e0e24ce6832a86c86aff898207dff696f46
3
+ metadata.gz: ea5b6e02f412859fd3016b0a96551f9dee113b59
4
+ data.tar.gz: cf62ffcdc1ae9cc7d59ef280ffdb81bd1cb3996b
5
5
  SHA512:
6
- metadata.gz: eef4c5f91858e5122667332b6bde79ee23565fd93231c4e6af0ba7d9beba7b8fc28b8c229f4ad3a695f90b4456517909c94707b5174a6a9dcd4fcea3b6c56dd4
7
- data.tar.gz: 3edc6e7429277294ddc163a541aa7ca9c85f606e15a78a5813e3ea49cf82bf40713c7f1e7e687bfbf6654a982659c41b840d5379648f10577e654fc5fed86be0
6
+ metadata.gz: f9451f2add48a93bfa1b7214df62286d4d1d9f73560aefc69a576d130d2820a79f1f04f7931a31523dfcfabd5b17c11e20ed46c3342ba2084b43442d6b719b40
7
+ data.tar.gz: 108bad544e5cc9344be67a5fcebd31642783a30c12e17744b5fe52accd0a6f2f1ab70afead2cce3808c54b8c0e30053fa0bc81fbb8753e7f57dd1e057c43e038
data/README.md CHANGED
@@ -46,9 +46,8 @@ To be added.
46
46
  ## To-Do
47
47
  Not in any specific order :
48
48
 
49
- - Improve error-checking and recovery while parsing the configuration file (convert to using my '[Confoog][confoog]' gem for example)
49
+ - Improve error-checking and recovery while parsing the configuration file
50
50
  * Ignore and report invalid or missing directories
51
- * Expand eg '~/' to full valid path.
52
51
  - Either add an option 'variants' or similar to allow non-standard git pull commands (eg Ubuntu kernel), or update the 'exceptions' option to do same.
53
52
  - Error checking and reporting for the git processes - retry for connection issues etc (config setting).
54
53
  - Add extra (optional) stats / info at end-of-job :
data/lib/update_repo.rb CHANGED
@@ -2,6 +2,7 @@ require 'update_repo/version'
2
2
  require 'yaml'
3
3
  require 'colorize'
4
4
  require 'update_repo/version'
5
+ require 'confoog'
5
6
 
6
7
  # Overall module with classes performing the functionality
7
8
  # Contains Class UpdateRepo::WalkRepo
@@ -19,8 +20,16 @@ module UpdateRepo
19
20
  # Class constructor. No parameters required.
20
21
  # @return [void]
21
22
  def initialize
23
+ # @counter - this will be ioncremented with each repo updated.
22
24
  @counter = 0
25
+ # @ start_time - will be used to get elapsed time
23
26
  @start_time = 0
27
+ # @config - Class. Reads the configuration from a file in YAML format and
28
+ # allows easy access to the configuration data
29
+ @config = Confoog::Settings.new(filename: '.updatereporc',
30
+ prefix: 'update_repo',
31
+ autoload: true)
32
+ exit 1 unless @config.status[:errors] == Status::INFO_FILE_LOADED
24
33
  end
25
34
 
26
35
  # This function will perform the required actions to traverse the Repo.
@@ -28,10 +37,10 @@ module UpdateRepo
28
37
  # walk_repo = UpdateRepo::WalkRepo.new
29
38
  # walk_repo.start
30
39
  def start
31
- configs, location = check_config
32
- show_header(configs, location)
33
- configs['location'].each do |loc|
34
- recurse_dir(loc, configs['exceptions'])
40
+ exceptions = @config['exceptions']
41
+ show_header(exceptions)
42
+ @config['location'].each do |loc|
43
+ recurse_dir(loc, exceptions)
35
44
  end
36
45
  # print out an informative footer...
37
46
  footer
@@ -48,7 +57,6 @@ module UpdateRepo
48
57
  dirpath = dirname + '/' + dir
49
58
  next unless File.directory?(dirpath) && notdot?(dir)
50
59
  if gitdir?(dirpath)
51
- dir.chomp!
52
60
  !exceptions.include?(dir) ? update_repo(dirpath) : skip_dir(dirpath)
53
61
  else
54
62
  recurse_dir(dirpath, exceptions)
@@ -56,45 +64,19 @@ module UpdateRepo
56
64
  end
57
65
  end
58
66
 
59
- # locate the configuration file and return this data.
60
- # Note that this will be re-written later to use my 'confoog' gem.
61
- # @return [hash] Hash containing all the configuration parameters.
62
- # @return [string] Location of the configuration file.
63
- def check_config
64
- # locate the configuration file.
65
- # first we check in this script location and if present then we ignore any
66
- # further files.
67
- dev_config = File.join '.', CONFIG_FILE
68
- user_config = File.join Gem.user_home, CONFIG_FILE
69
-
70
- if File.exist? dev_config
71
- # configuration exists in script directory so we ignore any others.
72
- return YAML.load_file(dev_config), File.expand_path(dev_config)
73
- elsif File.exist? user_config
74
- # configuration exists in user home directory so we use that.
75
- return YAML.load_file(user_config), File.expand_path(user_config)
76
- end
77
- # otherwise return error
78
- print 'Error : Cannot find configuration file'.red, user_config.red,
79
- 'aborting'.red
80
- exit 1
81
- end
82
-
83
67
  # Display a simple header to the console
84
- # @param configs [hash] Configuration hash, used here to list exceptions.
85
- # @param location [string] location of config file.
86
68
  # @example
87
- # show_header
88
- # @return []
89
- def show_header(configs, location)
69
+ # show_header(exceptions)
70
+ # @return [void]
71
+ def show_header(exceptions)
90
72
  # print an informative header before starting
91
73
  print "\nGit Repo update utility (v", VERSION, ')',
92
74
  " \u00A9 Grant Ramsay <seapagan@gmail.com>\n"
93
- print "Using Configuration from #{location}\n"
94
- list_locations(configs)
95
- if configs['exceptions']
75
+ print "Using Configuration from '#{@config.config_path}'\n"
76
+ list_locations
77
+ if exceptions
96
78
  print "\nExclusions:".underline, ' ',
97
- configs['exceptions'].join(', ').yellow, "\n"
79
+ exceptions.join(', ').yellow, "\n"
98
80
  end
99
81
  # save the start time for later display in the footer...
100
82
  @start_time = Time.now
@@ -109,9 +91,9 @@ module UpdateRepo
109
91
  "#{Time.at(duration).utc.strftime('%H:%M:%S')}\n\n".cyan
110
92
  end
111
93
 
112
- def list_locations(configs)
94
+ def list_locations
113
95
  print "\nRepo location(s):\n".underline
114
- configs['location'].each do |loc|
96
+ @config['location'].each do |loc|
115
97
  print '-> ', loc.cyan, "\n"
116
98
  end
117
99
  end
@@ -1,4 +1,4 @@
1
1
  module UpdateRepo
2
2
  # constant, current version of this Gem
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
data/update_repo.gemspec CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'wwtd'
35
35
 
36
36
  spec.add_dependency 'colorize'
37
+ spec.add_dependency 'confoog'
37
38
 
38
39
  # Depends on Ruby version if we can use 'Reek'
39
40
  spec.add_development_dependency 'reek', '~> 3.3' if RUBY_VERSION > '2.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: update_repo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Ramsay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-04 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: bundler
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: confoog
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: reek
197
211
  requirement: !ruby/object:Gem::Requirement