jah 0.0.3 → 0.0.5

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.
Files changed (69) hide show
  1. data/README.md +62 -13
  2. data/Rakefile +4 -3
  3. data/VERSION +1 -1
  4. data/bin/jah +4 -2
  5. data/jah.gemspec +73 -21
  6. data/lib/jah/act_pkg/apt.rb +13 -0
  7. data/lib/jah/act_pkg/base.rb +17 -0
  8. data/lib/jah/act_pkg/emerge.rb +4 -0
  9. data/lib/jah/act_pkg/pacman.rb +59 -0
  10. data/lib/jah/act_pkg/pkg.rb +52 -0
  11. data/lib/jah/act_pkg/ports.rb +9 -0
  12. data/lib/jah/act_pkg/slack.rb +8 -0
  13. data/lib/jah/act_pkg/urpm.rb +7 -0
  14. data/lib/jah/act_pkg/yum.rb +31 -0
  15. data/lib/jah/act_pkg/zypp.rb +12 -0
  16. data/lib/jah/act_pkg.rb +41 -0
  17. data/lib/jah/agent.rb +14 -6
  18. data/lib/jah/agents/xmpp.rb +164 -23
  19. data/lib/jah/cli.rb +15 -46
  20. data/lib/jah/command.rb +10 -5
  21. data/lib/jah/commands/cpu.rb +38 -0
  22. data/lib/jah/commands/disk.rb +35 -0
  23. data/lib/jah/commands/mem.rb +49 -0
  24. data/lib/jah/{collectors/net.rb → commands/netstat.rb} +11 -9
  25. data/lib/jah/commands/packages.rb +25 -0
  26. data/lib/jah/commands/prok.rb +97 -0
  27. data/lib/jah/commands/services.rb +14 -0
  28. data/lib/jah/commands/status.rb +1 -41
  29. data/lib/jah/commands/who.rb +27 -0
  30. data/lib/jah/history.rb +25 -0
  31. data/lib/jah/install.rb +12 -18
  32. data/lib/jah/opt.rb +87 -0
  33. data/lib/jah/prayer.rb +75 -0
  34. data/lib/jah.rb +21 -13
  35. data/lib/locales/en_us.yml +9 -1
  36. data/lib/locales/pt_br.yml +9 -1
  37. data/spec/jah/act_pkg/apt_spec.rb +40 -0
  38. data/spec/jah/act_pkg/pacman_spec.rb +141 -0
  39. data/spec/jah/act_pkg/pkg_spec.rb +51 -0
  40. data/spec/jah/act_pkg/ports_spec.rb +36 -0
  41. data/spec/jah/act_pkg/yum_spec.rb +55 -0
  42. data/spec/jah/act_pkg_spec.rb +41 -0
  43. data/spec/jah/agent_spec.rb +8 -0
  44. data/spec/jah/agents/xmpp_spec.rb +8 -0
  45. data/spec/jah/cli_spec.rb +47 -0
  46. data/spec/jah/command_spec.rb +5 -0
  47. data/spec/jah/commands/cpu_spec.rb +51 -0
  48. data/spec/jah/commands/disk_spec.rb +49 -0
  49. data/spec/jah/commands/mem_spec.rb +60 -0
  50. data/spec/jah/commands/netstat_spec.rb +13 -0
  51. data/spec/jah/commands/prok_spec.rb +248 -0
  52. data/spec/jah/commands/who_spec.rb +25 -0
  53. data/spec/jah/history_spec.rb +35 -0
  54. data/spec/jah/install_spec.rb +15 -0
  55. data/spec/jah/opt_spec.rb +37 -0
  56. data/spec/jah/prayer_spec.rb +8 -0
  57. data/spec/jah_spec.rb +4 -2
  58. data/spec/spec_helper.rb +3 -1
  59. metadata +67 -16
  60. data/lib/jah/collector.rb +0 -12
  61. data/lib/jah/collectors/cpu.rb +0 -35
  62. data/lib/jah/collectors/disk.rb +0 -14
  63. data/lib/jah/collectors/mem.rb +0 -51
  64. data/lib/jah/collectors/prok.rb +0 -88
  65. data/lib/jah/collectors/services.rb +0 -13
  66. data/lib/jah/collectors/who.rb +0 -20
  67. data/lib/jah/commands/pub.rb +0 -34
  68. data/lib/jah/god.rb +0 -24
  69. data/lib/jah.yaml.template +0 -26
