owldiff 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e21f9760c851d72036386d9c562a27f103754c55
4
+ data.tar.gz: 404e877468c4eb4199286528cae09e784fc4efa0
5
+ SHA512:
6
+ metadata.gz: c4f2b17a05e0e25fd320e6e6c5af053fcd91c912d94e7d08906b5aaf73c6ede571b2d8683522bb6e4caaedbe5e630510ea9d48b02bd8856269430d378c70047f
7
+ data.tar.gz: 53b75d3cf394cfde2f10bd97388646eaa60cf173fc52b92eb75b606a83353abd776d4c1b0d6dcc577ac88cca0c372ec45e3a7876d4684a9236db08ee4fb0e811
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
4
+ - jruby-19mode
5
+ env:
6
+ - JRUBY_OPTS="--debug"
7
+ addons:
8
+ code_climate:
9
+ repo_token: 30de3f179eef8193ff657053390917ac302ec9dae3a8a95a9ce6b430ead32cfb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in owldiff.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Owldiff
2
+
3
+ [![Build Status](https://travis-ci.org/andreasknoepfle/owldiff.svg)](https://travis-ci.org/andreasknoepfle/owldiff) [![Code Climate](https://codeclimate.com/github/andreasknoepfle/owldiff/badges/gpa.svg)](https://codeclimate.com/github/andreasknoepfle/owldiff) [![Test Coverage](https://codeclimate.com/github/andreasknoepfle/owldiff/badges/coverage.svg)](https://codeclimate.com/github/andreasknoepfle/owldiff)
4
+
5
+ This is the client library for the http://github.com/andreasknoepfle/owldiff-service server.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'owldiff'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install owldiff
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ client = Owldiff::Client.setup "localhost", 4567
27
+ client.query "http://test.de/a.owl", "http://test.de/b.owl"
28
+ ```
29
+ or
30
+ ```ruby
31
+ Owldiff::Client.setup "localhost", 4567
32
+ Owldiff::Client.diff "http://test.de/a.owl", "http://test.de/b.owl"
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Tests
42
+
43
+ $ rake test
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/[my-github-username]/owldiff/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'test'
8
+ t.pattern = "test/test_*.rb"
9
+ end
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "owldiff"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ module Owldiff
2
+ class OntologyChange
3
+ attr_accessor :value, :type, :action, :data
4
+ ACTIONS = [:added,:removed,:renamed,:modified]
5
+
6
+ def initialize value, type, action, data
7
+ @value, @type, @action, @data = value, type, action, data
8
+ end
9
+
10
+ def to_json(*opts)
11
+ {
12
+ 'value' => value,
13
+ 'type' => type.to_s,
14
+ 'action' => action.to_s,
15
+ 'data' => data
16
+ }.to_json(*opts)
17
+ end
18
+
19
+ def self.from_hash hash
20
+ OntologyChange.new(hash["value"],hash["type"],hash["action"],hash["data"])
21
+ end
22
+
23
+
24
+ end
25
+ end
@@ -0,0 +1,60 @@
1
+ module Owldiff
2
+ class OntologyDiff
3
+ SINGLE_CHANGE_TYPES = [:format,:ontology_id].map{ |type| "#{type}_change".to_sym }
4
+ SET_CHANGE_TYPES = [:prefix,:import,:annotation,:axiom].map{ |type| "#{type}_changes".to_sym }
5
+ ENTITIES = [:new,:modified,:removed].map{ |type| "#{type}_entities".to_sym }
6
+
7
+ ALL_TYPES = SINGLE_CHANGE_TYPES + SET_CHANGE_TYPES + ENTITIES
8
+
9
+ FROM_JSON = {
10
+ SINGLE_CHANGE_TYPES => lambda { |change| OntologyChange.from_hash(change) },
11
+ SET_CHANGE_TYPES => lambda { |changes| OntologyDiff.from_array(OntologyChange, changes)},
12
+ ENTITIES => lambda { |entities| OntologyDiff.from_array(OntologyEntity, entities) }
13
+ }
14
+
15
+ ALL_TYPES.each do |type|
16
+ attr_accessor type
17
+ end
18
+
19
+ def initialize binary_identical
20
+ @binary_identical = binary_identical
21
+ end
22
+
23
+ def binary_identical?
24
+ @binary_identical
25
+ end
26
+
27
+ def to_json(*opts)
28
+ diff = { binary_identical: @binary_identical }
29
+ ALL_TYPES.each do |type|
30
+ diff[type] = self.send(type)
31
+ end
32
+ diff.to_json(*opts)
33
+ end
34
+
35
+ def self.from_json json
36
+ ontology_changes = JSON.parse(json)
37
+ diff = OntologyDiff.new ontology_changes["binary_identical"]
38
+ FROM_JSON.each do |types, block|
39
+ diff.type_from_hash types, ontology_changes, block
40
+ end
41
+ diff
42
+ end
43
+
44
+ def type_from_hash types, hash, block
45
+ types.each do |type|
46
+ value = hash[type.to_s]
47
+ self.send "#{type}=", block.call(value) if value
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def self.from_array klass, values
54
+ values.map do |value|
55
+ klass.from_hash(value)
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,20 @@
1
+ module Owldiff
2
+ class OntologyEntity
3
+ attr_accessor :short, :full
4
+ def initialize short, full
5
+ @short, @full = short, full
6
+ end
7
+
8
+ def to_json(*opts)
9
+ {
10
+ short: @short,
11
+ full: @full
12
+ }.to_json(*opts)
13
+ end
14
+
15
+ def self.from_hash hash
16
+ OntologyEntity.new(hash["short"],hash["full"])
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Owldiff
2
+ VERSION = "0.1.1"
3
+ end
data/lib/owldiff.rb ADDED
@@ -0,0 +1,47 @@
1
+ require 'json'
2
+ require "owldiff/version"
3
+ require "owldiff/ontology_change"
4
+ require "owldiff/ontology_diff"
5
+ require "owldiff/ontology_entity"
6
+ require "uri"
7
+ require 'net/http'
8
+ require 'singleton'
9
+
10
+ module Owldiff
11
+
12
+ class Client
13
+ include Singleton
14
+
15
+ def self.setup *args
16
+ instance.set_uri(*args)
17
+ instance
18
+ end
19
+
20
+ def self.diff *args
21
+ instance.query *args
22
+ end
23
+
24
+ def set_uri host, port
25
+ @uri = URI::HTTP.build host: host, port: port , path: "/diff.json"
26
+ end
27
+
28
+ def query *args
29
+ raise_error unless @uri
30
+ @uri.query = params *args # build query
31
+ OntologyDiff.from_json Net::HTTP.get(@uri)
32
+ end
33
+
34
+ private
35
+
36
+ def params url1, url2
37
+ params = {owl1_url: url1, owl2_url: url2}
38
+ URI.encode_www_form params
39
+ end
40
+
41
+ def raise_error
42
+ raise Exception.new "Either did not set the host or the port for the diff service!"
43
+ end
44
+
45
+ end
46
+
47
+ end
data/owldiff.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'owldiff/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "owldiff"
8
+ spec.version = Owldiff::VERSION
9
+ spec.authors = ["Andreas Knöpfle"]
10
+ spec.email = ["andreas.knoepfle@gmail.com"]
11
+ spec.licenses = ['LGPL-3.0']
12
+ spec.summary = %q{A client library for the owldiff-service.}
13
+ spec.description = %q{This is the client library for the owldiff-service server. This library takes the HOST, PORT and two URLs of ontology files and returns a diff between those ontologies.}
14
+ spec.homepage = "https://github.com/andreasknoeplfe/owldiff"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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 "mocha", "~> 1.1"
24
+ spec.add_development_dependency "minitest", "~> 4.7"
25
+ spec.add_development_dependency "simplecov", "~> 0.9"
26
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
27
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: owldiff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Andreas Knöpfle
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-24 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: mocha
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.4'
97
+ description: This is the client library for the owldiff-service server. This library
98
+ takes the HOST, PORT and two URLs of ontology files and returns a diff between those
99
+ ontologies.
100
+ email:
101
+ - andreas.knoepfle@gmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/owldiff.rb
115
+ - lib/owldiff/ontology_change.rb
116
+ - lib/owldiff/ontology_diff.rb
117
+ - lib/owldiff/ontology_entity.rb
118
+ - lib/owldiff/version.rb
119
+ - owldiff.gemspec
120
+ homepage: https://github.com/andreasknoeplfe/owldiff
121
+ licenses:
122
+ - LGPL-3.0
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.2.3
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: A client library for the owldiff-service.
144
+ test_files: []