til_cli 0.0.3 → 0.0.4

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: d407f12beba107ba569ca26aa41c4dbe553e873e
4
- data.tar.gz: 9869122a9a035906d72ebbd57d36d66354fad19e
3
+ metadata.gz: 219d074e0bd606858cd008f6524db4a64646a4bb
4
+ data.tar.gz: 6fe01b25f7acecace8c85ca0c9e4ad541beb4cde
5
5
  SHA512:
6
- metadata.gz: 90e17b8c04f47edbd94523d29f67aadd4d025fbed09c234fd67685f85d765aa0eebb0b35291fb2d6fcceb11bf464ef139de5b8c232ab5b46c14694a7f4de396a
7
- data.tar.gz: 2ead72d1c5d2429f7386aa759857f15ac9201b79b99f5be5c1e6d3f1d614b7aa6be48e3e46014169e22d90b41b1e49f44971fadf2048ac99f65d191d4372f3cb
6
+ metadata.gz: db05e1a5be6541a85e3bd558aac099eee84df76585c23b404cbd44e2428be74d12884f68b466837373b1de45846cbc355431a2395a32d9d44caa3f9dc23937b0
7
+ data.tar.gz: 97f119ee3338e1508d72ee871a46dea63003ba89ff19ab6d83b06ffcdfba9bc75a02481de25ca287be8da31e79afa704b0e6ffe7d21988cdffc3bde8c2f9fed3
data/lib/til.rb CHANGED
@@ -10,8 +10,6 @@ require 'til/note_deleter'
10
10
  require 'til/initializer'
11
11
 
12
12
  module Til
13
- DIRECTORY = -> () { Settings.load.directory }
14
- GITHUB_REPO = -> () { Settings.load.github_repo }
15
13
  EDITOR = ENV["VISUAL"] || ENV["EDITOR"] || "vim"
16
14
  HIGHLIGHT_COLORS = {
17
15
  0 => :yellow,
@@ -26,11 +24,11 @@ module Til
26
24
  def self.init_settings_file_and_notes_repo
27
25
  Initializer.new.create_settings_file unless Settings.settings_file_configured?
28
26
  Initializer.new.create_notes_directory
29
- puts "Your settings file is at `#{Settings.settings_file_path}`. Your notes are at `#{DIRECTORY}`."
27
+ puts "Your settings file is at `#{Settings.settings_file_path}`. Your notes are at `#{Settings.load.directory}`."
30
28
  end
31
29
 
32
30
  def self.print_working_directory
33
- puts DIRECTORY
31
+ puts Settings.load.directory
34
32
  end
35
33
 
36
34
  def self.new_note(subject, title)
@@ -40,7 +38,7 @@ module Til
40
38
  end
41
39
 
42
40
  if_modified = Proc.new do |note_content|
43
- subject_path = DIRECTORY + "/#{subject.downcase}"
41
+ subject_path = Settings.load.directory + "/#{subject.downcase}"
44
42
  if !File.directory? subject_path
45
43
  FileUtils.mkdir(subject_path)
46
44
  puts "Created a new directory for #{subject.downcase}"
@@ -91,10 +89,11 @@ module Til
91
89
  end
92
90
 
93
91
  def self.open_github_page_for_repo
94
- if GITHUB_REPO
92
+ if Settings.github_repo
93
+ system("open https://www.github.com/#{Settings.github_repo}")
95
94
  else
96
95
  begin
97
- repo = %x|git --git-dir=#{DIRECTORY}/.git --work-tree=#{DIRECTORY} remote -v|.scan(/:(.*).git/).flatten.first
96
+ repo = %x|git --git-dir=#{Settings.load.directory}/.git --work-tree=#{Settings.load.directory} remote -v|.scan(/:(.*).git/).flatten.first
98
97
  system("open https://www.github.com/#{repo}")
99
98
  rescue
100
99
  puts "You don't appear to have a GitHub remote repository for your notes."
@@ -103,16 +102,16 @@ module Til
103
102
  end
104
103
 
105
104
  def self.run_git_command(*args)
106
- system("git --git-dir=#{DIRECTORY}/.git --work-tree=#{DIRECTORY} #{args.join(" ")}")
105
+ system("git --git-dir=#{Settings.load.directory}/.git --work-tree=#{Settings.load.directory} #{args.join(" ")}")
107
106
  end
108
107
 
109
108
 
110
109
  def self.run_grep_command(*args)
111
- system("grep -r #{args.join(" ")} #{DIRECTORY}")
110
+ system("grep -r #{args.join(" ")} #{Settings.load.directory}")
112
111
  end
113
112
 
114
113
  def self.run_ag_command(*args)
115
- system("ag #{args.join(" ")} #{DIRECTORY}")
114
+ system("ag #{args.join(" ")} #{Settings.load.directory}")
116
115
  end
117
116
 
118
117
 
@@ -141,8 +140,8 @@ module Til
141
140
 
142
141
  def self.list_subjects(list_style=:bullet_points)
143
142
  subjects = Array.new
144
- Dir.glob(DIRECTORY + "/*").each do |dirname|
145
- subjects.push dirname.gsub(DIRECTORY + "/", "")
143
+ Dir.glob(Settings.load.directory + "/*").each do |dirname|
144
+ subjects.push dirname.gsub(Settings.load.directory + "/", "")
146
145
  end
147
146
  if list_style==:flat
148
147
  puts subjects.join(", ")
data/lib/til/directory.rb CHANGED
@@ -6,9 +6,9 @@ module Til
6
6
 
7
7
  def initialize(subject=nil)
8
8
  if subject
9
- @path = DIRECTORY + "/#{subject}/*.md"
9
+ @path = Settings.load.directory + "/#{subject}/*.md"
10
10
  else
11
- @path = DIRECTORY + "/**/*.md"
11
+ @path = Settings.load.directory + "/**/*.md"
12
12
  end
13
13
  end
14
14
 
@@ -6,9 +6,12 @@ module Til
6
6
  include Thor::Actions
7
7
 
8
8
  def create_settings_file
9
- notes_directory = ask("What directory do you want your notes to live in? (If you have no preference, `~/til` is a good option.)\n>")
9
+ notes_directory = ask("What directory do you want your TIL notes to live in? (If you have no preference, `~/til` is a good option.)\n>")
10
+ github_repo = ask("Do you have a GitHub repo for your TIL notes? If so, enter it in the form `kevinlitchfield/til`.\n>")
11
+
10
12
  settings_hash = {
11
- "directory" => notes_directory
13
+ "directory" => notes_directory,
14
+ "github_repo" => github_repo
12
15
  }
13
16
  puts "Creating a settings file at `#{Settings.settings_file_path}`."
14
17
  File.open(Settings.settings_file_path, "w") do |f|
@@ -17,7 +20,7 @@ module Til
17
20
  end
18
21
 
19
22
  def create_notes_directory
20
- d = Settings.load.notes_directory
23
+ d = Settings.load.directory
21
24
  FileUtils.mkdir_p(File.expand_path(d))
22
25
  end
23
26
  end
data/lib/til/settings.rb CHANGED
@@ -22,7 +22,7 @@ module Til
22
22
  self.new(SETTINGS_FILE_PATH)
23
23
  end
24
24
 
25
- def notes_directory
25
+ def directory
26
26
  File.expand_path(settings["directory"])
27
27
  end
28
28
 
data/lib/til/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Til
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: til_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Litchfield