active_triples-local_name 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OThlYTNlODZlOGMwNTBiZGE0ZjYwOWZiNDE1Njc2NjViNjljNjgyNw==
5
- data.tar.gz: !binary |-
6
- MGRlMjgyMmE1ZDMxOGRmN2ZjODA2MmNlYTcwYTBlN2FjMjc3NjFmNw==
2
+ SHA1:
3
+ metadata.gz: 167a82e0b5dcf29e3580f9f684b61fcff31aef36
4
+ data.tar.gz: f0a6da5bf67290999379b9d458593db5adcc7389
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NmY4NjEzZDZmZTM0OWRjNGEwMTZmZTc2NzQ2YTMzZDAwZjYzOWFmZDljMWMw
10
- ZDAwNWM0OGQ4ODU4MWVjNmRmNzk1NTU4MmJkNTVjOWRiM2VmMDdkMjE5ODRk
11
- MGI1ODAxYmE2NDE3YTQ4YTRjZjk2YTNkNzJkNjVlYzllZGY4YzE=
12
- data.tar.gz: !binary |-
13
- Mjc1ZTZkZGQxYTQyZTk2ZTEyMzBmMGI1NTA2ZmRjNTM1NDZkYjIxZDIzYjIy
14
- ODg2ZjgzYmYwOGEyZTRiN2UxZGVhYWI3ODg4YTFjOWFkNmY2MzBhOTllOTRl
15
- MWRlYzQwNTUwMmUxOWJkNWFmZWQyZjliYmM1YWU0NGQwMWM1MGQ=
6
+ metadata.gz: ed11e4fa67b948fb424a7995025228ee3046d1dcbd06a0a4db12d6f3a45bbb038799e937000604b2ca97a819ca7f3e56d2d7bb54eeab051fe28ec24e31f8dc8f
7
+ data.tar.gz: 05d83f63cd81934c0d7958076db00cd1cb7288bd6f0ecddb9ce03acda4cf7dadeee4fd50a126b490493e7e929e62f09478aeca3f5d9325390f79b8ce702c349c
@@ -4,9 +4,11 @@ script: "bundle exec rspec spec"
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1.0
8
- - 2.1.1
7
+ - 2.1.6
8
+ - 2.2.2
9
+ - ruby-head
9
10
  - jruby-19mode
10
11
  matrix:
11
12
  allow_failures:
