devlog 0.1.4 → 0.2.0

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: 7cc4eca661b86e9c2fc1ee9e9aecb4f4cb9672f9
4
- data.tar.gz: e81533808dd173f8d0f205b6def0be29c1ff0de6
3
+ metadata.gz: 6f476f2c6ab76e00904a225dde4bb72747bd5fc4
4
+ data.tar.gz: ea182129ccc5398cec398a4019695d2b8f6c38a2
5
5
  SHA512:
6
- metadata.gz: cf35a9fa222273614cbe3e7e7602ddce55f28e412b756a31cbaa832f9a478bbdba0996d8b81fea23caa642dfd13d85b499d622e9e3c0fbe86a04ce11449889ac
7
- data.tar.gz: 7ccd816f9dec22056b28468f7624dffc2f92d655a5d6f1ace4741f57dc66b766a0553df9538dc09e3221df954f5664ca6ace2a921eafa4637d823fb6ef926332
6
+ metadata.gz: 2dd9c1464366e4739406f15c18338737710009f808af2fea868b697cc05b23bbbdac6e937e6887ad41a5d04e517ddd946df9d4a43c7188bebd933160b60ceb91
7
+ data.tar.gz: ae709d70274481ab35dea6981313cfb35a2c9600588721f13331b0958d4ff27ffd12dc80c9197af35a129c2e01c6c2783f7a02df420185ea8a21326e26664962
data/.ruby-version CHANGED
@@ -1,3 +1,3 @@
1
- 2.2.0
1
+ 2.3.0
2
2
 
3
3
 
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.3.0"
5
+ # uncomment this line if your project needs to run something other than `rake`:
6
+ # script: bundle exec rspec spec
data/Gemfile.lock CHANGED
@@ -1,28 +1,28 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (4.1.9)
5
- i18n (~> 0.6, >= 0.6.9)
4
+ activesupport (4.2.5)
5
+ i18n (~> 0.7)
6
6
  json (~> 1.7, >= 1.7.7)
7
7
  minitest (~> 5.1)
