yhara-lifelog 0.0.3 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +13 -1
- data/VERSION +1 -1
- data/controller/init.rb +1 -2
- data/controller/main.rb +2 -0
- data/layout/default.haml +12 -0
- data/main.rb +16 -0
- data/model/init.rb +3 -1
- data/spec/helper.rb +1 -0
- data/spec/main.rb +41 -0
- data/spec/models.rb +48 -0
- data/view/index.haml +16 -0
- metadata +26 -12
- data/bin/lifelog +0 -66
- data/layout/default.ges +0 -15
- data/lifelog.gemspec +0 -57
- data/view/index.ges +0 -25
data/Rakefile
CHANGED
@@ -11,7 +11,8 @@ Jeweler::Tasks.new do |gemspec|
|
|
11
11
|
gemspec.homepage = "http://github.com/yhara/lifelog"
|
12
12
|
gemspec.description = gemspec.summary
|
13
13
|
gemspec.authors = ["Yutaka HARA"]
|
14
|
-
gemspec.add_dependency('ramaze', '= 2009.
|
14
|
+
gemspec.add_dependency('ramaze', '= 2009.06.12')
|
15
|
+
gemspec.add_dependency('haml')
|
15
16
|
gemspec.add_dependency('dm-core')
|
16
17
|
gemspec.add_dependency('do_sqlite3')
|
17
18
|
end
|
@@ -20,3 +21,14 @@ desc "install current source as gem"
|
|
20
21
|
task :dogfood => [:gemspec, :build] do
|
21
22
|
sh "sudo gem install pkg/lifelog-#{File.read("VERSION").chomp}.gem"
|
22
23
|
end
|
24
|
+
|
25
|
+
desc "uninstall temporary gem and install from github"
|
26
|
+
task :nodogfood do
|
27
|
+
sh "sudo gem uninstall lifelog"
|
28
|
+
sh "sudo gem install yhara-lifelog"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "check for gem to be built"
|
32
|
+
task :stalk do
|
33
|
+
sh "gemstalk yhara lifelog"
|
34
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.1
|
data/controller/init.rb
CHANGED
data/controller/main.rb
CHANGED
data/layout/default.haml
ADDED
data/main.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'ruby-station'; RubyStation.parse_argv
|
5
|
+
require 'ramaze'
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift __DIR__("./")
|
8
|
+
require 'controller/init.rb'
|
9
|
+
require 'model/init.rb'
|
10
|
+
|
11
|
+
#module LifeLog
|
12
|
+
# VERSION = File.read(__DIR__("./VERSION"))
|
13
|
+
#end
|
14
|
+
|
15
|
+
Ramaze.start :port => RubyStation.port,
|
16
|
+
:root => __DIR__('./')
|
data/model/init.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'dm-core'
|
2
2
|
require 'dm-validations'
|
3
|
-
|
3
|
+
require 'dm-aggregates' # needed for #count in spec
|
4
|
+
db_path = RubyStation.data_path("lifelog.db")
|
5
|
+
DataMapper.setup(:default, "sqlite3://#{db_path}")
|
4
6
|
|
5
7
|
require __DIR__('./post.rb')
|
6
8
|
require __DIR__('./tag.rb')
|
data/spec/helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ramaze/spec/bacon'
|
data/spec/main.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec/helper.rb'
|
2
|
+
ARGV.concat ["--db", "test.db"]
|
3
|
+
load 'bin/lifelog'
|
4
|
+
|
5
|
+
describe Main do
|
6
|
+
behaves_like :rack_test
|
7
|
+
|
8
|
+
# index
|
9
|
+
|
10
|
+
it 'shows start page' do
|
11
|
+
get('/').status.should == 200
|
12
|
+
#last_response.should =~ /<h1>Welcome to Ramaze!<\/h1>/
|
13
|
+
end
|
14
|
+
|
15
|
+
# posting
|
16
|
+
|
17
|
+
it 'accepts a post' do
|
18
|
+
post('/say', :message => "This is test").status.should == 302
|
19
|
+
follow_redirect!
|
20
|
+
last_response.should =~ /This is test/
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should not create a post via GET method' do
|
24
|
+
lambda{
|
25
|
+
get('/say?message=test')
|
26
|
+
}.should.not.change{ Post.count }
|
27
|
+
end
|
28
|
+
|
29
|
+
# searching by tags
|
30
|
+
|
31
|
+
it 'searches tagged posts' do
|
32
|
+
post('/say', :message => "#foo test1")
|
33
|
+
post('/say', :message => "#foo test2")
|
34
|
+
post('/say', :message => "#bar test3")
|
35
|
+
|
36
|
+
get('/search/tag/foo')
|
37
|
+
last_response.should =~ /test1/
|
38
|
+
last_response.should =~ /test2/
|
39
|
+
last_response.should.not =~ /test3/
|
40
|
+
end
|
41
|
+
end
|
data/spec/models.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec/helper.rb'
|
2
|
+
module LifeLog
|
3
|
+
include Innate::Optioned
|
4
|
+
|
5
|
+
options.dsl do
|
6
|
+
o "Path of database file (for test)",
|
7
|
+
:db, "test.db"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
require 'model/init.rb'
|
11
|
+
|
12
|
+
describe Post do
|
13
|
+
# init
|
14
|
+
|
15
|
+
it 'does not exist at first' do
|
16
|
+
Post.all.should == []
|
17
|
+
end
|
18
|
+
|
19
|
+
# instantiation
|
20
|
+
|
21
|
+
it 'should create instance for valid data' do
|
22
|
+
lambda{
|
23
|
+
Post.create({
|
24
|
+
:posted_at => Time.now,
|
25
|
+
:message => "test",
|
26
|
+
})
|
27
|
+
}.should.change{ Post.count }
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should make tags for tagged message' do
|
31
|
+
post = Post.create({
|
32
|
+
:posted_at => Time.now,
|
33
|
+
:message => "#foo #bar test",
|
34
|
+
})
|
35
|
+
foo = Tag.first(:name => "foo")
|
36
|
+
bar = Tag.first(:name => "bar")
|
37
|
+
|
38
|
+
[foo, bar].each{|tag| tag.should.not == nil}
|
39
|
+
post.tags.should == [foo, bar]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe Tag do
|
44
|
+
it 'should check uniqueness' do
|
45
|
+
Tag.create(:name => "foo")
|
46
|
+
Tag.create(:name => "foo").id.should == nil
|
47
|
+
end
|
48
|
+
end
|
data/view/index.haml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
%table
|
2
|
+
%tr
|
3
|
+
%td
|
4
|
+
%td
|
5
|
+
%form{:action => "/say", :method => "POST"}
|
6
|
+
%input{:type => "text", :name => "message", :size => 120}
|
7
|
+
%input{:type => "submit", :value => "add"}
|
8
|
+
|
9
|
+
- @pager.each do |post|
|
10
|
+
%tr
|
11
|
+
%td.time&= post.time_str
|
12
|
+
%td.message!= format_message(h post.message)
|
13
|
+
|
14
|
+
- if @pager.needed?
|
15
|
+
%div.pager
|
16
|
+
!= @pager.navigation
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yhara-lifelog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yutaka HARA
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-07-18 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ramaze
|
@@ -20,7 +20,17 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 2009.06.12
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: haml
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
24
34
|
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: dm-core
|
@@ -44,8 +54,8 @@ dependencies:
|
|
44
54
|
version:
|
45
55
|
description: A lifelogging tool written in Ramaze
|
46
56
|
email: yutaka.hara/at/gmail.com
|
47
|
-
executables:
|
48
|
-
|
57
|
+
executables: []
|
58
|
+
|
49
59
|
extensions: []
|
50
60
|
|
51
61
|
extra_rdoc_files:
|
@@ -54,16 +64,18 @@ files:
|
|
54
64
|
- README.md
|
55
65
|
- Rakefile
|
56
66
|
- VERSION
|
57
|
-
- bin/lifelog
|
58
67
|
- controller/init.rb
|
59
68
|
- controller/main.rb
|
60
|
-
- layout/default.
|
61
|
-
-
|
69
|
+
- layout/default.haml
|
70
|
+
- main.rb
|
62
71
|
- model/init.rb
|
63
72
|
- model/migrations.rb
|
64
73
|
- model/post.rb
|
65
74
|
- model/tag.rb
|
66
|
-
-
|
75
|
+
- spec/helper.rb
|
76
|
+
- spec/main.rb
|
77
|
+
- spec/models.rb
|
78
|
+
- view/index.haml
|
67
79
|
has_rdoc: true
|
68
80
|
homepage: http://github.com/yhara/lifelog
|
69
81
|
post_install_message:
|
@@ -90,5 +102,7 @@ rubygems_version: 1.2.0
|
|
90
102
|
signing_key:
|
91
103
|
specification_version: 3
|
92
104
|
summary: A lifelogging tool written in Ramaze
|
93
|
-
test_files:
|
94
|
-
|
105
|
+
test_files:
|
106
|
+
- spec/helper.rb
|
107
|
+
- spec/main.rb
|
108
|
+
- spec/models.rb
|
data/bin/lifelog
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'optparse'
|
3
|
-
require 'rubygems'
|
4
|
-
require 'ramaze'
|
5
|
-
require 'controller/init.rb'
|
6
|
-
|
7
|
-
module LifeLog
|
8
|
-
include Innate::Optioned
|
9
|
-
VERSION = File.read(__DIR__("../VERSION"))
|
10
|
-
|
11
|
-
options.dsl do
|
12
|
-
o "Path of config file",
|
13
|
-
:config, File.expand_path("~/.lifelog.rb")
|
14
|
-
o "Path of database file",
|
15
|
-
:db, File.expand_path("~/.lifelog.db")
|
16
|
-
o "Port number",
|
17
|
-
:port, 7012
|
18
|
-
o "Whether to skip creating table :posts",
|
19
|
-
:no_create_post_table, false
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.parse_argv!
|
23
|
-
OptionParser.new{|o|
|
24
|
-
o.on("--config PATH"){|path|
|
25
|
-
LifeLog.options[:config] = path
|
26
|
-
}
|
27
|
-
o.on("--db DB_PATH"){|path|
|
28
|
-
LifeLog.options[:db] = File.expand_path(path, Dir.pwd)
|
29
|
-
}
|
30
|
-
o.on("--from-001"){
|
31
|
-
LifeLog.options[:no_create_post_table] = true
|
32
|
-
}
|
33
|
-
o.on("--port N"){|port|
|
34
|
-
LifeLog.options[:port] = port
|
35
|
-
}
|
36
|
-
o.on("--version"){ puts VERSION; exit }
|
37
|
-
o.on("--help"){ puts o.to_s; exit }
|
38
|
-
}.parse!(ARGV)
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.load_conf(conf)
|
42
|
-
if File.exist?(conf)
|
43
|
-
Ramaze::Log.info("Loading config file: #{conf}")
|
44
|
-
require conf
|
45
|
-
else
|
46
|
-
Ramaze::Log.warn("Config file not found: #{conf}")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.load_models(db)
|
51
|
-
Ramaze::Log.info("Loading database: #{db}")
|
52
|
-
require __DIR__('../model/init.rb')
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.start(port)
|
56
|
-
Ramaze::Log.info("Starting server with port #{port}")
|
57
|
-
Ramaze.start :port => port,
|
58
|
-
:root => __DIR__('../')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
LifeLog.parse_argv!
|
63
|
-
|
64
|
-
LifeLog.load_conf(LifeLog.options[:config])
|
65
|
-
LifeLog.load_models(LifeLog.options[:db])
|
66
|
-
LifeLog.start(LifeLog.options[:port])
|
data/layout/default.ges
DELETED
data/lifelog.gemspec
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{lifelog}
|
5
|
-
s.version = "0.0.3"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Yutaka HARA"]
|
9
|
-
s.date = %q{2009-05-26}
|
10
|
-
s.default_executable = %q{lifelog}
|
11
|
-
s.description = %q{A lifelogging tool written in Ramaze}
|
12
|
-
s.email = %q{yutaka.hara/at/gmail.com}
|
13
|
-
s.executables = ["lifelog"]
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
"README.md"
|
16
|
-
]
|
17
|
-
s.files = [
|
18
|
-
"README.md",
|
19
|
-
"Rakefile",
|
20
|
-
"VERSION",
|
21
|
-
"bin/lifelog",
|
22
|
-
"controller/init.rb",
|
23
|
-
"controller/main.rb",
|
24
|
-
"layout/default.ges",
|
25
|
-
"lifelog.gemspec",
|
26
|
-
"model/init.rb",
|
27
|
-
"model/migrations.rb",
|
28
|
-
"model/post.rb",
|
29
|
-
"model/tag.rb",
|
30
|
-
"view/index.ges"
|
31
|
-
]
|
32
|
-
s.has_rdoc = true
|
33
|
-
s.homepage = %q{http://github.com/yhara/lifelog}
|
34
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
-
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = %q{1.3.2}
|
37
|
-
s.summary = %q{A lifelogging tool written in Ramaze}
|
38
|
-
|
39
|
-
if s.respond_to? :specification_version then
|
40
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
-
s.specification_version = 3
|
42
|
-
|
43
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_runtime_dependency(%q<ramaze>, ["= 2009.05"])
|
45
|
-
s.add_runtime_dependency(%q<dm-core>, [">= 0"])
|
46
|
-
s.add_runtime_dependency(%q<do_sqlite3>, [">= 0"])
|
47
|
-
else
|
48
|
-
s.add_dependency(%q<ramaze>, ["= 2009.05"])
|
49
|
-
s.add_dependency(%q<dm-core>, [">= 0"])
|
50
|
-
s.add_dependency(%q<do_sqlite3>, [">= 0"])
|
51
|
-
end
|
52
|
-
else
|
53
|
-
s.add_dependency(%q<ramaze>, ["= 2009.05"])
|
54
|
-
s.add_dependency(%q<dm-core>, [">= 0"])
|
55
|
-
s.add_dependency(%q<do_sqlite3>, [">= 0"])
|
56
|
-
end
|
57
|
-
end
|
data/view/index.ges
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
table do
|
2
|
-
tr do
|
3
|
-
td {}
|
4
|
-
td {
|
5
|
-
form(:action => "/say", :method => "POST") do
|
6
|
-
input(:type => "text", :name => "message", :size => 120)
|
7
|
-
input(:type => "submit", :value => "add")
|
8
|
-
end
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
@pager.each do |post|
|
13
|
-
tr do
|
14
|
-
td(:class => "time"){
|
15
|
-
h post.time_str
|
16
|
-
}
|
17
|
-
td(:class => "message"){
|
18
|
-
format_message(h post.message)
|
19
|
-
}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
div(:class => "pager") { @pager.navigation if @pager.needed? }
|