iqvoc_similar_terms 0.8.0 → 2.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +67 -0
- data/.gitignore +11 -1
- data/Gemfile +14 -14
- data/Gemfile.lock +526 -146
- data/README.md +7 -12
- data/app/assets/javascripts/manifest.js +2 -0
- data/app/assets/stylesheets/manifest.scss +3 -0
- data/app/controllers/similar_terms_controller.rb +45 -12
- data/app/models/services/similar_terms_service.rb +141 -0
- data/app/views/similar_terms/_form.html.erb +21 -0
- data/app/views/similar_terms/new.html.erb +21 -0
- data/app/views/similar_terms/show.html.erb +32 -28
- data/app/views/similar_terms/show.xml.builder +17 -0
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/bin/setup +33 -0
- data/bin/update +31 -0
- data/bin/yarn +17 -0
- data/config/application.rb +30 -59
- data/config/boot.rb +3 -5
- data/config/cable.yml +10 -0
- data/config/database.yml.mysql +3 -3
- data/config/database.yml.postgresql +26 -0
- data/config/engine.rb +1 -1
- data/config/environment.rb +4 -4
- data/config/environments/development.rb +0 -1
- data/config/environments/test.rb +0 -1
- data/config/initializers/apipie.rb +5 -0
- data/config/initializers/content_security_policy.rb +25 -0
- data/config/initializers/filter_parameter_logging.rb +8 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/iqvoc.rb +6 -4
- data/config/initializers/new_framework_defaults_6_1.rb +67 -0
- data/config/initializers/permissions_policy.rb +11 -0
- data/config/locales/de.yml +12 -0
- data/config/locales/en.yml +12 -0
- data/config/routes.rb +4 -7
- data/config/secrets.yml +8 -0
- data/config/storage.yml +34 -0
- data/config.ru +4 -2
- data/db/migrate/.gitkeep +0 -0
- data/faucet.config.js +46 -0
- data/iqvoc_similar_terms.gemspec +1 -2
- data/lib/iqvoc/similar_terms/version.rb +1 -1
- data/lib/iqvoc/similar_terms.rb +12 -71
- data/lib/iqvoc_similar_terms.rb +14 -1
- data/package-lock.json +1486 -0
- data/package.json +29 -0
- data/test/compound_forms.nt +20 -0
- data/test/concept_test.nt +25 -0
- data/test/concept_test.ttl +33 -0
- data/test/controllers/similar_terms_controller_test.rb +167 -0
- data/test/models/entity_resolution_test.rb +42 -0
- data/test/models/results_test.rb +105 -0
- data/test/similar_terms.nt +14 -0
- data/test/similar_terms.ttl +19 -0
- data/test/test_helper.rb +4 -0
- metadata +58 -25
- data/.travis.yml +0 -18
- data/config/initializers/secret_token.rb.template +0 -16
- data/config/initializers/wrap_parameters.rb +0 -14
- data/script/ci/travis-before-build +0 -19
- data/script/ci/travis-build +0 -11
- data/test/functional/api_test.rb +0 -68
- data/test/unit/entity_resolution_test.rb +0 -46
- data/test/unit/results_test.rb +0 -55
data/README.md
CHANGED
@@ -1,21 +1,16 @@
|
|
1
|
-
Similar
|
1
|
+
# Similar terms for iQvoc
|
2
2
|
|
3
|
+
![CI](https://github.com/innoq/iqvoc_similar_terms/workflows/CI/badge.svg)
|
3
4
|
|
4
|
-
Getting Started
|
5
|
-
===============
|
5
|
+
## Getting Started
|
6
6
|
|
7
|
-
1. Initialize database:
|
8
|
-
|
9
|
-
$ bundle exec rake db:create
|
10
|
-
$ bundle exec rake db:migrate iqvoc:db:seed_all
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
$ rake iqvoc:setup:generate_secret_token
|
8
|
+
1. Initialize database:
|
15
9
|
|
10
|
+
$ bundle exec rake db:create
|
11
|
+
$ bundle exec rake db:migrate iqvoc:db:seed_all
|
16
12
|
|
17
|
-
Extensions
|
18
|
-
==========
|
13
|
+
## Extensions
|
19
14
|
|
20
15
|
In addition to regular SKOS, Similar Terms supports
|
21
16
|
[SKOS-XL](https://github.com/innoq/iqvoc_skosxl) and
|
@@ -1,28 +1,61 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'iqvoc/similar_terms' # XXX: should not be necessary!?
|
4
|
-
|
5
3
|
class SimilarTermsController < ApplicationController
|
4
|
+
resource_description do
|
5
|
+
name 'Similar concepts'
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
api :GET, ':lang/similar', <<-DOC
|
9
|
+
Returns labels which are semantically (not orthographically) similar,
|
10
|
+
as determined by concept relations.
|
11
|
+
DOC
|
12
|
+
formats [:html, :ttl, :rdf, :xml, :json]
|
13
|
+
param :terms, String, :required => true, :desc => <<-DOC
|
14
|
+
One or more terms (comma-separated, CSV-style) to be processed.
|
15
|
+
DOC
|
16
|
+
example <<-DOC
|
17
|
+
GET /de/similar.ttl?terms=wald,baum
|
9
18
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
19
|
+
# omitted namespace definitions
|
20
|
+
query:top skos:altLabel "Dünenwald"@de;
|
21
|
+
skos:altLabel "Baumart"@de.
|
22
|
+
DOC
|
23
|
+
|
24
|
+
def create
|
25
|
+
authorize! :read, Iqvoc::Concept.base_class
|
14
26
|
|
15
|
-
@terms =
|
27
|
+
@terms = InlineDataHelper.parse_inline_values(similar_terms_params)
|
16
28
|
lang = params[:lang]
|
29
|
+
options = {
|
30
|
+
synonyms_only: ['1', 'true'].include?(params[:synonyms_only])
|
31
|
+
}
|
17
32
|
|
18
33
|
respond_to do |format|
|
19
34
|
format.html do
|
20
|
-
@results =
|
35
|
+
@results = Services::SimilarTermsService.ranked(lang, options, *@terms)
|
36
|
+
render :show
|
21
37
|
end
|
22
|
-
format.any(:rdf, :ttl) do
|
23
|
-
@results =
|
38
|
+
format.any(:rdf, :ttl, :nt, :xml) do
|
39
|
+
@results = Services::SimilarTermsService.alphabetical(lang, options, *@terms)
|
40
|
+
render :show
|
24
41
|
end
|
42
|
+
format.json {
|
43
|
+
results = Services::SimilarTermsService.alphabetical(lang, options, *@terms)
|
44
|
+
render json: {
|
45
|
+
"url": request.original_url,
|
46
|
+
"total_results": results.length,
|
47
|
+
"results": results.map {|c| c.value }
|
48
|
+
}.to_json
|
49
|
+
}
|
25
50
|
end
|
26
51
|
end
|
27
52
|
|
53
|
+
def new
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def similar_terms_params
|
59
|
+
params.require(:terms)
|
60
|
+
end
|
28
61
|
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module Services
|
2
|
+
module SimilarTermsService # TODO: make language constraints optional
|
3
|
+
|
4
|
+
@@weightings = Iqvoc::SimilarTerms.weightings
|
5
|
+
|
6
|
+
# returns an array of label/concepts pairs, sorted descendingly by weighting -- XXX: unused/deprecated
|
7
|
+
# TODO: rename
|
8
|
+
def self.ranked(lang, options, *terms)
|
9
|
+
weighted(lang, options, *terms).sort_by { |label, _data| label }
|
10
|
+
.sort_by { |_label, data| data[0] }
|
11
|
+
.reverse
|
12
|
+
.map { |label, data| [label] + data[1..-1] } # drop weighting
|
13
|
+
end
|
14
|
+
|
15
|
+
# returns a list of labels, sorted alphabetically
|
16
|
+
def self.alphabetical(lang, options, *terms)
|
17
|
+
concepts = base_query(lang, *terms)
|
18
|
+
|
19
|
+
results = concepts.map { |c| c.labelings.map { |ln| ln.target } }
|
20
|
+
|
21
|
+
unless options[:synonyms_only]
|
22
|
+
results << find_related_and_narrower_concepts(concepts, lang, *terms).map { |c| c.pref_labels }
|
23
|
+
end
|
24
|
+
|
25
|
+
results.flatten.sort_by { |l| l.value }
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.base_query(lang, *terms)
|
29
|
+
# FIXME: move to initializer to run on start/boot. Could be a problem with intializer load
|
30
|
+
# order of host app because further_labeling classes are initialised after this check
|
31
|
+
Iqvoc::Concept.labeling_class_names.each do |klass_name, langs|
|
32
|
+
unless @@weightings.keys.include? klass_name
|
33
|
+
raise "#{klass_name} has no registered weighting. Please configure one using Iqvoc::SimilarTerms.register_weighting('MyLabelingClass', 1.0)"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# use only labelings with weighting > 0
|
38
|
+
used_weightings = @@weightings.select { |klass_name, weight| weight > 0 }.keys
|
39
|
+
terms_to_concepts(lang, *terms)
|
40
|
+
.includes(:labelings => [:owner, :target])
|
41
|
+
.where('labels.language' => lang)
|
42
|
+
.where('labelings.type IN (?)', used_weightings)
|
43
|
+
end
|
44
|
+
|
45
|
+
# returns a hash of label/weighting+concepts pairs -- XXX: unused/deprecated
|
46
|
+
def self.weighted(lang, options, *terms) # TODO: rename
|
47
|
+
concepts = base_query(lang, *terms)
|
48
|
+
|
49
|
+
return terms.inject({}) do |memo, term|
|
50
|
+
concepts.each do |concept|
|
51
|
+
concept.labelings.each do |ln|
|
52
|
+
concept = ln.owner
|
53
|
+
label = ln.target
|
54
|
+
weight = @@weightings[ln.class.name]
|
55
|
+
|
56
|
+
memo[label] ||= []
|
57
|
+
# weighting
|
58
|
+
memo[label][0] ||= 0
|
59
|
+
memo[label][0] += weight
|
60
|
+
# associated concepts
|
61
|
+
memo[label] << concept unless memo[label].include? concept
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
unless options[:synonyms_only]
|
66
|
+
find_related_and_narrower_concepts(concepts, lang, *terms).each do |c|
|
67
|
+
memo[c.pref_label] ||= []
|
68
|
+
# weighting
|
69
|
+
memo[c.pref_label][0] ||= 0
|
70
|
+
memo[c.pref_label][0] += 1
|
71
|
+
# associated concepts
|
72
|
+
memo[c.pref_label] << c unless memo[c.pref_label].include? c
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
memo
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.terms_to_concepts(lang, *terms)
|
81
|
+
concept_ids = terms_to_labels(lang, *terms)
|
82
|
+
.includes(:labelings)
|
83
|
+
.map { |label| label.labelings.map(&:owner_id) }.flatten.uniq
|
84
|
+
|
85
|
+
return Iqvoc::Concept.base_class.published.where(id: concept_ids)
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.find_related_and_narrower_concepts(concepts, lang, *terms)
|
89
|
+
results = []
|
90
|
+
concepts.each do |c|
|
91
|
+
results << c.narrower_relations.published.map(&:target_id)
|
92
|
+
results << c.concept_relation_skos_relateds.published.map(&:target_id)
|
93
|
+
end
|
94
|
+
|
95
|
+
# evaluate only if iqvoc_compound_forms engine is loaded
|
96
|
+
if Iqvoc.const_defined?(:CompoundForms) && results.empty?
|
97
|
+
terms.each do |term|
|
98
|
+
label = if Iqvoc.const_defined?(:Inflectionals)
|
99
|
+
hash = Inflectional::Base.normalize(term)
|
100
|
+
label_id = Inflectional::Base.select([:label_id])
|
101
|
+
.where(:normal_hash => hash)
|
102
|
+
.map(&:label_id)
|
103
|
+
.first
|
104
|
+
|
105
|
+
Iqvoc::XLLabel.base_class.where(:language => lang, :id => label_id).first
|
106
|
+
else
|
107
|
+
Iqvoc::XLLabel.base_class.where('LOWER(value) = ?', term.downcase).first
|
108
|
+
end
|
109
|
+
|
110
|
+
results << label.compound_in.map { |ci| ci.concepts.map { |c| c.id } } if label.present?
|
111
|
+
end
|
112
|
+
end
|
113
|
+
Iqvoc::Concept.base_class.where(id: results.flatten.uniq)
|
114
|
+
end
|
115
|
+
|
116
|
+
# NB: case-insensitive only when inflectionals are available
|
117
|
+
def self.terms_to_labels(lang, *terms)
|
118
|
+
# efficiency enhancement to turn `IN` into `=` queries where possible
|
119
|
+
reduce = lambda { |arr| arr.length < 2 ? arr[0] : arr }
|
120
|
+
|
121
|
+
if Iqvoc.const_defined?(:Inflectionals)
|
122
|
+
# use normalized form for case-insensitivity (and performance)
|
123
|
+
hashes = terms.map { |term| Inflectional::Base.normalize(term) }
|
124
|
+
label_ids = Inflectional::Base.select([:label_id])
|
125
|
+
.where(normal_hash: reduce.call(hashes))
|
126
|
+
.map(&:label_id)
|
127
|
+
|
128
|
+
return Iqvoc::XLLabel.base_class.where(language: lang, id: reduce.call(label_ids))
|
129
|
+
elsif Iqvoc.const_defined?(:XLLabel)
|
130
|
+
return Iqvoc::XLLabel.base_class
|
131
|
+
.where(language: lang)
|
132
|
+
.where('LOWER(value) IN (?)', terms.map(&:downcase))
|
133
|
+
else
|
134
|
+
return Iqvoc::Label.base_class
|
135
|
+
.where(language: lang)
|
136
|
+
.where('LOWER(value) IN (?)', terms.map(&:downcase))
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= bootstrap_form_tag(url: similar_url, method: :get) do |f| %>
|
2
|
+
<div class="p-3 row no-gutters align-items-center bg-white">
|
3
|
+
<div class="col-auto">
|
4
|
+
<i class="fa fa-search fa-lg"></i>
|
5
|
+
</div>
|
6
|
+
<div class="col">
|
7
|
+
<%= f.text_field :terms, hide_label: true, autofocus: (@terms ? false : true), wrapper_class: 'mb-0',
|
8
|
+
class: 'form-control-lg form-control-borderless border-0', autocomplete: 'off',
|
9
|
+
value: (@terms ? InlineDataHelper.generate_inline_values(@terms) : params[:terms])
|
10
|
+
%>
|
11
|
+
</div>
|
12
|
+
<div class="col-auto">
|
13
|
+
<%= f.submit t('txt.views.search_results.submit'), class: 'btn btn-block btn-lg btn-primary p-2' %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="py-3 row">
|
17
|
+
<div class="col-auto">
|
18
|
+
<%= f.check_box :synonyms_only, label: t('txt.views.similar_terms.synonyms_only'), checked: ['1', 'true'].include?(params[:synonyms_only]) %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="text-center my-5">
|
2
|
+
<h1 class="mb-5">
|
3
|
+
<%= t("txt.views.similar_terms.title") %>
|
4
|
+
</h1>
|
5
|
+
|
6
|
+
<div class="row justify-content-center">
|
7
|
+
<div class="col-12 col-md-10 col-lg-8">
|
8
|
+
<%= render 'form' %>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="my-5">
|
14
|
+
<h2 class="text-center my-4">
|
15
|
+
<%= t("txt.views.similar_terms.about.title") %>
|
16
|
+
</h2>
|
17
|
+
|
18
|
+
<div class="row col-md-8 offset-md-2">
|
19
|
+
<%= simple_format t("txt.views.similar_terms.about.description") %>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -1,32 +1,36 @@
|
|
1
|
-
|
1
|
+
<% if @results.any? %>
|
2
|
+
<h2 class="text-center my-5">
|
3
|
+
<%= raw t('txt.views.similar_terms.results', terms: @terms.join(', '), count: @results.size) %>
|
4
|
+
</h2>
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<%= form_tag(similar_path, :method => :get, :class => 'form-horizontal') do %>
|
13
|
-
<%= text_field_tag :terms, (@terms ?
|
14
|
-
Iqvoc::InlineDataHelper.generate_inline_values(@terms) :
|
15
|
-
params[:terms]) %>
|
16
|
-
<%= submit_tag t('txt.views.search_results.submit'), :class => 'btn btn-primary' %>
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<ol>
|
20
|
-
<% (@results || []).each do |data|
|
21
|
-
label = data[0]
|
22
|
-
concepts = data[1..-1]
|
23
|
-
%>
|
24
|
-
<li>
|
25
|
-
<%= label.value %>
|
26
|
-
(<%= concepts.map do |concept|
|
6
|
+
<ol>
|
7
|
+
<% (@results || []).each do |data|
|
8
|
+
label = data[0]
|
9
|
+
concepts = data[1..-1]
|
10
|
+
%>
|
11
|
+
<li>
|
12
|
+
<%= label.value %>
|
13
|
+
(<%= concepts.map do |concept|
|
27
14
|
origin = concept.origin
|
28
15
|
link_to origin, rdf_url(origin, :format => nil, :lang => nil)
|
29
16
|
end.join(", ").html_safe %>)
|
30
|
-
|
31
|
-
|
32
|
-
</ol>
|
17
|
+
</li>
|
18
|
+
<% end %>
|
19
|
+
</ol>
|
20
|
+
<% else %>
|
21
|
+
<h2 class="text-center my-5">
|
22
|
+
<%= t('txt.views.similar_terms.no_results') %>
|
23
|
+
</h2>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<div class="text-center my-5">
|
27
|
+
<h1 class="mb-5">
|
28
|
+
<%= t("txt.views.similar_terms.title") %>
|
29
|
+
</h1>
|
30
|
+
|
31
|
+
<div class="row justify-content-center">
|
32
|
+
<div class="col-12 col-md-10 col-lg-8">
|
33
|
+
<%= render 'form' %>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
2
|
+
xml.instruct!
|
3
|
+
|
4
|
+
xml.OneBoxResults "xmlns:xlink" => "http://www.w3.org/1999/xlink" do
|
5
|
+
xml.resultCode "success"
|
6
|
+
xml.totalResults @results.length
|
7
|
+
xml.urlText t("txt.views.similar_terms.title")
|
8
|
+
xml.urlLink url_for(request.query_parameters.
|
9
|
+
merge(:only_path => false, :anchor => ""))
|
10
|
+
xml.MODULE_RESULT do
|
11
|
+
xml.title t("txt.views.similar_terms.results_heading",
|
12
|
+
:terms => params[:terms])
|
13
|
+
@results.each do |label|
|
14
|
+
xml.Field label.value, "name" => label.value
|
15
|
+
end
|
16
|
+
end if @results.length > 0
|
17
|
+
end
|
data/bin/bundle
ADDED
data/bin/rails
ADDED
data/bin/rake
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.chdir APP_ROOT do
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts "== Installing dependencies =="
|
17
|
+
system! "gem install bundler --conservative"
|
18
|
+
system("bundle check") || system!("bundle install")
|
19
|
+
|
20
|
+
# puts "\n== Copying sample files =="
|
21
|
+
# unless File.exist?("config/database.yml")
|
22
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
23
|
+
# end
|
24
|
+
|
25
|
+
puts "\n== Preparing database =="
|
26
|
+
system! "bin/rails db:prepare"
|
27
|
+
|
28
|
+
puts "\n== Removing old logs and tempfiles =="
|
29
|
+
system! "bin/rails log:clear tmp:clear"
|
30
|
+
|
31
|
+
puts "\n== Restarting application server =="
|
32
|
+
system! "bin/rails restart"
|
33
|
+
end
|
data/bin/update
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a way to update your development environment automatically.
|
14
|
+
# Add necessary update steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
puts "\n== Updating database =="
|
24
|
+
system! 'bin/rails db:migrate'
|
25
|
+
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
27
|
+
system! 'bin/rails log:clear tmp:clear'
|
28
|
+
|
29
|
+
puts "\n== Restarting application server =="
|
30
|
+
system! 'bin/rails restart'
|
31
|
+
end
|
data/bin/yarn
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(APP_ROOT) do
|
4
|
+
yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
|
5
|
+
select { |dir| File.expand_path(dir) != __dir__ }.
|
6
|
+
product(["yarn", "yarn.cmd", "yarn.ps1"]).
|
7
|
+
map { |dir, file| File.expand_path(file, dir) }.
|
8
|
+
find { |file| File.executable?(file) }
|
9
|
+
|
10
|
+
if yarn
|
11
|
+
exec yarn, *ARGV
|
12
|
+
else
|
13
|
+
$stderr.puts "Yarn executable was not detected in the system."
|
14
|
+
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
end
|
data/config/application.rb
CHANGED
@@ -1,67 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
require_relative "boot"
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_model/railtie"
|
5
|
+
require "active_job/railtie"
|
6
|
+
require "active_record/railtie"
|
7
|
+
require "active_storage/engine"
|
8
|
+
require "action_controller/railtie"
|
9
|
+
require "action_mailer/railtie"
|
10
|
+
require "action_mailbox/engine"
|
11
|
+
require "action_text/engine"
|
12
|
+
require "action_view/railtie"
|
13
|
+
require "action_cable/engine"
|
14
|
+
# require "sprockets/railtie"
|
15
|
+
require "rails/test_unit/railtie"
|
16
|
+
|
17
|
+
# Require the gems listed in Gemfile, including any gems
|
18
|
+
# you've limited to :test, :development, or :production.
|
19
|
+
Bundler.require(*Rails.groups)
|
11
20
|
|
12
21
|
module Iqvoc::SimilarTerms
|
13
22
|
class Application < Rails::Application
|
23
|
+
# Initialize configuration defaults for originally generated Rails version.
|
24
|
+
config.load_defaults 7.0
|
25
|
+
|
26
|
+
# Configuration for the application, engines, and railties goes here.
|
27
|
+
#
|
28
|
+
# These settings can be overridden in specific environments using the files
|
29
|
+
# in config/environments, which are processed later.
|
30
|
+
#
|
31
|
+
# config.time_zone = "Central Time (US & Canada)"
|
32
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
33
|
+
#
|
14
34
|
|
15
35
|
# This tells iqvoc_similar_terms.rb whether it it runs as app or as engine
|
16
36
|
require 'iqvoc_similar_terms'
|
17
|
-
|
18
|
-
# Settings in config/environments/* take precedence over those specified here.
|
19
|
-
# Application configuration should go into files in config/initializers
|
20
|
-
# -- all .rb files in that directory are automatically loaded.
|
21
|
-
|
22
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
23
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
24
|
-
|
25
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
26
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
27
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
28
|
-
|
29
|
-
# Activate observers that should always be running.
|
30
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
31
|
-
|
32
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
33
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
34
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
35
|
-
|
36
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
37
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
38
|
-
config.i18n.default_locale = :de
|
39
|
-
# config.i18n.available_locales = [:de, :en]
|
40
|
-
|
41
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
42
|
-
config.encoding = "utf-8"
|
43
|
-
|
44
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
45
|
-
config.filter_parameters += [:password, :password_confirmation]
|
46
|
-
|
47
|
-
# Enable escaping HTML in JSON.
|
48
|
-
config.active_support.escape_html_entities_in_json = true
|
49
|
-
|
50
|
-
# Use SQL instead of Active Record's schema dumper when creating the database.
|
51
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
52
|
-
# like if you have constraints or database-specific column types
|
53
|
-
# config.active_record.schema_format = :sql
|
54
|
-
|
55
|
-
# Enforce whitelist mode for mass assignment.
|
56
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
57
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
58
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
59
|
-
config.active_record.whitelist_attributes = true
|
60
|
-
|
61
|
-
# Enable the asset pipeline
|
62
|
-
config.assets.enabled = true
|
63
|
-
|
64
|
-
# Version of your assets, change this if you want to expire all your assets
|
65
|
-
config.assets.version = "1.0.0"
|
66
37
|
end
|
67
38
|
end
|
data/config/boot.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
1
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
2
2
|
|
3
|
-
# Set up gems listed in the Gemfile.
|
4
|
-
|
5
|
-
|
6
|
-
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
3
|
+
require "bundler/setup" # Set up gems listed in the Gemfile.
|
4
|
+
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
|
data/config/cable.yml
ADDED
data/config/database.yml.mysql
CHANGED
@@ -6,7 +6,7 @@ development:
|
|
6
6
|
pool: 5
|
7
7
|
username: root
|
8
8
|
password:
|
9
|
-
|
9
|
+
host: 127.0.0.1
|
10
10
|
|
11
11
|
test:
|
12
12
|
adapter: mysql2
|
@@ -16,7 +16,7 @@ test:
|
|
16
16
|
pool: 5
|
17
17
|
username: root
|
18
18
|
password:
|
19
|
-
|
19
|
+
host: 127.0.0.1
|
20
20
|
|
21
21
|
production:
|
22
22
|
adapter: mysql2
|
@@ -26,4 +26,4 @@ production:
|
|
26
26
|
pool: 5
|
27
27
|
username: root
|
28
28
|
password:
|
29
|
-
|
29
|
+
host: 127.0.0.1
|
@@ -0,0 +1,26 @@
|
|
1
|
+
development:
|
2
|
+
adapter: postgresql
|
3
|
+
host: localhost
|
4
|
+
encoding: unicode
|
5
|
+
database: <%= ENV["POSTGRES_DB"] || 'iqvoc_similar_terms_development' %>
|
6
|
+
pool: 5
|
7
|
+
username: <%= ENV["POSTGRES_USER"] || 'postgres' %>
|
8
|
+
password: <%= ENV["POSTGRES_PASSWORD"] || 'postgres' %>
|
9
|
+
|
10
|
+
test:
|
11
|
+
adapter: postgresql
|
12
|
+
host: localhost
|
13
|
+
encoding: unicode
|
14
|
+
database: <%= ENV["POSTGRES_DB"] || 'iqvoc_similar_terms_test' %>
|
15
|
+
pool: 5
|
16
|
+
username: <%= ENV["POSTGRES_USER"] || 'postgres' %>
|
17
|
+
password: <%= ENV["POSTGRES_PASSWORD"] || 'postgres' %>
|
18
|
+
|
19
|
+
production:
|
20
|
+
adapter: postgresql
|
21
|
+
host: localhost
|
22
|
+
encoding: unicode
|
23
|
+
database: <%= ENV["POSTGRES_DB"] || 'iqvoc_similar_terms_production' %>
|
24
|
+
pool: 5
|
25
|
+
username: <%= ENV["POSTGRES_USER"] || 'postgres' %>
|
26
|
+
password: <%= ENV["POSTGRES_PASSWORD"] || 'postgres' %>
|
data/config/engine.rb
CHANGED
@@ -7,7 +7,7 @@ module Iqvoc
|
|
7
7
|
paths["lib/tasks"] << "lib/engine_tasks"
|
8
8
|
|
9
9
|
initializer "iqvoc_similar_terms.load_migrations" do |app|
|
10
|
-
app.config.paths['db/migrate']
|
10
|
+
app.config.paths['db/migrate'].concat(Iqvoc::SimilarTerms::Engine.paths['db/migrate'].existent)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|