iqvoc 3.5.5 → 3.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -136,7 +136,7 @@ module Iqvoc
136
136
  end
137
137
  e.squish!
138
138
  e.gsub!(/^:(.*)$/) do
139
- ":#{OriginMapping.merge($1)}" # Force correct origins in the default namespace
139
+ ":#{Iqvoc::Origin.new($1)}" # Force correct origins in the default namespace
140
140
  end
141
141
  end
142
142
 
data/lib/iqvoc/version.rb CHANGED
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module Iqvoc
18
- VERSION = "3.5.5"
18
+ VERSION = "3.5.6"
19
19
  end
@@ -20,53 +20,67 @@ module Iqvoc
20
20
  extend ActiveSupport::Concern
21
21
 
22
22
  included do
23
-
24
23
  # ********* Relations
25
24
 
26
25
  belongs_to :published_version, :foreign_key => 'published_version_id', :class_name => name
27
26
 
28
27
  belongs_to :locking_user, :foreign_key => 'locked_by', :class_name => 'User'
28
+ end
29
29
 
30
+ module ClassMethods
30
31
  # ********* Scopes
31
32
 
32
- scope :by_origin, lambda { |origin|
33
- where(:origin => origin)
34
- }
35
-
36
- scope :published, lambda {
37
- where(arel_table[:published_at].not_eq(nil))
38
- }
39
- scope :unpublished, lambda {
40
- where(:published_at => nil)
41
- }
42
- # The following scope returns all objects which should be selectable by the editor
43
- scope :editor_selectable, lambda {
44
- where(
45
- arel_table[:published_at].not_eq(nil).or( # == published (is there a way to OR combine two scopes? `published OR where(...)`)
46
- arel_table[:published_at].eq(nil).and(arel_table[:published_version_id].eq(nil)) # this are all unpublished with no published version
47
- )
48
- )
49
- }
50
-
51
- scope :in_edit_mode, lambda {
52
- where(arel_table[:locked_by].not_eq(nil))
53
- }
54
-
55
- scope :unpublished_or_follow_up, lambda {
56
- where(
57
- arel_table[:published_at].eq(nil).or(
58
- arel_table[:follow_up].not_eq(nil)
59
- )
60
- )
61
- }
62
-
63
- scope :unsynced, lambda {
64
- where(:rdf_updated_at => nil)
65
- }
66
-
33
+ def by_origin(origin)
34
+ where(:origin => origin)
35
+ end
36
+
37
+ def published
38
+ where(arel_table[:published_at].not_eq(nil))
39
+ end
40
+
41
+ def unpublished
42
+ where(:published_at => nil)
43
+ end
44
+
45
+ # The following method returns all objects which should be selectable by the editor
46
+ def editor_selectable
47
+ where(
48
+ arel_table[:published_at].not_eq(nil).or( # == published (is there a way to OR combine two scopes? `published OR where(...)`)
49
+ arel_table[:published_at].eq(nil).and(arel_table[:published_version_id].eq(nil)) # this are all unpublished with no published version
50
+ )
51
+ )
52
+ end
53
+
54
+ def in_edit_mode
55
+ where(arel_table[:locked_by].not_eq(nil))
56
+ end
57
+
58
+ def unpublished_or_follow_up
59
+ where(
60
+ arel_table[:published_at].eq(nil).or(
61
+ arel_table[:follow_up].not_eq(nil)
62
+ )
63
+ )
64
+ end
65
+
66
+ def unsynced
67
+ where(:rdf_updated_at => nil)
68
+ end
69
+
70
+ def include_to_deep_cloning(*association_names)
71
+ (@@include_to_deep_cloning ||= {})[self] ||= []
72
+ association_names.each do |association_name|
73
+ @@include_to_deep_cloning[self] << association_name
74
+ end
75
+ end
76
+
77
+ def includes_to_deep_cloning
78
+ (@@include_to_deep_cloning ||= {})[self] ||= []
79
+ (@@include_to_deep_cloning.keys & self.ancestors).map{|c| @@include_to_deep_cloning[c]}.flatten.compact
80
+ end
67
81
  end
68
82
 
69
- # ********* Methods
83
+ # ********* Instance methods
70
84
 
71
85
  def branch(user)
