geordi 1.3.2 → 1.4.0

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjgwZTFjZTY5YTQxNTY2NWRlZTgxMTUyZTczZjIxM2NiZWEwMTBhYQ==
5
+ data.tar.gz: !binary |-
6
+ YzY3OTBkOWVkY2Q2NjQxMTc2ZDg4MjI1OTY0ZmNmYWZkYTkzMzdkMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MWVmYjZjNDQzYTY3OTI0ODAyZDNkYjc1NDllOGVlYjg0ZjllMzVjYTZlOWQy
10
+ YjliMGZhYWFhZDRlZjE5YTZkODA0YWQyMGQyMjQxMjhjMGU1OWYwNWQ3ZDRh
11
+ MjI5YjNkMzdiNjA0YTNmZDRlZTdjNWM4N2Q0NTNmZDE5NmNhOTI=
12
+ data.tar.gz: !binary |-
13
+ NmNlNzU1YjczYTQwNTRiZGY3NWE4ZmJmOWI4Y2M4MmNhNTViODk3NDZkMTRi
14
+ YjJiNGM0NGU0NTkzNGU4ZGUyZDZjMDIxOTlkYmE1YjVhYTRiYzYwODg0NGEy
15
+ M2ZkNWI2MjQ0ODI1NmU4NWFlY2QyMmUxYTQzZDI5ZDQ4MzQyY2E=
data/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in geordi.gemspec
4
4
  gemspec
5
5
 
6
6
  gem 'aruba'
7
+ gem 'rspec-mocks'
7
8
  gem 'pry'
8
9
  gem 'highline'
9
10
 
10
11
  # Required for running features that test parallel test execution
11
- gem 'parallel_tests' if ENV['GEORDI_TESTING']
12
+ gem 'parallel_tests'
data/Gemfile.lock CHANGED
@@ -37,6 +37,9 @@ GEM
37
37
  method_source (0.8.2)
38
38
  multi_json (1.11.2)
39
39
  multi_test (0.1.2)
40
+ parallel (1.9.0)
41
+ parallel_tests (2.7.1)
42
+ parallel
40
43
  pry (0.10.3)
41
44
  coderay (~> 1.1.0)
42
45
  method_source (~> 0.8.1)
@@ -44,6 +47,9 @@ GEM
44
47
  rspec-expectations (3.4.0)
45
48
  diff-lcs (>= 1.2.0, < 2.0)
46
49
  rspec-support (~> 3.4.0)
50
+ rspec-mocks (3.4.1)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.4.0)
47
53
  rspec-support (3.4.1)
48
54
  slop (3.6.0)
49
55
  thor (0.19.1)
@@ -55,7 +61,9 @@ DEPENDENCIES
55
61
  aruba
56
62
  geordi!
57
63
  highline
64
+ parallel_tests
58
65
  pry
66
+ rspec-mocks
59
67
 
60
68
  BUNDLED WITH
61
- 1.10.6
69
+ 1.12.5
data/README.md CHANGED
@@ -182,6 +182,19 @@ Optimize a single file:
182
182
  geordi png-optimize input.png
183
183
 
184
184
 
185
+ ### geordi purge-kernels
186
+
187
+ Purge linux kernels older than the current one.
188
+
189
+ Example: `sudo geordi purge-kernels`
190
+
191
+ /boot quickly gets cluttered with unused old kernels, finally rendering your
192
+ machine unable to install updates.
193
+
194
+ This script will retrieve and print a list of all current or older kernels. If
195
+ confirmed, it will then purge all kernels older than the current one.
196
+
197
+
185
198
  ### geordi rake TASK
186
199
 
187
200
  Run a rake task in several Rails environments.
