tdiary-io-rdb 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: 9f1f3278cfb2194a6bacca2be1f34daff5544401
4
- data.tar.gz: ae93406a10b408c0ea0c85d759b7ee21ce2cd77f
3
+ metadata.gz: 227494226d6c740d601ad66f540837eec6715d8d
4
+ data.tar.gz: e7374c6d14e51de521372679c4b7d06289741fef
5
5
  SHA512:
6
- metadata.gz: e2dfb2b922649ac5b2e1649df445ee99184376b341e8df0db19af7a37e2c929845dcb1ac1c420fa2f2b82a37b35a33bf430a59834e9444a464f315667ba4a64a
7
- data.tar.gz: 921b64e1a0caffa1cdc1ab907d07b3cee3d9eea0363d1df3c58036156bd1369fef84c8a85e56fef6b95ccb09875a626ea868ecd581e3f5fbb0f56461eb468b05
6
+ metadata.gz: 50ccdb27765b59cf5db35e7cc4cc13b92f799c56643c1da0070acc47585a88f082d3db9e57aa1be4c0eb79cbf0123aa331ca358b7b3eb7144d0badef07b7320e
7
+ data.tar.gz: 4a5977040814b7627400693f9d9303fd54fb8c95dd9fc8b29abce937bad47b6f716db4ffc22b1c81d1533fe98becbdf4bad9bf70eac488d0921ffb2dd6ad7261
@@ -1,5 +1,9 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
4
  - 2.0.0
4
- - 1.9.3
5
- script: bundle exec rspec spec
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3.0
8
+ - ruby-head
9
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Tdiary::Io::Rdb
1
+ # TDiary::IO::Rdb
2
2
 
3
- TODO: Write a gem description
3
+ [![Gem Version](https://badge.fury.io/rb/tdiary-io-rdb.png)](https://rubygems.org/gems/tdiary-io-rdb) [![Build Status](https://secure.travis-ci.org/tdiary/tdiary-io-rdb.png)](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
- TODO: Write usage instructions here
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
 
@@ -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
- :diary_id => diary_id,
40
- :no => no
39
+ diary_id: diary_id,
40
+ no: no
41
41
  }
42
42
  body = {
43
- :name => com.name,
44
- :mail => com.mail,
45
- :last_modified => com.date.to_i,
46
- :visible => com.visible?,
47
- :comment => com.body
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, :text => true
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, :size => 8
103
- String :year, :size => 4
104
- String :month, :size => 2
105
- String :day, :size => 2
106
- String :title, :text => true
107
- String :body, :text => true
108
- String :style, :text => true
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, :size => 8
119
+ String :diary_id, size: 8
116
120
  Fixnum :no
117
- String :name, :text => true
118
- String :mail, :text => true
119
- String :comment, :text => true
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, :month => $2)
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
- :year => $1,
188
- :month => $2,
189
- :day => $3,
190
- :diary_id => diary_id
191
+ year: $1,
192
+ month: $2,
193
+ day: $3,
194
+ diary_id: diary_id
191
195
  }
192
196
  end
193
197
  body = {
194
- :title => diary.title,
195
- :last_modified => diary.last_modified.to_i,
196
- :style => diary.style,
197
- :visible => diary.visible?,
198
- :body => diary.to_src
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)
@@ -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 { TDiary::IO::Rdb.is_a?(TDiary::IO::Base) }.to be_true
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
@@ -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.1"
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.1
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: 2013-11-02 00:00:00.000000000 Z
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: '0'
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: '0'
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.2.0
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: