hiptask 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ddde3405e73d4ffdd450cfa6f8bbee865676918
4
- data.tar.gz: e006b4c161f5faeee9cc606e8f7ae49c042aed23
3
+ metadata.gz: 47fac6c67dd4402ee8a4167db588b9b4fc6f63ac
4
+ data.tar.gz: efbd5a2461e92151df86f3dcacc371f4de26bf96
5
5
  SHA512:
6
- metadata.gz: 56d1371238a331a2aabb61cabbb591c0bc13029d040308c6f8617821635495613c5f56470e67f951c7c0c7a2dee43788b3217f40811c7550ba5263ad3d946ed0
7
- data.tar.gz: 001144adffc87f25b47f39b3bc0e443572b255372460fefebfff8ad168ce2ca54f896b423646c13eb9686bdad8d4fc5dfc1cd08cac4cd0edcd3cd7f9ad957431
6
+ metadata.gz: 75b06db0db15031f0ea64cb88b3c842f98599540d376f5ba54bae6c781787980da4e85cdf70a8c498a0910f361b87d1919a622047f478f03371624505ef024e2
7
+ data.tar.gz: bbd5c4f8754cf3e3410531f82211e47b68e663a02498890729e4a0b13837931fd6f72760bb98aa2630528cf739b40ec78fce742c1ab92de98e26e6fc88c55a40
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Marc Qualie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,14 +1,17 @@
1
- ## Simple
1
+ ## Hiptask
2
2
 
3
3
  A hipster command line task applicaiton for me to put my newly learn ruby skills to practical use.
4
4
 
5
5
  ### Usage
6
6
 
7
- hiptask # prints help
7
+ hiptask # displays your task list
8
+ hiptask help # full list of commands
8
9
  hiptask list # displays your task list
9
10
  hiptask add CONTENT # adds a new task
10
11
  hiptask do ID # marks a task as complete
11
12
  hiptask undo ID # reverts task to normal
13
+ hiptask update ID CONTENT # update task content
14
+ hiptask config [ACTION] [KEY] [VALUE] # manipulate config variables
12
15
  hiptask delete ID # deletes a task forever
13
16
 
14
17
  ### Feedback
data/bin/hiptask CHANGED
@@ -5,4 +5,9 @@ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
5
 
6
6
  # Initialize CLI tool
7
7
  require 'hiptask/cli'
8
- Hiptask::CLI.start(ARGV)
8
+
9
+ begin
10
+ Hiptask::CLI.start(ARGV)
11
+ rescue
12
+ $stderr.puts "\n \033[31;1mHiptask Error:\033[0;31m #{$!.message}\033[0m\n\n"
13
+ end
data/hiptask.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
2
+ require 'hiptask/version'
3
+
4
+ Gem::Specification.new do |gem|
5
+
6
+ gem.name = "hiptask"
7
+ gem.version = Hiptask::VERSION
8
+ gem.description = "A simple command line tool for tracking your task list"
9
+ gem.summary = "Hipster tasks on the Command Line"
10
+
11
+ gem.email = "marc@marcqualie.com"
12
+ gem.author = "Marc Qualie"
13
+ gem.homepage = "https://github.com/marcqualie/hiptask"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency "thor", "~> 0.18.1"
22
+
23
+ end
data/lib/hiptask/cli.rb CHANGED
@@ -1,15 +1,67 @@
1
1
  require 'thor'
2
2
  require 'hiptask/list'
3
+ require 'hiptask/version'
4
+ require 'yaml'
3
5
 
4
6
  module Hiptask
5
7
 
6
8
  class CLI < Thor
7
9
 
8
- @@filename = './tasks.txt'
10
+ default_task :list
11
+
12
+
13
+ @@config = {}
14
+ @@config_file = ENV['HOME'] + '/.hiptask/config.yml'
15
+ @@tasks_file = ENV['HOME'] + '/.hiptask/tasks.txt'
16
+ @@message = nil
17
+
9
18
 
10
19
  def self.start(argv)