@@ -3,58 +3,18 @@ module Jah
3
3
  class Status
4
4
  include Command
5
5
  register(:ok, 'ok\??$')
6
- register(:who, 'who\??$')
7
- register(:mem, 'mem\??$')
8
- register(:cpu, 'cpu\??$')
9
- register(:net, 'net\??$')
10
- register(:disk, 'disk\??$')
11
- register(:proks, 'prok$|top$')
12
6
 
13
7
 
14
8
  class << self
15
9
 
16
10
  def ok
17
- I18n.t("states." + case Jah::Cpu.get.med
11
+ I18n.t("states." + case Jah::Cpu.med
18
12
  when 0..0.5 then :green
19
13
  when 0.51..0.7 then :yellow
20
14
  else :red
21
15
  end.to_s)
22
16
  end
23
17
 
24
- def mem
25
- Mem.get.percent.to_s + "%"
26
- end
27
-
28
- def cpu
29
- Cpu.get.load
30
- end
31
-
32
- def net
33
- out = ""
34
- Net.connections.each do |c|
35
- out << "#{c[0]} => #{c[1]} connections\n"
36
- end
37
- out << "Total: #{Net.count}"
38
- end
39
-
40
- def disk
41
- Disk.all.map do |d|
42
- "\n*#{d[:path]}* => #{d[:percent]}"
43
- end.join("\n")
44
- end
45
-
46
- def who
47
- Who.all.map do |w|
48
- "#{w[:who]} Logado via #{w[:terminal]} desde a data: #{w[:date]}"
49
- end.join("\n")
50
- end
51
-
52
- def proks(find = nil)
53
- Ps.all.map do |p|
54
- next if find && p.comm !~ /#{find}/i
55
- "#{p.comm} => #{p.mem}\n"
56
- end
57
- end
58
18
 
59
19
  end
60
20
  end
@@ -0,0 +1,27 @@
1
+ module Jah
2
+
3
+ class Who
4
+ include Command
5
+ register(:snap, 'who\??$')
6
+
7
+ def self.snap
8
+ all.map do |w|
9
+ "#{w[:who]} Logado via #{w[:terminal]} desde a data: #{w[:date]}"
10
+ end.join("\n")
11
+ end
12
+
13
+ def self.all
14
+ @who = `who`.to_a.map do |l|
15
+ l = l.split(" ")
16
+
17
+ hash = {}
18
+
19
+ hash[:who] = l[0]
20
+ hash[:tty] = l[1]
21
+ 2.times{ l.delete(l[0]) }
22
+ hash[:date] = l.join(" ")
23
+ hash
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ module Jah
2
+
3
+ class History
4
+
5
+ @cache = []
6
+
7
+ class << self
8
+
9
+ def set(jid, body, time = Time.now)
10
+ @cache << [jid, body, time]
11
+ end
12
+ alias :add :set
13
+
14
+ def all(filter = nil)
15
+ filter ? @cache.select { |i| i[0] =~ /#{filter}/ } : @cache
16
+ end
17
+
18
+ # delegate?
19
+ def method_missing(*meth)
20
+ @cache.send(*meth)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
data/lib/jah/install.rb CHANGED
@@ -16,20 +16,16 @@ module Jah
16
16
 
17
17
  Hello, thanks for trying Jah!
18
18
 
19
- Looks like #{Jah.hostname} doesn`t have a config file, shall we create one?
19
+ Looks like #{Opt.hostname} doesn`t have a config file, shall we create one?
20
20
 
21
21
  Jah needs to know how it will run: xmpp, post or dump.
22
22
 
23
23
  END_MODE
24
24
  mode = nil
25
25
  print "Enter mode: "
26
- while mode.nil?
27
- mode = case gets.to_s.strip
28
- when /xmpp/i then :xmpp
29
- when /post/i then :post
30
- when /dumpp/i then :dump
31
- else print "Valid: xmpp, post or dump: "; nil
32
- end
26
+ while mode !~ /xmpp|post|dump/i
27
+ print "Valid: xmpp, post or dump: "
28
+ mode = gets.strip
33
29
  end
34
30
  @config[:mode] = mode
35
31
  end
@@ -122,7 +118,7 @@ Use commas to separate multiple ones.
122
118
 
123
119
  END_INTRO
124
120
  print "ACL: "
125
- @config[:acl] = gets.strip
121
+ @config[:acl] = gets.split(",").map(&:strip)
126
122
  end
127
123
 
128
124
  #
@@ -139,7 +135,7 @@ Use commas to separate multiple ones.
139
135
 
140
136
  END_INTRO
141
137
  print "Groups: "
142
- @config[:groups] = gets.strip
138
+ @config[:groups] = gets.split(",").map(&:strip)
143
139
  end
144
140
 
145
141
 
@@ -239,9 +235,9 @@ Available options:
239
235
  * #{locs.join("\n* ")}
240
236
 
241
237
  END_I18N
242
- print "Choose one (#{Jah.locale}): "
238
+ print "Choose one (#{Opt.locale}): "
243
239
  @config[:i18n] = gets.to_s.strip.downcase
244
- @config[:i18n] = Jah.locale if @config[:i18n] == ""
240
+ @config[:i18n] = Opt.locale if @config[:i18n] == ""
245
241
  end
246
242
 
247
243
  #
@@ -279,11 +275,9 @@ END_ERROR
279
275
 
280
276
  def write_down
281
277
  outfile = "jah.yaml"
282
- template = File.read(File.join(File.dirname(__FILE__), '..', 'jah.yaml.template'))
283
278
  @outfile = File.writable?("/etc/") ? "/etc/" + outfile : HOME + outfile
284
279
  puts "Writing config to #{@outfile}.."
285
- @config.keys.each { |k| template.gsub!(/#{k.to_s.upcase}/, @config[k].to_s) }
286
- File.open(@outfile, "w") { |f| f.write template }
280
+ File.open(@outfile, "w") { |f| f.write @config.to_yaml }
287
281
  end
288
282
 
289
283
  def initialize
@@ -291,14 +285,14 @@ END_ERROR
291
285
  puts "No config file found.. running install.."
292
286
 
293
287
  @config = {}
294
- @config[:host] = Jah.hostname
288
+ @config[:host] = Opt.hostname
295
289
  get_mode
296
- if @config[:mode] == :xmpp
290
+ if @config[:mode] == 'xmpp'
297
291
  @config[:host] = ''
298
292
  get_jid
299
293
  get_pass
300
294
  end
301
- if @config[:mode] == :post
295
+ if @config[:mode] == 'post'
302
296
  @config[:jid] = ''
303
297
  get_key
304
298
  end
data/lib/jah/opt.rb ADDED
@@ -0,0 +1,87 @@
1
+ require 'logger'
2
+
3
+ module Jah
4
+
5
+ HOME = ENV['HOME'] + "/.jah/"
6
+ unless File.exists? HOME
7
+ FileUtils.mkdir_p HOME
8
+ end
9
+
10
+ I18n.default_locale = "en_us"
11
+
12
+ Log = Logger.new(HOME + "jah.log")
13
+ def Log.write(d); self.warn(d); end
14
+ # $stderr = Log
15
+
16
+ # Opt = {}
17
+ OptBackup = {}
18
+
19
+ class Opt
20
+ @hash = {}
21
+
22
+ class << self
23
+ def hash
24
+ @hash
25
+ end
26
+
27
+ def defaults
28
+ { :mode => "xmpp", :daemon => false, :port => 5222 }
29
+ end
30
+
31
+ def hostname
32
+ @hostame ||= `hostname`.chomp.gsub(/\W/, "") rescue "jah#{rand(42000)}"
33
+ end
34
+
35
+ def locale
36
+ @locale ||= `locale | grep LANG`.scan(/LANG=(.*)\./)[0][0].downcase rescue "en_us"
37
+ end
38
+
39
+ # Load config [., ~/.jah, /etc]
40
+ def autoload_config(options)
41
+ conf = "jah.yaml"
42
+ unless file = options[:config]
43
+ if file = [nil, HOME, "/etc/"].select { |c| File.exists? "#{c}#{conf}" }[0]
44
+ file << conf
45
+ options[:config] = file
46
+ end
47
+ end
48
+ options = YAML.load(File.read(file)).merge!(options) if file rescue nil
49
+
50
+ I18n.locale = options[:i18n] if options[:i18n]
51
+ options[:groups] ||= []
52
+
53
+ @hash.merge!(defaults )
54
+ @hash.merge!(options)
55
+ OptBackup.merge!(@hash)
56
+ end
57
+
58
+ def closing_time!
59
+ if @hash != OptBackup
60
+ puts "Writing config..."
61
+ File.open(@hash[:config], "w+") do |f|
62
+ f.write "# Auto generated on #{Time.now}"
63
+ f.write @hash.to_yaml
64
+ end
65
+ end
66
+ end
67
+
68
+ def [](val); @hash[val]; end
69
+ def []=(key, val); @hash[key] = val; end
70
+ def merge!(val); @hash.merge!(val); end
71
+
72
+ def method_missing(*meth)
73
+ key = meth[0].to_s.gsub(/\?|=/, "").to_sym
74
+ if val = meth[1]
75
+ @hash[key] = val
76
+ elsif !(val = @hash[key]).nil?
77
+ val
78
+ else
79
+ raise "No method #{ val} #{key}"
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ end
86
+
87
+ end
data/lib/jah/prayer.rb ADDED
@@ -0,0 +1,75 @@
1
+ module Jah
2
+
3
+ class Prayer
4
+
5
+ def initialize(config)
6
+ @config = config
7
+ setup
8
+ ping
9
+ end
10
+
11
+ def self.watch(options = {})
12
+
13
+ God.watch do |w|
14
+ w.name = "jah"
15
+ w.interval = 1.minute
16
+ w.start = "jah #{options[:config]}"
17
+ w.start_grace = 10.seconds
18
+ w.restart_grace = 10.seconds
19
+
20
+ w.start_if do |start|
21
+ start.condition(:process_running) do |c|
22
+ c.running = false
23
+ end
24
+ end
25
+
26
+ w.restart_if do |restart|
27
+ restart.condition(:memory_usage) do |c|
28
+ c.above = 30.megabytes
29
+ c.times = [3, 5]
30
+ end
31
+
32
+ restart.condition(:cpu_usage) do |c|
33
+ c.above = 25.percent
34
+ c.times = 5
35
+ end
36
+ end
37
+
38
+ w.lifecycle do |on|
39
+ on.condition(:flapping) do |c|
40
+ c.to_state = [:start, :restart]
41
+ c.times = 5
42
+ c.within = 5.minute
43
+ c.transition = :unmonitored
44
+ c.retry_in = 10.minutes
45
+ c.retry_times = 5
46
+ c.retry_within = 2.hours
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ def setup
53
+ DRb.start_service
54
+ @server = DRbObject.new(nil, God::Socket.socket(@config['god_port'])) || nil
55
+ rescue => e
56
+ @config[:god] = false
57
+ end
58
+
59
+ # ping server to ensure that it is responsive
60
+ def ping
61
+ if god?
62
+ tries = 3
63
+ begin
64
+ @server.ping
65
+ rescue Exception => e
66
+ retry if (tries -= 1) > 1
67
+ raise e, "The server is not available (or you do not have permissions to access it)"
68
+ end
69
+ end
70
+ end
71
+
72
+
73
+ end
74
+ end
75
+
data/lib/jah.rb CHANGED
@@ -1,26 +1,34 @@
1
1
  require 'rubygems'
2
2
  require 'optparse'
3
- require 'i18n'
3
+ begin
4
+ require 'i18n'
5
+ rescue LoadError
6
+ puts "Gem i18n not found. Try `gem install i18n`"
7
+ end
4
8
  #autoload :Drb, 'drb'
5
- autoload :God, 'god'
9
+ require 'jah/opt'
6
10
  require 'jah/cli'
7
11
  require 'jah/install'
8
12
  require 'jah/agent'
9
- require 'jah/collector'
10
- require "jah/collectors/mem"
11
- require "jah/collectors/cpu"
12
- require "jah/collectors/net"
13
- require "jah/collectors/disk"
14
- require "jah/collectors/prok"
15
- require "jah/collectors/net"
16
- require "jah/collectors/who"
13
+ require 'jah/history'
14
+ autoload :God, 'god'
15
+ autoload :Prayer, "jah/prayer"
17
16
  require 'jah/command'
17
+ require "jah/commands/mem"
18
+ require "jah/commands/cpu"
19
+ require "jah/commands/who"
20
+ require "jah/commands/disk"
21
+ require "jah/commands/prok"
22
+ require "jah/commands/netstat"
18
23
  require "jah/commands/admin"
19
24
  require "jah/commands/status"
20
25
  require "jah/commands/extra"
21
- require "jah/commands/pub"
26
+ require "jah/commands/packages"
27
+ require "jah/act_pkg"
28
+ require "jah/act_pkg/base"
29
+ require "jah/act_pkg/pkg"
22
30
 
23
31
  module Jah
24
- VERSION = "0.0.1"
25
-
32
+ VERSION = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
33
+ I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'locales', "*.{rb,yml}")]
26
34
  end
@@ -1,2 +1,10 @@
1
1
  en_us:
2
- fail: Fail..
2
+ fail: Fail..
3
+ exit_code: Exit code
4
+ access_fail: Access Fail
5
+ ok: Ok!
6
+ no_sudo: No sudo!
7
+ states:
8
+ green: Everything ok...
9
+ yellow: Start to worry about me...
10
+ red: Overload! Overload!
@@ -1,2 +1,10 @@
1
1
  pt_br:
2
- fail: Falhou..
2
+ fail: Falhou..
3
+ exit_code: Comando não fechou bem...
4
+ access_fail: Você não tem permissão!
5
+ ok: Ok!
6
+ no_sudo: sudo desabilitado!
7
+ states:
8
+ green: Tudo nos padrões...
9
+ yellow: Começo a me preocupar...
10
+ red: Sistema bem carregado!
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require "jah/act_pkg/apt"
3
+
4
+ describe Apt do
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ AP = <<APT
17
+ Desired=Unknown/Install/Remove/Purge/Hold
18
+ | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
19
+ |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
20
+ ||/ Name Version Description
21
+ +++-=============================================================-=========================================-=======================================================
22
+ ii ack-grep 1.80-1 A grep-like program specifically for large source trees
23
+ ii acl 2.2.47-2 Access control list utilities
24
+ ii acpi-support 0.121 scripts for handling many ACPI events
25
+ ii acpid 1.0.6-9ubuntu4.9.04.3 Utilities for using ACPI power management
26
+ ii adduser 3.110ubuntu5 add and remove users and groups
27
+ ii adobe-certs 1.5.8870 Certificates distributed by Adobe Systems.
28
+ ii adobe-flashplugin 10.0.32.18-1jaunty1 Adobe Flash Player plugin version 10
29
+ ii adobeair1.0 1.5.2.8870 Adobe AIR
30
+ ii alacarte 0.11.10-0ubuntu1 easy GNOME menu editing tool
31
+ ii alien 8.73 convert and install rpm and other packages
32
+ ii alsa-base 1.0.18.dfsg-1ubuntu8 ALSA driver configuration files
33
+ ii alsa-utils 1.0.18-1ubuntu11 ALSA utilities
34
+ ii amarok 2:2.0.2mysql5.1.30-0ubuntu3 easy to use media player based on the KDE 4 technology
35
+ ii amarok-common 2:2.0.2mysql5.1.30-0ubuntu3
36
+ ii bind9-host 1:9.5.1.dfsg.P2-1ubuntu0.1
37
+ APT
38
+
39
+
40
+ end
@@ -0,0 +1,141 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require "jah/act_pkg/pacman"
3
+
4
+ describe Pacman do
5
+
6
+ before do
7
+ @pac ||= Pacman.new
8
+ end
9
+
10
+ describe "Searching" do
11
+ before do
12
+ @pac.should_receive(:"`").with("pacman -Ss ruby").and_return(SS)
13
+ @pac.should_receive(:"`").with("pacman -Q").and_return(QL)
14
+ @pkgs = @pac.search("ruby")
15
+ end
16
+
17
+ it "should find pkgs" do
18
+ first = @pkgs[0]
19
+ first.name.should eql("ruby")
20
+ first.desc.should eql("An object-oriented language for quick and easy programming")
21
+ end
22
+
23
+ it "should work nicely" do
24
+ @pkgs[1].name.should eql("ruby-docs")
25
+ @pkgs[1].desc.should eql("Documentation files for ruby")
26
+ end
27
+
28
+ it "should have ruby" do
29
+ @pkgs[0].should be_installed
30
+ end
31
+
32
+ it "should not be installed" do
33
+ @pkgs[1].should_not be_installed
34
+ end
35
+
36
+ it "should install if I want" do
37
+ Pacman.should_receive(:new).and_return(@pac)
38
+ @pac.should_receive(:"`").with("pacman -Sy --noconfirm ruby")
39
+ @pkgs[0].install
40
+ end
41
+
42
+ end
43
+
44
+ it "should install stuff" do
45
+ @pac.should_receive(:"`").with("pacman -Sy --noconfirm foo")
46
+ @pac.install mock(Pkg, :name => "foo")
47
+ end
48
+
49
+ it "should list pkgs" do
50
+ @pac.should_receive(:"`").with("pacman -Q").and_return(QL)
51
+ @pac.all.first.should be_instance_of(Pkg)
52
+ end
53
+
54
+
55
+ describe "List" do
56
+
57
+ before do
58
+ @pac.stub!(:"`").and_return(QL)
59
+ @pkgs = @pac.all
60
+ @ruby = @pkgs[11]
61
+ end
62
+
63
+ it "should have name" do
64
+ @pkgs[0].name.should eql("a2ps")
65
+ end
66
+
67
+ it "should have version" do
68
+ @pkgs[0].version.should eql("4.14-1")
69
+ end
70
+
71
+ it "should fetch info about a pkg" do
72
+ @ruby.info.should be_instance_of Hash #("http://www.ruby-lang.org/en/")
73
+ end
74
+
75
+ it "should fetch url" do
76
+ @ruby.url.should eql("http://www.ruby-lang.org/en/")
77
+ end
78
+
79
+ it "should fetch arch" do
80
+ @ruby.arch.should eql("i686")
81
+ end
82
+
83
+ it "should fetch desc" do
84
+ @ruby.desc.should eql("An object-oriented language for quick and easy programming")
85
+ end
86
+
87
+ it "should fetch license" do
88
+ @ruby.license.should eql("custom")
89
+ end
90
+
91
+ end
92
+
93
+ SS = <<SS
94
+ extra/ruby 1.8.7_p174-1 [4.67 MB]
95
+ An object-oriented language for quick and easy programming
96
+ extra/ruby-docs 1.8.7_p174-1 [0.87 MB]
97
+ Documentation files for ruby
98
+ SS
99
+
100
+ QL = <<QL
101
+ a2ps 4.14-1
102
+ a52dec 0.7.4-4
103
+ acl 2.2.47-2
104
+ alsa-lib 1.0.21.a-1
105
+ ca-certificates 20090709-1
106
+ couchdb-svn 784601-1
107
+ emacs-cvs 20090730-1
108
+ emacs-magit-git 20090811-1
109
+ flashplugin 10.0.32.18-1.1
110
+ hal-info 0.20090716-2
111
+ libmad 0.15.1b-4
112
+ ruby 1.8.7_p174-1
113
+ xz-utils 4.999.9beta-1
114
+ QL
115
+
116
+ QI = <<QI
117
+ Name : ruby
118
+ Version : 1.8.7_p174-1
119
+ URL : http://www.ruby-lang.org/en/
120
+ Licenses : custom
121
+ Groups : None
122
+ Provides : None
123
+ Depends On : gdbm>=1.8.3 db>=4.7.25 openssl>=0.9.8k zlib>=1.2.3.3 readline>=6
124
+ Optional Deps : None
125
+ Required By : rubygems shoes
126
+ Conflicts With : None
127
+ Replaces : None
128
+ Installed Size : 11308.00 K
129
+ Packager : Allan McRae <allan@archlinux.org>
130
+ Architecture : i686
131
+ Build Date : Mon 20 Jul 2009 12:29:57 AM BRT
132
+ Install Date : Thu 23 Jul 2009 10:47:30 PM BRT
133
+ Install Reason : Explicitly installed
134
+ Install Script : No
135
+ Description : An object-oriented language for quick and easy programming
136
+
137
+
138
+ QI
139
+
140
+
141
+ end
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Pkg do
4
+
5
+ it "should instantiate" do
6
+ Pkg.new(:installed, "ruby", "1.9.1").should be_valid
7
+ end
8
+
9
+ describe "One pkg" do
10
+ before do
11
+ @pkg = Pkg.new(:installed, "jah", "1.0.0", "Talk to your machines.")
12
+ end
13
+
14
+ it "should have a name" do
15
+ @pkg.name.should eql("jah")
16
+ end
17
+
18
+ it "should have a version" do
19
+ @pkg.version.should eql("1.0.0")
20
+ end
21
+
22
+ it "should have a description" do
23
+ @pkg.desc.should eql("Talk to your machines.")
24
+ end
25
+
26
+ it "should have a installed meth" do
27
+ @pkg.should be_installed
28
+ end
29
+
30
+ it "should check equality with others" do
31
+ pkg2 = Pkg.new(:installed, "foo", "2.5b")
32
+ @pkg.should_not == pkg2
33
+ end
34
+
35
+ it "should check equality with others 2" do
36
+ pkg2 = Pkg.new(:installed, "jah", "1.0.0")
37
+ @pkg.should == pkg2
38
+ end
39
+
40
+ it "should compare version" do
41
+ pkg2 = Pkg.new(:installed, "jah", "1.0.1")
42
+ @pkg.should be < pkg2
43
+ pkg2.should be > @pkg
44
+ end
45
+
46
+ it "should not compare diff pkgs" do
47
+ pkg2 = Pkg.new(:installed, "foo", "1.0.1")
48
+ lambda { pkg2 > @pkg }.should raise_error
49
+ end
50
+ end
51
+ end