toga 0.0.1 → 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.
data/README.md CHANGED
@@ -12,6 +12,7 @@ Toga is a rubygem.
12
12
 
13
13
  ## Usage
14
14
 
15
+ $ toga init .
15
16
  $ mate Togafile
16
17
 
17
18
 
data/Togafile CHANGED
@@ -1,17 +1,12 @@
1
1
  CURRENT
2
2
 
3
- Regularly clean up whitespace in Togafile
4
- Synchronize how docs refer to "complete" with the codebase
3
+ Add dashes in front of tasks on strip
4
+ Handle misspelled tasks
5
5
 
6
- Add later command and current command.
7
6
  LATER
8
7
 
9
-
10
8
  Append timestamps on complete
11
9
  Append commit logs on push
12
-
13
-
14
-
15
10
  Add later
16
11
 
17
12
  MAYBE
@@ -20,11 +15,13 @@ Import previous git commit messages and put into completed group, so that toga i
20
15
  Scan for @todos in project and create `later` tasks for them
21
16
  Support multiline tasks (kind of don't want to)
22
17
 
23
-
24
-
25
18
  COMPLETED
19
+
20
+ Ensure completed task moves to completed group
21
+ Prepend completed tasks instead of appending
26
22
  Make toga commit interactive
27
23
  ! If you use a random heading in your file, the system includes its tasks in the preceding group
28
-
29
-
30
-
24
+ Update readme with correct init cmd.
25
+ Add later command and current command.
26
+ Add completed command
27
+ Regularly clean up whitespace in Togafile
data/USAGE CHANGED
@@ -7,7 +7,7 @@ Toga is a todo list for git.
7
7
 
8
8
  Examples:
9
9
  toga An empty command just prints this usage.
10
- toga <PATH> Creates a Togafile in that directory.
10
+ toga init <PATH> Creates a Togafile in that directory and adds the Togafile to your .gitignore.
11
11
  toga list <GROUP> Prints the task list. Optionally, print a specific list by name.
12
12
  toga edit Opens up the Togafile in your local editor.
13
13
  toga ignore .gitignores your Togafile
@@ -4,7 +4,7 @@ module Toga
4
4
 
5
5
  def self.run!(*args)
6
6
  Togafile.append_to_group :current, args.join(' ')
7
- Togafile.lines_in_group :current
7
+ puts Togafile.lines_in_group :current
8
8
  end
9
9
  end
10
10
  end
@@ -26,7 +26,9 @@ module Toga
26
26
  files_to_add = '.'
27
27
  if untracked.count > 0 || modified.count > 0 || added.count == 0
28
28
  if untracked.count > 0
29
+ files_to_add = [] if files_to_add.is_a? String
29
30
  puts error("You didn't add the following files:\n")
31
+ files_to_add.concat untracked
30
32
  puts untracked.join("\n") + "\n\n"
31
33
  end
32
34
 
@@ -37,7 +39,8 @@ module Toga
37
39
 
38
40
  if added.count == 0
39
41
  changed = git.status.changed.keys
40
- files_to_add = changed
42
+ files_to_add = [] if files_to_add.is_a? String
43
+ files_to_add.concat changed
41
44
  puts error("The following files are modified, but their changes aren't added:\n")
42
45
  puts changed.join("\n") + "\n\n"
43
46
  end
@@ -3,8 +3,8 @@ module Toga
3
3
  class Complete < Command
4
4
 
5
5
  def self.run!(*args)
6
- prefix = args.join(' ')
7
- Togafile.move prefix, :current => :completed
6
+ prefix = args.join(' ').strip
7
+ Togafile.move prefix, {:current => :completed}, {prepend: true}
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,10 @@
1
+ module Toga
2
+ module Commands
3
+ class Completed < Command
4
+
5
+ def self.run!(*args)
6
+ puts Commands::List.run! [:completed]
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'git'
2
3
 
3
4
  module Toga
4
5
  module Commands
@@ -12,9 +13,25 @@ module Toga
12
13
  FileUtils.mkdir_p dir if !File.directory?(dir)
13
14
 
14
15
  # Copies the Togafile scaffold to the new Togafile
15
- File.open(File.expand_path(File.join(dir, Toga::TOGAFILE_NAME)), 'w') do |f|
16
- togafile = File.expand_path(File.join(Toga::SCAFFOLD_PATH, Toga::TOGAFILE_NAME))
17
- f.write File.open(togafile).read
16
+ new_togafile = File.expand_path(File.join(dir, Toga::TOGAFILE_NAME))
17
+ unless File.exists?(new_togafile)
18
+ File.open(new_togafile, 'w') do |f|
19
+ togafile = File.expand_path(File.join(Toga::SCAFFOLD_PATH, Toga::TOGAFILE_NAME))
20
+ f.write File.open(togafile).read
21
+ end
22
+ end
23
+
24
+ # Add togafile to the .gitignore.
25
+ begin
26
+ git = Git.open(File.expand_path(File.join(dir)))
27
+ if !git.status.ignored.keys.include?(Toga::TOGAFILE_NAME)
28
+
29
+ File.open(File.expand_path(File.join(dir, '.gitignore')), 'a') do |f|
30
+ f.write Toga::TOGAFILE_NAME
31
+ end
32
+ end
33
+ rescue
34
+ puts "Couldn't find .gitignore, so Togafile won't be ignored by git."
18
35
  end
19
36
 
20
37
  "Created #{Toga::TOGAFILE_NAME} in #{dir}."
@@ -0,0 +1,10 @@
1
+ module Toga
2
+ module Commands
3
+ class Strip < Command
4
+
5
+ def self.run!(*args)
6
+ Togafile.strip!
7
+ end
8
+ end
9
+ end
10
+ end
@@ -28,18 +28,23 @@ module Toga
28
28
  end
29
29
 
30
30
  def append_to_group(group_name, string)
31
+ strip!
32
+
31
33
  lines = self.to_a
32
34
  range = group_range(group_name)
33
35
  last_index = range.last
34
36
 
35
37
  # Insert string at the end of the group
36
- lines.insert(last_index+1, string)
38
+ last_index += 1 if lines[last_index].strip != ""
39
+ lines.insert(last_index, string)
37
40
 
38
41
  # Write array back to file
39
42
  overwrite(lines)
40
43
  end
41
44
 
42
45
  def prepend_to_group(group_name, string)
46
+ strip!
47
+
43
48
  lines = self.to_a
44
49
  range = group_range(group_name)
45
50
  first_index = range.first + 1 # Add one to bypass title
@@ -71,7 +76,7 @@ module Toga
71
76
  full
72
77
  end
73
78
 
74
- def move(prefix, move_hash)
79
+ def move(prefix, move_hash, options)
75
80
  from = move_hash.keys.first
76
81
  to = move_hash.values.first
77
82
  if !lines_in_group(from).includes_prefix?(prefix)
@@ -79,7 +84,11 @@ module Toga
79
84
  end
80
85
 
81
86
  full = self.remove_from_group(from, prefix)
82
- self.append_to_group(to, full)
87
+ if options[:prepend]
88
+ self.prepend_to_group(to, full)
89
+ else
90
+ self.append_to_group(to, full)
91
+ end
83
92
  end
84
93
 
85
94
  def search(prefix)
@@ -144,6 +153,37 @@ module Toga
144
153
  group
145
154
  end
146
155
 
156
+ # Cleans all the whitespace in the file.
157
+ def strip!
158
+ lines = self.to_a
159
+ line_after_heading = false
160
+ in_group = ""
161
+ copy = []
162
+ lines.each_with_index do |line, i|
163
+ if line_after_heading == true
164
+ # Insert a blank line before the start of a group
165
+ copy << ""
166
+
167
+ line_after_heading = false
168
+ end
169
+
170
+ unless line == ""
171
+ # Copy the line
172
+ copy << line
173
+ end
174
+
175
+ in_group = line.match(HEADING_REGEX)
176
+ if in_group
177
+ # Insert a blank line after the end of a group
178
+ copy.insert copy.length-1, "" unless i == 0
179
+ line_after_heading = true
180
+ end
181
+
182
+ end
183
+
184
+ overwrite(copy)
185
+ end
186
+
147
187
  def overwrite(lines)
148
188
  handle = file_handle('w')
149
189
  lines.each {|l| handle.puts(l) }
@@ -1,3 +1,3 @@
1
1
  module Toga
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: git
16
- requirement: &70286308535840 !ruby/object:Gem::Requirement
16
+ requirement: &70366277590620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70286308535840
24
+ version_requirements: *70366277590620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: require_relative
27
- requirement: &70286308535240 !ruby/object:Gem::Requirement
27
+ requirement: &70366277590120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70286308535240
35
+ version_requirements: *70366277590120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &70286308534640 !ruby/object:Gem::Requirement
38
+ requirement: &70366277589620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70286308534640
46
+ version_requirements: *70366277589620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &70286308533960 !ruby/object:Gem::Requirement
49
+ requirement: &70366277589200 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70286308533960
57
+ version_requirements: *70366277589200
58
58
  description: a todo list that integrates seamlessly with git
59
59
  email:
60
60
  - me@colinyoung.com
@@ -76,6 +76,7 @@ files:
76
76
  - lib/toga/commands/add.rb
77
77
  - lib/toga/commands/commit.rb
78
78
  - lib/toga/commands/complete.rb
79
+ - lib/toga/commands/completed.rb
79
80
  - lib/toga/commands/current.rb
80
81
  - lib/toga/commands/init.rb
81
82
  - lib/toga/commands/later.rb
@@ -83,6 +84,7 @@ files:
83
84
  - lib/toga/commands/now.rb
84
85
  - lib/toga/commands/remove.rb
85
86
  - lib/toga/commands/rm.rb
87
+ - lib/toga/commands/strip.rb
86
88
  - lib/toga/commands/top.rb
87
89
  - lib/toga/commands/uncomplete.rb
88
90
  - lib/toga/error.rb