jini 0.1.5 → 1.1.5
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 +4 -4
- data/.rubocop.yml +35 -13
- data/Gemfile +2 -0
- data/README.md +3 -3
- data/Rakefile +14 -0
- data/jini.gemspec +1 -1
- data/lib/jini.rb +21 -13
- data/test/jini_test.rb +18 -9
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cb24e4c751e1f13a8bf330035a607e88f50ad4bd9bfa88716bae22ec9c626b8
|
|
4
|
+
data.tar.gz: 8566642f48c9b868b601aef9311a0894982da11ee27f01bc4390b0708169d788
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b86628c45f695f62b67687a90f1e1baa9147a0557303051ec7c5637d0862071c463964657203ac1729c259921a00b3c912c958d56da5f428934ec5fcc121c7d
|
|
7
|
+
data.tar.gz: 191a9dac94b2f19f89d86d1bfc12aa8e0beebe1a13be6953283e5b5f884ea1614b8b837120f975d381a4f2dc9c9626b3263d737269f3cf712f8df1cc184f2739
|
data/.rubocop.yml
CHANGED
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- 'bin/**/*'
|
|
4
|
+
- 'assets/**/*'
|
|
5
|
+
- '**.gemspec'
|
|
6
|
+
- 'out/**/*'
|
|
2
7
|
DisplayCopNames: true
|
|
3
|
-
TargetRubyVersion: 2.6.
|
|
4
|
-
SuggestExtensions: false
|
|
8
|
+
TargetRubyVersion: 2.6.0
|
|
5
9
|
NewCops: enable
|
|
10
|
+
SuggestExtensions: false
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- 'test/*.rb'
|
|
12
|
+
Layout/MultilineOperationIndentation:
|
|
13
|
+
Enabled: false
|
|
10
14
|
Layout/EmptyLineAfterGuardClause:
|
|
11
15
|
Enabled: false
|
|
12
|
-
|
|
16
|
+
Naming/MethodParameterName:
|
|
17
|
+
MinNameLength: 1
|
|
18
|
+
Style/CommandLiteral:
|
|
19
|
+
Enabled: false
|
|
20
|
+
Style/FrozenStringLiteralComment:
|
|
21
|
+
Enabled: false
|
|
22
|
+
Layout/IndentationWidth:
|
|
23
|
+
Enabled: false
|
|
24
|
+
Layout/ElseAlignment:
|
|
25
|
+
Enabled: false
|
|
26
|
+
Layout/EndAlignment:
|
|
27
|
+
Enabled: false
|
|
28
|
+
Lint/RescueException:
|
|
13
29
|
Enabled: false
|
|
14
|
-
Metrics/AbcSize:
|
|
15
|
-
Max: 30
|
|
16
30
|
Metrics/MethodLength:
|
|
17
|
-
Max:
|
|
31
|
+
Max: 50
|
|
32
|
+
Metrics/ClassLength:
|
|
33
|
+
Max: 200
|
|
34
|
+
Metrics/AbcSize:
|
|
35
|
+
Max: 60
|
|
36
|
+
Metrics/BlockLength:
|
|
37
|
+
Max: 100
|
|
38
|
+
Layout/MultilineMethodCallIndentation:
|
|
39
|
+
Enabled: false
|
|
18
40
|
Metrics/CyclomaticComplexity:
|
|
19
|
-
Max:
|
|
41
|
+
Max: 11
|
|
20
42
|
Metrics/PerceivedComplexity:
|
|
21
|
-
Max:
|
|
22
|
-
Layout/
|
|
23
|
-
|
|
43
|
+
Max: 11
|
|
44
|
+
Layout/LineLength:
|
|
45
|
+
Max: 120
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
[](https://badge.fury.io/rb/jini)
|
|
5
5
|
|
|
6
|
-
The class [`Jini`](https://www.rubydoc.info/gems/jini/
|
|
6
|
+
The class [`Jini`](https://www.rubydoc.info/gems/jini/1.1.5/Jini) helps you build a XPATH.
|
|
7
7
|
|
|
8
8
|
```ruby
|
|
9
9
|
require 'jini'
|
|
@@ -17,7 +17,7 @@ xpath = Jini
|
|
|
17
17
|
puts(xpath) # -> xpath: /parent[@key="value"]
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
The full list of methods is [here](https://www.rubydoc.info/gems/jini/
|
|
20
|
+
The full list of methods is [here](https://www.rubydoc.info/gems/jini/1.1.5).
|
|
21
21
|
|
|
22
22
|
Install it:
|
|
23
23
|
|
|
@@ -35,5 +35,5 @@ Pay attention, it is not a parser. The only functionality this gem provides
|
|
|
35
35
|
is _building_ XPATHs.
|
|
36
36
|
|
|
37
37
|
## New features requests
|
|
38
|
-
If you find an error, or you want to add new functionality,
|
|
38
|
+
If you find an error, or you want to add new functionality, just create a new `Issue`
|
|
39
39
|
and describe what happened, also try to add/fix something and send pull request.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
|
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
|
5
|
+
t.libs << 'test'
|
|
6
|
+
t.libs << 'lib'
|
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require 'rubocop/rake_task'
|
|
11
|
+
|
|
12
|
+
RuboCop::RakeTask.new
|
|
13
|
+
|
|
14
|
+
task default: %i[test rubocop]
|
data/jini.gemspec
CHANGED
|
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
|
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
6
6
|
s.required_ruby_version = '>=2.6.8'
|
|
7
7
|
s.name = 'jini'
|
|
8
|
-
s.version = '
|
|
8
|
+
s.version = '1.1.5'
|
|
9
9
|
s.license = 'MIT'
|
|
10
10
|
s.summary = 'Simple Immutable Ruby XPATH Builder'
|
|
11
11
|
s.description = 'Class Jini helps you build a XPATH and then modify its parts via a simple fluent interface.'
|
data/lib/jini.rb
CHANGED
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
#
|
|
30
30
|
# It's a simple XPATH builder.
|
|
31
31
|
# Class is thread safe.
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
32
|
+
# Example:
|
|
33
|
+
# require 'jini'
|
|
34
|
+
# xpath = Jini.new('parent')
|
|
35
|
+
# .add_node('child')
|
|
36
|
+
# .add_attr('toy', 'plane')
|
|
37
|
+
# .to_s
|
|
38
|
+
# => 'parent/child[@toy="plane"]
|
|
39
39
|
class Jini
|
|
40
40
|
# When path not valid
|
|
41
41
|
class InvalidPath < StandardError; end
|
|
@@ -81,9 +81,9 @@ class Jini
|
|
|
81
81
|
def replace_node(origin, new)
|
|
82
82
|
Jini.new(
|
|
83
83
|
@head
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
.split('/')
|
|
85
|
+
.map! { |node| node.eql?(origin) ? new : node }
|
|
86
|
+
.join('/')
|
|
87
87
|
)
|
|
88
88
|
end
|
|
89
89
|
|
|
@@ -91,13 +91,15 @@ class Jini
|
|
|
91
91
|
# @return nodes as [Array]
|
|
92
92
|
def nodes
|
|
93
93
|
checked = @head
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
.split(%r{(//|/)})
|
|
95
|
+
.each(&method(:empty_check))
|
|
96
96
|
checked.each { |node| checked.delete node if node.eql?('//') || node.eql?('/') }.to_a
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# Addition property in tail.
|
|
100
|
-
#
|
|
100
|
+
# Example:
|
|
101
|
+
# >> Jini.new('node/').property('prop').to_s
|
|
102
|
+
# => node/property()
|
|
101
103
|
# @param property [String] to add
|
|
102
104
|
# @return [Jini] with property on tail
|
|
103
105
|
# @since 0.0.1
|
|
@@ -129,6 +131,12 @@ class Jini
|
|
|
129
131
|
Jini.new("#{@head}@#{key}")
|
|
130
132
|
end
|
|
131
133
|
|
|
134
|
+
# Just wrap current XPATH into count() function
|
|
135
|
+
# @return [Jini] wrapped
|
|
136
|
+
def count
|
|
137
|
+
Jini.new("count(#{@head})")
|
|
138
|
+
end
|
|
139
|
+
|
|
132
140
|
# Removes attr by name.
|
|
133
141
|
# before:
|
|
134
142
|
# '/parent/child [@k="v"]'
|
data/test/jini_test.rb
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# (The MIT License)
|
|
4
|
-
#
|
|
5
1
|
# Copyright (c) 2022 Ivanchuk Ivan
|
|
6
2
|
#
|
|
7
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
@@ -26,13 +22,15 @@ require_relative '../lib/jini'
|
|
|
26
22
|
require 'minitest/autorun'
|
|
27
23
|
require_relative 'test_helper'
|
|
28
24
|
|
|
29
|
-
# Jini
|
|
30
|
-
# Author:: Ivan
|
|
31
|
-
# Copyright:: Copyright (c) 2022 Ivan
|
|
25
|
+
# Test for Jini class.
|
|
26
|
+
# Author:: Ivanchuk Ivan (clicker.heroes.acg@gmail.com)
|
|
27
|
+
# Copyright:: Copyright (c) 2022 Ivanchuck Ivan
|
|
32
28
|
# License:: MIT
|
|
29
|
+
# rubocop:disable Metrics/ClassLength
|
|
33
30
|
class JiniTest < Minitest::Test
|
|
34
|
-
PARENT = 'parent'
|
|
35
|
-
CHILD = 'child'
|
|
31
|
+
PARENT = 'parent'.freeze
|
|
32
|
+
CHILD = 'child'.freeze
|
|
33
|
+
|
|
36
34
|
def test_add_path_and_at_success
|
|
37
35
|
assert_equal(
|
|
38
36
|
'/parent/child[1]',
|
|
@@ -321,4 +319,15 @@ class JiniTest < Minitest::Test
|
|
|
321
319
|
.nodes
|
|
322
320
|
end
|
|
323
321
|
end
|
|
322
|
+
|
|
323
|
+
def test_count_success
|
|
324
|
+
assert_equal(
|
|
325
|
+
'count(parent/child)',
|
|
326
|
+
Jini.new(PARENT)
|
|
327
|
+
.add_node(CHILD)
|
|
328
|
+
.count
|
|
329
|
+
.to_s
|
|
330
|
+
)
|
|
331
|
+
end
|
|
324
332
|
end
|
|
333
|
+
# rubocop:enable Metrics/ClassLength
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jini
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan Ivanchuck
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -70,6 +70,7 @@ files:
|
|
|
70
70
|
- Gemfile
|
|
71
71
|
- LICENSE
|
|
72
72
|
- README.md
|
|
73
|
+
- Rakefile
|
|
73
74
|
- doc/Jini.html
|
|
74
75
|
- doc/Jini/InvalidPath.html
|
|
75
76
|
- doc/_index.html
|
|
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
112
113
|
- !ruby/object:Gem::Version
|
|
113
114
|
version: '0'
|
|
114
115
|
requirements: []
|
|
115
|
-
rubygems_version: 3.3.
|
|
116
|
+
rubygems_version: 3.3.26
|
|
116
117
|
signing_key:
|
|
117
118
|
specification_version: 4
|
|
118
119
|
summary: Simple Immutable Ruby XPATH Builder
|