Top Level Namespace
Defined Under Namespace
Modules: Jgit
Constant Summary collapse
- EXE_DESC =
%{ `jgit exe` will execute command in every task Example: > $ jgit exe "git add ." > $ jgit exe "mkdir temp" }- FOLDER_PATH =
"#{Dir.home}/.jgit"- GROUP_DATA =
"#{FOLDER_PATH}/group.json"- CURRENT_GROUP =
"#{FOLDER_PATH}/current.json"
Instance Method Summary collapse
- #bold(text) ⇒ Object
- #delete_file(file) ⇒ Object
- #get_current_group ⇒ Object
- #jexit(str = nil) ⇒ Object
- #load_data(path) ⇒ Object
- #load_obj(path, cls) ⇒ Object
- #project_path(current = nil) ⇒ Object
- #prompt(args, default = "") ⇒ Object
- #save_data(path, data) ⇒ Object
Instance Method Details
#bold(text) ⇒ Object
31 32 33 |
# File 'lib/jgit/jutil.rb', line 31 def bold(text) "\033[1;4m#{text}\033[0m" end |
#delete_file(file) ⇒ Object
23 24 25 26 27 |
# File 'lib/jgit/common.rb', line 23 def delete_file(file) if File.exist?(file) File.delete(file) end end |
#get_current_group ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/jgit/common.rb', line 15 def get_current_group if File.exists?(CURRENT_GROUP) File.read(CURRENT_GROUP) else "" end end |
#jexit(str = nil) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/jgit/jutil.rb', line 22 def jexit(str = nil) if str.nil? puts "exit with 0" else puts str end exit end |
#load_data(path) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/jgit/common.rb', line 38 def load_data(path) if File.exists?(path) File.read(path) else "" end end |
#load_obj(path, cls) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/jgit/common.rb', line 46 def load_obj(path, cls) if File.exists?(path) file = File.read(path) JSON.parse(file) else cls.new end end |
#project_path(current = nil) ⇒ Object
10 11 12 13 |
# File 'lib/jgit/common.rb', line 10 def project_path(current = nil) current = load_data(CURRENT_GROUP) if current.nil? "#{FOLDER_PATH}/record_#{current}.json" end |
#prompt(args, default = "") ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jgit/jutil.rb', line 3 def prompt(args, default = "") begin puts(args) print "> " STDOUT.flush text = STDIN.gets.chomp rescue SystemExit, Interrupt jexit end if text.empty? default else text end end |
#save_data(path, data) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/jgit/common.rb', line 29 def save_data(path, data) unless File.exist?(FOLDER_PATH) FileUtils.mkdir_p(FOLDER_PATH) end File.open(path, 'w+') do |f| f.write(data) end end |