@@ -72,7 +72,7 @@ Feature: The cucumber command
72
72
  """
73
73
 
74
74
  When I run `geordi cucumber features/sub`
75
- Then the output should contain "> Only: features/sub/two.feature, features/sub/one.feature"
75
+ Then the output should contain "> Only: features/sub/one.feature, features/sub/two.feature"
76
76
  And the output should contain "> Using parallel_tests"
77
77
 
78
78
 
@@ -1,5 +1,8 @@
1
1
  require 'aruba/cucumber'
2
2
  require 'pry'
3
3
 
4
+ # require 'geordi'
5
+ # require 'cucumber/rspec/doubles'
6
+
4
7
  # Disables execution of Util.system! calls
5
8
  ENV['GEORDI_TESTING'] = 'true'
data/geordi.gemspec CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency 'thor', '>= 0.18.0'
24
24
 
25
25
  s.post_install_message = <<-ATTENTION
26
- Binary `geordi` installed
26
+ * Binary `geordi` installed
27
27
  ATTENTION
28
28
  end
@@ -0,0 +1,29 @@
1
+ desc 'purge-kernels', 'Purge linux kernels older than the current one'
2
+ long_desc <<-LONGDESC
3
+ Example: `sudo geordi purge-kernels`
4
+
5
+ /boot quickly gets cluttered with unused old kernels, finally rendering your
6
+ machine unable to install updates.
7
+
8
+ This script will retrieve and print a list of all current or older kernels. If
9
+ confirmed, it will then purge all kernels older than the current one.
10
+ LONGDESC
11
+
12
+ def purge_kernels
13
+ kernels = Util.retrieve_kernels
14
+
15
+ announce 'Purging old kernels'
16
+ Util.root_required
17
+ note 'Current kernel: ' + kernels[:current]
18
+
19
+ if kernels[:old].any?
20
+ note ['Old kernels:', *kernels[:old].reverse].join "\n"
21
+
22
+ Util.system! 'apt-get purge -y ' + kernels[:old].join(' '),
23
+ :show_cmd => true,
24
+ :confirm => true,
25
+ :fail_message => 'Failed, or cancelled.'
26
+ else
27
+ success 'No old kernels found.'
28
+ end
29
+ end
data/lib/geordi/util.rb CHANGED
@@ -15,7 +15,7 @@ module Geordi
15
15
  error.message =~ /-- (\S+)\Z/
16
16
  $1 or raise # could not extract a gem name from the error message, re-raise the error
17
17
 
18
- gem_name = $1.strip
18
+ gem_name = $1.strip.split('/').first
19
19
  install_command = 'gem install ' + gem_name
20
20
 
21
21
  # install missing gem
@@ -33,16 +33,23 @@ module Geordi
33
33
  # Run a command with a clean environment.
34
34
  # Print an error message and exit if the command fails.
35
35
  #
36
- # Options: show_cmd, fail_message
36
+ # @option show_cmd: Whether to print the command
37
+ # @option confirm: Whether to ask for confirmation before running it
38
+ # @option fail_message: The text to print on command failure
37
39
  def system!(*commands)
38
40
  options = commands.last.is_a?(Hash) ? commands.pop : {}
39
41
  note_cmd commands.join(' ') if options[:show_cmd]
40
42
 
43
+ if options[:confirm]
44
+ prompt('Run this now?', 'n', /y|yes/) or fail('Cancelled.')
45
+ end
46
+
41
47
  if ENV['GEORDI_TESTING']
42
48
  puts "Util.system! #{ commands.join(' ') }"
43
49
  else
44
50
  # Remove Geordi's Bundler environment when running commands.
45
- Bundler.clean_system(*commands) or fail(options[:fail_message] || 'Something went wrong.')
51
+ success = defined?(Bundler) ? Bundler.clean_system(*commands) : system(*commands)
52
+ success or fail(options[:fail_message] || 'Something went wrong.')
46
53
  end
47
54
  end
48
55
 
@@ -66,6 +73,27 @@ module Geordi
66
73
  `git rev-parse --abbrev-ref HEAD`.strip
67
74
  end
68
75
 
76
+ def retrieve_kernels
77
+ current_kernel = `uname -r`.strip
78
+
79
+ old_kernels = %x{
80
+ dpkg --list | # List installed packages
81
+ grep linux-image | # Filter
82
+ awk '{ print $2 }' | # Print second field (= package name)
83
+ sort -V | # Sort ASC (version number mode)
84
+ sed -n '/'#{ current_kernel }'/q;p' # Cut list at current kernel
85
+ }.split("\n")
86
+
87
+ { :current => current_kernel, :old => old_kernels }
88
+ end
89
+
90
+ def root_required
91
+ unless ENV['GEORDI_TESTING']
92
+ user = `whoami`.strip
93
+ user == 'root' or fail 'Run this as root.'
94
+ end
95
+ end
96
+
69
97
  end
70
98
  end
71
99
  end
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '1.3.2'
2
+ VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
5
- prerelease:
4
+ version: 1.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Henning Koch
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-08-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -107,6 +104,7 @@ files:
107
104
  - lib/geordi/commands/firefox.rb
108
105
  - lib/geordi/commands/migrate.rb
109
106
  - lib/geordi/commands/png_optimize.rb
107
+ - lib/geordi/commands/purge_kernels.rb
110
108
  - lib/geordi/commands/rake.rb
111
109
  - lib/geordi/commands/remove_executable_flags.rb
112
110
  - lib/geordi/commands/rspec.rb
@@ -130,29 +128,28 @@ files:
130
128
  homepage: http://makandra.com
131
129
  licenses:
132
130
  - MIT
133
- post_install_message: ! 'Binary `geordi` installed
131
+ metadata: {}
132
+ post_install_message: ! '* Binary `geordi` installed
134
133
 
135
134
  '
136
135
  rdoc_options: []
137
136
  require_paths:
138
137
  - lib
139
138
  required_ruby_version: !ruby/object:Gem::Requirement
140
- none: false
141
139
  requirements:
142
140
  - - ! '>='
143
141
  - !ruby/object:Gem::Version
144
142
  version: '0'
145
143
  required_rubygems_version: !ruby/object:Gem::Requirement
146
- none: false
147
144
  requirements:
148
145
  - - ! '>='
149
146
  - !ruby/object:Gem::Version
150
147
  version: '0'
151
148
  requirements: []
152
149
  rubyforge_project: geordi
153
- rubygems_version: 1.8.23.2
150
+ rubygems_version: 2.4.8
154
151
  signing_key:
155
- specification_version: 3
152
+ specification_version: 4
156
153
  summary: Collection of command line tools we use in our daily work with Ruby, Rails
157
154
  and Linux at makandra.
158
155
  test_files: []