cardigan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Mark Ryall
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ = Cardigan
2
+
3
+ A simple command line project task tracking tool.
4
+
5
+ == Installation
6
+
7
+ gem install cardigan
8
+
9
+ == Usage
10
+
11
+ cardigan
12
+
13
+ This will prompt for your name and email address (for no good reason at the moment), create a folder called .cards in the current directory and enter a shell.
14
+
15
+ cardigan >
16
+
17
+ So what now?
18
+
19
+ == Listing mode
20
+
21
+ You are in listing mode.
22
+
23
+ The commands available are (with the awesome power of tab completion):
24
+
25
+ * quit
26
+ * exit
27
+ * list - shows all cards
28
+ * list <filter> - shows a subset of cards. Filter is some ruby code such as card[:name].start_with?('a')
29
+ * edit <name> - creates a card and enters edit mode
30
+
31
+ == Editing mode
32
+
33
+ * quit
34
+ * exit
35
+ * set <key> - creates a new key and prompts for the new value
36
+
37
+ == Future plans
38
+
39
+ Refer to the .cards for detailed story breakdown but mostly importing, exporting and generating pretty html reports/charts.
data/bin/cardigan ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.dirname(__FILE__)+'/../lib'
4
+
5
+ require 'cardigan/cli'
6
+
7
+ Cardigan::Cli.new.execute *ARGV
@@ -0,0 +1,26 @@
1
+ require 'cardigan/io'
2
+ require 'cardigan/root_context'
3
+ require 'cardigan/directory'
4
+
5
+ module Cardigan
6
+ class Cli
7
+ CONFIG_FILE = '.cardigan'
8
+
9
+ def initialize io=Io.new
10
+ @io = io
11
+ @home = Directory.new('~')
12
+ end
13
+
14
+ def execute *args
15
+ if @home.has_file?(CONFIG_FILE)
16
+ config = @home.load(CONFIG_FILE)
17
+ else
18
+ config = { :name => @io.ask('Enter your full name'),
19
+ :email => @io.ask('Enter your email address')
20
+ }
21
+ @home.store CONFIG_FILE, config
22
+ end
23
+ RootContext.new(@io, Directory.new('.cards')).push
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,46 @@
1
+ require 'readline'
2
+
3
+ module Cardigan
4
+ module Context
5
+ def refresh
6
+ refresh_commands if respond_to?(:refresh_commands)
7
+ Readline.completion_proc = lambda do |text|
8
+ (@commands + ['quit', 'exit']).grep( /^#{Regexp.escape(text)}/ ).sort
9
+ end
10
+ Readline.completer_word_break_characters = ''
11
+ end
12
+
13
+ def push
14
+ refresh
15
+ begin
16
+ while line = Readline.readline(@prompt_text, true)
17
+ line.strip!
18
+ case line
19
+ when 'quit','exit'
20
+ return
21
+ when /(\w+) (.*)/
22
+ process_command $1, $2
23
+ when /(\w+)/
24
+ process_command $1
25
+ else
26
+ puts 'unknown command'
27
+ end
28
+ puts
29
+ refresh
30
+ end
31
+ rescue Interrupt => e
32
+ return
33
+ end
34
+ puts
35
+ end
36
+
37
+ def process_command name, parameter=nil
38
+ m = "#{name}_command".to_sym
39
+ if respond_to?(m)
40
+ send(m, parameter)
41
+ else
42
+ @io.say 'unknown command'
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,30 @@
1
+ require 'yaml'
2
+ require 'fileutils'
3
+
4
+ module Cardigan
5
+ class Directory
6
+ def initialize path
7
+ @path = File.expand_path(path)
8
+ end
9
+
10
+ def has_file? file
11
+ File.exist? File.join(@path, file)
12
+ end
13
+
14
+ def load file
15
+ YAML::load File.read(File.join(@path, file))
16
+ end
17
+
18
+ def store file, hash
19
+ File.open(File.join(@path, file), 'w') {|f| f.print hash.to_yaml}
20
+ end
21
+
22
+ def create
23
+ FileUtils.mkdir_p @path
24
+ end
25
+
26
+ def find pattern
27
+ Dir.glob(File.join(@path, pattern)).map {|path| YAML::load File.read(path) }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ require 'cardigan/context'
2
+
3
+ module Cardigan
4
+ class EntryContext
5
+ include Context
6
+
7
+ def initialize io, entry
8
+ @io, @entry = io, entry
9
+ @prompt_text = "c/#{entry[:name]} > "
10
+ @commands = ['set']
11
+ end
12
+
13
+ def set_command key
14
+ @entry[:text] = @io.ask("Enter the new value for #{key}")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module Cardigan
2
+ class Io
3
+ def initialize in_io=$stdin, out_io=$stdout
4
+ @in_io, @out_io = in_io, out_io
5
+ end
6
+
7
+ def ask prompt
8
+ @out_io.print "#{prompt} > "
9
+ @in_io.gets.chomp
10
+ end
11
+
12
+ def say message
13
+ @out_io.puts message
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ require 'rubygems'
2
+ require 'uuidtools'
3
+ require 'cardigan/context'
4
+ require 'cardigan/entry_context'
5
+
6
+ module Cardigan
7
+ class RootContext
8
+ include Context
9
+
10
+ def initialize io, directory
11
+ @io, @directory = io, directory
12
+ @directory.create
13
+ @prompt_text = 'cardigan > '
14
+ end
15
+
16
+ def refresh_commands
17
+ @cards = @directory.find('*.card')
18
+ @commands = ['edit', 'list']
19
+ @cards.each do |card|
20
+ @commands << "edit #{card[:name]}"
21
+ end
22
+ end
23
+
24
+ def edit_command text
25
+ card = @cards.find {|card| card[:name] == text}
26
+ card ||= { :id => UUIDTools::UUID.random_create.to_s,
27
+ :name => text
28
+ }
29
+ EntryContext.new(@io, card).push
30
+ @directory.store "#{card[:id]}.card", card
31
+ end
32
+
33
+ def list_command text=nil
34
+ cards = text ? @cards.select {|card| eval text } : @cards
35
+ @io.say "\n#{cards.count} cards"
36
+ cards.map {|card| card[:name] }.sort.each {|name| @io.say name }
37
+ end
38
+ end
39
+ end
40
+
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cardigan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark Ryall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-10 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: highline
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.5.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: uuidtools
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: crypt
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.4
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: pathname2
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.6.3
54
+ version:
55
+ description: |
56
+ A command line utility that manages cards as individual files so that they can be added to a version control system
57
+
58
+ email: mark@ryall.name
59
+ executables:
60
+ - cardigan
61
+ extensions: []
62
+
63
+ extra_rdoc_files: []
64
+
65
+ files:
66
+ - lib/cardigan/cli.rb
67
+ - lib/cardigan/context.rb
68
+ - lib/cardigan/directory.rb
69
+ - lib/cardigan/entry_context.rb
70
+ - lib/cardigan/io.rb
71
+ - lib/cardigan/root_context.rb
72
+ - bin/cardigan
73
+ - README.rdoc
74
+ - MIT-LICENSE
75
+ has_rdoc: true
76
+ homepage: http://github.com/markryall/cardigan
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ requirements: []
97
+
98
+ rubyforge_project:
99
+ rubygems_version: 1.3.5
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: command line utility for managing cards (tasks, bugs, stories or whatever)
103
+ test_files: []
104
+