notenote 0.0.2 → 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
  SHA256:
3
- metadata.gz: '09351642b43ef12aa169a2b8f861b1882397153d029c90a82d6d85a83dfd36ad'
4
- data.tar.gz: ddc9b0421e3c66f367a877a97ccec2038e16110d68d2b63b655d8216d8bab89c
3
+ metadata.gz: 6b6879e1aa7c6522ca4115b8cc9e2bb35e5b35c56d3d844546fbf5207472bd6b
4
+ data.tar.gz: 1b88305949d1ae6d7d8b1b63a0704942f8b3bf14df7ddb47b9c976675e079b46
5
5
  SHA512:
6
- metadata.gz: 7e3c7dc3285f7c715d66abfab6cb96857aec7fed0de60cd88f913ad6c65176381578d988dd4f26a707905e0c04dceab7e85a10e38d4d296c65ffce78870a9e32
7
- data.tar.gz: 967d5900a7c65b37cd2b1b01cb1ae74ec353e2f1de6e6ba2958fe86a86016d328ddc39522c2ef084b47b7ba890b8b0abb4dbcd7c5e59a03b80d8072e1df4e4cb
6
+ metadata.gz: 0c710812b969e74bc21283132d006af95fa2883cbf64a510cf6bc32cf1170998ee770db5243cca139593094c1f181293781f6758e4d60734773cd6dbc5eab4c2
7
+ data.tar.gz: 582f0e27bb423fc3f54f5997c4d42d4c1ebf54f637e2a2931921ab4016af1e8f5e7ba4e5064a62ff5608d48b02dcdffc76143e81d572f6e40df400717011a786
data/lib/note/cli.rb CHANGED
@@ -25,9 +25,13 @@ module Note
25
25
  Dir.mkdir(notes_folder)
26
26
  end
27
27
 
28
- create_config_file(notes_folder: notes_folder)
28
+ notes_folder_full_path = File.join(Dir.pwd, notes_folder)
29
+
30
+ create_config_file(notes_folder: notes_folder_full_path)
31
+ create_readme_file
29
32
  create_note_file
30
33
 
34
+
31
35
  puts %(Your note folder "#{notes_folder}" and the first log file are created. You're ready to go! 🚀)
32
36
 
33
37
  0
@@ -37,6 +41,29 @@ module Note
37
41
 
38
42
  create_note_file(file_name: "#{file_name}.md")
39
43
 
44
+ 0
45
+ elsif args.first == "all"
46
+ notes_folder = notenote_config["notes_folder"]
47
+
48
+ open_editor(path: notes_folder)
49
+
50
+ 0
51
+ elsif args.first == "folder"
52
+ unless mac?
53
+ puts "Unfortunately, this command works only on Mac devices atm. Please, make a PR to support your OS. 🙏"
54
+ end
55
+
56
+ notes_folder = notenote_config["notes_folder"]
57
+
58
+ osascript <<-END
59
+ tell application "Terminal"
60
+ activate
61
+ tell application "System Events" to keystroke "t" using command down
62
+ do script "cd #{notes_folder}" in front window
63
+ do script "clear" in front window
64
+ end tell
65
+ END
66
+
40
67
  0
41
68
  else
42
69
  puts "Hm, I don't know this command 🤔"
@@ -47,6 +74,20 @@ module Note
47
74
 
48
75
  private
49
76
 
77
+ def create_readme_file
78
+ notes_folder = notenote_config["notes_folder"]
79
+
80
+ readme_file = File.join(notes_folder, "README.md")
81
+
82
+ File.open(readme_file, "w") do |file|
83
+ file.puts unindent <<-TEXT
84
+ # Daily notes
85
+
86
+
87
+ TEXT
88
+ end
89
+ end
90
+
50
91
  def create_config_file(notes_folder:)
51
92
  config_template = File.read(File.join(File.dirname(__FILE__), "config.json.template"))
52
93
 
@@ -72,7 +113,7 @@ module Note
72
113
 
73
114
  FileUtils.touch(note_file)
74
115
 
75
- open_editor(file: note_file)
116
+ open_editor(path: note_file)
76
117
  end
77
118
 
78
119
  def notenote_config
@@ -81,10 +122,22 @@ module Note
81
122
  JSON.parse(File.read(config_file))
82
123
  end
83
124
 
84
- def open_editor(note_file:)
125
+ def open_editor(path:)
85
126
  editor_command = notenote_config["editor_command"]
86
127
 
87
- system("#{editor_command} #{note_file}")
128
+ system("#{editor_command} #{path}")
129
+ end
130
+
131
+ def mac?
132
+ RbConfig::CONFIG["host_os"] =~ /darwin/
133
+ end
134
+
135
+ def osascript(script)
136
+ system "osascript", *unindent(script).split(/\n/).map { |line| ['-e', line] }.flatten
137
+ end
138
+
139
+ def unindent(str)
140
+ str.gsub(/^#{str.scan(/^[ \t]+(?=\S)/).min}/, "")
88
141
  end
89
142
  end
90
143
  end
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "notes_folder": "%{notes_folder}",
3
- "editor_command": "code"
3
+ "editor_command": "code",
4
+ "commit_message": "Added new notes"
4
5
  }
data/lib/note/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Note
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notenote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoli Makarevich