dhole 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ec9a1b3cf83cdf6547b06d5ac378eba04b481f7
4
+ data.tar.gz: e28f8fffa4fa80acb1b454b08271d906e0ca329c
5
+ SHA512:
6
+ metadata.gz: f7f0983e1191f2d09d1ff9a1a7a8982c225eeba60d903dd31f5e0db5aab525be3a2bae0ba404fecacb76494048eb0865f7cde858488127d338cce966fe89e1d1
7
+ data.tar.gz: e9db9f11a06a421bd28a006574196284551a41b868e38e802371d44523439f662155dc887bf0c67da930419fcbf7365bccfc2f4eec63b4a17782b86a246706b0
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dhole.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Asaf Bartov
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.
@@ -0,0 +1,16 @@
1
+ dhole
2
+ =====
3
+
4
+ A Ruby gem with ActiveRecord models and relations for the Mediawiki DB schema.
5
+
6
+
7
+ What is a Dhole?
8
+ ================
9
+
10
+ I thought of calling this gem *mworm* - Mediawiki ORM - but figured as long as we're entering worm territory, we may as well go all the way. Besides:
11
+
12
+ "Dholes are huge, slimy worm-like creatures, at least several hundred feet long. Because they avoid daylight and are covered in viscous goo, their features are nearly impossible to discern." --https://en.wikipedia.org/wiki/Dhole_%28Cthulhu_Mythos%29
13
+
14
+ ...and that is a pretty good description of the Mediawiki DB schema, right? :)
15
+
16
+ E-mail asaf.bartov@gmail.com with questions or file issues on GitHub at https://github.com/abartov/dhole
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dhole/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dhole"
8
+ spec.version = Dhole::VERSION
9
+ spec.authors = ["Asaf Bartov"]
10
+ spec.email = ["asaf.bartov@gmail.com"]
11
+ spec.summary = %q{Mediawiki Object-Relational Mapping}
12
+ spec.description = %q{ActiveRecord mapping of main Mediawiki entities and relationships}
13
+ spec.homepage = "https://github.com/abartov/dhole"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "activerecord"
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'active_record'
2
+ require "dhole/version"
3
+ require "dhole/page.rb"
4
+ require "dhole/revision.rb"
5
+ require "dhole/langlink.rb"
6
+ require "dhole/text.rb"
7
+ require "dhole/image.rb"
8
+ require "dhole/imagelink.rb"
9
+
10
+ module Dhole
11
+ class Dhole
12
+ def initialize(adapter, db, user, pass, host = 'localhost')
13
+ ActiveRecord::Base.establish_connection(
14
+ :adapter => adapter,
15
+ :database => db,
16
+ :username => user,
17
+ :password => pass,
18
+ :host => host)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module Dhole
2
+ class GlobalImageLink < ActiveRecord::Base
3
+ self.table_name = 'globalimagelinks'
4
+ belongs_to :linking_page, class_name: 'Page', foreign_key: 'gil_from'
5
+ #belongs_to :linked_image, class_name: 'Image', foreign_key: 'gil_to' # TODO: replace this with an actual lookup, as this doesn't resolve to an ID, of course
6
+ end
7
+ end
8
+
@@ -0,0 +1,17 @@
1
+ module Dhole
2
+ class Image < ActiveRecord::Base
3
+ self.table_name = 'image'
4
+ #has_many :localimagelinks, class_name: 'ImageLink'
5
+ #has_many :localusages, through: :image_links, class_name: 'Page'
6
+
7
+ belongs_to :uploader, :class_name => 'User', :foreign_key => 'img_user'
8
+
9
+ def local_usage
10
+ ImageLink.where(il_to: img_name).pluck(:il_from)
11
+ end
12
+ def global_usage
13
+ GlobalImageLink.where(gil_to: img_name).pluck(:gil_from)
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,8 @@
1
+ module Dhole
2
+ class ImageLink < ActiveRecord::Base
3
+ self.table_name = 'imagelinks'
4
+ belongs_to :linking_page, class_name: 'Page', foreign_key: 'il_from'
5
+ #belongs_to :linked_image, class_name: 'Image', foreign_key: 'il_to' # TODO: replace this with an actual lookup, as this doesn't resolve to an ID, of course
6
+ end
7
+ end
8
+
@@ -0,0 +1,5 @@
1
+ module Dhole
2
+ class LangLink < ActiveRecord::Base
3
+ self.table_name = 'langlinks'
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ module Dhole
2
+ class Page < ActiveRecord::Base
3
+ self.table_name = 'page'
4
+ has_many :categories
5
+ has_many :langlinks, class_name: 'LangLink', foreign_key: 'll_from'
6
+ has_many :imagelinks, class_name: 'ImageLink', foreign_key: 'il_from'
7
+ #has_many :images, through: :imagelinks, class_name: 'Image'
8
+ belongs_to :latest_revision, class_name: 'Revision', foreign_key: 'page_latest'
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module Dhole
2
+ class Revision < ActiveRecord::Base
3
+ self.table_name = 'revision'
4
+ belongs_to :text, :class_name => 'Text', :foreign_key => 'rev_text_id'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Dhole
2
+ class Text < ActiveRecord::Base
3
+ self.table_name = 'text'
4
+ has_one :revision, :class_name => 'Revision'
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Dhole
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dhole
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Asaf Bartov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-19 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activerecord
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ActiveRecord mapping of main Mediawiki entities and relationships
56
+ email:
57
+ - asaf.bartov@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - dhole.gemspec
68
+ - lib/dhole.rb
69
+ - lib/dhole/globalimagelink.rb
70
+ - lib/dhole/image.rb
71
+ - lib/dhole/imagelink.rb
72
+ - lib/dhole/langlink.rb
73
+ - lib/dhole/page.rb
74
+ - lib/dhole/revision.rb
75
+ - lib/dhole/text.rb
76
+ - lib/dhole/version.rb
77
+ homepage: https://github.com/abartov/dhole
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.5
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Mediawiki Object-Relational Mapping
101
+ test_files: []