72
86
  new_version = self.dup(:include => self.class.includes_to_deep_cloning)
@@ -133,21 +147,5 @@ module Iqvoc
133
147
  write_attribute(:to_review, true)
134
148
  end
135
149
 
136
- module ClassMethods
137
-
138
- def include_to_deep_cloning(*association_names)
139
- (@@include_to_deep_cloning ||= {})[self] ||= []
140
- association_names.each do |association_name|
141
- @@include_to_deep_cloning[self] << association_name
142
- end
143
- end
144
-
145
- def includes_to_deep_cloning
146
- (@@include_to_deep_cloning ||= {})[self] ||= []
147
- (@@include_to_deep_cloning.keys & self.ancestors).map{|c| @@include_to_deep_cloning[c]}.flatten.compact
148
- end
149
-
150
- end
151
-
152
150
  end
153
151
  end
@@ -24,14 +24,14 @@ class ConceptSchemeTest < ActionDispatch::IntegrationTest
24
24
 
25
25
  test "list top concepts in rdf scheme" do
26
26
  visit "/scheme.ttl"
27
-
27
+
28
28
  assert page.has_content? ":scheme a skos:ConceptScheme"
29
29
  assert page.has_content? "skos:hasTopConcept :#{@concept.origin}"
30
30
  end
31
-
31
+
32
32
  test "top terms rdf" do
33
33
  visit "/#{@concept.origin}.ttl"
34
-
34
+
35
35
  assert page.has_content? "skos:topConceptOf :scheme"
36
36
  end
37
37
 
@@ -23,9 +23,9 @@ class TreeTest < ActionDispatch::IntegrationTest
23
23
  narrower_concept = concept.narrower_relations.first.target
24
24
 
25
25
  visit hierarchical_concepts_path(:lang => :de, :format => :html)
26
- assert page.has_link?(concept.pref_label.to_s),
26
+ assert page.has_link?(concept.pref_label.to_s),
27
27
  "Concept #{concept.pref_label} isn't visible in the hierarchical concepts list"
28
- assert !page.has_content?(narrower_concept.pref_label.to_s),
28
+ assert !page.has_content?(narrower_concept.pref_label.to_s),
29
29
  "Narrower relation (#{narrower_concept.pref_label}) shouldn't be visible in the hierarchical concepts list"
30
30
  end
31
31
 
@@ -16,6 +16,8 @@
16
16
 
17
17
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_helper')
18
18
  require 'capybara/rails'
19
+ require 'test/unit/failure'
20
+ require 'test/unit/error'
19
21
  require 'fileutils'
20
22
 
21
23
  module ActionController
@@ -51,12 +53,36 @@ module ActionController
51
53
  def create_snapshot
52
54
  filename = "#{self.class.name.underscore}_#{method_name}.html"
53
55
  filepath = File.join(CAPYBARA_SNAPSHOTS_DIR, filename)
54
- if File.writable?(filepath)
55
- File.open(filepath, "w") do |f|
56
- f.write page.body
57
- end
56
+ File.open(filepath, "w") do |f|
57
+ f.write page.body
58
58
  end
59
59
  end
60
60
 
61
61
  end
62
62
  end
