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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 262bc6df490d8ed92927a393deb279de2a8395c5
4
- data.tar.gz: 72836a595e1666bb63cbcc7cb5df3d3ef614d03e
3
+ metadata.gz: 761211469f9d3ff25f2fbc5f28401fbbaf5440c1
4
+ data.tar.gz: d749c7dbfdff6598e6da2cb993c84c65ac7d112d
5
5
  SHA512:
6
- metadata.gz: ecf2431d0070c22050d2ef7142abbff4e5a9777eb62ba2677648d7d594930ee87848faf8faf28b5c5ded48f8d51931e2908022dbd34aabe07a18c94c0f3ccfbe
7
- data.tar.gz: 97174fe493e142ce967b3b3164275470ad367e9547bb08510a6c99193eac4e89eebab1b8039c7433edf521310e522d96d9dfba312a306fd27769695564b2bb0b
6
+ metadata.gz: 3c345022db55ef23c7de1ea869af21e45c719362fba4371cf7676d539b2212d3164e01f549ba1cb8bfc5bed07c21bedf2e1314ecd846d7e4778868e95adf1f06
7
+ data.tar.gz: 87eec4440b020845f53893e55b6f8b65504cbe56675a94b115226a3a9a927ddd1bd9217425aa82a28a1b665ca3436a1008c4d8e8f57a1c33d70c1dc1d12ffb98
data/History.txt ADDED
@@ -0,0 +1,9 @@
1
+ === 0.0.2 2013-04-29
2
+
3
+ * upgrade database : now --db_upgrade
4
+ * save logs : now --log
5
+ * when --limit
6
+
7
+ === 0.0.1 2013-04-28
8
+
9
+ * initial release
data/README.md CHANGED
@@ -13,6 +13,7 @@ Usage
13
13
  -----
14
14
 
15
15
  % now yummy
16
+ % now -log http://example.com/food
16
17
  % when yummy
17
18
 
18
19
 
@@ -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 = parser.argv.empty? ? {} : {:what => parser.argv[0].strip}
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
@@ -10,14 +10,19 @@ module NoWhen
10
10
  property :longitude, Float
11
11
 
12
12
  def self.find(query={})
13
- {:order => [:created_at.desc], :limit => 40}.each do |k,v|
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(query)
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 '[%m/%d %a] (%H:%M:%S)'} \"#{self.what}\""
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
 
@@ -1,3 +1,3 @@
1
1
  module NoWhen
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/nowhen.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "nowhen/version"
2
+ require "date"
3
+ require "backports"
2
4
  require "nowhen/model"
3
5
 
4
6
  module NoWhen
data/nowhen.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "args_parser"
25
25
  spec.add_dependency "data_mapper"
26
26
  spec.add_dependency "dm-sqlite-adapter"
27
+ spec.add_dependency "backports"
27
28
  end
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.1
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