tdiary-io-rdb 0.0.1 → 0.0.2
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/.travis.yml +6 -2
- data/README.md +9 -3
- data/lib/tdiary/io/rdb.rb +36 -32
- data/spec/tdiary/io/rdb_spec.rb +1 -1
- data/tdiary-io-rdb.gemspec +2 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 227494226d6c740d601ad66f540837eec6715d8d
|
4
|
+
data.tar.gz: e7374c6d14e51de521372679c4b7d06289741fef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ccdb27765b59cf5db35e7cc4cc13b92f799c56643c1da0070acc47585a88f082d3db9e57aa1be4c0eb79cbf0123aa331ca358b7b3eb7144d0badef07b7320e
|
7
|
+
data.tar.gz: 4a5977040814b7627400693f9d9303fd54fb8c95dd9fc8b29abce937bad47b6f716db4ffc22b1c81d1533fe98becbdf4bad9bf70eac488d0921ffb2dd6ad7261
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# TDiary::IO::Rdb
|
2
2
|
|
3
|
-
|
3
|
+
[](https://rubygems.org/gems/tdiary-io-rdb) [](https://travis-ci.org/tdiary/tdiary-io-rdb)
|
4
|
+
|
5
|
+
RDB like sqlite, mysql and postgresql adapter for tDiary
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -18,7 +20,11 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
Add follow snipet to your tdiary.conf
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
@io_class = TDiary::IO::Rdb
|
27
|
+
```
|
22
28
|
|
23
29
|
## Contributing
|
24
30
|
|
data/lib/tdiary/io/rdb.rb
CHANGED
@@ -23,7 +23,7 @@ module TDiary
|
|
23
23
|
def restore_comment(diaries)
|
24
24
|
diaries.each do |date, diary_object|
|
25
25
|
db[:comments].filter(:diary_id => date).order_by(:no).select(:name, :mail, :last_modified, :visible, :comment).each do |row|
|
26
|
-
comment = Comment.new(row[:name], row[:mail], row[:comment], Time.at(row[:last_modified].to_i))
|
26
|
+
comment = TDiary::Comment.new(row[:name], row[:mail], row[:comment], Time.at(row[:last_modified].to_i))
|
27
27
|
comment.show = row[:visible]
|
28
28
|
diary_object.add_comment(comment)
|
29
29
|
end
|
@@ -36,15 +36,15 @@ module TDiary
|
|
36
36
|
diary.each_comment(diary.count_comments(true)) do |com|
|
37
37
|
no += 1
|
38
38
|
date = {
|
39
|
-
:
|
40
|
-
:
|
39
|
+
diary_id: diary_id,
|
40
|
+
no: no
|
41
41
|
}
|
42
42
|
body = {
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
43
|
+
name: com.name,
|
44
|
+
mail: com.mail,
|
45
|
+
last_modified: com.date.to_i,
|
46
|
+
visible: com.visible?,
|
47
|
+
comment: com.body
|
48
48
|
}
|
49
49
|
comment = db[:comments].filter(date)
|
50
50
|
if comment.count > 0
|
@@ -92,31 +92,35 @@ module TDiary
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def db(conf)
|
95
|
-
@@_db ||= Sequel.connect(conf.database_url || ENV['DATABASE_URL'])
|
95
|
+
@@_db ||= Sequel.connect(conf.database_url || ENV['DATABASE_URL']).tap{|db|
|
96
|
+
db.extension(:connection_validator)
|
97
|
+
db.pool.connection_validation_timeout = -1
|
98
|
+
}
|
99
|
+
|
100
|
+
@@_db.test_connection
|
96
101
|
|
97
102
|
@@_db.create_table :conf do
|
98
|
-
String :body, :
|
103
|
+
String :body, text: true
|
99
104
|
end unless @@_db.table_exists?(:conf)
|
100
105
|
|
101
106
|
@@_db.create_table :diaries do
|
102
|
-
String :diary_id, :
|
103
|
-
String :year, :
|
104
|
-
String :month, :
|
105
|
-
String :day, :
|
106
|
-
String :title, :
|
107
|
-
String :body, :
|
108
|
-
String :style, :
|
107
|
+
String :diary_id, size: 8, primary_key: true
|
108
|
+
String :year, size: 4
|
109
|
+
String :month, size: 2
|
110
|
+
String :day, size: 2
|
111
|
+
String :title, text: true
|
112
|
+
String :body, text: true
|
113
|
+
String :style, text: true
|
109
114
|
Fixnum :last_modified
|
110
115
|
TrueClass :visible
|
111
|
-
primary_key :diary_id
|
112
116
|
end unless @@_db.table_exists?(:diaries)
|
113
117
|
|
114
118
|
@@_db.create_table :comments do
|
115
|
-
String :diary_id, :
|
119
|
+
String :diary_id, size: 8
|
116
120
|
Fixnum :no
|
117
|
-
String :name, :
|
118
|
-
String :mail, :
|
119
|
-
String :comment, :
|
121
|
+
String :name, text: true
|
122
|
+
String :mail, text: true
|
123
|
+
String :comment, text: true
|
120
124
|
Fixnum :last_modified
|
121
125
|
TrueClass :visible
|
122
126
|
primary_key [:diary_id, :no]
|
@@ -164,7 +168,7 @@ module TDiary
|
|
164
168
|
def restore(date, diaries, month = true)
|
165
169
|
query = db[:diaries].select(:diary_id, :title, :last_modified, :visible, :body, :style)
|
166
170
|
query = if month && /(\d\d\d\d)(\d\d)(\d\d)/ =~ date
|
167
|
-
query.filter(:year => $1, :
|
171
|
+
query.filter(:year => $1, month: $2)
|
168
172
|
else
|
169
173
|
query.filter(:diary_id => date)
|
170
174
|
end
|
@@ -184,18 +188,18 @@ module TDiary
|
|
184
188
|
diaries.each do |diary_id, diary|
|
185
189
|
date = if /(\d\d\d\d)(\d\d)(\d\d)/ =~ diary_id
|
186
190
|
{
|
187
|
-
:
|
188
|
-
:
|
189
|
-
:
|
190
|
-
:
|
191
|
+
year: $1,
|
192
|
+
month: $2,
|
193
|
+
day: $3,
|
194
|
+
diary_id: diary_id
|
191
195
|
}
|
192
196
|
end
|
193
197
|
body = {
|
194
|
-
:
|
195
|
-
:
|
196
|
-
:
|
197
|
-
:
|
198
|
-
:
|
198
|
+
title: diary.title,
|
199
|
+
last_modified: diary.last_modified.to_i,
|
200
|
+
style: diary.style,
|
201
|
+
visible: diary.visible?,
|
202
|
+
body: diary.to_src
|
199
203
|
}
|
200
204
|
|
201
205
|
entry = db[:diaries].filter(date)
|
data/spec/tdiary/io/rdb_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe TDiary::IO::Rdb do
|
4
4
|
it 'is_a TDiary::IO::Base' do
|
5
|
-
expect
|
5
|
+
expect(TDiary::IO::Rdb.new(DummyTDiary.new)).to be_a(TDiary::IO::Base)
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "#save_cgi_conf and #load_cgi_conf" do
|
data/tdiary-io-rdb.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "tdiary-io-rdb"
|
5
|
-
spec.version = "0.0.
|
5
|
+
spec.version = "0.0.2"
|
6
6
|
spec.authors = ["SHIBATA Hiroshi"]
|
7
7
|
spec.email = ["shibata.hiroshi@gmail.com"]
|
8
8
|
spec.summary = %q{rdb adapter for tDiary}
|
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_development_dependency "bundler"
|
21
21
|
spec.add_development_dependency "rake"
|
22
|
-
spec.add_development_dependency "rspec"
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdiary-io-rdb
|
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
|
- SHIBATA Hiroshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.1.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.1.0
|
69
69
|
description: rdb adapter for tDiary
|
70
70
|
email:
|
71
71
|
- shibata.hiroshi@gmail.com
|
@@ -104,10 +104,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.5.1
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: rdb adapter for tDiary
|
111
111
|
test_files:
|
112
112
|
- spec/spec_helper.rb
|
113
113
|
- spec/tdiary/io/rdb_spec.rb
|
114
|
+
has_rdoc:
|