til_cli 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8571a5af0ee187a3b0bc6156467bc6b0059f946f
4
- data.tar.gz: ab777a8ab74f8c3d614e12acfdc3c91b8ced403b
3
+ metadata.gz: e5424f2ec2c5462dcbe69ab9808149afb244060b
4
+ data.tar.gz: 4d4dd31c6439a6352c67630271dff2d99a11da4e
5
5
  SHA512:
6
- metadata.gz: 5b45f55fd8e8c8ca524d202db891b0137b8bc7fb3bf4ed4aff5a22adac11554ce3eb4138969b75cc38c7dd8c2c175f077689ceadba44153990bcd7fc0d5bf8d6
7
- data.tar.gz: b4a562bde54b96dc139bdffdf371e1c4d809fded1af998833fe77633a4ab1e3e15a7b8224ffb44481d78463ae7e73265c7fc086518b6d3751b6c8cf4378bb2bf
6
+ metadata.gz: 5cb0ddd2b70237c028d57d4df2d94eaefad02f0f90ba1c35f9e67ce886e19ca27062ad09f425f0b518de4578e143c1bc3a1fc732769ae28925e4deee6435f380
7
+ data.tar.gz: 96816a2a720219aa531cacf0e77132c37a10fe8ef4d5ec238695ad94be44a3cf96f1062939e632579067bdba040a9b060c6c4d9d721e48ac93223f93f03e143f
data/README.md CHANGED
@@ -9,7 +9,7 @@ sudo gem install til_cli
9
9
 
10
10
  ## Setup
11
11
  ```
12
- til init
12
+ til config
13
13
  ```
14
14
 
15
15
  ## Usage
data/lib/til.rb CHANGED
@@ -7,19 +7,10 @@ require 'til/models/note_list'
7
7
  require 'til/services/note_writer'
8
8
  require 'til/services/note_editor'
9
9
  require 'til/services/note_deleter'
10
+ require 'til/services/note_displayer'
10
11
  require 'til/services/initializer'
11
12
 
12
13
  module Til
13
- HIGHLIGHT_COLORS = {
14
- 0 => :yellow,
15
- 1 => :light_blue,
16
- 2 => :green,
17
- 3 => :blue,
18
- 4 => :red,
19
- 5 => :magenta,
20
- 6 => :light_magenta,
21
- }
22
-
23
14
  def self.config_settings_file_and_notes_repo
24
15
  Initializer.new.create_settings_file
25
16
  Initializer.new.create_notes_directory
@@ -63,7 +54,6 @@ module Til
63
54
  matches
64
55
  end
65
56
 
66
-
67
57
  def self.edit_file(search_term, options)
68
58
  if options[:last]
69
59
  system(Settings.load.editor, Directory.root.notes.most_recent.path)
@@ -94,16 +84,16 @@ module Til
94
84
  repo = %x|git --git-dir=#{Settings.load.directory}/.git --work-tree=#{Settings.load.directory} remote -v|.scan(/:(.*).git/).flatten.first
95
85
  system("open https://www.github.com/#{repo}")
96
86
  rescue
97
- puts "You don't appear to have a GitHub remote repository for your notes."
87
+ puts "You don't appear to have a GitHub remote repository for your notes.".red
98
88
  end
99
89
  end
100
90
  end
101
91
 
92
+
102
93
  def self.run_git_command(*args)
103
94
  system("git --git-dir=#{Settings.load.directory}/.git --work-tree=#{Settings.load.directory} #{args.join(" ")}")
104
95
  end
105
96
 
106
-
107
97
  def self.run_grep_command(*args)
108
98
  system("grep -r #{args.join(" ")} #{Settings.load.directory}")
109
99
  end
@@ -112,17 +102,19 @@ module Til
112
102
  system("ag #{args.join(" ")} #{Settings.load.directory}")
113
103
  end
114
104
 
115
-
116
105
  def self.print_most_recent_note quantity
117
- Directory.root.notes.sort_by_modified_time.take(quantity).each {|note| Til.print note}
106
+ notes = Directory.root.notes.sort_by_modified_time.take(quantity)
107
+ notes.each {|note| NoteDisplayer.new(note).print}
118
108
  end
119
109
 
120
110
  def self.print_all_notes
121
- Directory.root.notes.each {|note| Til.print note}
111
+ notes = Directory.root.notes
112
+ NoteDisplayer.new(notes).print
122
113
  end
123
114
 
124
115
  def self.print_all_notes_in(subject)
125
- Directory.for(subject).notes.each {|note| Til.print note}
116
+ notes = Directory.for(subject).notes
117
+ NoteDisplayer.new(notes).print
126
118
  end
127
119
 
128
120
  def self.list_notes_in(subject)
@@ -130,9 +122,9 @@ module Til
130
122
  if notes.empty?
