journal_dev 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/journal +97 -0
  3. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c881080e6093ae95fc4a8d7b4c3ae3fc3af1065
4
+ data.tar.gz: 3b9fa039969169c598bf91bcf7dcf86025fd06fb
5
+ SHA512:
6
+ metadata.gz: 34da7c062b1bead733d5908cb7b8f54051cc4f00a7373f15d873a686b9147ad46d29a7580237a0875ff5c6556e5b0902d7155756a77638c717a7a99cff975b1a
7
+ data.tar.gz: 2081efa1678c6e5838fafb5eaef5ec35bca441f5170a730a26bc644d368b4a1c2c6745f66f64801a4bbe03a9cea7c6efdc07cbd2e8dc6351bfa77657fcb6f555
data/bin/journal ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'rubygems'
4
+ require 'colorator'
5
+
6
+ options = {}
7
+ parser = OptionParser.new do |opts|
8
+ opts.banner = 'Developer journal utility'
9
+ opts.define_head 'Usage: journal (command|message)'
10
+ opts.separator ''
11
+ opts.separator 'Examples:'
12
+ opts.separator ' journal create'
13
+ opts.separator ' journal "Some problem in User model, keep investigating..."'
14
+ opts.separator ' journal latest'
15
+ opts.separator ''
16
+ opts.separator 'Options:'
17
+
18
+ opts.on_tail('-h', '--help', 'Show this help message') do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+ argv = parser.parse!
24
+
25
+ # Exit if more than one argument
26
+ if argv.length != 1
27
+ puts parser
28
+ exit 1
29
+ end
30
+
31
+ def initJournal()
32
+ if File.exists?('journal')
33
+ puts "A journal already exists at #{Dir.pwd}/journal".red
34
+ exit 1
35
+ end
36
+
37
+ File.open('journal', 'a')
38
+ end
39
+
40
+ def addJournalEntry()
41
+ unless File.file?('journal')
42
+ puts "Couldn't find a journal at #{Dir.pwd}/journal".red
43
+ exit 1
44
+ end
45
+
46
+ File.open('journal', 'a') do |f|
47
+ f.puts(Time.now.strftime('%Y-%m-%d %H:%M:%S') + ' ' + ARGV[0])
48
+ end
49
+ end
50
+
51
+ def printLatestEntry()
52
+ file = 0;
53
+ #Open and check that file exists
54
+ begin
55
+ file = File.open('journal', 'r')
56
+ rescue
57
+ puts "Couldn't find a journal at #{Dir.pwd}/journal".red
58
+ exit 1
59
+ end
60
+
61
+ # If file is a regular file
62
+ unless File.file?('journal')
63
+ puts "Couldn't find a journal at #{Dir.pwd}/journal".red
64
+ exit 1
65
+ end
66
+
67
+ # If file is empty
68
+ if File.zero?('journal')
69
+ puts 'The journal seems to be empty...'.red
70
+ exit 1
71
+ end
72
+
73
+ # Find the last line
74
+ file.seek(-2, IO::SEEK_END)
75
+ begin
76
+ while (c = file.getc)
77
+ break if c == "\n"
78
+
79
+ file.ungetc(c)
80
+ file.seek(-1, IO::SEEK_CUR)
81
+ end
82
+ rescue # Journal contains only one entry
83
+ file.seek(0, IO::SEEK_SET)
84
+ end
85
+
86
+ # Print the last line
87
+ puts file.readline
88
+ end
89
+
90
+ case argv[0]
91
+ when 'create'
92
+ initJournal()
93
+ when 'latest'
94
+ printLatestEntry()
95
+ else
96
+ addJournalEntry()
97
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: journal_dev
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jari Leskinen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorator
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ description: Keep a journal for every app to help you remember where you left off
28
+ email: jarileskinen@icloud.com
29
+ executables:
30
+ - journal
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/journal
35
+ homepage:
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.4.1
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Developer journal
59
+ test_files: []