11
- @@list = List.new(@@filename)
20
+
21
+ # Config
22
+ config_dir = File.dirname(@@config_file)
23
+ Dir.mkdir(config_dir) unless Dir.exists? config_dir
24
+ unless File.exists? @@config_file
25
+ file = File.open(@@config_file, "w+") { |file |
26
+ file.puts "tasks_file: " + @@tasks_file
27
+ }
28
+ end
29
+ @@config = YAML::load_file(@@config_file)
30
+ @@tasks_file = @@config['tasks_file'] if @@config['tasks_file']
31
+
32
+ # Environment
33
+ @@list = List.new(@@tasks_file)
34
+
12
35
  super argv
36
+
37
+ end
38
+
39
+
40
+ desc "config [ACTION] [KEY] [VAL]", "Get a config variable"
41
+ def config(action=nil, key=nil, value=nil)
42
+ case action
43
+ when 'get'
44
+ puts @@config[key]
45
+ when 'set'
46
+ if value
47
+ @@config[key] = value
48
+ puts key + ' = ' + value.to_s
49
+ else
50
+ @@config.delete(key) unless value
51
+ puts "deleted " + key
52
+ end
53
+ File.open(@@config_file, "w") { |file|
54
+ YAML.dump(@@config, file)
55
+ }
56
+ when 'delete'
57
+ puts "deleted " + key
58
+ @@config.delete(key)
59
+ File.open(@@config_file, "w") { |file|
60
+ YAML.dump(@@config, file)
61
+ }
62
+ else
63
+ puts @@config
64
+ end
13
65
  end
14
66
 
15
67
 
@@ -17,18 +69,24 @@ module Hiptask
17
69
  def list()
18
70
 
19
71
  puts " "
72
+ puts " \033[33m[ \033[1m#{@@message}\033[0;33m ]\033[0m\n\n" if @@message
73
+
20
74
  puts " \033[32;1m#{@@list.items.length} Items\033[0m"
21
75
  puts " "
22
- @@list.items.each_with_index do |item, index|
23
- index = index + 1
24
- print " \033[33m#{index.to_s.ljust(2)}\033[0m"
25
- if item.start_with? ">"
26
- print " [x] "
27
- puts "#{item[1, item.length - 1]}"
28
- else
29
- print " [ ] "
30
- puts "#{item}"
31
- end
76
+ if @@list.items.length > 0
77
+ @@list.items.each_with_index { |item, index|
78
+ index = index + 1
79
+ print " \033[33m#{index.to_s.ljust(2)}\033[0m"
80
+ if item.start_with? ">"
81
+ print " [x] "
82
+ puts "#{item[1, item.length - 1]}"
83
+ else
84
+ print " [ ] "
85
+ puts "#{item}"
86
+ end
87
+ }
88
+ else
89
+ puts " \033[33mAdd a new task with: \033[1mhiptask add \"Get milk\"\033[0m"
32
90
  end
33
91
  puts " "
34
92
 
@@ -38,6 +96,7 @@ module Hiptask
38
96
  desc "add CONTENT", "Add a new task"
39
97
  def add(content)
40
98
  @@list.add(content)
99
+ @@message = "Task #{@@list.items.length - 1} was created"
41
100
  list
42
101
  end
43
102
 
@@ -45,13 +104,23 @@ module Hiptask
45
104
  desc "do ID", "Complete a task"
46
105
  def do(id)
47
106
  @@list.do(id)
107
+ @@message = "Task #{id} is now marked as complete"
48
108
  list
49
109
  end
50
110
 
51
111
 
52
- desc "undo ID", "Complete a task"
112
+ desc "undo ID", "Un-complete a task"
53
113
  def undo(id)
54
114
  @@list.undo(id)
115
+ @@message = "Task #{id} is now marked as incomplete"
116
+ list
117
+ end
118
+
119
+
120
+ desc "update ID CONTENT", "Update a task"
121
+ def update(id, content)
122
+ @@list.update(id, content)
123
+ @@message = "Task #{id} updated"
55
124
  list
56
125
  end
57
126
 
@@ -59,9 +128,17 @@ module Hiptask
59
128
  desc "delete ID", "Delete a task"