131
123
  puts "You don't seem to have any notes on that subject!"
132
124
  puts "You DO have notes on the following subjects:"
133
- Til.list_subjects :flat
125
+ Til.list_subjects
134
126
  else
135
- Til.enumerate notes
127
+ NoteDisplayer.new(notes).list
136
128
  end
137
129
  end
138
130
 
@@ -151,23 +143,10 @@ module Til
151
143
  def self.list_all_notes
152
144
  notes = Directory.root.notes.sort_by_modified_time
153
145
  puts "Listing all #{notes.length} notes: "
154
- Til.enumerate notes
146
+ NoteDisplayer.new(notes).list
155
147
  end
156
148
 
157
149
  def self.print note
158
- puts note.subject.underline + ": " + note.title.bold + " (" + note.pretty_printed_mtime + ")"
159
- puts note.content
160
- end
161
-
162
- def self.enumerate notes
163
- subjects_seen = Array.new
164
- longest_subject_length = notes.sort_by{|note| note.subject.length}.last.subject.length
165
- notes.each do |note|
166
- subjects_seen.push(note.subject) if !subjects_seen.include?(note.subject)
167
- color_index = subjects_seen.index(note.subject) % HIGHLIGHT_COLORS.length
168
- color = HIGHLIGHT_COLORS[color_index]
169
- spacing = " " * (longest_subject_length - note.subject.length)
170
- puts note.subject.colorize(color) + ": " + spacing + note.title.bold + " (" + note.pretty_printed_mtime + ")"
171
- end
150
+ NoteDisplayer.new(note).print
172
151
  end
173
152
  end
@@ -1,6 +1,7 @@
1
1
  module Til
2
2
  class Note
3
3
  attr_accessor :path
4
+
4
5
  def initialize path
5
6
  @path = path
6
7
  end
@@ -36,5 +37,9 @@ module Til
36
37
  def date_modified
37
38
  @date_modified ||= mtime.to_date
38
39
  end
40
+
41
+ def to_note_list
42
+ NoteList.new([self])
43
+ end
39
44
  end
40
45
  end
@@ -8,8 +8,12 @@ module Til
8
8
  @notes = notes
9
9
  end
10
10
 
11
+ def to_note_list
12
+ self
13
+ end
14
+
11
15
  def sort_by_modified_time
12
- notes.sort { |a, b| b.mtime <=> a.mtime }
16
+ NoteList.new(notes.sort { |a, b| b.mtime <=> a.mtime })
13
17
  end
14
18
 
15
19
  def most_recent
@@ -0,0 +1,39 @@
1
+ module Til
2
+ class NoteDisplayer
3
+ attr_accessor :notes
4
+
5
+ HIGHLIGHT_COLORS = {
6
+ 0 => :yellow,
7
+ 1 => :light_blue,
8
+ 2 => :green,
9
+ 3 => :blue,
10
+ 4 => :red,
11
+ 5 => :magenta,
12
+ 6 => :light_magenta,
13
+ }
14
+
15
+ def initialize notes
16
+ @notes = notes.to_note_list
17
+ end
18
+
19
+ def print
20
+ notes.each do |note|
21
+ puts note.subject.underline + ": " + note.title.bold + " (" + note.pretty_printed_mtime + ")"
22
+ puts note.content
23
+ end
24
+ end
25
+
26
+ def list
27
+ subjects_seen = Array.new
28
+ longest_subject_length = notes.sort_by{|note| note.subject.length}.last.subject.length
29
+ notes.each do |note|
30
+ subjects_seen.push(note.subject) if !subjects_seen.include?(note.subject)
31
+ color_index = subjects_seen.index(note.subject) % HIGHLIGHT_COLORS.length
32
+ color = HIGHLIGHT_COLORS[color_index]
33
+ spacing = " " * (longest_subject_length - note.subject.length)
34
+ puts note.subject.colorize(color) + ": " + spacing + note.title.bold + " (" + note.pretty_printed_mtime + ")"
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Til
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency "bundler", "~> 1.7"
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
  spec.add_dependency "thor", "~> 0.19.1"
23
- spec.add_dependency "colorize", "~> 0.7.7"
23
+ spec.add_dependency "colorize", ">= 0.7.2"
24
24
  spec.add_dependency "json", "1.8.1"
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: til_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Litchfield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-28 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: colorize
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.7.7
61
+ version: 0.7.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.7.7
68
+ version: 0.7.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,7 @@ files:
102
102
  - lib/til/models/settings.rb
103
103
  - lib/til/services/initializer.rb
104
104
  - lib/til/services/note_deleter.rb
105
+ - lib/til/services/note_displayer.rb
105
106
  - lib/til/services/note_editor.rb
106
107
  - lib/til/services/note_finder.rb
107
108
  - lib/til/services/note_writer.rb