nowhen 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/bin/now +6 -0
- data/bin/when +6 -0
- data/lib/nowhen/command.rb +53 -0
- data/lib/nowhen/model/tag.rb +24 -0
- data/lib/nowhen/model.rb +23 -0
- data/lib/nowhen/version.rb +3 -0
- data/lib/nowhen.rb +5 -0
- data/nowhen.gemspec +27 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 262bc6df490d8ed92927a393deb279de2a8395c5
|
4
|
+
data.tar.gz: 72836a595e1666bb63cbcc7cb5df3d3ef614d03e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ecf2431d0070c22050d2ef7142abbff4e5a9777eb62ba2677648d7d594930ee87848faf8faf28b5c5ded48f8d51931e2908022dbd34aabe07a18c94c0f3ccfbe
|
7
|
+
data.tar.gz: 97174fe493e142ce967b3b3164275470ad367e9547bb08510a6c99193eac4e89eebab1b8039c7433edf521310e522d96d9dfba312a306fd27769695564b2bb0b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Sho Hashimoto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
nowhen
|
2
|
+
======
|
3
|
+
Tagger for Life Log
|
4
|
+
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
% gem install nowhen
|
10
|
+
|
11
|
+
|
12
|
+
Usage
|
13
|
+
-----
|
14
|
+
|
15
|
+
% now yummy
|
16
|
+
% when yummy
|
17
|
+
|
18
|
+
|
19
|
+
Test
|
20
|
+
----
|
21
|
+
|
22
|
+
% gem install bundler
|
23
|
+
% bundle install
|
24
|
+
% bin/now todo
|
25
|
+
% bin/when todo
|
26
|
+
|
27
|
+
|
28
|
+
Contributing
|
29
|
+
------------
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/now
ADDED
data/bin/when
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "nowhen"
|
2
|
+
require "args_parser"
|
3
|
+
|
4
|
+
module NoWhen
|
5
|
+
module Command
|
6
|
+
def self.show_help(parser)
|
7
|
+
STDERR.puts "nowhen - Tagger for LifeLog v#{NoWhen::VERSION}"
|
8
|
+
STDERR.puts " https://github.com/shokai/nowhen"
|
9
|
+
STDERR.puts parser.help
|
10
|
+
STDERR.puts
|
11
|
+
STDERR.puts "e.g."
|
12
|
+
STDERR.puts " % now yummy"
|
13
|
+
STDERR.puts " % when yummy"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.now(argv)
|
17
|
+
parser = ArgsParser.parse argv do
|
18
|
+
arg :version, 'show version', :alias => :v
|
19
|
+
arg :help, 'show help', :alias => :h
|
20
|
+
end
|
21
|
+
if parser.has_option? :help
|
22
|
+
show_help parser
|
23
|
+
elsif parser.has_option? :version
|
24
|
+
STDERR.puts "nowhen version #{NoWhen::VERSION}"
|
25
|
+
elsif !parser.argv.empty?
|
26
|
+
what = parser.argv[0].strip
|
27
|
+
tag = NoWhen::Model::Tag.new(:what => what)
|
28
|
+
tag.save
|
29
|
+
puts tag
|
30
|
+
else
|
31
|
+
show_help parser
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.when(argv)
|
36
|
+
parser = ArgsParser.parse argv do
|
37
|
+
arg :version, 'show version', :alias => :v
|
38
|
+
arg :help, 'show help', :alias => :h
|
39
|
+
end
|
40
|
+
if parser.has_option? :help
|
41
|
+
show_help parser
|
42
|
+
elsif parser.has_option? :version
|
43
|
+
STDERR.puts "nowhen version #{NoWhen::VERSION}"
|
44
|
+
else
|
45
|
+
query = parser.argv.empty? ? {} : {:what => parser.argv[0].strip}
|
46
|
+
tags = NoWhen::Model::Tag.find query
|
47
|
+
tags.each do |tag|
|
48
|
+
puts tag
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module NoWhen
|
2
|
+
module Model
|
3
|
+
class Tag
|
4
|
+
include DataMapper::Resource
|
5
|
+
property :id, Serial
|
6
|
+
timestamps :at
|
7
|
+
property :what, String, :required => true, :length => 0...256
|
8
|
+
property :who, String, :length => 0...256, :default => lambda{|r,p| `whoami`.strip }
|
9
|
+
property :latitude, Float
|
10
|
+
property :longitude, Float
|
11
|
+
|
12
|
+
def self.find(query={})
|
13
|
+
{:order => [:created_at.desc], :limit => 40}.each do |k,v|
|
14
|
+
query[k] = v unless query.include? k
|
15
|
+
end
|
16
|
+
self.all(query)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"#{self.created_at.strftime '[%m/%d %a] (%H:%M:%S)'} \"#{self.what}\""
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/nowhen/model.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "data_mapper"
|
2
|
+
require "dm-sqlite-adapter"
|
3
|
+
require "nowhen/model/tag"
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
module NoWhen
|
7
|
+
module Model
|
8
|
+
def self.init(db_path="#{ENV['HOME']}/.nowhen.sqlite")
|
9
|
+
FileUtils.mkdir_p File.dirname(db_path) unless File.exists? File.dirname(db_path)
|
10
|
+
DataMapper.setup(:default, {:adapter => :sqlite, :database => db_path})
|
11
|
+
DataMapper::Logger.new($stdout, :debug)
|
12
|
+
migrate unless File.exists? db_path
|
13
|
+
DataMapper.finalize
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.migrate
|
17
|
+
require 'dm-migrations'
|
18
|
+
DataMapper.auto_migrate!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
NoWhen::Model.init
|
data/lib/nowhen.rb
ADDED
data/nowhen.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nowhen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nowhen"
|
8
|
+
spec.version = NoWhen::VERSION
|
9
|
+
spec.authors = ["Sho Hashimoto"]
|
10
|
+
spec.email = ["hashimoto@shokai.org"]
|
11
|
+
spec.description = %q{Tagger for Life Log}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/shokai/nowhen"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/).reject{|i| i == "Gemfile.lock" }
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "args_parser"
|
25
|
+
spec.add_dependency "data_mapper"
|
26
|
+
spec.add_dependency "dm-sqlite-adapter"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nowhen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sho Hashimoto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: args_parser
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: data_mapper
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dm-sqlite-adapter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Tagger for Life Log
|
84
|
+
email:
|
85
|
+
- hashimoto@shokai.org
|
86
|
+
executables:
|
87
|
+
- now
|
88
|
+
- when
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/now
|
98
|
+
- bin/when
|
99
|
+
- lib/nowhen.rb
|
100
|
+
- lib/nowhen/command.rb
|
101
|
+
- lib/nowhen/model.rb
|
102
|
+
- lib/nowhen/model/tag.rb
|
103
|
+
- lib/nowhen/version.rb
|
104
|
+
- nowhen.gemspec
|
105
|
+
homepage: https://github.com/shokai/nowhen
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.0.3
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Tagger for Life Log
|
129
|
+
test_files: []
|