thor_tasks 0.0.8 → 0.0.9

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.
@@ -0,0 +1,41 @@
1
+ class Apt < Thor
2
+ include Thor::Actions
3
+
4
+ map "s" => :search
5
+
6
+ desc "search \"terms\"", "runs apt-cache search and pretty-prints the output"
7
+ def search(terms)
8
+ # attempt to load rainbow for pretty-print
9
+ begin
10
+ require 'rainbow'
11
+ pp = true
12
+ rescue GEM::LoadError
13
+ pp = false
14
+ end
15
+ # run apt-cache search
16
+ results = `apt-cache search "#{terms}"`.split("\n")
17
+ # create a Hash out of the results
18
+ results = results.inject({}) { |r,k| r[k.partition(" - ")[0]] = k.partition(" - ")[2]; r }
19
+ # find the longest key
20
+ longest = 0
21
+ results.each do |k,v|
22
+ longest = k.length > longest ? k.length : longest
23
+ end
24
+ # pretty print the results
25
+ results.each do |k,v|
26
+ if pp
27
+ # print the name in bright yellow
28
+ print "#{k}".foreground(:yellow).bright
29
+ # pad the names with spaces
30
+ print "#{" " * (longest - k.length)}"
31
+ # print the description in green
32
+ print " #{v}\n".foreground(:white).bright
33
+ else
34
+ # print the name, padding, and description
35
+ puts "#{k + " " * (longest - k.length) + " " + v}"
36
+ end
37
+ end
38
+ # restore the terminal color
39
+ print "".reset
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module ThorTasks
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/thor_tasks.gemspec CHANGED
@@ -18,4 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
+
22
+ s.add_dependency(%q<rainbow>, [">= 1.1.1"])
21
23
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Travis Haynes
@@ -14,10 +14,24 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-06-30 00:00:00 -07:00
17
+ date: 2011-07-04 00:00:00 -07:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rainbow
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 1
31
+ - 1
32
+ version: 1.1.1
33
+ type: :runtime
34
+ version_requirements: *id001
21
35
  description: A collection of helpful thor tasks to use in Ruby on Rails projects.
22
36
  email:
23
37
  - travis.j.haynes@gmail.com
@@ -33,6 +47,7 @@ files:
33
47
  - Gemfile
34
48
  - README.rdoc
35
49
  - Rakefile
50
+ - lib/tasks/apt.thor
36
51
  - lib/tasks/mongo.thor
37
52
  - lib/tasks/spec.thor
38
53
  - lib/tasks/spork.thor