60
129
  def delete(id)
61
130
  @@list.delete(id)
131
+ @@message = "Task #{id} deleted"
62
132
  list
63
133
  end
64
134
 
135
+
136
+ desc "version", "Displays current version"
137
+ def version
138
+ puts "Hiptask #{Hiptask::VERSION}"
139
+ end
140
+
141
+
65
142
  end
66
143
 
67
144
  end
data/lib/hiptask/list.rb CHANGED
@@ -62,6 +62,16 @@ module Hiptask
62
62
  end
63
63
 
64
64
 
65
+ def update(id, content)
66
+ id = id.to_i - 1
67
+ raise "ID must be greater than 0" if id < 0
68
+ raise "Task not found" unless @items[id]
69
+ done = @items[id].start_with? ">"
70
+ @items[id] = (done ? ">" : "") + content
71
+ save
72
+ end
73
+
74
+
65
75
  def delete(id)
66
76
  id = id.to_i - 1
67
77
  raise "ID must be greater than 0" if id < 0
@@ -0,0 +1,5 @@
1
+ module Hiptask
2
+
3
+ VERSION = "0.0.2"
4
+
5
+ end
data/test/tc_list.rb CHANGED
@@ -1,38 +1,52 @@
1
- require 'test/unit'
2
- require 'hiptask/list'
1
+ $:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
2
+
3
+ require "test/unit"
4
+ require "hiptask/list"
3
5
 
4
6
  class TestList < Test::Unit::TestCase
5
7
 
6
8
  def test_add
7
- list = Hiptask::List.new('/dev/null')
9
+ list = Hiptask::List.new("/dev/null")
8
10
  list.add("Test 1")
9
11
  puts list.items
10
12
  assert_equal(list.items, ["Test 1"])
11
13
  end
12
14
 
13
15
  def test_do
14
- list = Hiptask::List.new('/dev/null')
16
+ list = Hiptask::List.new("/dev/null")
15
17
  list.add("Test 1")
16
18
  assert_equal(list.items, ["Test 1"])
17
- list.do('1')
19
+ list.do("1")
18
20
  assert_equal(list.items, [">Test 1"])
19
21
  end
20
22
 
21
23
  def test_undo
22
- list = Hiptask::List.new('/dev/null')
24
+ list = Hiptask::List.new("/dev/null")
23
25
  list.add("Test 1")
24
26
  assert_equal(list.items, ["Test 1"])
25
- list.do('1')
27
+ list.do("1")
26
28
  assert_equal(list.items, [">Test 1"])
27
- list.undo('1')
29
+ list.undo("1")
30
+ assert_equal(list.items, ["Test 1"])
31
+ end
32
+
33
+ def test_update
34
+ list = Hiptask::List.new("/dev/null")
35
+ list.add("Test 1")
28
36
  assert_equal(list.items, ["Test 1"])
37
+ list.update("1", "Test 2")
38
+ assert_equal(list.items, ["Test 2"])
39
+ list.do("1")
40
+ assert_equal(list.items, [">Test 2"])
41
+ list.update("1", "Test 3")
42
+ assert_equal(list.items, [">Test 3"])
29
43
  end
30
44
 
31
45
  def test_delete
32
- list = Hiptask::List.new('/dev/null')
46
+ list = Hiptask::List.new("/dev/null")
33
47
  list.add("Test 1")
34
48
  assert_equal(list.items, ["Test 1"])
35
- list.delete('1')
49
+ list.delete("1")
36
50
  assert_equal(list.items, [])
37
51
  end
38
52
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiptask
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Qualie
@@ -32,10 +32,13 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - .gitignore
35
+ - LICENSE
35
36
  - README.md
36
37
  - bin/hiptask
38
+ - hiptask.gemspec
37
39
  - lib/hiptask/cli.rb
38
40
  - lib/hiptask/list.rb
41
+ - lib/hiptask/version.rb
39
42
  - test/tc_list.rb
40
43
  homepage: https://github.com/marcqualie/hiptask
41
44
  licenses: