pbm 0.0.0 → 0.0.2

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/pbm +23 -1
  3. data/lib/pbm/commands/exit.rb +9 -0
  4. data/lib/pbm.rb +23 -0
  5. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e25c264ed7dbf28bb78fdefbd58a9ac33f87534
4
- data.tar.gz: ac32a037f2ea41c35e9a63a872662df6ed488860
3
+ metadata.gz: 72395ba1ec7512460857a4f71404909a9602b316
4
+ data.tar.gz: c77ab99a57e6f8f26068fc2e291c5291d10f40e6
5
5
  SHA512:
6
- metadata.gz: f522dfdfa3ec32d52c8d7c57e39c34f0650e2fbf88df63dfe9e6c23afd323ee4d759055c34ee4abe9318776911e267f8ec9875bff222922be8e153e6b05047e3
7
- data.tar.gz: 68dc008106716f003d0e13ec1277de51bd5b9df006064c5b28c7f2a93a51415ad87750891319cdda9b632ef1f101921decabe5cb46bba5328f4ff0e210325d85
6
+ metadata.gz: 9f26ef8d9fdb9c3f82dd3a52eaeaadbe1d792ea50a2e49b0be66848b7b0bb0bfb752d8f5588fc93355d669653e40ce41636693dc44a65dbcca7121a0e8974c5a
7
+ data.tar.gz: dbad43f52fd56108f03fbc120ee113f64555760ce30b5935cb4770a95adeec792bcd473e12085b5ef4c1f5800e353f318a1f19e27c22406e3654b64f28960bb6
data/bin/pbm CHANGED
@@ -1,3 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- puts 'Not implemented yet'
3
+ require 'pbm'
4
+
5
+ pbm = PBM.new
6
+
7
+ puts '============================='
8
+ puts 'PBM - Personal Budget Manager'
9
+ puts '============================='
10
+ puts
11
+ puts 'Type \'help\' to display a list of commands.'
12
+ puts 'Type \'exit\' to quit.'
13
+ puts
14
+
15
+ while pbm.running?
16
+ command = gets.chomp
17
+
18
+ begin
19
+ pbm.exec(command)
20
+ rescue => e
21
+ puts e.message
22
+ end
23
+ end
24
+
25
+ puts 'Closing.'
@@ -0,0 +1,9 @@
1
+ class Exit
2
+ def initialize(pbm)
3
+ @pbm = pbm
4
+ end
5
+
6
+ def run
7
+ @pbm.running = false
8
+ end
9
+ end
data/lib/pbm.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'pbm/commands/exit'
2
+
3
+ class PBM
4
+ attr_writer :running
5
+
6
+ def initialize
7
+ @running = true
8
+ @commands = {
9
+ :exit => Exit.new(self)
10
+ }
11
+ end
12
+
13
+ def exec command
14
+ command.to_sym.tap do |c|
15
+ raise "#{c}: invalid command." unless @commands.has_key?(c)
16
+ @commands[c].run
17
+ end
18
+ end
19
+
20
+ def running?
21
+ !!@running
22
+ end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tarso Aires
@@ -18,6 +18,8 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - bin/pbm
21
+ - lib/pbm.rb
22
+ - lib/pbm/commands/exit.rb
21
23
  homepage: http://rubygems.org/gems/pbm
22
24
  licenses:
23
25
  - MIT