12
- - rvm: jruby-19mode
13
+ - rvm: ruby-head
14
+ - rvm: jruby-19mode
data/AUTHORS CHANGED
@@ -1,2 +1 @@
1
- * Tom Johnson (thomas.johnson@oregonstate.edu)
2
- * Trey Terrell
1
+ * E. Lynette Rayle (elr37@cornell.edu)
data/README.md CHANGED
@@ -4,8 +4,7 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/ActiveTriples/active_triples-local_name/badge.png?branch=master)](https://coveralls.io/r/ActiveTriples/active_triples-local_name?branch=master)
5
5
  [![Gem Version](https://badge.fury.io/rb/active_triples-local_name.svg)](http://badge.fury.io/rb/active_triples-local_name)
6
6
 
7
- Provides utilities for working with local names under the [ActiveTriples](https://github.com/ActiveTriples/ActiveTriples)
8
- framework. Includes a default implementation of a local name minter.
7
+ Provides utilities for working with local names under the [ActiveTriples](https://github.com/ActiveTriples/ActiveTriples) framework. Includes a default implementation of a local name minter.
9
8
 
10
9
 
11
10
  ## Installation
@@ -60,15 +59,11 @@ localname = ActiveTriples::LocalName::Minter.generate_local_name(
60
59
 
61
60
  Parameter NOTES:
62
61
  * for_class = DummyResourceWithBaseURI - resource class must have base_uri configured
63
- * max_tries = 10 - If using default minter, it should easily find an available local name in 10 tries.
64
- If your minter algorithm gets lots of clashes with existing URIs and max_tries is set high, you may
65
- run into performance issues.
62
+ * max_tries = 10 - If using default minter, it should easily find an available local name in 10 tries.
63
+ If your minter algorithm gets lots of clashes with existing URIs and max_tries is set high, you may run into performance issues.
66
64
  * minter_args (optional) = {:prefix=>'d'} - The default minter takes a single hash argument. You can
67
65
  define minters that take no arguments, multiple arguments, or a multiple item hash argument.
68
- * minter_block = nil - When minter_block is not passed in, the default minter algorithm, which produces
69
- a UUID, will be used. Best practice is to start local names with an alpha character. UUIDs generate
70
- with either an alpha or numeric as the first character. Passing in a prefix of 'd' forces the local
71
- name to start with the character 'd'.
66
+ * minter_block = nil - When minter_block is not passed in, the default minter algorithm, which produces a UUID, will be used. Best practice is to start local names with an alpha character. UUIDs generate with either an alpha or numeric as the first character. Passing in a prefix of 'd' forces the local name to start with the character 'd'.
72
67
 
73
68
 
74
69
  #### Example: Passing in a block as minter
@@ -14,11 +14,13 @@ Gem::Specification.new do |s|
14
14
  s.license = "APACHE2"
15
15
  s.required_ruby_version = '>= 1.9.3'
16
16
 
17
- s.add_dependency('active-triples', '~> 0.5')
17
+ s.add_dependency('active-triples')
18
18
 
19
- s.add_dependency('deprecation', '~> 0.1')
20
- s.add_dependency('activesupport', '>= 3.0.0')
19
+ s.add_dependency('deprecation')
20
+ s.add_dependency('activesupport')
21
21
 
22
+ s.add_development_dependency('pry')
23
+ # s.add_development_dependency('pry-byebug') # uncomment for ruby >= 2.0
22
24
  s.add_development_dependency('rdoc')
23
25
  s.add_development_dependency('rspec')
24
26
  s.add_development_dependency('coveralls')
@@ -9,19 +9,8 @@ module ActiveTriples
9
9
  autoload :Minter
10
10
  end
11
11
 
12
- def self.class_from_string(class_name, container_class=Kernel)
13
- container_class = container_class.name if container_class.is_a? Module
14
- container_parts = container_class.split('::')
15
- (container_parts + class_name.split('::')).flatten.inject(Kernel) do |mod, class_name|
16
- if mod == Kernel
17
- Object.const_get(class_name)
18
- elsif mod.const_defined? class_name.to_sym
19
- mod.const_get(class_name)
20
- else
21
- container_parts.pop
22
- class_from_string(class_name, container_parts.join('::'))
23
- end
24
- end
12
+ def self.post_ActiveTriples_0_7?
13
+ ActiveTriples.constants.include?(:RDFSource)
25
14
  end
26
15
  end
27
16
  end
@@ -10,7 +10,7 @@ module ActiveTriples
10
10
  # Generate a random localname that combined with a class' base_uri does not already exist in
11
11
  # registered triplestores.
12
12
  #
13
- # @param [Class] the class inheriting from <tt>ActiveTriples::Reource</tt> whose configuration
13
+ # @param [Class] the class inheriting from <tt>ActiveTriples::Reource</tt> (ActiveTriples < 0.7) or including <tt>ActiveTriples::RDFSource</tt> (ActiveTriples >= 0.7) whose configuration
14
14
  # is used to generate the full URI for testing for uniqueness of the generated local name
15
15
  # @param [Integer] the maximum number of attempts to make a unique local name
16
16
  # @yieldparam the arguments to pass to the minter block (optional)
@@ -21,7 +21,7 @@ module ActiveTriples
21
21
  # @return [String] the generated local name
22
22
  #
23
23
  # @raise [ArgumentError] if maximum allowed tries is less than 0
24
- # @raise [ArgumentError] if for_class does not inherit from ActiveTriples::Resources
24
+ # @raise [ArgumentError] if for_class does not inherit from ActiveTriples::Resources (ActiveTriples < 0.7) or include ActiveTriples:RDFSource (ActiveTriples >= 0.7)
25
25
  # @raise [ArgumentError] if minter_block is not a block (does not respond to call)
26
26
  # @raise [Exception] if for_class does not have base_uri configured
27
27
  # @raise [Exception] if an available local name is not found in the maximum allowed tries.
@@ -35,7 +35,14 @@ module ActiveTriples
35
35
  def self.generate_local_name(for_class, max_tries=10, *minter_args, &minter_block)
36
36
  raise ArgumentError, 'Argument max_tries must be >= 1 if passed in' if max_tries <= 0
37
37
 
38
- raise ArgumentError, 'Argument for_class must inherit from ActiveTriples::Resource' unless for_class < ActiveTriples::Resource
38
+ if( ActiveTriples::LocalName.post_ActiveTriples_0_7? ) # Supports ActiveTriples >= 0.7
39
+ raise ArgumentError, 'Argument for_class must inherit from ActiveTriples::Resource or include module ActiveTriples::RDFSource' unless
40
+ ( for_class < ActiveTriples::Resource || for_class.included_modules.include?(ActiveTriples::RDFSource) )
41
+ else # Supports ActiveTriples < 0.7
42
+ raise ArgumentError, 'Argument for_class must inherit from ActiveTriples::Resource' unless
43
+ ( for_class < ActiveTriples::Resource )
44
+ end
45
+
39
46
  raise 'Requires base_uri to be defined in for_class.' unless for_class.base_uri
40
47
 
41
48
  raise ArgumentError, 'Invalid minter_block.' if minter_block && !minter_block.respond_to?(:call)
@@ -1,5 +1,5 @@
1
1
  module ActiveTriples
2
2
  module LocalName
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -109,11 +109,20 @@ describe ActiveTriples::LocalName::Minter do
109
109
  end
110
110
 
111
111
  it "should raise error" do
112
+ if( ActiveTriples::LocalName.post_ActiveTriples_0_7? ) # for ActiveTriples >= 0.7
113
+ err_msg = 'Argument for_class must inherit from ActiveTriples::Resource or include module ActiveTriples::RDFSource'
114
+ else # for ActiveTriples < 0.7
115
+ err_msg = 'Argument for_class must inherit from ActiveTriples::Resource'
116
+ end
112
117
  expect{ ActiveTriples::LocalName::Minter.generate_local_name(DummyNonResource) }.
113
- to raise_error(ArgumentError, 'Argument for_class must inherit from ActiveTriples::Resource')
118
+ to raise_error(ArgumentError, err_msg)
114
119
  end
115
- end
116
120
 
121
+ it "should not raise error when inheriting from ActiveTriples::Resource" do
122
+ expect{ ActiveTriples::LocalName::Minter.generate_local_name(DummyResourceWithBaseURI) }.
123
+ not_to raise_error
124
+ end
125
+ end
117
126
 
118
127
  context "and class doesn't have base_uri defined" do
119
128
  it "should raise error" do
@@ -436,4 +445,31 @@ describe ActiveTriples::LocalName::Minter do
436
445
  end
437
446
  end
438
447
  end
448
+
449
+ describe "test validation when ActiveTriples >= 0.7" do
450
+ before do
451
+ if( ActiveTriples::LocalName.post_ActiveTriples_0_7? ) # Check that ActiveTriples >= 0.7
452
+ class DummyResourceInclude
453
+ include ActiveTriples::RDFSource
454
+ configure :base_uri => "http://example.org",
455
+ :type => RDF::URI('http://example.org/SomeClass')
456
+ property :title, :predicate => RDF::DC.title
457
+ end
458
+ end
459
+ end
460
+ after do
461
+ if( ActiveTriples::LocalName.post_ActiveTriples_0_7? ) # Check that ActiveTriples >= 0.7
462
+ Object.send(:remove_const, "DummyResourceInclude") if Object
463
+ end
464
+ end
465
+
466
+ it "should not raise error when including from ActiveTriples::RDFSource" do
467
+ unless( ActiveTriples::LocalName.post_ActiveTriples_0_7? ) # Supports ActiveTriples >= 0.7
468
+ skip ('Cannot test include ActiveTriples::RDFSource when ActiveTriples < 0.7 installed')
469
+ else
470
+ expect{ ActiveTriples::LocalName::Minter.generate_local_name(DummyResourceInclude) }.
471
+ not_to raise_error
472
+ end
473
+ end
474
+ end
439
475
  end
@@ -6,7 +6,7 @@ Bundler.setup
6
6
 
7
7
  require 'active_triples/local_name'
8
8
  require 'active_triples'
9
-
9
+ require 'pry' unless ENV['CI']
10
10
 
11
11
  Dir['./spec/support/**/*.rb'].each { |f| require f }
12
12
 
metadata CHANGED
@@ -1,111 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_triples-local_name
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E. Lynette Rayle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-triples
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.5'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: deprecation
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.1'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.0
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 3.0.0
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rdoc
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ! '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ! '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ! '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ! '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: coveralls
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ! '>='
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ! '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: guard-rspec
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ! '>='
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ! '>='
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  description: active_triples-local_name provides a standard interface and default implementation
@@ -117,9 +131,9 @@ extra_rdoc_files:
117
131
  - LICENSE
118
132
  - README.md
119
133
  files:
120
- - .coveralls.yml
121
- - .gitignore
122
- - .travis.yml
134
+ - ".coveralls.yml"
135
+ - ".gitignore"
136
+ - ".travis.yml"
123
137
  - AUTHORS
124
138
  - Gemfile
125
139
  - Guardfile
@@ -141,17 +155,17 @@ require_paths:
141
155
  - lib
142
156
  required_ruby_version: !ruby/object:Gem::Requirement
143
157
  requirements:
144
- - - ! '>='
158
+ - - ">="
145
159
  - !ruby/object:Gem::Version
146
160
  version: 1.9.3
147
161
  required_rubygems_version: !ruby/object:Gem::Requirement
148
162
  requirements:
149
- - - ! '>='
163
+ - - ">="
150
164
  - !ruby/object:Gem::Version
151
165
  version: '0'
152
166
  requirements: []
153
167
  rubyforge_project:
154
- rubygems_version: 2.2.2
168
+ rubygems_version: 2.4.5
155
169
  signing_key:
156
170
  specification_version: 4
157
171
  summary: Local name minter for ActiveTriples based resources.