augeas 0.6.0 → 0.6.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75d2dd413111560ecd6863377650e4f99e1d4be1
4
- data.tar.gz: ac115f04323b69b96aba2a82a4c7f4497d81af3a
3
+ metadata.gz: b71dd4532d404d0af0b17a7bfb2c87336386be5c
4
+ data.tar.gz: 11ba1ab7ff33b7e8fcdca35a31114b98f669ac26
5
5
  SHA512:
6
- metadata.gz: 4f3401fc55b371e25a2a94330ec390c69a24a56537563197086bb8edf0a0b98c0a13120faa266c53905a41fe4f94438ceabf10a43af3e971149ea9a34bf7847b
7
- data.tar.gz: 49268ca68505d4260f1660b8392276f8b66e5faa827185fca4842dd18d2b92879f76dc797b79c1d55ec91c83def55119859ed81b16066aee1d8678ab6a1a7f7e
6
+ metadata.gz: 787431db47c11bab4ead53c061ad1d04d30570e73c81a6a71f25642cfd8ff9579e8041ae6dd7e0f27bc8ee533ef6705f33078acf902b282e5bbf859eeb5446a4
7
+ data.tar.gz: f02341ca9e1d9f42055381ba53698f5a7fc6510c3633870d40c15a114aad8315511c7a31876db18753b403521a7cfdff0bc3d50f019b16a9860342ca35e6bc2e
data/COPYING CHANGED
@@ -1,9 +1,8 @@
1
-
2
1
  GNU LESSER GENERAL PUBLIC LICENSE
3
2
  Version 2.1, February 1999
4
3
 
5
4
  Copyright (C) 1991, 1999 Free Software Foundation, Inc.
6
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7
6
  Everyone is permitted to copy and distribute verbatim copies
8
7
  of this license document, but changing it is not allowed.
9
8
 
@@ -23,8 +22,7 @@ specially designated software packages--typically libraries--of the
23
22
  Free Software Foundation and other authors who decide to use it. You
24
23
  can use it too, but we suggest you first think carefully about whether
25
24
  this license or the ordinary General Public License is the better
26
- strategy to use in any particular case, based on the explanations
27
- below.
25
+ strategy to use in any particular case, based on the explanations below.
28
26
 
29
27
  When we speak of free software, we are referring to freedom of use,
30
28
  not price. Our General Public Licenses are designed to make sure that
@@ -57,7 +55,7 @@ modified by someone else and passed on, the recipients should know
57
55
  that what they have is not the original version, so that the original
58
56
  author's reputation will not be affected by problems that might be
59
57
  introduced by others.
60
- ^L
58
+
61
59
  Finally, software patents pose a constant threat to the existence of
62
60
  any free program. We wish to make sure that a company cannot
63
61
  effectively restrict the users of a free program by obtaining a
@@ -89,9 +87,9 @@ libraries. However, the Lesser license provides advantages in certain
89
87
  special circumstances.
90
88
 
91
89
  For example, on rare occasions, there may be a special need to
92
- encourage the widest possible use of a certain library, so that it
93
- becomes a de-facto standard. To achieve this, non-free programs must
94
- be allowed to use the library. A more frequent case is that a free
90
+ encourage the widest possible use of a certain library, so that it becomes
91
+ a de-facto standard. To achieve this, non-free programs must be
92
+ allowed to use the library. A more frequent case is that a free
95
93
  library does the same job as widely used non-free libraries. In this
96
94
  case, there is little to gain by limiting the free library to free
97
95
  software only, so we use the Lesser General Public License.
@@ -113,7 +111,7 @@ modification follow. Pay close attention to the difference between a
113
111
  "work based on the library" and a "work that uses the library". The
114
112
  former contains code derived from the library, whereas the latter must
115
113
  be combined with the library in order to run.
116
- ^L
114
+
117
115
  GNU LESSER GENERAL PUBLIC LICENSE
118
116
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
119
117
 
@@ -138,8 +136,8 @@ included without limitation in the term "modification".)
138
136
  "Source code" for a work means the preferred form of the work for
139
137
  making modifications to it. For a library, complete source code means
140
138
  all the source code for all modules it contains, plus any associated
141
- interface definition files, plus the scripts used to control
142
- compilation and installation of the library.
139
+ interface definition files, plus the scripts used to control compilation
140
+ and installation of the library.
143
141
 
144
142
  Activities other than copying, distribution and modification are not
145
143
  covered by this License; they are outside its scope. The act of
@@ -218,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
218
216
  ordinary GNU General Public License has appeared, then you can specify
219
217
  that version instead if you wish.) Do not make any other change in
220
218
  these notices.
221
- ^L
219
+
222
220
  Once this change is made in a given copy, it is irreversible for
223
221
  that copy, so the ordinary GNU General Public License applies to all
224
222
  subsequent copies and derivative works made from that copy.
@@ -269,7 +267,7 @@ Library will still fall under Section 6.)
269
267
  distribute the object code for the work under the terms of Section 6.
270
268
  Any executables containing that work also fall under Section 6,
271
269
  whether or not they are linked directly with the Library itself.
272
- ^L
270
+
273
271
  6. As an exception to the Sections above, you may also combine or
274
272
  link a "work that uses the Library" with the Library to produce a
275
273
  work containing portions of the Library, and distribute that work
@@ -305,10 +303,10 @@ of these things:
305
303
  the user installs one, as long as the modified version is
306
304
  interface-compatible with the version that the work was made with.
307
305
 
308
- c) Accompany the work with a written offer, valid for at least
309
- three years, to give the same user the materials specified in
310
- Subsection 6a, above, for a charge no more than the cost of
311
- performing this distribution.
306
+ c) Accompany the work with a written offer, valid for at
307
+ least three years, to give the same user the materials
308
+ specified in Subsection 6a, above, for a charge no more
309
+ than the cost of performing this distribution.
312
310
 
