tdiary-io-mongodb 4.1.1.3 → 5.1.0

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
- SHA1:
3
- metadata.gz: d83e67043b04eb154ef1c0ecc2bc5ff3279e19a3
4
- data.tar.gz: 081e18e51fee6655872bb72ddf31cdc5e741a9be
2
+ SHA256:
3
+ metadata.gz: e238fc1411ee9e6c2799b957680df12df93b21e615d7cd1b6710a923fc94946a
4
+ data.tar.gz: bf84b576fdfca7607fda1f7b9b554f40f2ca3193c2e96590a1175bab348c5887
5
5
  SHA512:
6
- metadata.gz: 2086944b2afb55cdd6e85766ee2a13f9403e8e5a8a97304c64e5fff5bf494912553c6d144c7daecffea60125d4b777421c46acd107a77b6ded4a221d84df17d4
7
- data.tar.gz: 7595e470e22af7c62fe730bc5c524c862d5025dd35250990a752e4245bfce1a1fc97b53d785ee224e58498c99aabbf13b10b013687830b73b25591e920927a9f
6
+ metadata.gz: d39177a691525bf37a60c4f0bec0673db8c24487d9d7cd9ab6081f206ddbf4a1b478ab67601fc7fead882950c724644b90ddd87e526e867f9b65e1329812fb24
7
+ data.tar.gz: 95d8171ea0a0094f2b468e3dd10634a77b948609a7bd7aea98f26925e0440cca9c37fc8d318ef1702fcb8aabb1715352d022b9062c37a7ffd868721ec6ad4592
@@ -1,8 +1,20 @@
1
1
  language: ruby
2
+ cache: bundler
3
+
2
4
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1
5
+ - 2.3.8
6
+ - 2.4.5
7
+ - 2.5.3
8
+ - 2.6.0
9
+ - ruby-head
10
+
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
14
+
15
+ before_install:
16
+
6
17
  script: bundle exec rake spec
18
+
7
19
  services:
8
20
  - mongodb
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in mongodb.gemspec
4
4
  gemspec
5
-
6
- gem 'tdiary', github: 'tdiary/tdiary-core'
data/README.md CHANGED
@@ -4,7 +4,7 @@ mongoid adapter for tDiary
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add this line to your tDiary's Gemfile.local:
8
8
 
9
9
  gem 'tdiary-io-mongodb'
10
10
 
@@ -12,10 +12,6 @@ And then execute:
12
12
 
13
13
  $ bundle
14
14
 
15
- Or install it yourself as:
16
-
17
- $ gem install tdiary-io-mongodb
18
-
19
15
  ## Usage
20
16
 
21
17
  Add follow snipet to your tdiary.conf
@@ -24,6 +20,45 @@ Add follow snipet to your tdiary.conf
24
20
  @io_class = TDiary::IO::MongoDB