8
- thread_safe (~> 0.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
9
  tzinfo (~> 1.1)
10
- addressable (2.3.5)
10
+ addressable (2.4.0)
11
11
  builder (3.2.2)
12
- descendants_tracker (0.0.3)
13
- faraday (0.9.0)
12
+ descendants_tracker (0.0.4)
13
+ thread_safe (~> 0.3, >= 0.3.1)
14
+ faraday (0.9.2)
14
15
  multipart-post (>= 1.2, < 3)
15
- git (1.2.6)
16
- github_api (0.11.2)
17
- addressable (~> 2.3)
18
- descendants_tracker (~> 0.0.1)
16
+ git (1.2.9.1)
17
+ github_api (0.13.1)
18
+ addressable (~> 2.4.0)
19
+ descendants_tracker (~> 0.0.4)
19
20
  faraday (~> 0.8, < 0.10)
20
- hashie (>= 1.2)
21
+ hashie (>= 3.4)
21
22
  multi_json (>= 1.7.5, < 2.0)
22
- nokogiri (~> 1.6.0)
23
23
  oauth2
24
- hashie (2.0.5)
25
- highline (1.6.20)
24
+ hashie (3.4.3)
25
+ highline (1.7.8)
26
26
  i18n (0.7.0)
27
27
  jeweler (2.0.1)
28
28
  builder
@@ -33,30 +33,28 @@ GEM
33
33
  nokogiri (>= 1.5.10)
34
34
  rake
35
35
  rdoc
36
- json (1.8.1)
37
- jwt (0.1.11)
38
- multi_json (>= 1.5)
39
- mini_portile (0.5.2)
40
- minitest (5.5.1)
41
- multi_json (1.8.4)
36
+ json (1.8.3)
37
+ jwt (1.5.2)
38
+ mini_portile2 (2.0.0)
39
+ minitest (5.8.3)
40
+ multi_json (1.11.2)
42
41
  multi_xml (0.5.5)
43
42
  multipart-post (2.0.0)
44
- nokogiri (1.6.1)
45
- mini_portile (~> 0.5.0)
46
- oauth2 (0.9.3)
43
+ nokogiri (1.6.7.1)
44
+ mini_portile2 (~> 2.0.0.rc2)
45
+ oauth2 (1.0.0)
47
46
  faraday (>= 0.8, < 0.10)
48
- jwt (~> 0.1.8)
47
+ jwt (~> 1.0)
49
48
  multi_json (~> 1.3)
50
49
  multi_xml (~> 0.5)
51
50
  rack (~> 1.2)
52
- power_assert (0.2.2)
53
- rack (1.5.2)
54
- rake (10.1.1)
55
- rdoc (4.1.1)
56
- json (~> 1.4)
57
- test-unit (3.0.8)
51
+ power_assert (0.2.7)
52
+ rack (1.6.4)
53
+ rake (10.4.2)
54
+ rdoc (4.2.1)
55
+ test-unit (3.1.5)
58
56
  power_assert
59
- thread_safe (0.3.4)
57
+ thread_safe (0.3.5)
60
58
  tzinfo (1.2.2)
61
59
  thread_safe (~> 0.1)
62
60
 
@@ -67,3 +65,6 @@ DEPENDENCIES
67
65
  activesupport (>= 4.1)
68
66
  jeweler (~> 2.0)
69
67
  test-unit
68
+
69
+ BUNDLED WITH
70
+ 1.11.2
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/mihael/devlog.svg?branch=master)](https://travis-ci.org/mihael/devlog)
2
+
1
3
  devlog
2
4
  ======
3
5
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.2.0
data/bin/devlog CHANGED
@@ -27,6 +27,10 @@ write commands for the current folder, the top three:
27
27
  #{'devlog'.green} commit ~ commit git repo
28
28
  #{'devlog'.green} push ~ push git repo
29
29
 
30
+ exporting devlog into a book, which can be read top down, like normal books:
31
+
32
+ #{'devlog'.green} x ~ exports into devlog.txt
33
+
30
34
  EOF
31
35
  #arguments
32
36
  $:.unshift File.join(File.dirname(__FILE__))
@@ -41,11 +45,20 @@ def parse_now(devlog_file='devlog.markdown', msg='')
41
45
  puts t.to_info_string
42
46
  puts is_session_open(devlog_file) ? "\nSession is open...".yellow : "\nNo open session.".green
43
47
  end
48
+ def export_now(devlog_file='devlog.markdown', msg='')
49
+ puts msg
50
+ exported_file = export_devlog_now(devlog_file)
51
+ puts "\nExported to #{exported_file}.".yellow
52
+ end
44
53
  def dodo
45
54
  include Devlog
46
- time = Benchmark.realtime do
55
+ time = Benchmark.realtime do
47
56
 
48
- if @in_file_or_cmd == 'commit'
57
+ if @in_file_or_cmd == 'help'
58
+ print_usage
59
+ elsif @in_file_or_cmd == 'x'
60
+ export_now('devlog.markdown',"Exporting devlog.markdown in current folder...".green)
61
+ elsif @in_file_or_cmd == 'commit'
49
62
  `git commit -am 'devlog';git push`
50
63
  elsif @in_file_or_cmd == 'b'
51
64
  puts "CodingSession::BEGIN"
data/devlog.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: devlog 0.1.4 ruby lib
5
+ # stub: devlog 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "devlog"
9
- s.version = "0.1.4"
9
+ s.version = "0.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["mihael"]
14
- s.date = "2015-11-26"
14
+ s.date = "2016-01-24"
15
15
  s.description = "devlog.markdown time&space extractor"
16
16
  s.email = "kitschmaster@gmail.com"
17
17
  s.executables = ["devlog"]
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.files = [
23
23
  ".ruby-gemset",
24
24
  ".ruby-version",
25
+ ".travis.yml",
25
26
  "Gemfile",
26
27
  "Gemfile.lock",
27
28
  "LICENSE",
@@ -47,6 +48,7 @@ Gem::Specification.new do |s|
47
48
  "test/devlog_test.rb",
48
49
  "test/test_helper.rb",
49
50
  "test_devlog.markdown",
51
+ "test_devlog_export.markdown",
50
52
  "test_negative_devlog.markdown",
51
53
  "test_open_devlog.markdown",
52
54
  "test_single_devlog.markdown",
@@ -54,7 +56,7 @@ Gem::Specification.new do |s|
54
56
  ]
55
57
  s.homepage = "http://github.com/mihael/devlog"
56
58
  s.licenses = ["MIT"]
57
- s.rubygems_version = "2.4.5"
59
+ s.rubygems_version = "2.5.1"
58
60
  s.summary = "takes devlog.markdown and gives info"
59
61
 
60
62
  if s.respond_to? :specification_version then
data/devlog.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ #24.01.2016 20:44:45 CodingSession::END
2
+
3
+ ii can now export the devlog. the top session becomes the bottom one, and a human can read the devlog like a book: top down...
4
+
5
+ #24.01.2016 19:43:25 CodingSession::BEGIN
6
+
1
7
  #21.02.2015 09:48:04 CodingSession::END
2
8
 
3
9
  when using the `devlog saver` command, it will also copy the devlog.markdown to `README.markdown`
@@ -63,14 +69,14 @@ added some tests, and some new calculations, the devlog binary prints out better
63
69
  #02.02.2014 17:06:00 CodingSession::END
64
70
 
65
71
  experiencing some bad weather, which took down an optical cable and cut our village off the internet grid...
66
- which is always a good time to do an open source coding session.
72
+ which is always a good time to do an open source coding session.
67
73
 
68
74
  ii added new folder "sublime_text". it will hold everything Sublime Text snippets and commands, which make working with the devlog DSL a breeze. that said, ii feel like a marketeer, haha.
69
75
 
70
76
  ii added this command "tu.py". which ii use the most, to insert a date time entry into the devlog, like this one #02.02.2014 14:03:35.
71
77
  You can attach it to Your favourite key binding, ii usually use "ctrl+alt+t".
72
78
 
73
- to install a command, drop it into
79
+ to install a command, drop it into
74
80
 
75
81
  /Users/You/Library/Application Suport/Sublime Text 3/Packages/User/
76
82
 
@@ -85,11 +91,11 @@ ii added a TextMate bundle, which can be installed for Sublime Text as well. it
85
91
 
86
92
  and the last one should work in TextMate to insert time:
87
93
 
88
- tu+Tab: #`date '+%d.%m.%Y %H:%M:%S'`
94
+ tu+Tab: #`date '+%d.%m.%Y %H:%M:%S'`
89
95
 
90
96
  the tmbundle can be dropped in the same folder as the "tu.py" snippet.
91
97
 
92
- just realized, the date format could be something that one would want to configure to its liking... so how would ii code that?
98
+ just realized, the date format could be something that one would want to configure to its liking... so how would ii code that?
93
99
  the snippets would have to be adjusted as well, and the parsing method would have to read some setting from somewhere. which ii dislike very much at this moment, so let me postpone this idea for someone else or some other time...
94
100
 
95
101
  currently the parser is amazingly simple, written in a very very very short time. and it can stay like that, the devlog only needs to parse its own DSL entries from the devlog file. what ii want to to now is to extend the current code to load each coding session as a separate object, then ii want to see how much time per day, per week... and so on...
@@ -100,7 +106,7 @@ coding... kids building lego rifles, little fast cars and minifigs...
100
106
 
101
107
  man, ii really have to think hard to not do it old school, to not simply stare at the code and stare and stare, until ii see it and simply write it down. this time, ii have to just ask questions about the functionality, then we will stare. so the first question is, what do ii want to know:
102
108
 
103
- + how much ii coded per day in hours (this is a sum/n(sum) value)
109
+ + how much ii coded per day in hours (this is a sum/n(sum) value)
104
110
  + how much ii coded per week in hours
105
111
  + how much ii coded per month in hours
106
112
 
@@ -115,7 +121,7 @@ kids are still playing... haha...
115
121
 
116
122
  ii added an empty devlog, to test that too... it should not give any results other than Zero...
117
123
 
118
- this works out of the box,
124
+ this works out of the box,
119
125
 
120
126
  4 tests, 15 assertions, 0 failures, 3 errors, 0 skips
121
127
 
@@ -125,11 +131,11 @@ ii already know, ii need to keep the whole dataset of datetimes of coding sessio
125
131
 
126
132
  obviously the parse_devlog method returns the Tajm object, so that is where the methods belong to... for now, ... how long is now? usually not much...
127
133
 
128
- ii have the methods implemented at #02.02.2014 15:10:01 and am about to run the test again... the darn thing still fails! :) and the methods are simply empty now, so let's make the tests pass by returning what, more than zero... ii would need to know exactly the hours and the some testing... so let me do something funky...
134
+ ii have the methods implemented at #02.02.2014 15:10:01 and am about to run the test again... the darn thing still fails! :) and the methods are simply empty now, so let's make the tests pass by returning what, more than zero... ii would need to know exactly the hours and the some testing... so let me do something funky...
129
135
 
130
136
  ii added parse_devlog_now, which will be developed as the new thing, (LOL back at this record at #16.02.2015 22:59:10) while parse_devlog will be used as reference, to get the reference time and compare for validity.
131
137
 
132
- also, this morning, ii discovered ii am unable to install gems under ruby 1.8.7 after installing that with rvm on 10.9 OSX, soo ii will add some more code to the binary script, to enable me to push this devlog to a github or any git repo actually and have the summary of the devlog parse inserted before pushing. it just requires some more commands to be implemented and some more parsing...
138
+ also, this morning, ii discovered ii am unable to install gems under ruby 1.8.7 after installing that with rvm on 10.9 OSX, soo ii will add some more code to the binary script, to enable me to push this devlog to a github or any git repo actually and have the summary of the devlog parse inserted before pushing. it just requires some more commands to be implemented and some more parsing...
133
139
 
134
140
  anyway... ii don't see any other way but to code another class...
135
141
 
@@ -143,8 +149,8 @@ each Parsing represents one parsing, and holds an array of sessions read from th
143
149
 
144
150
  and the kids are playing zombies, while the internets are still hovering somewhere, winter times came late...
145
151
 
146
- let me add
147
- -9000h
152
+ let me add
153
+ -9000h
148
154
 
149
155
  of communication hours to this devlog, so that tests can be written...
150
156
 
@@ -158,9 +164,9 @@ as text gets written down, at the end of the session ii scroll to the top again
158
164
 
159
165
  adding some simple testing :)
160
166
 
161
- the devlog is always written in real time,
167
+ the devlog is always written in real time,
162
168
 
163
- it starts and stops the coding session,
169
+ it starts and stops the coding session,
164
170
 
165
171
  ii begin coding by entering begin+Tab inside Sublime Text,
166
172
  this gives me CodingSession::BEGIN,
@@ -169,7 +175,7 @@ when ii am done with work ii simly enter end+Tab and CodingSessin::END is insert
169
175
 
170
176
  it is a very simple proces, quick to do, the file is always in the editor, You can use it to record any thing project related,
171
177
 
172
- currently it is up to You to present the devlog to a customer, ii usually use a markdown parser and show the html version of the log,
178
+ currently it is up to You to present the devlog to a customer, ii usually use a markdown parser and show the html version of the log,
173
179
  You can even insert links and have the devlog inside a git repository, pushing it to Your customer or Your website...
174
180
 
175
181
  there are endless options for devlogs... any project can have a nice devlog... :D
data/lib/devlog.rb CHANGED
@@ -56,7 +56,7 @@ module Devlog
56
56
  def self.log(txt)
57
57
  puts "#{txt}"
58
58
  end
59
-
59
+
60
60
  #parsing datetime
61
61
  DATETIME_FORMAT = "%d.%m.%Y %H:%M:%S"
62
62
  def parse_datetime(line)
@@ -80,15 +80,15 @@ module Devlog
80
80
 
81
81
  line_number = 0
82
82
  File.open(devlog, "r").each do |line|
83
- line_number+=1
84
-
83
+ line_number+=1
84
+
85
85
  if line =~ /-NOCHARGE/
86
86
  in_session = false #do not count nocharge sessions, this is a secret feature
87
87
  elsif line =~ /\A#/ && line =~ /CodingSession::END/
88
88
  in_session = true
89
89
  timeEnd = parse_datetime(line)
90
90
  timeEnd_line_number = line_number
91
-
91
+
92
92
  #zezzion
93
93
  temp_zezzion = Zezzion.new
94
94
  temp_zezzion.zzend = timeEnd
@@ -147,7 +147,7 @@ module Devlog
147
147
  if temp_zezzion
148
148
  temp_zezzion.com_session_time += delta
149
149
  else
150
- puts "error adding temp_zezzion com_session_time at line: #{line}"
150
+ puts "error adding temp_zezzion com_session_time at line: #{line}"
151
151
  end
152
152
  elsif line =~ /\A\+[0-9]+[m]/
153
153
  delta = (line.to_f / 60)
@@ -157,7 +157,7 @@ module Devlog
157
157
  if temp_zezzion
158
158
  temp_zezzion.com_session_time += delta
159
159
  else
160
- puts "error adding temp_zezzion com_session_time at line: #{line}"
160
+ puts "error adding temp_zezzion com_session_time at line: #{line}"
161
161
  end
162
162
  elsif line =~ /\A\-[0-9]+[h]/
163
163
  delta = (line.to_f)
@@ -165,17 +165,17 @@ module Devlog
165
165
 
166
166
  #zezzion
167
167
  if temp_zezzion
168
- temp_zezzion.payed_time += delta
168
+ temp_zezzion.payed_time += delta
169
169
  else
170
170
  puts "error adding temp_zezzion delta time at line: #{line}"
171
171
  end
172
172
  end
173
-
173
+
174
174
  end
175
175
  #return the Parsing object
176
176
  t
177
177
  end
178
-
178
+
179
179
  #this is just a historic event, not used
180
180
  def parse_devlog(devlog=nil)
181
181
  t = Tajm.new
@@ -184,7 +184,7 @@ module Devlog
184
184
  timeEnd = nil
185
185
  timeBegin = nil
186
186
  in_session = false
187
-
187
+
188
188
  File.open(devlog, "r").each do |line|
189
189
  if line =~ /-NOCHARGE/
190
190
  in_session = false #do not count nocharge sessions
@@ -214,7 +214,7 @@ module Devlog
214
214
  elsif line =~ /\A\-[0-9]+[h]/
215
215
  t.payed_time += (line.to_f)
216
216
  end
217
-
217
+
218
218
  end
219
219
  #return the Tajm object
220
220
  t
@@ -228,11 +228,23 @@ module Devlog
228
228
  end
229
229
 
230
230
  #prepend a string to a text file
231
- def prepend_string(t="\n", devlog_file='devlog.markdown')
232
- system "echo '#{t}' | cat - #{devlog_file} > #{devlog_file}.tmp && mv #{devlog_file}.tmp #{devlog_file}"
231
+ #def prepend_string(t="\n", devlog_file='devlog.markdown')
232
+ # system "echo '#{t}' | cat - #{devlog_file} > #{devlog_file}.tmp && mv #{devlog_file}.tmp #{devlog_file}"
233
+ #end
234
+
235
+ require 'tempfile'
236
+ def prepend_string(string="\n", path)
237
+ Tempfile.open File.basename(path) do |tempfile|
238
+ tempfile << string
239
+ File.open(path, 'r+') do |file|
240
+ tempfile << file.read
241
+ file.pos = tempfile.pos = 0
242
+ file << tempfile.read
243
+ end
244
+ end
233
245
  end
234
246
 
235
- #insert a new session
247
+ #insert a new session
236
248
  def start_coding_session(devlog_file='devlog.markdown')
237
249
  prepend_string(devlog_session_entry('Coding', 'BEGIN'), devlog_file)
238
250
  end
@@ -261,10 +273,10 @@ module Devlog
261
273
  is_open = true
262
274
  File.open(devlog_file, 'r') do |f|
263
275
  loop do
264
- break if not line = f.gets #exit on end of file, read line
276
+ break if not line = f.gets #exit on end of file, read line
265
277
  if (line.strip.size>0) #non empty line
266
278
  if (line =~ /Session::END/)
267
- is_open = false
279
+ is_open = false
268
280
  break
269
281
  else
270
282
  break
@@ -275,6 +287,45 @@ module Devlog
275
287
  is_open
276
288
  end
277
289
 
290
+ def export_devlog_now(devlog_file='devlog.markdown')
291
+ devlog_export_file = File.join(File.dirname(devlog_file), 'devlog_book.markdown')
292
+ #`sed -n '1!G;h;$p' #{devlog_file} > #{devlog_export_file}` #not what we want! , we want just the sessions upside down, but text intact
293
+ #so need to parse all sessions and print them out in reverse!
294
+
295
+ sessionEnd = ''
296
+ sessionMidd = ''
297
+ sessionBegin = ''
298
+ in_session = false
299
+
300
+ #the ends are the begins, the begins are the ends
301
+
302
+ File.new(devlog_export_file, 'wb')
303
+
304
+ File.open(devlog_file, "r").each do |line|
305
+ if line =~ /-NOCHARGE/
306
+ in_session = false #do not export nocharge sessions
307
+ elsif line =~ /\A#/ && (line =~ /CodingSession::END/ || line =~ /ComSession::END/ )
308
+ in_session = true
309
+ sessionEnd = line
310
+ elsif line =~ /\A#/ && ( line =~ /CodingSession::BEGIN/ || line =~ /ComSession::BEGIN/ )
311
+ if in_session
312
+ in_session = false
313
+ sessionBegin = line
314
+ s = sessionBegin + sessionMidd + sessionEnd
315
+ #system "echo '#{s}' | cat - #{devlog_export_file} > #{devlog_export_file}.tmp && mv #{devlog_export_file}.tmp #{devlog_export_file}"
316
+ prepend_string(s, devlog_export_file)
317
+ sessionEnd = ''
318
+ sessionMidd = ''
319
+ sessionBegin = ''
320
+ end
321
+ else
322
+ sessionMidd << line
323
+ end
324
+ end
325
+
326
+ devlog_export_file
327
+ end
328
+
278
329
  #the parsing object
279
330
  class Parsing
280
331
  #this is the total time, but each session has these same params
@@ -285,7 +336,7 @@ module Devlog
285
336
  def initialize(viewing_time_current_date=DateTime.now)
286
337
  @viewing_time_current_date = viewing_time_current_date
287
338
  @zezzions = []
288
-
339
+
289
340
  #backward compatible object with Tajm, from devlog 0.0.0
290
341
  @coding_session_time = 0.0
291
342
  @com_session_time = 0.0
@@ -338,7 +389,7 @@ module Devlog
338
389
  end
339
390
 
340
391
  #hours per day
341
- def per_day
392
+ def per_day
342
393
  (self.session_time/self.devlog_days).round(2)
343
394
  end
344
395
  def per_week
@@ -352,7 +403,7 @@ module Devlog
352
403
  def charge_time
353
404
  (coding_session_time + com_session_time).round(2)
354
405
  end
355
-
406
+
356
407
  #total charge time in hours, coding plus communication sessions - payed hours
357
408
  def unpayed_time
358
409
  (coding_session_time + com_session_time + payed_time).round(2)
@@ -446,7 +497,7 @@ module Devlog
446
497
  s
447
498
  end
448
499
 
449
- private
500
+ private
450
501
  def sessions_to_s(sessions)
451
502
  "\n" + sessions.collect{|session| " " + session.to_s}.join("\n")
452
503
  end
@@ -505,7 +556,7 @@ module Devlog
505
556
 
506
557
  #hours per day
507
558
  def per_day
508
- #whole time over number of days the parsing covers
559
+ #whole time over number of days the parsing covers
509
560
  session_time/days
510
561
  end
511
562
  def per_week
data/test/devlog_test.rb CHANGED
@@ -33,7 +33,7 @@ class DevlogTest < Test::Unit::TestCase
33
33
  assert(@tajm_test.payed_time==-1, "wrong payed time")
34
34
  assert(@tajm_test.unpayed_time==4.5, "wrong unpayed wrong")
35
35
  assert(@tajm_test.charge_time==5.5, "wrong charge wrong")
36
- end
36
+ end
37
37
 
38
38
  def test_p_session_time
39
39
  p = Parsing.new
@@ -69,7 +69,7 @@ class DevlogTest < Test::Unit::TestCase
69
69
 
70
70
  def test_how_much_per_month
71
71
  load_devlog_stat
72
- assert(@tajm_stat.per_week>0, "the middle month value, not the mean")
72
+ assert(@tajm_stat.per_week>0, "the middle month value, not the mean")
73
73
  end
74
74
 
75
75
  def test_devlog_days_0
@@ -111,7 +111,7 @@ class DevlogTest < Test::Unit::TestCase
111
111
  load_devlog_stat
112
112
  hours = @tajm_stat.hours_for_last(1, parse_datetime("#09.03.2014 11:00:00"))
113
113
  assert(hours==1, "should be 1, but is #{hours}")
114
-
114
+
115
115
  end
116
116
 
117
117
  def test_session_count
@@ -142,7 +142,7 @@ class DevlogTest < Test::Unit::TestCase
142
142
  assert(File.readlines(@empty_devlog).grep(/CodingSession::BEGIN/).size>0, "should insert CodingSession::BEGIN at top of file")
143
143
  assert(is_session_open(@empty_devlog)==true, "should be true, session should be open after starting")
144
144
  File.delete(@empty_devlog)
145
- end
145
+ end
146
146
 
147
147
  def test_stop_coding_session
148
148
  @empty_devlog = File.join(File.dirname(__FILE__), '..', 'tmp2_devlog.markdown')
@@ -152,7 +152,7 @@ class DevlogTest < Test::Unit::TestCase
152
152
  assert(File.readlines(@empty_devlog).grep(/CodingSession::END/).size>0, "should insert CodingSession::END at top of file")
153
153
  assert(is_session_open(@empty_devlog)==false, "should be false, session should be closed after stopping")
154
154
  File.delete(@empty_devlog) if File.exist?(@empty_devlog)
155
- end
155
+ end
156
156
 
157
157
  def test_save_info_after_stop_coding_session
158
158
  @devlog_info = File.join(File.dirname(__FILE__), '..', 'info.markdown')
@@ -173,14 +173,31 @@ class DevlogTest < Test::Unit::TestCase
173
173
  assert(File.readlines(@devlog_info).grep(/Session::Time/).size>0, "should have info about Session::Time")
174
174
  assert(File.readlines(@devlog_info).grep(/Unpayed::Time/).size>0, "should have info about Session::Time")
175
175
  assert(File.readlines(@devlog_info).grep(/Num of Sessions/).size==0, "should not include full info")
176
- #File.delete(@empty_devlog) if File.exist?(@empty_devlog)
177
- end
176
+ File.delete(@empty_devlog) if File.exist?(@empty_devlog)
177
+ end
178
178
 
179
179
  def test_is_session_open
180
180
  @closed_devlog = File.join(File.dirname(__FILE__), '..', 'test_devlog.markdown')
181
181
  assert(is_session_open(@closed_devlog)==false, "should be false, session should be closed")
182
182
  @open_devlog = File.join(File.dirname(__FILE__), '..', 'test_open_devlog.markdown')
183
183
  assert(is_session_open(@open_devlog)==true, "should be true, session should be open")
184
- end
184
+ end
185
+
186
+ def test_devlog_export
187
+ @exported_devlog = export_devlog_now(File.join(File.dirname(__FILE__), '..', 'test_devlog_export.markdown'))
188
+ assert(File.exists?(@exported_devlog))
189
+ assert(File.size(@exported_devlog)>0, "file should not be empty")
190
+ File.open(@exported_devlog, "r") do |f|
191
+ first = f.readline
192
+ assert(first.blank? == false, "first line isn't blank")
193
+ assert(first =~ /17\.01/, "last line becomes first line in")
194
+ f.readline #empty line
195
+ assert(f.readline =~ /Al/, "should keep text as it was, and in proper session")
196
+ assert(f.readline =~ /Ag/, "should keep text as it was, and in proper session")
197
+ f.readline #empty line
198
+ assert(f.readline =~ /17\.01/, "first line becomes last line")
199
+ end
200
+ File.delete(@exported_devlog) if File.exist?(@exported_devlog)
201
+ end
185
202
 
186
203
  end
@@ -0,0 +1,18 @@
1
+ #19.01.2016 19:41:52 CodingSession::END
2
+
3
+ Ch
4
+
5
+ #19.01.2016 19:41:46 CodingSession::BEGIN
6
+
7
+ #18.01.2016 19:41:18 CodingSession::END
8
+
9
+ Be
10
+
11
+ #18.01.2016 19:41:13 CodingSession::BEGIN
12
+
13
+ #17.01.2016 19:41:09 CodingSession::END
14
+
15
+ Al
16
+ Ag
17
+
18
+ #17.01.2016 19:41:05 CodingSession::BEGIN
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mihael
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2016-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -63,6 +63,7 @@ extra_rdoc_files:
63
63
  files:
64
64
  - ".ruby-gemset"
65
65
  - ".ruby-version"
66
+ - ".travis.yml"
66
67
  - Gemfile
67
68
  - Gemfile.lock
68
69
  - LICENSE
@@ -88,6 +89,7 @@ files:
88
89
  - test/devlog_test.rb
89
90
  - test/test_helper.rb
90
91
  - test_devlog.markdown
92
+ - test_devlog_export.markdown
91
93
  - test_negative_devlog.markdown
92
94
  - test_open_devlog.markdown
93
95
  - test_single_devlog.markdown
@@ -112,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
114
  version: '0'
113
115
  requirements: []
114
116
  rubyforge_project:
115
- rubygems_version: 2.4.5
117
+ rubygems_version: 2.5.1
116
118
  signing_key:
117
119
  specification_version: 4
118
120
  summary: takes devlog.markdown and gives info