313
311
  d) If distribution of the work is made by offering access to copy
314
312
  from a designated place, offer equivalent access to copy the above
@@ -331,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
331
329
  accompany the operating system. Such a contradiction means you cannot
332
330
  use both them and the Library together in an executable that you
333
331
  distribute.
334
- ^L
332
+
335
333
  7. You may place library facilities that are a work based on the
336
334
  Library side-by-side in a single library together with other library
337
335
  facilities not covered by this License, and distribute such a combined
@@ -372,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
372
370
  restrictions on the recipients' exercise of the rights granted herein.
373
371
  You are not responsible for enforcing compliance by third parties with
374
372
  this License.
375
- ^L
373
+
376
374
  11. If, as a consequence of a court judgment or allegation of patent
377
375
  infringement or for any other reason (not limited to patent issues),
378
376
  conditions are imposed on you (whether by court order, agreement or
@@ -386,10 +384,9 @@ all those who receive copies directly or indirectly through you, then
386
384
  the only way you could satisfy both it and this License would be to
387
385
  refrain entirely from distribution of the Library.
388
386
 
389
- If any portion of this section is held invalid or unenforceable under
390
- any particular circumstance, the balance of the section is intended to
391
- apply, and the section as a whole is intended to apply in other
392
- circumstances.
387
+ If any portion of this section is held invalid or unenforceable under any
388
+ particular circumstance, the balance of the section is intended to apply,
389
+ and the section as a whole is intended to apply in other circumstances.
393
390
 
394
391
  It is not the purpose of this section to induce you to infringe any
395
392
  patents or other property right claims or to contest validity of any
@@ -407,11 +404,11 @@ be a consequence of the rest of this License.
407
404
 
408
405
  12. If the distribution and/or use of the Library is restricted in
409
406
  certain countries either by patents or by copyrighted interfaces, the
410
- original copyright holder who places the Library under this License
411
- may add an explicit geographical distribution limitation excluding those
412
- countries, so that distribution is permitted only in or among
413
- countries not thus excluded. In such case, this License incorporates
414
- the limitation as if written in the body of this License.
407
+ original copyright holder who places the Library under this License may add
408
+ an explicit geographical distribution limitation excluding those countries,
409
+ so that distribution is permitted only in or among countries not thus
410
+ excluded. In such case, this License incorporates the limitation as if
411
+ written in the body of this License.
415
412
 
416
413
  13. The Free Software Foundation may publish revised and/or new
417
414
  versions of the Lesser General Public License from time to time.
@@ -425,7 +422,7 @@ conditions either of that version or of any later version published by
425
422
  the Free Software Foundation. If the Library does not specify a
426
423
  license version number, you may choose any version ever published by
427
424
  the Free Software Foundation.
428
- ^L
425
+
429
426
  14. If you wish to incorporate parts of the Library into other free
430
427
  programs whose distribution conditions are incompatible with these,
431
428
  write to the author to ask for permission. For software which is
@@ -459,21 +456,19 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
459
456
  DAMAGES.
460
457
 
461
458
  END OF TERMS AND CONDITIONS
462
- ^L
459
+
463
460
  How to Apply These Terms to Your New Libraries
464
461
 
465
462
  If you develop a new library, and you want it to be of the greatest
466
463
  possible use to the public, we recommend making it free software that
467
464
  everyone can redistribute and change. You can do so by permitting
468
- redistribution under these terms (or, alternatively, under the terms
469
- of the ordinary General Public License).
470
-
471
- To apply these terms, attach the following notices to the library.
472
- It is safest to attach them to the start of each source file to most
473
- effectively convey the exclusion of warranty; and each file should
474
- have at least the "copyright" line and a pointer to where the full
475
- notice is found.
465
+ redistribution under these terms (or, alternatively, under the terms of the
466
+ ordinary General Public License).
476
467
 
468
+ To apply these terms, attach the following notices to the library. It is
469
+ safest to attach them to the start of each source file to most effectively
470
+ convey the exclusion of warranty; and each file should have at least the
471
+ "copyright" line and a pointer to where the full notice is found.
477
472
 
478
473
  <one line to give the library's name and a brief idea of what it does.>
479
474
  Copyright (C) <year> <name of author>
@@ -490,21 +485,18 @@ notice is found.
490
485
 
491
486
  You should have received a copy of the GNU Lesser General Public
492
487
  License along with this library; if not, write to the Free Software
493
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
488
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
494
489
 
495
490
  Also add information on how to contact you by electronic and paper mail.
496
491
 
497
- You should also get your employer (if you work as a programmer) or
498
- your school, if any, to sign a "copyright disclaimer" for the library,
499
- if necessary. Here is a sample; alter the names:
492
+ You should also get your employer (if you work as a programmer) or your
493
+ school, if any, to sign a "copyright disclaimer" for the library, if
494
+ necessary. Here is a sample; alter the names:
500
495
 
501
496
  Yoyodyne, Inc., hereby disclaims all copyright interest in the
502
- library `Frob' (a library for tweaking knobs) written by James
503
- Random Hacker.
497
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
504
498
 
505
499
  <signature of Ty Coon>, 1 April 1990
506
500
  Ty Coon, President of Vice
507
501
 
508
502
  That's all there is to it!
509
-
510
-
data/NEWS CHANGED
@@ -1,3 +1,9 @@
1
+ 0.6.4 - 2015-04-09
2
+ - use pkg-config to lookup libxml2 header location
3
+
4
+ 0.6.3 - 2014-02-20
5
+ - clean up, restore Ruby 1.8.7 compatibility in tests
6
+
1
7
  0.6.0 - 2014-01-19
2
8
  - merge pull request by mapleoin (https://github.com/mapleoin):
3
9
  raise exceptions instead of returning error codes
data/README.rdoc CHANGED
@@ -1,5 +1,8 @@
1
1
  = Ruby bindings for augeas
2
2
 
3
+ {<img src="https://travis-ci.org/dotdoom/augeas.png?branch=master" alt="Travis CI build results" />}[https://travis-ci.org/dotdoom/augeas]
4
+ {<img src="https://badge.fury.io/rb/augeas.png" alt="Gem Version" />}[http://badge.fury.io/rb/augeas]
5
+
3
6
  The class Augeas provides bindings to augeas [http://augeas.net] library.
4
7
 
5
8
  == Usage: Setting Data
@@ -36,7 +39,12 @@ startup; that allows setting up a custom transform.
36
39
  aug.get("/files/etc/aliases/*[name = 'postmaster']/value")
37
40
  end
38
41
 
39
-
42
+
43
+ == Build Dependencies
44
+
45
+ To build or install this gem manually, headers for libaugeas and libxml are
46
+ needed. Additionally the pkg-config tool has to be installed.
47
+
40
48
  == Deprecation Warning
41
49
 
42
50
  The Augeas API has been heavily rewritten in order to better support
data/Rakefile CHANGED
@@ -1,96 +1,92 @@
1
1
  # -*- ruby -*-
2
+ # Rakefile: build ruby augeas bindings
3
+ #
4
+ # See AUTHORS for the list of authors
5
+ #
6
+ # Distributed under the GNU Lesser General Public License v2.1 or later.
7
+ # See COPYING for details
2
8
 
3
9
  require 'rake/clean'
4
10
  require 'rdoc/task'
5
11
  require 'rake/testtask'
6
12
  require 'rubygems/package_task'
7
13
 
8
- GEM_NAME='augeas'
9
- GEM_VERSION='0.6.0'
10
- EXT_CONF='ext/augeas/extconf.rb'
11
- MAKEFILE="ext/augeas/Makefile"
12
- AUGEAS_MODULE="ext/augeas/_augeas.so"
13
- SPEC_FILE="augeas.spec"
14
- AUGEAS_SRC=AUGEAS_MODULE.gsub(/.so$/, ".c")
14
+ GEM_NAME = 'augeas'
15
+ GEM_VERSION = '0.6.4'
16
+ EXT_CONF = 'ext/augeas/extconf.rb'
17
+ MAKEFILE = 'ext/augeas/Makefile'
18
+ AUGEAS_MODULE = 'ext/augeas/_augeas.so'
19
+ SPEC_FILE = 'augeas.spec'
20
+ AUGEAS_SRC = AUGEAS_MODULE.gsub(/\.so$/, '.c')
15
21
 
16
- #
17
- # Building the actual bits
18
- #
19
- CLEAN.include [ "**/*~",
20
- "ext/**/*.o", AUGEAS_MODULE,
21
- "ext/**/depend" ]
22
+ # Clean - remove all intermediate files / temporary files, do not touch final product.
23
+ CLEAN.include '**/*~',
24
+ 'ext/**/*.o',
25
+ MAKEFILE,
26
+ 'ext/**/depend',
27
+ 'ext/**/mkmf.log'
22
28
 
23
- CLOBBER.include [ "config.save",
24
- "ext/**/mkmf.log",
25
- MAKEFILE ]
29
+ # Clobber - return to original state.
30
+ CLOBBER.include AUGEAS_MODULE
26
31
 
27
32
  file MAKEFILE => EXT_CONF do |t|
28
- Dir::chdir(File::dirname(EXT_CONF)) do
29
- unless sh "ruby #{File::basename(EXT_CONF)}"
30
- $stderr.puts "Failed to run extconf"
31
- break
32
- end
33
- end
33
+ Dir::chdir(File::dirname(EXT_CONF)) do
34
+ unless sh 'ruby', File::basename(EXT_CONF)
35
+ fail 'Failed to run extconf'
36
+ end
37
+ end
34
38
  end
39
+
35
40
  file AUGEAS_MODULE => [ MAKEFILE, AUGEAS_SRC ] do |t|
36
- Dir::chdir(File::dirname(EXT_CONF)) do
37
- unless sh "make"
38
- $stderr.puts "make failed"
39
- break
40
- end
41
- end
41
+ Dir::chdir(File::dirname(EXT_CONF)) do
42
+ unless sh "make"
43
+ fail 'make failed'
44
+ end
45
+ end
42
46
  end
43
- desc "Build the native library"
47
+
48
+ desc 'Build the native library'
44
49
  task :build => AUGEAS_MODULE
45
50
 
46
- #
47
- # Testing
48
- #
49
51
  Rake::TestTask.new(:test) do |t|
50
- t.test_files = FileList['tests/tc_*.rb']
51
- t.libs = [ 'lib', 'ext/augeas' ]
52
+ t.test_files = FileList['tests/tc_*.rb']
53
+ t.libs = ['lib', 'ext/augeas']
52
54
  end
53
55
  task :test => :build
54
56
 
55
57
 
56
- #
57
- # Generate the documentation
58
- #
59
58
  RDoc::Task.new do |rd|
60
- rd.main = "README.rdoc"
61
- rd.rdoc_dir = "doc/site/api"
62
- rd.rdoc_files.include("README.rdoc", "ext/**/*.[ch]","lib/**/*.rb")
59
+ rd.main = "README.rdoc"
60
+ rd.rdoc_dir = "doc/site/api"
61
+ rd.rdoc_files.include("README.rdoc", "ext/**/*.[ch]","lib/**/*.rb")
63
62
  end
64
63
 
65
- #
66
- # Packaging
67
- #
68
64
  PKG_FILES = FileList[
69
- "Rakefile", "COPYING","README.rdoc", "NEWS",
70
- "ext/**/*.[ch]", "lib/**/*.rb", "ext/**/MANIFEST", "ext/**/extconf.rb",
71
- "tests/**/*",
72
- "spec/**/*"
65
+ "Rakefile", "COPYING","README.rdoc", "NEWS",
66
+ "ext/**/*.[ch]", "lib/**/*.rb", "ext/**/MANIFEST", "ext/**/extconf.rb",
67
+ "tests/**/*",
68
+ "spec/**/*"
73
69
  ]
74
70
 
75
71
  SPEC = Gem::Specification.new do |s|
76
- s.name = GEM_NAME
77
- s.version = GEM_VERSION
78
- s.email = "dot.doom@gmail.com"
79
- s.homepage = "http://augeas.net/"
80
- s.summary = "Ruby bindings for augeas"
81
- s.authors = [ "Bryan Kearney", "David Lutterkort", "Ionut Artarisi", "Artem Sheremet" ]
82
- s.files = PKG_FILES
83
- s.licenses = ['LGPLv2']
84
- s.required_ruby_version = '>= 1.8.7'
85
- s.extensions = "ext/augeas/extconf.rb"
86
- s.description = "Provides bindings for augeas."
87
- s.add_development_dependency "rake"
88
- s.add_development_dependency "rdoc"
72
+ s.name = GEM_NAME
73
+ s.version = GEM_VERSION
74
+ s.email = "dot.doom@gmail.com"
75
+ s.homepage = "https://github.com/dotdoom/augeas"
76
+ s.summary = "Ruby bindings for augeas"
77
+ s.authors = File.read('AUTHORS').lines.grep(/^ /).map { |a| a[/[^<]+/].strip }.uniq
78
+ s.files = PKG_FILES
79
+ s.licenses = ['LGPL-2.1+']
80
+ s.required_ruby_version = '>= 1.8.7'
81
+ s.extensions = "ext/augeas/extconf.rb"
82
+ s.description = "A fork of ruby-augeas (bindings for augeas) with exceptions support."
83
+ s.add_development_dependency "rake"
84
+ s.add_development_dependency "rdoc"
89
85
  end
90
86
 
91
87
  Gem::PackageTask.new(SPEC) do |pkg|
92
- pkg.need_tar = true
93
- pkg.need_zip = true
88
+ pkg.need_tar = true
89
+ pkg.need_zip = true
94
90
  end
95
91
 
96
92
  task :default => [:build, :test]
data/ext/augeas/_augeas.c CHANGED
@@ -25,6 +25,7 @@
25
25
 
26
26
  #include <ruby.h>
27
27
  #include <augeas.h>
28
+ #include <errno.h>
28
29
 
29
30
  static VALUE c_augeas;
30
31
 
@@ -54,12 +55,12 @@ VALUE augeas_get(VALUE s, VALUE path) {
54
55
  const char *cpath = StringValueCStr(path);
55
56
  const char *value = NULL;
56
57
 
57
- int retval = aug_get(aug, cpath, &value);
58
+ int retval = aug_get(aug, cpath, &value);
58
59
 
59
60
  if (retval == 1 && value != NULL) {
60
- return rb_str_new(value, strlen(value));
61
+ return rb_str_new(value, strlen(value));
61
62
  } else {
62
- return Qnil;
63
+ return Qnil;
63
64
  }
64
65
  }
65
66
 
@@ -94,30 +95,6 @@ VALUE augeas_set(VALUE s, VALUE path, VALUE value) {
94
95
  return INT2FIX(callValue);
95
96
  }
96
97
 
97
- /*
98
- * call-seq:
99
- * set(PATH, VALUE) -> boolean
100
- *
101
- * Set the value associated with PATH to VALUE. VALUE is copied into the
102
- * internal data structure. Intermediate entries are created if they don't
103
- * exist.
104
- */
105
- VALUE augeas_set_old(VALUE s, VALUE path, VALUE value) {
106
- augeas *aug = aug_handle(s);
107
- const char *cpath = StringValueCStr(path) ;
108
- const char *cvalue = StringValueCStrOrNull(value) ;
109
-
110
- int callValue = aug_set(aug, cpath, cvalue) ;
111
- VALUE returnValue ;
112
-
113
- if (callValue == 0)
114
- returnValue = Qtrue ;
115
- else
116
- returnValue = Qfalse ;
117
-
118
- return returnValue ;
119
- }
120
-
121
98
  /*
122
99
  * call-seq:
123
100
  * setm(BASE, SUB, VALUE) -> boolean
@@ -214,35 +191,6 @@ VALUE augeas_match(VALUE s, VALUE p) {
214
191
  return result ;
215
192
  }
216
193
 
217
- /*
218
- * call-seq:
219
- * match(PATH) -> an_array
220
- *
221
- * Return all the paths that match the path expression PATH as an aray of
222
- * strings.
223
- * Raises an error if no paths were found.
224
- */
225
- VALUE augeas_match_old(VALUE s, VALUE p) {
226
- augeas *aug = aug_handle(s);
227
- const char *path = StringValueCStr(p);
228
- char **matches = NULL;
229
- int cnt, i;
230
-
231
- cnt = aug_match(aug, path, &matches) ;
232
- if (cnt < 0)
233
- rb_raise(rb_eSystemCallError, "Matching path expression '%s' failed",
234
- path);
235
-
236
- VALUE result = rb_ary_new();
237
- for (i = 0; i < cnt; i++) {
238
- rb_ary_push(result, rb_str_new(matches[i], strlen(matches[i])));
239
- free(matches[i]) ;
240
- }
241
- free (matches) ;
242
-
243
- return result ;
244
- }
245
-
246
194
  /*
247
195
  * call-seq:
248
196
  * save() -> int
@@ -255,25 +203,6 @@ VALUE augeas_save(VALUE s) {
255
203
  return INT2FIX(callValue);
256
204
  }
257
205
 
258
- /*
259
- * call-seq:
260
- * save() -> boolean
261
- *
262
- * Write all pending changes to disk
263
- */
264
- VALUE augeas_save_old(VALUE s) {
265
- augeas *aug = aug_handle(s);
266
- int callValue = aug_save(aug) ;
267
- VALUE returnValue ;
268
-
269
- if (callValue == 0)
270
- returnValue = Qtrue ;
271
- else
272
- returnValue = Qfalse ;
273
-
274
- return returnValue ;
275
- }
276
-
277
206
  /*
278
207
  * call-seq:
279
208
  * load() -> int
@@ -286,25 +215,6 @@ VALUE augeas_load(VALUE s) {
286
215
  return INT2FIX(callValue);
287
216
  }
288
217
 
289
- /*
290
- * call-seq:
291
- * load() -> boolean
292
- *
293
- * Load files from disk according to the transforms under +/augeas/load+
294
- */
295
- VALUE augeas_load_old(VALUE s) {
296
- augeas *aug = aug_handle(s);
297
- int callValue = aug_load(aug);
298
- VALUE returnValue ;
299
-
300
- if (callValue == 0)
301
- returnValue = Qtrue ;
302
- else
303
- returnValue = Qfalse ;
304
-
305
- return returnValue ;
306
- }
307
-
308
218
  /*
309
219
  * call-seq:
310
220
  * defvar(NAME, EXPR) -> boolean
@@ -355,10 +265,7 @@ VALUE augeas_defnode(VALUE s, VALUE name, VALUE expr, VALUE value) {
355
265
  return (r < 0) ? Qfalse : INT2NUM(r);
356
266
  }
357
267
 
358
- /* This function returns different names for different augeas API */
359
- /* version specified in the +version+ argument. See augeas_init_old and */
360
- /* augeas_init. */
361
- VALUE augeas_init_split(VALUE m, VALUE r, VALUE l, VALUE f, char version) {
268
+ VALUE augeas_init(VALUE m, VALUE r, VALUE l, VALUE f) {
362
269
  unsigned int flags = NUM2UINT(f);
363
270
  const char *root = StringValueCStrOrNull(r);
364
271
  const char *loadpath = StringValueCStrOrNull(l);
@@ -366,19 +273,11 @@ VALUE augeas_init_split(VALUE m, VALUE r, VALUE l, VALUE f, char version) {
366
273
 
367
274
  aug = aug_init(root, loadpath, flags);
368
275
  if (aug == NULL) {
369
- rb_raise(rb_eSystemCallError, "Failed to initialize Augeas");
276
+ rb_raise(rb_eSystemCallError, "Failed to initialize Augeas (%d)", errno);
370
277
  }
371
278
  return Data_Wrap_Struct(c_augeas, NULL, augeas_free, aug);
372
279
  }
373
280
 
374
- VALUE augeas_init_old(VALUE m, VALUE r, VALUE l, VALUE f) {
375
- return augeas_init_split(m, r, l, f, 0);
376
- }
377
- VALUE augeas_init(VALUE m, VALUE r, VALUE l, VALUE f) {
378
- return augeas_init_split(m, r, l, f, 1);
379
- }
380
-
381
-
382
281
  VALUE augeas_close (VALUE s) {
383
282
  augeas *aug = aug_handle(s);
384
283
 
@@ -590,6 +489,7 @@ void Init__augeas() {
590
489
  DEF_AUG_FLAG(NO_LOAD);
591
490
  DEF_AUG_FLAG(NO_MODL_AUTOLOAD);
592
491
  DEF_AUG_FLAG(ENABLE_SPAN);
492
+ DEF_AUG_FLAG(NO_ERR_CLOSE);
593
493
  #undef DEF_AUG_FLAG
594
494
 
595
495
  /* Constants for enum aug_errcode_t */
@@ -607,8 +507,8 @@ void Init__augeas() {
607
507
  DEF_AUG_ERR(ENOSPAN);
608
508
  DEF_AUG_ERR(EMVDESC);
609
509
  DEF_AUG_ERR(ECMDRUN);
610
- DEF_AUG_ERR(EBADARG);
611
- DEF_AUG_ERR(ELABEL);
510
+ DEF_AUG_ERR(EBADARG);
511
+ DEF_AUG_ERR(ELABEL);
612
512
  #undef DEF_AUG_ERR
613
513
 
614
514
  /* Define the methods */
@@ -43,4 +43,6 @@ unless have_library("xml2")
43
43
  raise "libxml2 is not installed"
44
44
  end
45
45
 
46
+ pkg_config('libxml-2.0')
47
+
46
48
  create_makefile(extension_name)
data/lib/augeas.rb CHANGED
@@ -43,23 +43,23 @@ class Augeas
43
43
  class CommandExecutionError < Error; end
44
44
  class InvalidArgumentError < Error; end
45
45
  class InvalidLabelError < Error; end
46
- @@error_hash = {
46
+ ERRORS_HASH = Hash[{
47
47
  # the cryptic error names come from the C library, we just make
48
48
  # them more ruby and more human
49
- ENOMEM => NoMemoryError,
50
- EINTERNAL => InternalError,
51
- EPATHX => InvalidPathError,
52
- ENOMATCH => NoMatchError,
53
- EMMATCH => MultipleMatchesError,
54
- ESYNTAX => LensSyntaxError,
55
- ENOLENS => LensNotFoundError,
56
- EMXFM => MultipleTransformsError,
57
- ENOSPAN => NoSpanInfoError,
58
- EMVDESC => DescendantError,
59
- ECMDRUN => CommandExecutionError,
60
- EBADARG => InvalidArgumentError,
61
- ELABEL => InvalidLabelError,
62
- }
49
+ :ENOMEM => NoMemoryError,
50
+ :EINTERNAL => InternalError,
51
+ :EPATHX => InvalidPathError,
52
+ :ENOMATCH => NoMatchError,
53
+ :EMMATCH => MultipleMatchesError,
54
+ :ESYNTAX => LensSyntaxError,
55
+ :ENOLENS => LensNotFoundError,
56
+ :EMXFM => MultipleTransformsError,
57
+ :ENOSPAN => NoSpanInfoError,
58
+ :EMVDESC => DescendantError,
59
+ :ECMDRUN => CommandExecutionError,
60
+ :EBADARG => InvalidArgumentError,
61
+ :ELABEL => InvalidLabelError,
62
+ }.map { |k, v| [(const_get(k) rescue nil), v] }].freeze
63
63
 
64
64
  # Create a new Augeas instance and return it.
65
65
  #
@@ -101,7 +101,7 @@ class Augeas
101
101
  # aug_flags is a bitmask in the underlying library, we add all the
102
102
  # values of the flags which were set to true to the default value
103
103
  # Augeas::NONE (which is 0)
104
- aug_flags = Augeas::NONE
104
+ aug_flags = defined?(Augeas::NO_ERR_CLOSE) ? Augeas::NO_ERR_CLOSE : Augeas::NONE
105
105
 
106
106
  flags = {
107
107
  :type_check => Augeas::TYPE_CHECK,
@@ -117,10 +117,10 @@ class Augeas
117
117
  }
118
118
  opts.each_key do |key|
119
119
  if flags.key? key
120
- aug_flags += flags[key]
120
+ aug_flags |= flags[key]
121
121
  elsif key == :save_mode
122
122
  if save_modes[opts[:save_mode]]
123
- aug_flags += save_modes[opts[:save_mode]]
123
+ aug_flags |= save_modes[opts[:save_mode]]
124
124
  else
125
125
  raise ArgumentError, "Invalid save mode #{opts[:save_mode]}."
126
126
  end
@@ -131,6 +131,13 @@ class Augeas
131
131
 
132
132
  aug = Augeas::open3(opts[:root], opts[:loadpath], aug_flags)
133
133
 
134
+ begin
135
+ aug.send(:raise_last_error)
136
+ rescue
137
+ aug.close
138
+ raise
139
+ end
140
+
134
141
  if block_given?
135
142
  begin
136
143
  yield aug
@@ -248,8 +255,8 @@ class Augeas
248
255
  begin
249
256
  run_command :augeas_save
250
257
  rescue Augeas::CommandExecutionError => e
251
- raise e, "Saving failed. Search the augeas tree in /augeas//error"+
252
- "for the actual errors."
258
+ raise e, 'Saving failed. Search the augeas tree in /augeas//error ' <<
259
+ 'for the actual errors.'
253
260
  end
254
261
 
255
262
  nil
@@ -366,11 +373,7 @@ class Augeas
366
373
  def run_command(cmd, *params)
367
374
  result = self.send cmd, *params
368
375
 
369
- errcode = error[:code]
370
- unless errcode.zero?
371
- raise @@error_hash[errcode],
372
- "#{error[:message]} #{error[:details]}"
373
- end
376
+ raise_last_error
374
377
 
375
378
  if result.kind_of? Fixnum and result < 0
376
379
  # we raise CommandExecutionError here, because this is the error that
@@ -380,4 +383,11 @@ class Augeas
380
383
 
381
384
  return result
382
385
  end
386
+
387
+ def raise_last_error
388
+ error_cache = error
389
+ unless error_cache[:code].zero?
390
+ raise ERRORS_HASH[error_cache[:code]], "#{error_cache[:message]} #{error_cache[:details]}"
391
+ end
392
+ end
383
393
  end
data/tests/tc_augeas.rb CHANGED
@@ -87,57 +87,6 @@ class TestAugeas < Test::Unit::TestCase
87
87
  assert_equal(foo, 'bar')
88
88
  end
89
89
 
90
- def test_load
91
- aug = aug_create(no_load: true)
92
- assert_equal([], aug.match("/files/etc/*"))
93
- aug.rm("/augeas/load/*");
94
- assert_nothing_raised {
95
- aug.load
96
- }
97
- assert_equal([], aug.match("/files/etc/*"))
98
- end
99
-
100
- def test_transform
101
- aug = aug_create(no_load: true)
102
- aug.clear_transforms
103
- aug.transform(:lens => "Hosts.lns",
104
- :incl => "/etc/hosts")
105
- assert_raise(ArgumentError) {
106
- aug.transform(:name => "Fstab",
107
- :incl => [ "/etc/fstab" ],
108
- :excl => [ "*~", "*.rpmnew" ])
109
- }
110
- aug.transform(:lens => "Inittab",
111
- :incl => "/etc/inittab")
112
- aug.transform(:lens => "Fstab.lns",
113
- :incl => "/etc/fstab*",
114
- :excl => "*~")
115
- assert_equal(["/augeas/load/Fstab", "/augeas/load/Fstab/excl",
116
- "/augeas/load/Fstab/incl", "/augeas/load/Fstab/lens",
117
- "/augeas/load/Hosts", "/augeas/load/Hosts/incl",
118
- "/augeas/load/Hosts/lens", "/augeas/load/Inittab",
119
- "/augeas/load/Inittab/incl",
120
- "/augeas/load/Inittab/lens"],
121
- aug.match("/augeas/load//*").sort)
122
- aug.load
123
- assert_equal(["/files/etc/hosts", "/files/etc/inittab"],
124
- aug.match("/files/etc/*").sort)
125
- end
126
-
127
- def test_defvar
128
- Augeas::create(root: "/dev/null") do |aug|
129
- aug.set("/a/b", "bval")
130
- aug.set("/a/c", "cval")
131
- assert aug.defvar("var", "/a/b")
132
- assert_equal(["/a/b"], aug.match("$var"))
133
- assert aug.defvar("var", nil)
134
- assert_raises(SystemCallError) {
135
- aug.match("$var")
136
- }
137
- assert ! aug.defvar("var", "/foo/")
138
- end
139
- end
140
-
141
90
  def test_close
142
91
  aug = Augeas::create(:root => "/tmp", :save_mode => :newfile)
143
92
  assert_equal("newfile", aug.get("/augeas/save"))
@@ -273,19 +222,15 @@ class TestAugeas < Test::Unit::TestCase
273
222
  assert aug.defvar("var", "/a/b")
274
223
  assert_equal(["/a/b"], aug.match("$var"))
275
224
  assert aug.defvar("var", nil)
276
- assert_raises(SystemCallError) {
225
+ assert_raises(Augeas::InvalidPathError) {
277
226
  aug.match("$var")
278
227
  }
279
- assert ! aug.defvar("var", "/foo/")
228
+ assert_raises(Augeas::InvalidPathError) {
229
+ aug.defvar("var", "/foo/")
230
+ }
280
231
  end
281
232
  end
282
233
 
283
- def test_defnode
284
- aug = aug_create
285
- assert aug.defnode("x", "/files/etc/hosts/*[ipaddr = '127.0.0.1']", nil)
286
- assert_equal(["/files/etc/hosts/1"], aug.match("$x"))
287
- end
288
-
289
234
  def test_insert_before
290
235
  aug = aug_create
291
236
  aug.set("/parent/child", "foo")
@@ -383,20 +328,6 @@ class TestAugeas < Test::Unit::TestCase
383
328
  assert_equal(aug.get("/files/etc/group/disk/user"), nil)
384
329
  end
385
330
 
386
- def test_setm
387
- aug = aug_create
388
-
389
- aug.setm("/files/etc/group/*[label() =~ regexp(\"rpc.*\")]",
390
- "users", "testuser1")
391
- assert_equal(aug.get("/files/etc/group/rpc/users"), "testuser1")
392
- assert_equal(aug.get("/files/etc/group/rpcuser/users"), "testuser1")
393
-
394
- aug.setm("/files/etc/group/*[label() =~ regexp(\"rpc.*\")]/users",
395
- nil, "testuser2")
396
- assert_equal(aug.get("/files/etc/group/rpc/users"), "testuser2")
397
- assert_equal(aug.get("/files/etc/group/rpcuser/users"), "testuser2")
398
- end
399
-
400
331
  def test_setm_invalid_path
401
332
  aug = aug_create
402
333
  assert_raises (Augeas::InvalidPathError) { aug.setm("[]", "bar", "baz") }
@@ -438,16 +369,6 @@ class TestAugeas < Test::Unit::TestCase
438
369
  assert err[:details]
439
370
  end
440
371
 
441
- def test_defvar
442
- Augeas::create(:root => "/dev/null") do |aug|
443
- aug.set("/a/b", "bval")
444
- aug.set("/a/c", "cval")
445
- assert aug.defvar("var", "/a/b")
446
- assert_equal(["/a/b"], aug.match("$var"))
447
- assert aug.defvar("var", nil)
448
- end
449
- end
450
-
451
372
  def test_defvar_invalid_path
452
373
  aug = aug_create
453
374
  assert_raises(Augeas::InvalidPathError) { aug.defvar('var', 'F#@!$#@') }
@@ -464,20 +385,6 @@ class TestAugeas < Test::Unit::TestCase
464
385
  assert_raises (Augeas::InvalidPathError) { aug.defnode('x', '//', nil)}
465
386
  end
466
387
 
467
- def test_span
468
- aug = aug_create
469
-
470
- aug.set("/augeas/span", "enable")
471
- aug.rm("/files/etc")
472
- aug.load
473
-
474
- span = aug.span("/files/etc/ssh/sshd_config/Protocol")
475
- assert_not_nil(span[:filename])
476
- assert_equal(29..37, span[:label])
477
- assert_equal(38..39, span[:value])
478
- assert_equal(29..40, span[:span])
479
- end
480
-
481
388
  def test_span_no_span_info
482
389
  aug = aug_create
483
390
  # this error should be raised because we haven't enabled the span
@@ -510,28 +417,6 @@ class TestAugeas < Test::Unit::TestCase
510
417
  assert_equal("enable", aug.get("/augeas/span"))
511
418
  end
512
419
 
513
- def test_set
514
- aug = aug_create
515
- aug.set("/files/etc/group/disk/user[last()+1]",["user1","user2"])
516
- assert_equal( aug.get("/files/etc/group/disk/user[1]"),"root" )
517
- assert_equal( aug.get("/files/etc/group/disk/user[2]"),"user1" )
518
- assert_equal( aug.get("/files/etc/group/disk/user[3]"),"user2" )
519
-
520
- aug.set("/files/etc/group/new_group/user[last()+1]",
521
- "nuser1",["nuser2","nuser3"])
522
- assert_equal( aug.get("/files/etc/group/new_group/user[1]"),"nuser1")
523
- assert_equal( aug.get("/files/etc/group/new_group/user[2]"),"nuser2" )
524
- assert_equal( aug.get("/files/etc/group/new_group/user[3]"),"nuser3" )
525
-
526
- aug.rm("/files/etc/group/disk/user")
527
- aug.set("/files/etc/group/disk/user[last()+1]","testuser")
528
- assert_equal( aug.get("/files/etc/group/disk/user"),"testuser")
529
-
530
- aug.rm("/files/etc/group/disk/user")
531
- aug.set("/files/etc/group/disk/user[last()+1]", nil)
532
- assert_equal( aug.get("/files/etc/group/disk/user"), nil)
533
- end
534
-
535
420
  def test_setm
536
421
  aug = aug_create
537
422
 
@@ -587,14 +472,14 @@ class TestAugeas < Test::Unit::TestCase
587
472
  end
588
473
 
589
474
  def test_label
590
- Augeas::create(root: "/dev/null") do |aug|
475
+ Augeas::create(:root => "/dev/null") do |aug|
591
476
  assert_equal 'augeas', aug.label('/augeas')
592
477
  assert_equal 'files', aug.label('/files')
593
478
  end
594
479
  end
595
480
 
596
481
  def test_rename
597
- Augeas::create(root: "/dev/null") do |aug|
482
+ Augeas::create(:root => "/dev/null") do |aug|
598
483
  assert_raises(Augeas::InvalidLabelError) { aug.rename('/files', 'invalid/label') }
599
484
  assert_equal 0, aug.rename('/nonexistent', 'label')
600
485
  assert_equal ['/files'], aug.match('/files')
@@ -603,7 +488,7 @@ class TestAugeas < Test::Unit::TestCase
603
488
  end
604
489
 
605
490
  def test_text_store_retrieve
606
- Augeas::create(root: "/dev/null") do |aug|
491
+ Augeas::create(:root => "/dev/null") do |aug|
607
492
  # text_store errors
608
493
  assert_raises(Augeas::NoMatchError) { aug.text_store('Simplelines.lns', '/input', '/store') }
609
494
 
@@ -623,7 +508,7 @@ class TestAugeas < Test::Unit::TestCase
623
508
  end
624
509
 
625
510
  def test_context
626
- Augeas::create(root: "/dev/null") do |aug|
511
+ Augeas::create(:root => "/dev/null") do |aug|
627
512
  aug.context = '/augeas'
628
513
  assert_equal '/augeas', aug.get('/augeas/context')
629
514
  assert_equal '/augeas', aug.get('context')
@@ -632,7 +517,7 @@ class TestAugeas < Test::Unit::TestCase
632
517
  end
633
518
 
634
519
  def test_touch
635
- Augeas::create(root: "/dev/null") do |aug|
520
+ Augeas::create(:root => "/dev/null") do |aug|
636
521
  assert_equal [], aug.match('/foo')
637
522
  aug.touch '/foo'
638
523
  assert_equal ['/foo'], aug.match('/foo')
@@ -644,7 +529,7 @@ class TestAugeas < Test::Unit::TestCase
644
529
  end
645
530
 
646
531
  def test_clearm
647
- Augeas::create(root: "/dev/null") do |aug|
532
+ Augeas::create(:root => "/dev/null") do |aug|
648
533
  aug.set('/foo/a', '1')
649
534
  aug.set('/foo/b', '2')
650
535
  aug.clearm('/foo', '*')
metadata CHANGED
@@ -1,69 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: augeas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Kearney
8
8
  - David Lutterkort
9
- - Ionut Artarisi
9
+ - Dominic Cleal
10
+ - Raphaël Pinson
10
11
  - Artem Sheremet
12
+ - Frederik Wagner
13
+ - Ben
14
+ - Ionuț Arțăriși
15
+ - Jacob McCann
11
16
  autorequire:
12
17
  bindir: bin
13
18
  cert_chain: []
14
- date: 2014-01-18 00:00:00.000000000 Z
19
+ date: 2015-08-03 00:00:00.000000000 Z
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: rake
18
23
  requirement: !ruby/object:Gem::Requirement
19
24
  requirements:
20
- - - '>='
25
+ - - ">="
21
26
  - !ruby/object:Gem::Version
22
27
  version: '0'
23
28
  type: :development
24
29
  prerelease: false
25
30
  version_requirements: !ruby/object:Gem::Requirement
26
31
  requirements:
27
- - - '>='
32
+ - - ">="
28
33
  - !ruby/object:Gem::Version
29
34
  version: '0'
30
35
  - !ruby/object:Gem::Dependency
31
36
  name: rdoc
32
37
  requirement: !ruby/object:Gem::Requirement
33
38
  requirements:
34
- - - '>='
39
+ - - ">="
35
40
  - !ruby/object:Gem::Version
36
41
  version: '0'
37
42
  type: :development
38
43
  prerelease: false
39
44
  version_requirements: !ruby/object:Gem::Requirement
40
45
  requirements:
41
- - - '>='
46
+ - - ">="
42
47
  - !ruby/object:Gem::Version
43
48
  version: '0'
44
- description: Provides bindings for augeas.
49
+ description: A fork of ruby-augeas (bindings for augeas) with exceptions support.
45
50
  email: dot.doom@gmail.com
46
51
  executables: []
47
52
  extensions:
48
53
  - ext/augeas/extconf.rb
49
54
  extra_rdoc_files: []
50
55
  files:
51
- - Rakefile
52
56
  - COPYING
53
- - README.rdoc
54
57
  - NEWS
58
+ - README.rdoc
59
+ - Rakefile
55
60
  - ext/augeas/_augeas.c
56
61
  - ext/augeas/_augeas.h
57
- - lib/augeas.rb
58
62
  - ext/augeas/extconf.rb
63
+ - lib/augeas.rb
59
64
  - tests/root/etc/group
60
65
  - tests/root/etc/hosts
61
66
  - tests/root/etc/inittab
62
67
  - tests/root/etc/ssh/sshd_config
63
68
  - tests/tc_augeas.rb
64
- homepage: http://augeas.net/
69
+ homepage: https://github.com/dotdoom/augeas
65
70
  licenses:
66
- - LGPLv2
71
+ - LGPL-2.1+
67
72
  metadata: {}
68
73
  post_install_message:
69
74
  rdoc_options: []
@@ -71,17 +76,17 @@ require_paths:
71
76
  - lib
72
77
  required_ruby_version: !ruby/object:Gem::Requirement
73
78
  requirements:
74
- - - '>='
79
+ - - ">="
75
80
  - !ruby/object:Gem::Version
76
81
  version: 1.8.7
77
82
  required_rubygems_version: !ruby/object:Gem::Requirement
78
83
  requirements:
79
- - - '>='
84
+ - - ">="
80
85
  - !ruby/object:Gem::Version
81
86
  version: '0'
82
87
  requirements: []
83
88
  rubyforge_project:
84
- rubygems_version: 2.0.14
89
+ rubygems_version: 2.4.3
85
90
  signing_key:
86
91
  specification_version: 4
87
92
  summary: Ruby bindings for augeas