25
21
  ```
26
22
 
23
+ ## Migration
24
+
25
+ `bin/tdiary-mongodb-convert` is utility that uploads tDiary default IO data to MongoDB.
26
+
27
+ (1) Migrate tDiary configuration
28
+
29
+ Migrate your tDiary configuration to MongoDB.
30
+
31
+ ```
32
+ $ bundle exec tdiary-mongodb-convert -c $DATA_PATH/tdiary.conf -m $MONGODB_URI
33
+ ```
34
+
35
+ * $MONGODB_URI: the uri of mongodb (mongodb://)
36
+ * $DATA_PATH: the path of your tdiary data directory
37
+
38
+ (2) Migrate tDiary data
39
+
40
+ Migrate your tDiary data to MongoDB.
41
+
42
+ ```
43
+ $ bundle exec tdiary-mongodb-convert -s ./lib/tdiary/style -m $MONGODB_URI $DATA_PATH
44
+ ```
45
+ * $MONGODB_URI: the uri of mongodb (mongodb://)
46
+ * $DATA_PATH: the path of your tdiary data directory
47
+
48
+ ### Note
49
+
50
+ If you use the style provided by an external gem (like GFM style), append the gem to Gemfile and run `bundle`.
51
+
52
+ ```
53
+ gem 'tdiary-style-gfm'
54
+ gem 'tdiary-style-etdiary'
55
+ gem 'tdiary-style-rd
56
+ ```
57
+
58
+ ### See also
59
+
60
+ * http://sho.tdiary.net/20150206.html#p01 (in Japanese)
61
+
27
62
  ## Contributing
28
63
 
29
64
  1. Fork it
@@ -10,6 +10,7 @@ require 'tdiary/referer_manager'
10
10
  require 'tdiary/style'
11
11
  require 'tdiary/cache/file'
12
12
  require 'ostruct'
13
+ require 'tdiary/core_ext'
13
14
 
14
15
  def load_diaries(data_path, style_path)
15
16
  require 'tdiary/io/default'
@@ -31,7 +31,7 @@ module TDiary
31
31
  include Mongoid::Timestamps
32
32
  store_in collection: "comments"
33
33
 
34
- belongs_to :diary
34
+ belongs_to :diary, class_name: 'TDiary::IO::MongoDB::Diary'
35
35
  field :name, type: String
36
36
  field :mail, type: String
37
37
  field :body, type: String
@@ -61,8 +61,8 @@ module TDiary
61
61
  field :style, type: String
62
62
  field :last_modified, type: Integer
63
63
  field :visible, type: Boolean
64
- has_many :comments, autosave: true
65
- has_many :referers, autosave: true
64
+ has_many :comments, autosave: true, class_name: 'TDiary::IO::MongoDB::Comment'
65
+ has_many :referers, autosave: true, class_name: 'TDiary::IO::MongoDB::Referer'
66
66
 
67
67
  index({diary_id: 1}, {unique: true})
68
68
  index({year: 1, month: 1})
@@ -110,6 +110,8 @@ module TDiary
110
110
  include Cache
111
111
 
112
112
  class << self
113
+ Mongo::Logger.level = Logger::WARN
114
+
113
115
  def load_cgi_conf(conf)
114
116
  db(conf)
115
117
  if cgi_conf = Conf.all.first
@@ -131,7 +133,7 @@ module TDiary
131
133
 
132
134
  def db(conf)
133
135
  @@_db ||= Mongoid::Config.load_configuration(
134
- {sessions:{default:{uri:(conf.database_url || 'mongodb://localhost:27017/tdiary')}}}
136
+ {clients:{default:{uri:(conf.database_url || 'mongodb://localhost:27017/tdiary')}}}
135
137
  )
136
138
  end
137
139
 
@@ -181,9 +183,15 @@ module TDiary
181
183
  end
182
184
 
183
185
  def calendar
186
+ mongo_project = {
187
+ "$group" => {
188
+ "_id" => {"year" => "$year", "month" => "$month"},
189
+ "count" => {"$sum" => 1}
190
+ }
191
+ }
184
192
  calendar = Hash.new{|hash, key| hash[key] = []}
185
- Diary.all.map{|d|[d.year, d.month]}.sort.uniq.each do |ym|
186
- calendar[ym[0]] << ym[1]
193
+ Diary.collection.aggregate([mongo_project]).map do |cal|
194
+ calendar[cal['_id']['year']] << cal['_id']['month']
187
195
  end
188
196
  calendar
189
197
  end
@@ -83,7 +83,7 @@ end
83
83
 
84
84
  RSpec.configure do |c|
85
85
  c.after(:suite) do
86
- Mongoid.default_session.collections.each do |collection|
86
+ Mongoid.default_client.database.collections.each do |collection|
87
87
  collection.drop
88
88
  end
89
89
  end
@@ -4,8 +4,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "tdiary-io-mongodb"
7
- spec.version = "4.1.1.3"
8
- spec.authors = ["TADA Tadashi"]
7
+ spec.version = "5.1.0"
8
+ spec.authors = ["Tada, Tadashi"]
9
9
  spec.email = ["t@tdtds.jp"]
10
10
  spec.description = %q{MongoDB adapter for tDiary}
11
11
  spec.summary = %q{MongoDB adapter for tDiary}
@@ -17,10 +17,12 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "mongoid"
20
+ spec.add_dependency "mongoid", "~> 7.0"
21
+ spec.add_dependency "mongo", "< 2.9.0"
21
22
  spec.add_dependency "hikidoc"
23
+ spec.add_dependency "tdiary", ">= 5.0"
22
24
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "bundler"
24
26
  spec.add_development_dependency "rake"
25
27
  spec.add_development_dependency "rspec"
26
28
  spec.add_development_dependency "pry"
metadata CHANGED
@@ -1,17 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary-io-mongodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1.3
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - TADA Tadashi
7
+ - Tada, Tadashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2020-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mongo
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.9.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "<"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: hikidoc
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
45
  - - ">="
@@ -25,33 +53,33 @@ dependencies:
25
53
  - !ruby/object:Gem::Version
26
54
  version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
- name: hikidoc
56
+ name: tdiary
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - ">="
32
60
  - !ruby/object:Gem::Version
33
- version: '0'
61
+ version: '5.0'
34
62
  type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - ">="
39
67
  - !ruby/object:Gem::Version
40
- version: '0'
68
+ version: '5.0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - "~>"
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: '1.3'
75
+ version: '0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: '1.3'
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rake
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -133,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
161
  - !ruby/object:Gem::Version
134
162
  version: '0'
135
163
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.4.5
164
+ rubygems_version: 3.1.2
138
165
  signing_key:
139
166
  specification_version: 4
140
167
  summary: MongoDB adapter for tDiary