ld-patch 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 487103c7936e34423555d2da4dcdee60ef0b882f
4
- data.tar.gz: d394490da8bea83bc4198e7bb9a278ef4719aeb3
3
+ metadata.gz: 27a3642a91846cb23466184a3d5bfc4397b20df4
4
+ data.tar.gz: f542b62f93ad91a1899097a47c0ab5e6c4047d1a
5
5
  SHA512:
6
- metadata.gz: 363c254bb67028732686af8e1ce2808a9250b93d400f16c4c3e4b0ac32a133d94e80f5e22a0483b3e6e3b27a48de92fe9f5d5f3c2064476fcbd23a156ed419b1
7
- data.tar.gz: a1aff9d1f218b27ccd9a77f9a6bccacc7c57d2d656ba608235ff772d06b4acda023c7d9734941e5d37666a9ae6fea7fc39ea6596c168f21274b8c3947d8e64f4
6
+ metadata.gz: 714a26208900d98bb44ea32b08e76624ce3712ecb90eeb2a3a6ad66c0424b780676ed83c3c723eefd0e931919c3cceb5a48c5d9d569b0fc1162e07ecd9477c3b
7
+ data.tar.gz: 0b330bc3cc7892334f6c84aeea48c01cf203b0ad7d7899f5b849f346fe486b59940c9e4d2cd32d534cf05ac0c05d2c4e346b2c405a2bd332a8e03bf4ca5e77d7
data/README.md CHANGED
@@ -53,6 +53,19 @@ Full documentation available on [Rubydoc.info][LD-Patch doc]
53
53
  operator = LD::Patch.parse(patch, base_uri: "http://rubygems.org/gems/ld-patch")
54
54
  operator.execute(queryable) # alternatively queryable.query(operator)
55
55
 
56
+ ## Command Line
57
+ When the `linkeddata` gem is installed, RDF.rb includes a `rdf` executable which acts as a wrapper to perform a number of different
58
+ operations on RDF files, including LD::Patch, which is used as a stream command and must be followed by serialize to see the results. The commands specific to LD::Patch is
59
+
60
+ * `ld-patch`: Patch the current graph using a patch file
61
+
62
+ Using this command requires either a `patch-input` where the patch is URI encoded, or `patch-file`, which references a URI or file path to the patch.
63
+ Example usage:
64
+
65
+ rdf patch serialize https://raw.githubusercontent.com/ruby-rdf/ld-patch/develop/etc/doap.ttl \
66
+ --patch-input Add%20%7B%20%3Chttp://example.org/s2%3E%20%3Chttp://example.org/p2%3E%20%3Chttp://example.org/o2%3E%20%7D%20. \
67
+ --output-format ttl
68
+
56
69
  ## Implementation Notes
57
70
  The reader uses the [EBNF][] gem to generate first, follow and branch tables, and uses the `Parser` and `Lexer` modules to implement the LD Patch parser.
58
71
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
data/bin/ldpatch CHANGED
@@ -22,9 +22,9 @@ def run(graph, options = {})
22
22
 
23
23
  patch = LD::Patch.parse(options[:patch], options)
24
24
 
25
- puts ("\nSSE:\n" + patch.to_sse) if options[:debug] || options[:to_sse]
25
+ puts ("\nSXP:\n" + patch.to_sse) if options[:debug] || options[:to_sxp]
26
26
 
27
- unless options[:to_sse]
27
+ unless options[:to_sxp]
28
28
  res = patch.execute(graph, options)
29
29
  puts res.dump(:ttl, base_uri: patch.base_uri, prefixes: patch.prefixes, standard_prefixes: true)
30
30
  end
