doneski 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 577d92d59a306cacb1c4296049d61d9f80f5a0db
4
+ data.tar.gz: 696ff74c7360f8ae6cbccc21c85a5cec6d721a35
5
+ SHA512:
6
+ metadata.gz: c3b16435c538d2cd6efe8ebc74f354d5df373f7d4787f276cd63be97b6cef6eb0f5bddd30e3493cdad9b35c19cc08a1294e3dbf6186b30beda9466deba4db434
7
+ data.tar.gz: 5d7d3e2aa31291a1fe9194f4392fa0dc2c9892a55dac4c975d191125b1a5b12705c26e6c9454752e7b0f2528b84beb22c73dca9463b70737969959a7a0f073ca
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in doneski.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Chad McKenna
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # doneski
2
+
3
+ This is a quick CLI to manage tasks.
4
+
5
+ ``` ./lib/doneski.rb -h ```
6
+
7
+ I recommend adding an alias to the app:
8
+
9
+ ``` alias done=~/Location/Of/Directory/doneski/lib/doneski.rb ```
10
+
11
+ "This is just a sample":
12
+
13
+ ![alt tag](https://raw.github.com/chadmckenna/doneski/master/screenshot.png)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'doneski'
4
+
5
+ @done = TasksCollection.new
6
+ @sort = :stage
7
+
8
+ options = {}
9
+
10
+ optparse = OptionParser.new do |opts|
11
+ opts.banner = "Usage: doneski.rb"
12
+
13
+ opts.on('-l', '--list [sort]', 'Show all tasks. Optionally you can supply a column to sort by: id, title, date_created, or stage') do |sort|
14
+ @sort = sort.downcase.to_sym if sort && ['id', 'title', 'date_created', 'stage'].include?(sort.downcase)
15
+ @done.all
16
+ end
17
+
18
+ opts.on('-r', '--remove [ID]', 'Clears all completed tasks from the list') do |id|
19
+ @done.remove id: id if id
20
+ @done.remove stage: Task::STATUS[:complete] unless id
21
+ end
22
+
23
+ opts.on('-a', '--add title', 'Add a new task') do |title|
24
+ @sort = :date_created
25
+ ARGV.unshift title
26
+ @done.add("#{ARGV.join(' ')}")
27
+ end
28
+
29
+ opts.on('-s', '--start id', 'Start a task') do |id|
30
+ @done.start(id)
31
+ end
32
+
33
+ opts.on('-f', '--finish id', "Finish a task") do |id|
34
+ @done.finish(id)
35
+ end
36
+
37
+ opts.on('-h', '--help', 'Display help') do
38
+ puts opts
39
+ exit
40
+ end
41
+
42
+ end
43
+ optparse.parse!
44
+
45
+ puts TasksCollection.display_header
46
+ puts @done.sort(@sort)
47
+ puts TasksCollection.display_footer
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'doneski/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "doneski"
8
+ spec.version = Doneski::VERSION
9
+ spec.authors = ["Chad McKenna"]
10
+ spec.email = ["chad.mckenna@gmail.com"]
11
+ spec.summary = %q{A simple task management CLI}
12
+ spec.description = %q{A simple task management CLI similar in usage to PivotalTracker.}
13
+ spec.homepage = "https://github.com/chadmckenna/doneski"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,3 @@
1
+ require "doneski/version"
2
+ require "doneski/tasks_collection"
3
+ require "doneski/task"
@@ -0,0 +1,33 @@
1
+ class Task
2
+ attr_reader :id
3
+ attr_accessor :title, :date_created, :date_updated, :stage
4
+
5
+ STATUS = {new: 1, started: 5, complete: 2}
6
+
7
+ def initialize(options)
8
+ @id = options['id'] || (0...4).map { ('a'..'z').to_a[rand(26)] }.join
9
+ @title = options['title']
10
+ @stage = options['stage'] || STATUS[:new]
11
+ @date_created = options['date_created'] || Time.now
12
+ @date_updated = options['date_updated'] || nil
13
+ end
14
+
15
+ def complete
16
+ @date_updated = Time.now
17
+ @stage = STATUS[:complete]
18
+ end
19
+
20
+ def start
21
+ @date_updated = Time.now
22
+ @stage = STATUS[:started]
23
+ end
24
+
25
+ def match(options)
26
+ options.each{|key, value| return true if self.send(key) == value}
27
+ false
28
+ end
29
+
30
+ def to_s
31
+ "| \e[0;3#{stage.to_s}m#{id.to_s.ljust(8)}#{title.ljust(80)[0...80]}#{date_created.to_s.ljust(30)}#{date_updated.to_s.ljust(30)}\e[0m |"
32
+ end
33
+ end
@@ -0,0 +1,58 @@
1
+ require 'yaml/store'
2
+
3
+ class TasksCollection
4
+
5
+ @@location = ENV['HOME'] + '/.task.store'
6
+
7
+ def initialize
8
+ `touch #{@@location}`
9
+ @yaml = YAML.load_file(@@location)
10
+ @tasks = @yaml ? @yaml['tasks'] : []
11
+ end
12
+
13
+ def all
14
+ @tasks
15
+ end
16
+
17
+ def sort(column = :stage)
18
+ @tasks.sort {|a, b| a.send(column) <=> b.send(column)}
19
+ end
20
+
21
+ def remove(options)
22
+ @tasks = @tasks.select{|task| !task.match(options)}
23
+ store
24
+ end
25
+
26
+ def add(title)
27
+ @tasks << Task.new({'title' => title})
28
+ store
29
+ end
30
+
31
+ def finish(id)
32
+ @tasks.select{|task| task.id.to_s == id.to_s}.first.complete
33
+ store
34
+ end
35
+
36
+ def start(id)
37
+ @tasks.select{|task| task.id.to_s == id.to_s}.first.start
38
+ store
39
+ end
40
+
41
+ def self.display_header
42
+ "#{'-'*152}\n| #{'id:'.ljust(8)}#{'title:'.ljust(80)}#{'created:'.ljust(30)}#{'updated:'.ljust(30)} |\n#{'-'*152}"
43
+ end
44
+
45
+ def self.display_footer
46
+ "#{'-'*152}"
47
+ end
48
+
49
+ private
50
+
51
+ def store
52
+ @store = YAML::Store.new(@@location)
53
+ @store.transaction do
54
+ @store['tasks'] = @tasks
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,3 @@
1
+ module Doneski
2
+ VERSION = "0.1.0"
3
+ end
Binary file
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doneski
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chad McKenna
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A simple task management CLI similar in usage to PivotalTracker.
42
+ email:
43
+ - chad.mckenna@gmail.com
44
+ executables:
45
+ - doneski
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/doneski
56
+ - doneski.gemspec
57
+ - lib/doneski.rb
58
+ - lib/doneski/task.rb
59
+ - lib/doneski/tasks_collection.rb
60
+ - lib/doneski/version.rb
61
+ - screenshot.png
62
+ homepage: https://github.com/chadmckenna/doneski
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.3
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: A simple task management CLI
86
+ test_files: []