63
+
64
+ module Test
65
+ module Unit
66
+
67
+ module FailureHandler
68
+
69
+ def add_failure_with_snapshot(*args)
70
+ create_snapshot
71
+ add_failure_without_snapshot(*args)
72
+ end
73
+ alias_method_chain :add_failure, :snapshot
74
+
75
+ end
76
+
77
+ module ErrorHandler
78
+
79
+ def add_error_with_snapshot(*args)
80
+ create_snapshot
81
+ add_error_without_snapshot(*args)
82
+ end
83
+ alias_method_chain :add_error, :snapshot
84
+
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+
3
+ class HygieneTest < ActiveSupport::TestCase
4
+
5
+ test "trailing whitespace" do
6
+ begin
7
+ assert_no_occurrence '[[:blank:]]$', "trailing whitespace"
8
+ rescue Test::Unit::AssertionFailedError => exc
9
+ warn "[WARNING] #{exc}"
10
+ end
11
+ end
12
+
13
+ test "mixed whitespace" do
14
+ tab = " "
15
+ space = " "
16
+ assert_no_occurrence "#{space}#{tab}\|#{tab}#{space}", "mixed whitespace", true
17
+ end
18
+
19
+ def assert_no_occurrence(pattern, error_message, extended=false)
20
+ extra_options = extended ? "E" : ""
21
+ lines = `git grep -In#{extra_options} '#{pattern}' | grep -v '^vendor/'`
22
+ assert_not_equal 0, $?.to_i, "#{error_message}:\n#{lines}"
23
+ end
24
+
25
+ end
@@ -0,0 +1,75 @@
1
+ # encoding: UTF-8
2
+
3
+ # Copyright 2011 innoQ Deutschland GmbH
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../test_helper')
18
+
19
+ class FoobarStripper < Iqvoc::Origin::Filters::GenericFilter
20
+ def call(obj, str)
21
+ str = str.gsub("foobar", "")
22
+ run(obj, str)
23
+ end
24
+ end
25
+
26
+ class OriginTest < ActiveSupport::TestCase
27
+
28
+ def test_should_replace_umlauts
29
+ assert_equal "AeaeUeueOeoess", Iqvoc::Origin.new("ÄäÜüÖöß").to_s
30
+ end
31
+
32
+ def test_should_camalize_string
33
+ assert_equal "AWeighting", Iqvoc::Origin.new("'A' Weighting").to_s
34
+ end
35
+
36
+ def test_should_handle_numbers_at_the_beginning
37
+ assert_equal "_123", Iqvoc::Origin.new("123").to_s
38
+ end
39
+
40
+ def test_should_handle_whitespaces_at_strange_positions
41
+ assert_equal "test12", Iqvoc::Origin.new("test 12 ").to_s
42
+ end
43
+
44
+ def test_should_preserve_underlines
45
+ assert_equal "_test", Iqvoc::Origin.new("_test").to_s
46
+ assert_equal "a_Test", Iqvoc::Origin.new("a_Test").to_s
47
+ end
48
+
49
+ def test_should_preserve_case
50
+ assert_equal "test", Iqvoc::Origin.new("test").to_s
51
+ assert_equal "Test", Iqvoc::Origin.new("Test").to_s
52
+ assert_equal "_5test", Iqvoc::Origin.new("5test").to_s
53
+ assert_equal "_5Test", Iqvoc::Origin.new("5Test").to_s
54
+ end
55
+
56
+ def test_should_replace_brackets
57
+ assert_equal "--Energie-Ressource", Iqvoc::Origin.new("[Energie/Ressource]").to_s
58
+ end
59
+
60
+ def test_should_replace_comma
61
+ assert_equal "-", Iqvoc::Origin.new(",").to_s
62
+ end
63
+
64
+ def test_should_merge_all_together
65
+ assert_equal "--Energie-Ressource", Iqvoc::Origin.new("[Energie - Ressource]").to_s
66
+ assert_equal "--Hydrosphaere-WasserUndGewaesser", Iqvoc::Origin.new("[Hydrosphäre - Wasser und Gewässer]").to_s
67
+ end
68
+
69
+ def test_register_custom_filter
70
+ Iqvoc::Origin::Filters.register(:strip_foobars, FoobarStripper)
71
+ assert_equal "trololo_", Iqvoc::Origin.new("trololo_foobar").strip_foobars.to_s
72
+ assert_equal "trololo_", Iqvoc::Origin.new("trololo_foobar").to_s
73
+ end
74
+
75
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iqvoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.5
4
+ version: 3.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-02-08 00:00:00.000000000 Z
14
+ date: 2012-03-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- requirement: &70225955354300 !ruby/object:Gem::Requirement
18
+ requirement: &70105304325980 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 3.2.1
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70225955354300
26
+ version_requirements: *70105304325980
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
- requirement: &70225955352820 !ruby/object:Gem::Requirement
29
+ requirement: &70105304325580 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70225955352820
37
+ version_requirements: *70105304325580
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: kaminari
40
- requirement: &70225955349560 !ruby/object:Gem::Requirement
40
+ requirement: &70105304325060 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *70225955349560
48
+ version_requirements: *70105304325060
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: authlogic
51
- requirement: &70225955347600 !ruby/object:Gem::Requirement
51
+ requirement: &70105304324600 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *70225955347600
59
+ version_requirements: *70105304324600
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: cancan
62
- requirement: &70225955344200 !ruby/object:Gem::Requirement
62
+ requirement: &70105304324180 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *70225955344200
70
+ version_requirements: *70105304324180
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: iq_rdf
73
- requirement: &70225955341860 !ruby/object:Gem::Requirement
73
+ requirement: &70105304323680 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: 0.1.2
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *70225955341860
81
+ version_requirements: *70105304323680
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: json
84
- requirement: &70225955340160 !ruby/object:Gem::Requirement
84
+ requirement: &70105304323240 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
- version_requirements: *70225955340160
92
+ version_requirements: *70105304323240
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rails_autolink
95
- requirement: &70225955338400 !ruby/object:Gem::Requirement
95
+ requirement: &70105304322720 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: '0'
101
101
  type: :runtime