@@ -35,7 +35,7 @@ opts = GetoptLong.new(
35
35
  ["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT],
36
36
  ["--patch", GetoptLong::REQUIRED_ARGUMENT],
37
37
  ["--progress", GetoptLong::NO_ARGUMENT],
38
- ["--to-sse", GetoptLong::NO_ARGUMENT],
38
+ ["--to-sxp", GetoptLong::NO_ARGUMENT],
39
39
  ["--validate", GetoptLong::NO_ARGUMENT],
40
40
  ["--verbose", GetoptLong::NO_ARGUMENT],
41
41
  ["--help", "-?", GetoptLong::NO_ARGUMENT]
@@ -50,7 +50,7 @@ opts.each do |opt, arg|
50
50
  when '--execute' then options[:patch] = arg
51
51
  when '--patch' then options[:patch] = RDF::Util::File.open_file(arg).read
52
52
  when '--progress' then options[:debug] ||= 2
53
- when '--to-sse' then options[:to_sse] = true
53
+ when '--to-sxp' then options[:to_sxp] = true
54
54
  when '--validate' then options[:validate] = true
55
55
  when '--verbose' then options[:verbose] = true
56
56
  when "--help"
@@ -61,7 +61,7 @@ opts.each do |opt, arg|
61
61
  puts " --execute,-e: Use option argument as the patch input"
62
62
  puts " --patch: Location of patch document"
63
63
  puts " --progress Display parse tree"
64
- puts " --to-sse: Generate SSE for patch instead of running query"
64
+ puts " --to-sxp: Generate S-Expression for patch instead of running query"
65
65
  puts " --validate: Validate patch document"
66
66
  puts " --verbose: Display details of processing"
67
67
  puts " --help,-?: This message"
@@ -20,29 +20,43 @@ module LD::Patch
20
20
  def self.cli_commands
21
21
  {
22
22
  patch: {
23
- description: "Patch the current graph using a URI Encoded patch file, or a referenced path file/URI",
24
- help: "patch [--patch 'patch'] [--patch-file file]",
23
+ description: "Patch the current graph using a patch file",
24
+ help: "patch [--patch-input 'patch'] [--patch-file file]",
25
+ control: :button,
25
26
  parse: true,
26
27
  lambda: -> (argv, opts) do
27
- opts[:patch] ||= RDF::Util::File.open_file(opts[:patch_file]) {|f| f.read}
28
- raise ArgumentError, "Patching requires a URI encoded patch or reference to patch resource" unless opts[:patch]
29
- $stdout.puts "Patch"
30
- patch = LD::Patch.parse(opts[:patch], base_uri: opts.fetch(:patch_file, "http://rubygems.org/gems/ld-patch"))
28
+ opts[:patch_input] ||= case opts[:patch_file]
29
+ when IO, StringIO then opts[:patch_file]
30
+ else RDF::Util::File.open_file(opts[:patch_file]) {|f| f.read}
31
+ end
32
+ raise ArgumentError, "Patching requires a patch or reference to patch resource" unless opts[:patch_input]
33
+ opts[:logger].info "Patch"
34
+ patch = LD::Patch.parse(opts[:patch_input], base_uri: opts.fetch(:patch_file, "http://rubygems.org/gems/ld-patch"))
35
+ opts[:messages][:"S-Expression"] = [patch.to_sse] if opts[:to_sxp]
31
36
  RDF::CLI.repository.query(patch)
32
37
  end,
33
38
  options: [
34
39
  RDF::CLI::Option.new(
35
- symbol: :patch,
40
+ symbol: :patch_input,
36
41
  datatype: String,
37
- on: ["--patch STRING"],
42
+ control: :none,
43
+ on: ["--patch-input STRING"],
38
44
  description: "Patch in URI encoded format"
39
45
  ) {|v| URI.decode(v)},
40
46
  RDF::CLI::Option.new(
41
47
  symbol: :patch_file,
42
48
  datatype: String,
49
+ control: :url2,
43
50
  on: ["--patch-file URI"],
44
- description: "URI of patch file"
51
+ description: "Patch file"
45
52
  ) {|v| RDF::URI(v)},
53
+ RDF::CLI::Option.new(
54
+ symbol: :to_sxp,
55
+ datatype: String,
56
+ control: :checkbox,
57
+ on: ["--to-sxp"],
58
+ description: "Instead of patching repository, display parsed patch as an S-Expression"
59
+ ),
46
60
  ]
47
61
  }
48
62
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ld-patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-31 00:00:00.000000000 Z
11
+ date: 2017-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -255,8 +255,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  - !ruby/object:Gem::Version
256
256
  version: '0'
257
257
  requirements: []
258
- rubyforge_project: ld-patch
259
- rubygems_version: 2.6.8
258
+ rubyforge_project:
259
+ rubygems_version: 2.6.12
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: W3C Linked Data Patch Format for RDF.rb.