nowhen 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +9 -0
- data/README.md +1 -0
- data/lib/nowhen/command.rb +16 -1
- data/lib/nowhen/model/log.rb +17 -0
- data/lib/nowhen/model/tag.rb +8 -3
- data/lib/nowhen/model.rb +6 -0
- data/lib/nowhen/version.rb +1 -1
- data/lib/nowhen.rb +2 -0
- data/nowhen.gemspec +1 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 761211469f9d3ff25f2fbc5f28401fbbaf5440c1
|
4
|
+
data.tar.gz: d749c7dbfdff6598e6da2cb993c84c65ac7d112d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c345022db55ef23c7de1ea869af21e45c719362fba4371cf7676d539b2212d3164e01f549ba1cb8bfc5bed07c21bedf2e1314ecd846d7e4778868e95adf1f06
|
7
|
+
data.tar.gz: 87eec4440b020845f53893e55b6f8b65504cbe56675a94b115226a3a9a927ddd1bd9217425aa82a28a1b665ca3436a1008c4d8e8f57a1c33d70c1dc1d12ffb98
|
data/History.txt
ADDED
data/README.md
CHANGED
data/lib/nowhen/command.rb
CHANGED
@@ -15,6 +15,8 @@ module NoWhen
|
|
15
15
|
|
16
16
|
def self.now(argv)
|
17
17
|
parser = ArgsParser.parse argv do
|
18
|
+
arg :log, 'save log'
|
19
|
+
arg :db_upgrade, 'upgrade database'
|
18
20
|
arg :version, 'show version', :alias => :v
|
19
21
|
arg :help, 'show help', :alias => :h
|
20
22
|
end
|
@@ -22,6 +24,13 @@ module NoWhen
|
|
22
24
|
show_help parser
|
23
25
|
elsif parser.has_option? :version
|
24
26
|
STDERR.puts "nowhen version #{NoWhen::VERSION}"
|
27
|
+
elsif parser.has_option? :db_upgrade
|
28
|
+
NoWhen::Model.upgrade
|
29
|
+
elsif parser[:log]
|
30
|
+
log = parser.has_param?(:log) ? parser[:log] : parser.argv.join(' ')
|
31
|
+
log = NoWhen::Model::Log.new(:log => log)
|
32
|
+
log.save
|
33
|
+
p log
|
25
34
|
elsif !parser.argv.empty?
|
26
35
|
what = parser.argv[0].strip
|
27
36
|
tag = NoWhen::Model::Tag.new(:what => what)
|
@@ -34,6 +43,7 @@ module NoWhen
|
|
34
43
|
|
35
44
|
def self.when(argv)
|
36
45
|
parser = ArgsParser.parse argv do
|
46
|
+
arg :limit, 'tags count', :default => 40
|
37
47
|
arg :version, 'show version', :alias => :v
|
38
48
|
arg :help, 'show help', :alias => :h
|
39
49
|
end
|
@@ -42,10 +52,15 @@ module NoWhen
|
|
42
52
|
elsif parser.has_option? :version
|
43
53
|
STDERR.puts "nowhen version #{NoWhen::VERSION}"
|
44
54
|
else
|
45
|
-
query =
|
55
|
+
query = {}
|
56
|
+
query[:what] = parser.argv[0].strip unless parser.argv.empty?
|
57
|
+
query[:limit] = parser[:limit]
|
46
58
|
tags = NoWhen::Model::Tag.find query
|
47
59
|
tags.each do |tag|
|
48
60
|
puts tag
|
61
|
+
tag.logs.each do |log|
|
62
|
+
puts " - #{log.log}"
|
63
|
+
end
|
49
64
|
end
|
50
65
|
end
|
51
66
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module NoWhen
|
2
|
+
module Model
|
3
|
+
class Log
|
4
|
+
include DataMapper::Resource
|
5
|
+
property :id, Serial
|
6
|
+
timestamps :at
|
7
|
+
property :log, String, :required => true, :length => 0...2048
|
8
|
+
|
9
|
+
def self.find(query={})
|
10
|
+
{:order => [:created_at.asc], :limit => 40}.each do |k,v|
|
11
|
+
query[k] = v unless query.include? k
|
12
|
+
end
|
13
|
+
self.all query
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/nowhen/model/tag.rb
CHANGED
@@ -10,14 +10,19 @@ module NoWhen
|
|
10
10
|
property :longitude, Float
|
11
11
|
|
12
12
|
def self.find(query={})
|
13
|
-
{:order => [:created_at.
|
13
|
+
{:order => [:created_at.asc], :limit => 40}.each do |k,v|
|
14
14
|
query[k] = v unless query.include? k
|
15
15
|
end
|
16
|
-
self.all
|
16
|
+
self.all query
|
17
|
+
end
|
18
|
+
|
19
|
+
def logs(minute=5)
|
20
|
+
rational = Rational(1, 24*60/minute)
|
21
|
+
Log.find :created_at => (self.created_at-rational)..(self.created_at+rational)
|
17
22
|
end
|
18
23
|
|
19
24
|
def to_s
|
20
|
-
"#{self.created_at.strftime '
|
25
|
+
"[#{self.what}]\t#{self.created_at.strftime '(%m/%d %a %H:%M:%S)'}"
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
data/lib/nowhen/model.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "data_mapper"
|
2
2
|
require "dm-sqlite-adapter"
|
3
3
|
require "nowhen/model/tag"
|
4
|
+
require "nowhen/model/log"
|
4
5
|
require "fileutils"
|
5
6
|
|
6
7
|
module NoWhen
|
@@ -17,6 +18,11 @@ module NoWhen
|
|
17
18
|
require 'dm-migrations'
|
18
19
|
DataMapper.auto_migrate!
|
19
20
|
end
|
21
|
+
|
22
|
+
def self.upgrade
|
23
|
+
require 'dm-migrations'
|
24
|
+
DataMapper.auto_upgrade!
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
data/lib/nowhen/version.rb
CHANGED
data/lib/nowhen.rb
CHANGED
data/nowhen.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nowhen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: backports
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Tagger for Life Log
|
84
98
|
email:
|
85
99
|
- hashimoto@shokai.org
|
@@ -91,6 +105,7 @@ extra_rdoc_files: []
|
|
91
105
|
files:
|
92
106
|
- .gitignore
|
93
107
|
- Gemfile
|
108
|
+
- History.txt
|
94
109
|
- LICENSE.txt
|
95
110
|
- README.md
|
96
111
|
- Rakefile
|
@@ -99,6 +114,7 @@ files:
|
|
99
114
|
- lib/nowhen.rb
|
100
115
|
- lib/nowhen/command.rb
|
101
116
|
- lib/nowhen/model.rb
|
117
|
+
- lib/nowhen/model/log.rb
|
102
118
|
- lib/nowhen/model/tag.rb
|
103
119
|
- lib/nowhen/version.rb
|
104
120
|
- nowhen.gemspec
|