102
102
  prerelease: false
103
- version_requirements: *70225955338400
103
+ version_requirements: *70105304322720
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: fastercsv
106
- requirement: &70225955337300 !ruby/object:Gem::Requirement
106
+ requirement: &70105304322280 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,7 +111,7 @@ dependencies:
111
111
  version: '0'
112
112
  type: :runtime
113
113
  prerelease: false
114
- version_requirements: *70225955337300
114
+ version_requirements: *70105304322280
115
115
  description: iQvoc - a SKOS(-XL) vocabulary management system built on the Semantic
116
116
  Web
117
117
  email:
@@ -237,7 +237,6 @@ files:
237
237
  - app/models/note/skos/example.rb
238
238
  - app/models/note/skos/history_note.rb
239
239
  - app/models/note/skos/scope_note.rb
240
- - app/models/origin_mapping.rb
241
240
  - app/models/rdf_store.rb
242
241
  - app/models/search_extension.rb
243
242
  - app/models/user.rb
@@ -317,7 +316,6 @@ files:
317
316
  - config/database.yml
318
317
  - config/database.yml.mysql
319
318
  - config/database.yml.sqlite
320
- - config/deploy.rb
321
319
  - config/engine.rb
322
320
  - config/environment.rb
323
321
  - config/environments/development.rb
@@ -388,12 +386,13 @@ files:
388
386
  - lib/iqvoc/environments/production.rb
389
387
  - lib/iqvoc/environments/test.rb
390
388
  - lib/iqvoc/instance_configuration.rb
389
+ - lib/iqvoc/maker.rb
390
+ - lib/iqvoc/origin.rb
391
391
  - lib/iqvoc/rdf_helper.rb
392
392
  - lib/iqvoc/skos_importer.rb
393
393
  - lib/iqvoc/version.rb
394
394
  - lib/iqvoc/versioning.rb
395
395
  - lib/iqvoc.rb
396
- - lib/maker.rb
397
396
  - lib/ojdbc14.jar
398
397
  - lib/string.rb
399
398
  - lib/tasks/heroku.rake
@@ -419,9 +418,10 @@ files:
419
418
  - test/performance/browsing_test.rb
420
419
  - test/test_helper.rb
421
420
  - test/unit/concept_test.rb
421
+ - test/unit/hygiene_test.rb
422
422
  - test/unit/instance_configuration_test.rb
423
423
  - test/unit/note_test.rb
424
- - test/unit/origin_mapping_test.rb
424
+ - test/unit/origin_test.rb
425
425
  - test/unit/skos_import_test.rb
426
426
  - vendor/assets/images/ajax-loader.gif
427
427
  - vendor/assets/images/file.gif
@@ -489,7 +489,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
489
489
  version: '0'
490
490
  requirements: []
491
491
  rubyforge_project:
492
- rubygems_version: 1.8.10
492
+ rubygems_version: 1.8.15
493
493
  signing_key:
494
494
  specification_version: 3
495
495
  summary: iQvoc
@@ -514,7 +514,8 @@ test_files:
514
514
  - test/performance/browsing_test.rb
515
515
  - test/test_helper.rb
516
516
  - test/unit/concept_test.rb
517
+ - test/unit/hygiene_test.rb
517
518
  - test/unit/instance_configuration_test.rb
518
519
  - test/unit/note_test.rb
519
- - test/unit/origin_mapping_test.rb
520
+ - test/unit/origin_test.rb
520
521
  - test/unit/skos_import_test.rb