devlog 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/devlog_test.yml +8 -6
- data/.ruby-version +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +9 -6
- data/LICENSE.txt +21 -0
- data/README.md +16 -0
- data/Rakefile +8 -54
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/devlog.gemspec +49 -43
- data/devlog.markdown +16 -1
- data/{bin → exe}/devlog +4 -1
- data/lib/devlog/date_time_ago_in_words.rb +34 -0
- data/lib/{devlog_settings.rb → devlog/settings.rb} +1 -1
- data/lib/devlog/utils.rb +18 -0
- data/lib/devlog/version.rb +5 -0
- data/lib/devlog.rb +99 -89
- data/test/devlog_test.rb +50 -18
- data/test/test_devlogs/test_invalid_date_devlog.markdown +1 -1
- data/test/test_helper.rb +46 -48
- metadata +40 -43
- data/LICENSE +0 -3
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6af19a193f7add3438d8bebacbd17cf430ac898eddaab5c82f7fa98e8b794509
|
4
|
+
data.tar.gz: ef126fee122ede38c05e8adc9ba12d57733b15d94ba35ec263b64ec2eb551562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca17bbc8140aa2ae11ffa43f95fb3e95eb2cdf8fb0e3c7232a4392a8e78978b1dbe8831f7d7483025eca13407f7913e1836ed3ea0e9b70dd41971b82001cae1
|
7
|
+
data.tar.gz: b725512cc215e70eec1eb327d4700d2aba3199c4042d1f60ccb932d2c83716bed828d2fc44b2697b7f55fbc2ee521b9a2f11159231724d9577573158af1d9aef
|
@@ -6,6 +6,9 @@ on:
|
|
6
6
|
pull_request:
|
7
7
|
branches: [ main ]
|
8
8
|
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
9
12
|
jobs:
|
10
13
|
test:
|
11
14
|
|
@@ -13,16 +16,15 @@ jobs:
|
|
13
16
|
|
14
17
|
strategy:
|
15
18
|
matrix:
|
16
|
-
ruby-version: [3.
|
17
|
-
os: [ubuntu-latest, macOS-
|
19
|
+
ruby-version: ['3.2.2', '3.0.1']
|
20
|
+
os: [ubuntu-latest, macOS-latest]
|
18
21
|
|
19
22
|
steps:
|
20
|
-
- uses: actions/checkout@
|
23
|
+
- uses: actions/checkout@v4
|
21
24
|
- name: Set up Ruby ${{ runner.os }}-§${{ matrix.ruby-version }}
|
22
|
-
uses: ruby/setup-ruby@
|
25
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf
|
23
26
|
with:
|
24
27
|
ruby-version: ${{ matrix.ruby-version }}
|
25
|
-
|
26
|
-
run: bundle install
|
28
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
27
29
|
- name: Run tests
|
28
30
|
run: bundle exec rake
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.3
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
|
-
#
|
4
|
-
|
5
|
+
# Specify your gem's dependencies in devlog.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "activesupport"
|
5
10
|
|
6
11
|
group :development, :test do
|
7
|
-
gem "test-unit"
|
8
|
-
|
9
|
-
gem "nokogiri", "~> 1.8" # jeweler 2.0.1 depends on 1.5.10, but that has sec issue
|
10
|
-
end
|
12
|
+
gem "test-unit"
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 mihael
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -105,3 +105,19 @@ devlog_file: ../info/devlog.markdown
|
|
105
105
|
weekly_timesheet_template: ../info/weekly_timesheet.erb.html
|
106
106
|
convert_to_pdf_command: wkhtmltopdf --dpi 400 --viewport-size 600x800 --orientation Landscape
|
107
107
|
```
|
108
|
+
|
109
|
+
development
|
110
|
+
===========
|
111
|
+
|
112
|
+
Run test suite:
|
113
|
+
|
114
|
+
```
|
115
|
+
rake test
|
116
|
+
```
|
117
|
+
|
118
|
+
Build and install gem locally:
|
119
|
+
|
120
|
+
```
|
121
|
+
rake build
|
122
|
+
rake install
|
123
|
+
```
|
data/Rakefile
CHANGED
@@ -1,58 +1,12 @@
|
|
1
|
-
|
2
|
-
require 'rake'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "devlog"
|
8
|
-
gem.summary = %Q{takes devlog.markdown and gives info}
|
9
|
-
gem.description = %Q{devlog.markdown time&space extractor}
|
10
|
-
gem.email = "kitschmaster@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/mihael/devlog"
|
12
|
-
gem.authors = ["mihael"]
|
13
|
-
gem.executables = ["devlog"]
|
14
|
-
gem.license = 'MIT'
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
-
end
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
-
end
|
21
|
-
|
22
|
-
require 'rake/testtask'
|
23
|
-
Rake::TestTask.new(:test) do |test|
|
24
|
-
test.libs << 'lib' << 'test'
|
25
|
-
test.pattern = 'test/**/*_test.rb'
|
26
|
-
test.verbose = true
|
27
|
-
end
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
28
5
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
test.pattern = 'test/**/*_test.rb'
|
34
|
-
test.verbose = true
|
35
|
-
end
|
36
|
-
rescue LoadError
|
37
|
-
task :rcov do
|
38
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
-
end
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
40
10
|
end
|
41
11
|
|
42
|
-
task :
|
43
|
-
|
44
|
-
task :default => :test
|
45
|
-
|
46
|
-
require 'rdoc/task'
|
47
|
-
Rake::RDocTask.new do |rdoc|
|
48
|
-
if File.exist?('VERSION')
|
49
|
-
version = File.read('VERSION')
|
50
|
-
else
|
51
|
-
version = ""
|
52
|
-
end
|
53
|
-
|
54
|
-
rdoc.rdoc_dir = 'rdoc'
|
55
|
-
rdoc.title = "devlog #{version}"
|
56
|
-
rdoc.rdoc_files.include('README*')
|
57
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
-
end
|
12
|
+
task default: :test
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "devlog"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "irb"
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/devlog.gemspec
CHANGED
@@ -1,38 +1,53 @@
|
|
1
|
-
#
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: devlog 0.3.5 ruby lib
|
1
|
+
# frozen_string_literal: true
|
6
2
|
|
7
|
-
|
8
|
-
s.name = "devlog".freeze
|
9
|
-
s.version = "0.3.5"
|
3
|
+
require_relative "lib/devlog/version"
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "devlog"
|
7
|
+
spec.version = Devlog::VERSION
|
8
|
+
spec.authors = ["mihael"]
|
9
|
+
spec.email = ["kitschmaster@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Write a development log while also easily track time spent in coding sessions using just a markdown text file and a few CLI commands."
|
12
|
+
spec.description = "devlog.markdown time&space extractor ~ Track the time spent in coding sessions and money payed to you, while also writing a development log. Export a timesheet for your bills."
|
13
|
+
spec.homepage = "https://manitu.si/devlog"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/mihael/devlog"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/mihael/devlog/blob/main/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
# gemspec = File.basename(__FILE__)
|
26
|
+
# spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
|
27
|
+
# ls.readlines("\x0", chomp: true).reject do |f|
|
28
|
+
# (f == gemspec) ||
|
29
|
+
# f.start_with?(*%w[bin/ lib/ sublime_text/ templates/ test/ .git .github .gitignore .ruby-gemset .ruby-version devlog.gemspec devlog.markdown Gemfile LICENSE.txt CHANGELOG.md README.md Rakefile tmp/.gitignore])
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
spec.files = [
|
23
33
|
".github/workflows/devlog_test.yml",
|
24
34
|
".ruby-gemset",
|
25
35
|
".ruby-version",
|
26
36
|
"Gemfile",
|
27
|
-
"LICENSE",
|
37
|
+
"LICENSE.txt",
|
28
38
|
"README.md",
|
39
|
+
"CHANGELOG.md",
|
29
40
|
"Rakefile",
|
30
|
-
"
|
31
|
-
"bin/
|
41
|
+
"bin/console",
|
42
|
+
"bin/setup",
|
43
|
+
"exe/devlog",
|
32
44
|
"devlog.gemspec",
|
33
45
|
"devlog.markdown",
|
34
46
|
"lib/devlog.rb",
|
35
|
-
"lib/
|
47
|
+
"lib/devlog/utils.rb",
|
48
|
+
"lib/devlog/date_time_ago_in_words.rb",
|
49
|
+
"lib/devlog/settings.rb",
|
50
|
+
"lib/devlog/version.rb",
|
36
51
|
"sublime_text/devlog.tmbundle/Snippets/begin.tmSnippet",
|
37
52
|
"sublime_text/devlog.tmbundle/Snippets/combegin.tmSnippet",
|
38
53
|
"sublime_text/devlog.tmbundle/Snippets/comend.tmSnippet",
|
@@ -62,25 +77,16 @@ Gem::Specification.new do |s|
|
|
62
77
|
"test/test_helper.rb",
|
63
78
|
"tmp/.gitignore"
|
64
79
|
]
|
65
|
-
s.homepage = "http://github.com/mihael/devlog".freeze
|
66
|
-
s.licenses = ["MIT".freeze]
|
67
|
-
s.rubygems_version = "3.2.15".freeze
|
68
|
-
s.summary = "takes devlog.markdown and gives info".freeze
|
69
80
|
|
70
|
-
|
71
|
-
|
72
|
-
|
81
|
+
spec.bindir = "exe"
|
82
|
+
spec.executables = ["devlog"]
|
83
|
+
spec.require_paths = ["lib"]
|
73
84
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
s.add_development_dependency(%q<nokogiri>.freeze, ["~> 1.8"])
|
79
|
-
else
|
80
|
-
s.add_dependency(%q<activesupport>.freeze, ["> 4.1"])
|
81
|
-
s.add_dependency(%q<test-unit>.freeze, ["~> 3.1"])
|
82
|
-
s.add_dependency(%q<jeweler>.freeze, ["~> 2.0"])
|
83
|
-
s.add_dependency(%q<nokogiri>.freeze, ["~> 1.8"])
|
84
|
-
end
|
85
|
-
end
|
85
|
+
# Dependencies
|
86
|
+
spec.add_dependency "activesupport"
|
87
|
+
spec.add_development_dependency "test-unit"
|
88
|
+
spec.add_development_dependency "nokogiri"
|
86
89
|
|
90
|
+
# For more information and examples about making a new gem, check out our
|
91
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
92
|
+
end
|
data/devlog.markdown
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
#17.10.2024 09:10:08 CodingSession::END
|
2
|
+
|
3
|
+
Fixing up for ruby 3 and doing some minor cleanup.
|
4
|
+
|
5
|
+
Ditching jeweler for bundler to package and release gem.
|
6
|
+
|
7
|
+
The tasks to work with the gem are now:
|
8
|
+
|
9
|
+
rake build
|
10
|
+
rake install
|
11
|
+
rake release
|
12
|
+
|
13
|
+
More here: https://bundler.io/guides/creating_gem.html
|
14
|
+
|
15
|
+
#17.10.2024 05:20:32 CodingSession::BEGIN
|
16
|
+
|
1
17
|
#23.09.2019 23:08:08 CodingSession::END
|
2
18
|
|
3
19
|
some quick adjustments...
|
@@ -130,7 +146,6 @@ aha... no comment haha...
|
|
130
146
|
|
131
147
|
#09.02.2015 15:41:09 CodingSession::BEGIN
|
132
148
|
|
133
|
-
|
134
149
|
#02.02.2015 17:53:20 CodingSession::END
|
135
150
|
|
136
151
|
cleaning up a little... enhancing the devlog executable features...
|
data/{bin → exe}/devlog
RENAMED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'benchmark'
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib devlog.rb]))
|
4
|
+
require "active_support/configurable"
|
5
|
+
|
4
6
|
USAGE = <<-EOF
|
5
7
|
#{Devlog.display_version}
|
6
8
|
This software is intended to parse and present information within devlog.markdown development logs. It also helps You to write the devlog.
|
@@ -68,7 +70,8 @@ include Devlog
|
|
68
70
|
|
69
71
|
def dodo
|
70
72
|
load_settings('.devlog.yml')
|
71
|
-
|
73
|
+
tz = devlog_timezone_setting
|
74
|
+
puts "Timezone: {tz}"
|
72
75
|
default_devlog_file = devlog_file_setting
|
73
76
|
time = Benchmark.realtime do
|
74
77
|
if @in_file_or_cmd =~ /.(markdown|md)$/ # devlog_file is passed directly via CLI
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "active_support/all"
|
2
|
+
|
3
|
+
module DateTimeAgoInWords
|
4
|
+
def ago_in_words
|
5
|
+
return 'a very very long time ago' if self.year < 1800
|
6
|
+
secs = Time.now - self
|
7
|
+
return 'just over' if secs > -1 && secs < 1
|
8
|
+
return 'now' if secs <= -1
|
9
|
+
pair = ago_in_words_pair(secs)
|
10
|
+
ary = ago_in_words_singularize(pair)
|
11
|
+
ary.size == 0 ? '' : ary.join(' and ') << ' ago'
|
12
|
+
end
|
13
|
+
private
|
14
|
+
def ago_in_words_pair(secs)
|
15
|
+
[[60, :seconds], [60, :minutes], [24, :hours], [100_000, :days]].map{ |count, name|
|
16
|
+
if secs > 0
|
17
|
+
secs, n = secs.divmod(count)
|
18
|
+
"#{n.to_i} #{name}"
|
19
|
+
end
|
20
|
+
}.compact.reverse[0..1]
|
21
|
+
end
|
22
|
+
def ago_in_words_singularize(pair)
|
23
|
+
if pair.size == 1
|
24
|
+
pair.map! {|part| part[0, 2].to_i == 1 ? part.chomp('s') : part }
|
25
|
+
else
|
26
|
+
pair.map! {|part| part[0, 2].to_i == 1 ? part.chomp('s') : part[0, 2].to_i == 0 ? nil : part }
|
27
|
+
end
|
28
|
+
pair.compact
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ActiveSupport::TimeWithZone
|
33
|
+
include DateTimeAgoInWords
|
34
|
+
end
|
data/lib/devlog/utils.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Colors for devlog
|
2
|
+
class String
|
3
|
+
def red; colorize(self, "\e[1m\e[31m"); end
|
4
|
+
def green; colorize(self, "\e[1m\e[32m"); end
|
5
|
+
def dark_green; colorize(self, "\e[32m"); end
|
6
|
+
def yellow; colorize(self, "\e[1m\e[33m"); end
|
7
|
+
def blue; colorize(self, "\e[1m\e[34m"); end
|
8
|
+
def dark_blue; colorize(self, "\e[34m"); end
|
9
|
+
def pur; colorize(self, "\e[1m\e[35m"); end
|
10
|
+
def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Rounding seconds to hours
|
14
|
+
class Float
|
15
|
+
def rounded_hours
|
16
|
+
(self / 60.0 / 60.0).round(2)
|
17
|
+
end
|
18
|
+
end
|
data/lib/devlog.rb
CHANGED
@@ -1,26 +1,17 @@
|
|
1
|
-
#require "time"
|
2
|
-
#require "date"
|
3
1
|
require "active_support/all"
|
4
|
-
require_relative "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def yellow; colorize(self, "\e[1m\e[33m"); end
|
12
|
-
def blue; colorize(self, "\e[1m\e[34m"); end
|
13
|
-
def dark_blue; colorize(self, "\e[34m"); end
|
14
|
-
def pur; colorize(self, "\e[1m\e[35m"); end
|
15
|
-
def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
|
16
|
-
end
|
2
|
+
require_relative "devlog/date_time_ago_in_words"
|
3
|
+
require_relative "devlog/version"
|
4
|
+
require_relative "devlog/utils"
|
5
|
+
require_relative "devlog/settings"
|
6
|
+
|
7
|
+
# DEPRECATION WARNING: to_time will always preserve the timezone offset of the receiver in Rails 8.0. To opt in to the new behavior, set `ActiveSupport.to_time_preserves_timezone = true`
|
8
|
+
ActiveSupport.to_time_preserves_timezone = true
|
17
9
|
|
18
10
|
# The devlog module with all the mumbo
|
19
11
|
module Devlog
|
20
12
|
# :stopdoc:
|
21
13
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
22
14
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
23
|
-
VERSION = File.open(File.join(File.dirname(__FILE__), %w[.. VERSION]), 'r').read
|
24
15
|
|
25
16
|
# :startdoc:
|
26
17
|
# Returns the version string for the library.
|
@@ -69,10 +60,21 @@ module Devlog
|
|
69
60
|
end
|
70
61
|
|
71
62
|
# Parsing datetime
|
63
|
+
def time_with_zone
|
64
|
+
if !Time.zone
|
65
|
+
tz = devlog_timezone_setting
|
66
|
+
puts "Setting timezone to: #{tz}"
|
67
|
+
Time.zone = tz
|
68
|
+
end
|
69
|
+
Time.zone
|
70
|
+
end
|
71
|
+
|
72
72
|
DATETIME_FORMAT = '%d.%m.%Y %H:%M:%S'.freeze
|
73
73
|
def parse_datetime(line)
|
74
74
|
parts = line[1..-1].split
|
75
|
-
|
75
|
+
result = time_with_zone.strptime("#{parts[0]} #{parts[1]}", DATETIME_FORMAT)
|
76
|
+
# puts "parse_datetime: #{line} => #{result}\n"
|
77
|
+
result
|
76
78
|
rescue StandardError
|
77
79
|
abort "\nError\nCan not parse line with invalid date:\n\n#{line}".to_s.blue
|
78
80
|
end
|
@@ -114,9 +116,13 @@ module Devlog
|
|
114
116
|
timeBegin_line_number = line_number
|
115
117
|
|
116
118
|
# cs_time += (timeEnd - timeBegin).to_f * 24 #hours *60 #minutes *60 #seconds
|
117
|
-
delta = (timeEnd - timeBegin)
|
119
|
+
delta = (timeEnd - timeBegin) #.to_f * 24 #hours *60 #minutes *60 #seconds
|
118
120
|
t.coding_session_time += delta
|
119
121
|
|
122
|
+
#puts "timeBegin: #{timeBegin.class} #{timeEnd.to_i - timeBegin.to_i}"
|
123
|
+
#puts "timeEnd: #{timeEnd}"
|
124
|
+
#puts "delta: #{delta}"
|
125
|
+
|
120
126
|
# zezzion
|
121
127
|
temp_zezzion.coding_session_time += delta
|
122
128
|
temp_zezzion.zzbegin = timeBegin
|
@@ -141,7 +147,7 @@ module Devlog
|
|
141
147
|
timeBegin = parse_datetime(line)
|
142
148
|
timeBegin_line_number = line_number
|
143
149
|
|
144
|
-
delta = (timeEnd - timeBegin)
|
150
|
+
delta = (timeEnd - timeBegin) #.to_f * 24
|
145
151
|
t.com_session_time += delta
|
146
152
|
|
147
153
|
# zezzion
|
@@ -163,7 +169,7 @@ module Devlog
|
|
163
169
|
puts "error adding temp_zezzion com_session_time at line: #{line}"
|
164
170
|
end
|
165
171
|
elsif line =~ /\A\+[0-9]+[m]/
|
166
|
-
delta = (line.to_f
|
172
|
+
delta = (line.to_f * 60)
|
167
173
|
t.com_session_time += delta
|
168
174
|
|
169
175
|
# zezzion
|
@@ -173,7 +179,7 @@ module Devlog
|
|
173
179
|
puts "error adding temp_zezzion com_session_time at line: #{line}"
|
174
180
|
end
|
175
181
|
elsif line =~ /\A\-[0-9]+[h]/
|
176
|
-
delta = (line.to_f)
|
182
|
+
delta = (line.to_f * 60 * 60)
|
177
183
|
t.payed_time += delta
|
178
184
|
|
179
185
|
# zezzion
|
@@ -192,7 +198,7 @@ module Devlog
|
|
192
198
|
|
193
199
|
# Helper for the time entries
|
194
200
|
def devlog_session_entry(session_type = 'Coding', begin_end = 'BEGIN')
|
195
|
-
"\n##{
|
201
|
+
"\n##{time_with_zone.now.strftime(DATETIME_FORMAT)} #{session_type}Session::#{begin_end}\n"
|
196
202
|
end
|
197
203
|
|
198
204
|
# Prepend a string to a text file
|
@@ -321,7 +327,7 @@ module Devlog
|
|
321
327
|
|
322
328
|
module SevendaysTotal
|
323
329
|
def total_hours
|
324
|
-
all.inject(0) { |time, zezzion| time + zezzion.session_time }.round(2)
|
330
|
+
((all.inject(0) { |time, zezzion| time + zezzion.session_time }) / 60 / 60).round(2)
|
325
331
|
end
|
326
332
|
|
327
333
|
def total_hours_string
|
@@ -329,7 +335,7 @@ module Devlog
|
|
329
335
|
|
330
336
|
return "" if total <= 0
|
331
337
|
|
332
|
-
"#{total}h"
|
338
|
+
"#{total} [h]"
|
333
339
|
end
|
334
340
|
end
|
335
341
|
|
@@ -409,8 +415,6 @@ module Devlog
|
|
409
415
|
end
|
410
416
|
|
411
417
|
DAYS.each do |day|
|
412
|
-
attr_accessor day
|
413
|
-
|
414
418
|
define_method(day) do
|
415
419
|
value = Day.new(day, all.select { |zezzion| zezzion.zzbegin.send("#{day.to_s}?") } )
|
416
420
|
instance_variable_set("@__#{day.to_s}", value) unless instance_variable_get("@__#{day.to_s}")&.any?
|
@@ -456,14 +460,13 @@ module Devlog
|
|
456
460
|
@zezzions.first.zzend
|
457
461
|
end
|
458
462
|
|
459
|
-
#
|
460
|
-
# in seconds
|
461
|
-
# def devlog_time
|
462
|
-
# (self.devlog_end.to_time - self.devlog_begin.to_time)/60.0/60.0
|
463
|
-
# end
|
464
|
-
|
463
|
+
# total session time
|
465
464
|
def session_time
|
466
|
-
@zezzions.inject(0) { |time, zezzion| time + zezzion.session_time }
|
465
|
+
@zezzions.inject(0) { |time, zezzion| time + zezzion.session_time }
|
466
|
+
end
|
467
|
+
|
468
|
+
def session_time_h
|
469
|
+
session_time.rounded_hours
|
467
470
|
end
|
468
471
|
|
469
472
|
# how many days devlog spans
|
@@ -481,35 +484,55 @@ module Devlog
|
|
481
484
|
count_time( :months => 1)
|
482
485
|
end
|
483
486
|
|
484
|
-
#
|
487
|
+
# seconds per day
|
485
488
|
def per_day
|
486
|
-
|
489
|
+
self.session_time/self.devlog_days
|
490
|
+
end
|
491
|
+
|
492
|
+
def per_day_h
|
493
|
+
per_day.rounded_hours
|
487
494
|
end
|
488
495
|
|
489
496
|
def per_week
|
490
|
-
|
497
|
+
self.session_time/self.devlog_weeks
|
498
|
+
end
|
499
|
+
|
500
|
+
def per_week_h
|
501
|
+
per_week.rounded_hours
|
491
502
|
end
|
492
503
|
|
493
504
|
def per_month
|
494
|
-
|
505
|
+
self.session_time/self.devlog_months
|
506
|
+
end
|
507
|
+
|
508
|
+
def per_month_h
|
509
|
+
per_month.rounded_hours
|
495
510
|
end
|
496
511
|
|
497
512
|
# total charge time in hours, coding plus communication sessions
|
498
513
|
def charge_time
|
499
|
-
|
514
|
+
coding_session_time + com_session_time
|
515
|
+
end
|
516
|
+
|
517
|
+
def charge_time_h
|
518
|
+
charge_time.rounded_hours
|
500
519
|
end
|
501
520
|
|
502
521
|
# total charge time in hours, coding plus communication sessions - payed hours
|
503
522
|
def unpayed_time
|
504
|
-
|
523
|
+
coding_session_time + com_session_time + payed_time
|
524
|
+
end
|
525
|
+
|
526
|
+
def unpayed_time_h
|
527
|
+
unpayed_time.rounded_hours
|
505
528
|
end
|
506
529
|
|
507
530
|
# return hours worked for the last X days, from current_time
|
508
531
|
def hours_for_last(days, current_time = DateTime.now)
|
509
532
|
endTime = current_time.to_time - days.days
|
510
533
|
selected_zezzions = @zezzions.select { |z| z.zzbegin.to_time < current_time && z.zzend >= endTime }
|
511
|
-
|
512
|
-
selected_zezzions.inject(0) { |time, z| time + z.session_time }.
|
534
|
+
|
535
|
+
selected_zezzions.inject(0) { |time, z| time + z.session_time }.to_f.rounded_hours
|
513
536
|
end
|
514
537
|
|
515
538
|
# from time to time select some zezzions
|
@@ -576,6 +599,18 @@ module Devlog
|
|
576
599
|
@zezzions
|
577
600
|
end
|
578
601
|
|
602
|
+
def coding_session_time_h
|
603
|
+
coding_session_time.rounded_hours
|
604
|
+
end
|
605
|
+
|
606
|
+
def com_session_time_h
|
607
|
+
com_session_time.rounded_hours
|
608
|
+
end
|
609
|
+
|
610
|
+
def payed_time_h
|
611
|
+
payed_time.rounded_hours
|
612
|
+
end
|
613
|
+
|
579
614
|
def validation_string
|
580
615
|
vs = ''
|
581
616
|
vs << (@zezzions.any? ? '' : "No sessions recorded, add some first...\n".red)
|
@@ -584,17 +619,17 @@ module Devlog
|
|
584
619
|
|
585
620
|
def to_info_string(short=false)
|
586
621
|
s = ''
|
587
|
-
s << "\nSession::Time: = #{
|
588
|
-
s << ("\nCodingSession::Time = %.1f [h]\n" %
|
589
|
-
s << ("\nComSession::Time = %.1f [h]\n" %
|
590
|
-
s << ("\nCharge::Time = #{
|
591
|
-
s << ("\nUnpayed::Time = #{
|
622
|
+
s << "\nSession::Time: = #{session_time_h} [h]\n"
|
623
|
+
s << ("\nCodingSession::Time = %.1f [h]\n" % coding_session_time_h)
|
624
|
+
s << ("\nComSession::Time = %.1f [h]\n" % com_session_time_h)
|
625
|
+
s << ("\nCharge::Time = #{charge_time_h} [h]\n")
|
626
|
+
s << ("\nUnpayed::Time = #{unpayed_time_h} [h]\n")
|
592
627
|
s << ("\n")
|
593
628
|
unless short
|
594
629
|
s << ("Num of Sessions = #{self.devlog_sessions.size}\n")
|
595
|
-
s << ("Hours per Day = #{self.
|
596
|
-
s << ("Hours per Week = #{self.
|
597
|
-
s << ("Hours per Month = #{self.
|
630
|
+
s << ("Hours per Day = #{self.per_day_h} [h]\n")
|
631
|
+
s << ("Hours per Week = #{self.per_week_h} [h]\n")
|
632
|
+
s << ("Hours per Month = #{self.per_month_h} [h]\n")
|
598
633
|
s << ("Hours last 7 days = #{self.hours_for_last(7)} [h]\n")
|
599
634
|
s << ("Hours last 14 days = #{self.hours_for_last(14)} [h]\n")
|
600
635
|
s << ("Hours last 28 days = #{self.hours_for_last(28)} [h]\n")
|
@@ -613,8 +648,8 @@ module Devlog
|
|
613
648
|
end
|
614
649
|
s << ("\n")
|
615
650
|
s << ("Longest Session = #{self.longest_session.to_s}\n")
|
616
|
-
s << ("Shortest Session = #{self.shortest_session.
|
617
|
-
s << ("Last Session = #{self.devlog_end.ago_in_words}, duration: #{self.last_session.
|
651
|
+
s << ("Shortest Session = #{self.shortest_session.to_s_in_seconds}\n")
|
652
|
+
s << ("Last Session = #{self.devlog_end.ago_in_words}, duration: #{self.last_session.in_hours} [h]")
|
618
653
|
s << ("\n")
|
619
654
|
s << ("Weekly Sessions\n")
|
620
655
|
s << ("\n")
|
@@ -628,9 +663,9 @@ module Devlog
|
|
628
663
|
sevendays_total += current_day_total_hours
|
629
664
|
s << ("#{dayname.upcase}\n")
|
630
665
|
s << ("begins at: #{current_day.begins_at}\n")
|
631
|
-
s << ("breaks: #{current_day.breaks_at}\n")
|
632
|
-
s << ("
|
633
|
-
s << ("sum: #{current_day_total_hours}h\n")
|
666
|
+
s << ("breaks at: #{current_day.breaks_at}\n")
|
667
|
+
s << ("ends at: #{current_day.ends_at}\n")
|
668
|
+
s << ("sum: #{current_day_total_hours} [h]\n")
|
634
669
|
s << ("\n")
|
635
670
|
end
|
636
671
|
end
|
@@ -644,7 +679,7 @@ module Devlog
|
|
644
679
|
s << "No weekly sessions for week #{week}.\n"
|
645
680
|
end
|
646
681
|
end
|
647
|
-
s << "Last payed: #{last_payed_session.zzend.to_s
|
682
|
+
s << "Last payed: #{last_payed_session.zzend.to_s}" if last_payed_session
|
648
683
|
end
|
649
684
|
s
|
650
685
|
end
|
@@ -729,7 +764,15 @@ module Devlog
|
|
729
764
|
end
|
730
765
|
|
731
766
|
def to_s
|
732
|
-
"#{session_time.round(3)} [h] #{type}, begin on line #{@zzbegin_line_number} at #{@zzbegin}, ends on line #{@zzend_line_number} at #{@zzend}"
|
767
|
+
"#{(session_time / 60 / 60).round(3)} [h] #{type}, begin on line #{@zzbegin_line_number} at #{@zzbegin}, ends on line #{@zzend_line_number} at #{@zzend}"
|
768
|
+
end
|
769
|
+
|
770
|
+
def to_s_in_seconds
|
771
|
+
"#{session_time.round(3)} [s] #{type}, begin on line #{@zzbegin_line_number} at #{@zzbegin}, ends on line #{@zzend_line_number} at #{@zzend}"
|
772
|
+
end
|
773
|
+
|
774
|
+
def in_hours
|
775
|
+
(session_time / 60 / 60).round(3)
|
733
776
|
end
|
734
777
|
end
|
735
778
|
|
@@ -743,36 +786,3 @@ module Devlog
|
|
743
786
|
end
|
744
787
|
end
|
745
788
|
end
|
746
|
-
|
747
|
-
module DateTimeAgoInWords
|
748
|
-
def ago_in_words
|
749
|
-
return 'a very very long time ago' if self.year < 1800
|
750
|
-
secs = Time.now - self
|
751
|
-
return 'just over' if secs > -1 && secs < 1
|
752
|
-
return 'now' if secs <= -1
|
753
|
-
pair = ago_in_words_pair(secs)
|
754
|
-
ary = ago_in_words_singularize(pair)
|
755
|
-
ary.size == 0 ? '' : ary.join(' and ') << ' ago'
|
756
|
-
end
|
757
|
-
private
|
758
|
-
def ago_in_words_pair(secs)
|
759
|
-
[[60, :seconds], [60, :minutes], [24, :hours], [100_000, :days]].map{ |count, name|
|
760
|
-
if secs > 0
|
761
|
-
secs, n = secs.divmod(count)
|
762
|
-
"#{n.to_i} #{name}"
|
763
|
-
end
|
764
|
-
}.compact.reverse[0..1]
|
765
|
-
end
|
766
|
-
def ago_in_words_singularize(pair)
|
767
|
-
if pair.size == 1
|
768
|
-
pair.map! {|part| part[0, 2].to_i == 1 ? part.chomp('s') : part }
|
769
|
-
else
|
770
|
-
pair.map! {|part| part[0, 2].to_i == 1 ? part.chomp('s') : part[0, 2].to_i == 0 ? nil : part }
|
771
|
-
end
|
772
|
-
pair.compact
|
773
|
-
end
|
774
|
-
end
|
775
|
-
|
776
|
-
class DateTime
|
777
|
-
include DateTimeAgoInWords
|
778
|
-
end
|
data/test/devlog_test.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DevlogTest < Test::Unit::TestCase
|
4
|
+
def test_version
|
5
|
+
assert ::Devlog.const_defined?(:VERSION)
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_devlog_session_entry
|
9
|
+
dse = devlog_session_entry
|
10
|
+
tajmstring = "\n##{Time.zone.now.strftime(DATETIME_FORMAT)} CodingSession::BEGIN\n"
|
11
|
+
|
12
|
+
assert_equal tajmstring, dse
|
13
|
+
end
|
14
|
+
|
4
15
|
def test_empty_devlog
|
5
16
|
@tajm = parse_devlog_now(File.join(File.dirname(__FILE__), TEST_FILES_PATH, 'empty_devlog.markdown'))
|
6
17
|
puts "#{@tajm.coding_session_time} #{@tajm.com_session_time} #{@tajm.payed_time}"
|
@@ -13,25 +24,34 @@ class DevlogTest < Test::Unit::TestCase
|
|
13
24
|
load_devlog
|
14
25
|
load_devlog_now
|
15
26
|
|
16
|
-
assert(@tajm.coding_session_time==@tajm_now.coding_session_time, "not equal coding times")
|
27
|
+
assert(@tajm.coding_session_time==@tajm_now.coding_session_time, "not equal coding times #{@tajm.coding_session_time} #{@tajm_now.coding_session_time}")
|
17
28
|
assert(@tajm.com_session_time==@tajm_now.com_session_time, "selftalk not repeated")
|
18
29
|
assert(@tajm.payed_time==@tajm_now.payed_time, "selfpay not equal")
|
19
30
|
|
20
31
|
assert(@tajm_now.zezzions.size>0, "where are the seeds of zezzions?")
|
21
|
-
assert(@tajm_now.unpayed_time<0, "let's make sure opensource is free to develop it self")
|
32
|
+
assert(@tajm_now.unpayed_time<0, "let's make sure opensource is free to develop it self #{@tajm_now.unpayed_time} should be less than zero")
|
22
33
|
assert(@tajm_now.zezzions.size>4, "at least 4 recorded sessions must there be?")
|
23
|
-
assert(@tajm_now.devlog_begin.to_s=="2014-01-
|
24
|
-
assert(@tajm_now.devlog_begin.to_time.to_i ==
|
34
|
+
assert(@tajm_now.devlog_begin.to_s=="2014-01-19 10:16:08 +0100", "a historycal moment in the akashic records was deleted, what?")
|
35
|
+
assert(@tajm_now.devlog_begin.to_time.to_i == 1390122968, "or just a random number in a random dream...")
|
25
36
|
end
|
26
37
|
|
27
38
|
def test_devlog_test
|
28
39
|
load_devlog_test
|
29
40
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
41
|
+
assert_equal 16200.0, @tajm_test.coding_session_time, "wrong coding session time in seconds"
|
42
|
+
assert_equal 4.5, @tajm_test.coding_session_time_h , "wrong coding session time in hours"
|
43
|
+
|
44
|
+
assert_equal 3600.0, @tajm_test.com_session_time, "wrong com session time in seconds"
|
45
|
+
assert_equal 1.0, @tajm_test.com_session_time_h, "wrong com session time in hours"
|
46
|
+
|
47
|
+
assert_equal (-3600.0), @tajm_test.payed_time, "wrong payed time in seconds"
|
48
|
+
assert_equal (-1.0), @tajm_test.payed_time_h, "wrong payed time in hours"
|
49
|
+
|
50
|
+
assert_equal 16200.0, @tajm_test.unpayed_time, "wrong unpayed time in seconds"
|
51
|
+
assert_equal 4.5, @tajm_test.unpayed_time_h, "wrong unpayed time in hours"
|
52
|
+
|
53
|
+
assert_equal 19800.0, @tajm_test.charge_time, "wrong charge time in seconds"
|
54
|
+
assert_equal 5.5, @tajm_test.charge_time_h, "wrong charge time in hours"
|
35
55
|
end
|
36
56
|
|
37
57
|
def test_devlog_invalid_date
|
@@ -57,14 +77,17 @@ class DevlogTest < Test::Unit::TestCase
|
|
57
77
|
|
58
78
|
def test_how_much_per_day
|
59
79
|
load_devlog_stat
|
80
|
+
|
60
81
|
assert(@tajm_stat.per_day>0, "the middle day value, not the mean")
|
61
|
-
|
82
|
+
assert_equal 3600.0, @tajm_stat.per_day, "per day should be 3600.0 but is #{@tajm_stat.per_day}"
|
83
|
+
assert_equal 1.0, @tajm_stat.per_day_h, "per day in hours should be 1.0 but is #{@tajm_stat.per_day_h}"
|
62
84
|
end
|
63
85
|
|
64
86
|
def test_how_much_per_week
|
65
87
|
load_devlog_stat
|
66
88
|
assert(@tajm_stat.per_week>0, "the middle week value, not the mean")
|
67
|
-
|
89
|
+
assert_equal 7.02, @tajm_stat.per_week_h, "per week in hours should be 7.02 but is #{@tajm_stat.per_week_h}"
|
90
|
+
assert(@tajm_stat.per_week>=25263.15, "per week in seconds should be 25263.16 but is #{@tajm_stat.per_week}")
|
68
91
|
end
|
69
92
|
|
70
93
|
def test_devlog_weeks
|
@@ -74,7 +97,9 @@ class DevlogTest < Test::Unit::TestCase
|
|
74
97
|
|
75
98
|
def test_how_much_per_month
|
76
99
|
load_devlog_stat
|
77
|
-
assert(@tajm_stat.
|
100
|
+
assert(@tajm_stat.per_month>0, "the middle month value, not the mean")
|
101
|
+
assert_equal 8.0, @tajm_stat.per_month_h, "per month in hours should be 8.0 but is #{@tajm_stat.per_month_h}"
|
102
|
+
assert_equal 28800.0, @tajm_stat.per_month, "per month in seconds should be 28800.0 but is #{@tajm_stat.per_month}"
|
78
103
|
end
|
79
104
|
|
80
105
|
def test_devlog_days_0
|
@@ -84,22 +109,24 @@ class DevlogTest < Test::Unit::TestCase
|
|
84
109
|
|
85
110
|
def test_devlog_days_1
|
86
111
|
load_devlog_stat
|
87
|
-
|
112
|
+
assert_equal 8, @tajm_stat.devlog_days, "should be 8 devlog days"
|
88
113
|
end
|
89
114
|
|
90
115
|
def test_devlog_days_2
|
91
116
|
load_devlog_single
|
92
|
-
|
117
|
+
assert_equal 1, @tajm_single.devlog_days, "should be 1 devlog day"
|
93
118
|
end
|
94
119
|
|
95
120
|
def test_devlog_begin
|
96
121
|
load_devlog_stat
|
97
|
-
|
122
|
+
|
123
|
+
assert_equal "2014-03-01 10:00:00 +0100", @tajm_stat.devlog_begin.to_s, "devlog begin is wrong"
|
98
124
|
end
|
99
125
|
|
100
126
|
def test_devlog_end
|
101
127
|
load_devlog_stat
|
102
|
-
|
128
|
+
|
129
|
+
assert_equal "2014-03-08 11:00:00 +0100", @tajm_stat.devlog_end.to_s, "devlog end is wrong"
|
103
130
|
end
|
104
131
|
|
105
132
|
def test_hours_for_last0
|
@@ -107,11 +134,13 @@ class DevlogTest < Test::Unit::TestCase
|
|
107
134
|
hours = @tajm_stat.hours_for_last(0, parse_datetime("#09.03.2014 11:00:00"))
|
108
135
|
assert(hours==0, "should be 0, but is #{hours}")
|
109
136
|
end
|
137
|
+
|
110
138
|
def test_hours_for_last7
|
111
139
|
load_devlog_stat
|
112
140
|
hours = @tajm_stat.hours_for_last(7, parse_datetime("#09.03.2014 11:00:00"))
|
113
141
|
assert(hours==7, "should be 7, but is #{hours}")
|
114
142
|
end
|
143
|
+
|
115
144
|
def test_hours_for_last1
|
116
145
|
load_devlog_stat
|
117
146
|
hours = @tajm_stat.hours_for_last(1, parse_datetime("#09.03.2014 11:00:00"))
|
@@ -125,9 +154,12 @@ class DevlogTest < Test::Unit::TestCase
|
|
125
154
|
|
126
155
|
def test_negative_sessions
|
127
156
|
load_devlog_negative
|
157
|
+
|
128
158
|
assert(@tajm_negative.devlog_sessions.size==5, "should be 5, but is #{@tajm_negative.devlog_sessions.size}")
|
159
|
+
|
129
160
|
shortest_session_time_rounded = @tajm_negative.shortest_session.session_time.round(2)
|
130
|
-
|
161
|
+
|
162
|
+
assert_equal (-7200.0), shortest_session_time_rounded, "should be -7200.0, but is #{shortest_session_time_rounded}"
|
131
163
|
assert(@tajm_negative.negative_sessions.size==2, "should be 2, but is #{@tajm_negative.negative_sessions.size}")
|
132
164
|
end
|
133
165
|
|
@@ -171,7 +203,7 @@ class DevlogTest < Test::Unit::TestCase
|
|
171
203
|
stop_coding_session(@empty_devlog)
|
172
204
|
assert(File.readlines(@empty_devlog).grep(/CodingSession::END/).size>0, "should insert CodingSession::END at top of file")
|
173
205
|
assert(is_session_open(@empty_devlog)==false, "should be false, session should be closed after stopping")
|
174
|
-
assert(File.
|
206
|
+
assert(File.exist?(@devlog_info)==true, "should exist")
|
175
207
|
hasinfo = parse_devlog_now(@empty_devlog).has_info?
|
176
208
|
assert(hasinfo==true, 'should have info')
|
177
209
|
assert(File.readlines(@devlog_info).grep(/Session::Time/).size>0, "should have info about Session::Time")
|
data/test/test_helper.rb
CHANGED
@@ -1,57 +1,55 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
3
|
require 'devlog'
|
7
|
-
|
8
|
-
class Test::Unit::TestCase
|
9
|
-
include Devlog
|
10
|
-
end
|
4
|
+
require 'test/unit'
|
11
5
|
|
12
6
|
TEST_FILES_PATH = 'test_devlogs'.freeze
|
13
7
|
TEMP_PATH = '../tmp'.freeze
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def load_devlog
|
20
|
-
@tajm = parse_devlog_now(File.join(File.dirname(__FILE__), '..', 'devlog.markdown'))
|
21
|
-
puts "#{@tajm.coding_session_time} #{@tajm.com_session_time} #{@tajm.payed_time}"
|
22
|
-
assert(@tajm.coding_session_time>0, "truth")
|
23
|
-
assert(@tajm.com_session_time>0, "love")
|
24
|
-
assert(@tajm.payed_time<0, "simplicity")
|
25
|
-
end
|
26
|
-
|
27
|
-
def load_devlog_now
|
28
|
-
@tajm_now = parse_devlog_now(File.join(File.dirname(__FILE__), '..', 'devlog.markdown'))
|
29
|
-
puts "#{@tajm_now.coding_session_time} #{@tajm_now.com_session_time} #{@tajm_now.payed_time}"
|
30
|
-
assert(@tajm_now.coding_session_time>0, "truth")
|
31
|
-
assert(@tajm_now.com_session_time>0, "love")
|
32
|
-
assert(@tajm_now.payed_time<0, "simplicity")
|
33
|
-
end
|
34
|
-
|
35
|
-
def load_devlog_test
|
36
|
-
@tajm_test = parse_test_devlog('test_devlog.markdown')
|
37
|
-
puts "#{@tajm_test.coding_session_time} #{@tajm_test.com_session_time} #{@tajm_test.payed_time}"
|
38
|
-
assert(@tajm_test.coding_session_time>0, "truth")
|
39
|
-
assert(@tajm_test.com_session_time>0, "love")
|
40
|
-
assert(@tajm_test.payed_time<0, "simplicity")
|
41
|
-
end
|
42
|
-
|
43
|
-
def load_devlog_stat
|
44
|
-
@tajm_stat = parse_test_devlog('test_stats_devlog.markdown')
|
45
|
-
end
|
46
|
-
|
47
|
-
def load_devlog_single
|
48
|
-
@tajm_single = parse_test_devlog('test_single_devlog.markdown')
|
49
|
-
end
|
50
|
-
|
51
|
-
def load_devlog_negative
|
52
|
-
@tajm_negative = parse_test_devlog('test_negative_devlog.markdown')
|
53
|
-
end
|
9
|
+
class Test::Unit::TestCase
|
10
|
+
include Devlog
|
54
11
|
|
55
|
-
def
|
56
|
-
|
12
|
+
def parse_test_devlog(filename)
|
13
|
+
parse_devlog_now(File.join(File.dirname(__FILE__), TEST_FILES_PATH, filename))
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_devlog
|
17
|
+
@tajm = parse_devlog_now(File.join(File.dirname(__FILE__), '..', 'devlog.markdown'))
|
18
|
+
puts "#{@tajm.coding_session_time} #{@tajm.com_session_time} #{@tajm.payed_time}"
|
19
|
+
assert(@tajm.coding_session_time>0, "truth")
|
20
|
+
assert(@tajm.com_session_time>0, "love")
|
21
|
+
assert(@tajm.payed_time<0, "simplicity")
|
22
|
+
end
|
23
|
+
|
24
|
+
def load_devlog_now
|
25
|
+
@tajm_now = parse_devlog_now(File.join(File.dirname(__FILE__), '..', 'devlog.markdown'))
|
26
|
+
puts "#{@tajm_now.coding_session_time} #{@tajm_now.com_session_time} #{@tajm_now.payed_time}"
|
27
|
+
assert(@tajm_now.coding_session_time>0, "truth")
|
28
|
+
assert(@tajm_now.com_session_time>0, "love")
|
29
|
+
assert(@tajm_now.payed_time<0, "simplicity")
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_devlog_test
|
33
|
+
@tajm_test = parse_test_devlog('test_devlog.markdown')
|
34
|
+
puts "#{@tajm_test.coding_session_time} #{@tajm_test.com_session_time} #{@tajm_test.payed_time}"
|
35
|
+
assert(@tajm_test.coding_session_time>0, "truth")
|
36
|
+
assert(@tajm_test.com_session_time>0, "love")
|
37
|
+
assert(@tajm_test.payed_time<0, "simplicity")
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_devlog_stat
|
41
|
+
@tajm_stat = parse_test_devlog('test_stats_devlog.markdown')
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_devlog_single
|
45
|
+
@tajm_single = parse_test_devlog('test_single_devlog.markdown')
|
46
|
+
end
|
47
|
+
|
48
|
+
def load_devlog_negative
|
49
|
+
@tajm_negative = parse_test_devlog('test_negative_devlog.markdown')
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_devlog_weekly
|
53
|
+
@tajm_weekly = parse_test_devlog('test_weekly_devlog.markdown')
|
54
|
+
end
|
57
55
|
end
|
metadata
CHANGED
@@ -1,93 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mihael
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: test-unit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: jeweler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.0'
|
40
|
+
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: nokogiri
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - "
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
description: devlog.markdown time&space extractor
|
70
|
-
|
54
|
+
version: '0'
|
55
|
+
description: devlog.markdown time&space extractor ~ Track the time spent in coding
|
56
|
+
sessions and money payed to you, while also writing a development log. Export a
|
57
|
+
timesheet for your bills.
|
58
|
+
email:
|
59
|
+
- kitschmaster@gmail.com
|
71
60
|
executables:
|
72
61
|
- devlog
|
73
62
|
extensions: []
|
74
|
-
extra_rdoc_files:
|
75
|
-
- LICENSE
|
76
|
-
- README.md
|
63
|
+
extra_rdoc_files: []
|
77
64
|
files:
|
78
65
|
- ".github/workflows/devlog_test.yml"
|
79
66
|
- ".ruby-gemset"
|
80
67
|
- ".ruby-version"
|
68
|
+
- CHANGELOG.md
|
81
69
|
- Gemfile
|
82
|
-
- LICENSE
|
70
|
+
- LICENSE.txt
|
83
71
|
- README.md
|
84
72
|
- Rakefile
|
85
|
-
-
|
86
|
-
- bin/
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
87
75
|
- devlog.gemspec
|
88
76
|
- devlog.markdown
|
77
|
+
- exe/devlog
|
89
78
|
- lib/devlog.rb
|
90
|
-
- lib/
|
79
|
+
- lib/devlog/date_time_ago_in_words.rb
|
80
|
+
- lib/devlog/settings.rb
|
81
|
+
- lib/devlog/utils.rb
|
82
|
+
- lib/devlog/version.rb
|
91
83
|
- sublime_text/devlog.tmbundle/Snippets/begin.tmSnippet
|
92
84
|
- sublime_text/devlog.tmbundle/Snippets/combegin.tmSnippet
|
93
85
|
- sublime_text/devlog.tmbundle/Snippets/comend.tmSnippet
|
@@ -116,10 +108,14 @@ files:
|
|
116
108
|
- test/test_devlogs/test_weekly_devlog.markdown
|
117
109
|
- test/test_helper.rb
|
118
110
|
- tmp/.gitignore
|
119
|
-
homepage:
|
111
|
+
homepage: https://manitu.si/devlog
|
120
112
|
licenses:
|
121
113
|
- MIT
|
122
|
-
metadata:
|
114
|
+
metadata:
|
115
|
+
allowed_push_host: https://rubygems.org
|
116
|
+
homepage_uri: https://manitu.si/devlog
|
117
|
+
source_code_uri: https://github.com/mihael/devlog
|
118
|
+
changelog_uri: https://github.com/mihael/devlog/blob/main/CHANGELOG.md
|
123
119
|
post_install_message:
|
124
120
|
rdoc_options: []
|
125
121
|
require_paths:
|
@@ -128,15 +124,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
124
|
requirements:
|
129
125
|
- - ">="
|
130
126
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
127
|
+
version: 3.0.0
|
132
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
129
|
requirements:
|
134
130
|
- - ">="
|
135
131
|
- !ruby/object:Gem::Version
|
136
132
|
version: '0'
|
137
133
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.5.11
|
139
135
|
signing_key:
|
140
136
|
specification_version: 4
|
141
|
-
summary:
|
137
|
+
summary: Write a development log while also easily track time spent in coding sessions
|
138
|
+
using just a markdown text file and a few CLI commands.
|
142
139
|
test_files: []
|
data/LICENSE
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.5
|