Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package rubygem-gyoku for openSUSE:Factory 
checked in at 2022-05-02 16:24:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-gyoku (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-gyoku.new.1538 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-gyoku"

Mon May  2 16:24:42 2022 rev:2 rq:974049 version:1.4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-gyoku/rubygem-gyoku.changes      
2017-07-28 09:46:58.537901839 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-gyoku.new.1538/rubygem-gyoku.changes    
2022-05-02 16:24:45.644784244 +0200
@@ -1,0 +2,33 @@
+Thu Apr 28 05:32:19 UTC 2022 - Stephan Kulow <co...@suse.com>
+
+updated to version 1.4.0
+ see installed CHANGELOG.md
+
+  # CHANGELOG
+  
+  ## 1.4.0 (2022-04-01)
+  
+  ### Fixed
+  
+  - Fix [Issue #56](https://github.com/savonrb/gyoku/issue/56) with PR 
[#57](https://github.com/savonrb/gyoku/pull/57). Thanks, [@jpmoral]!
+  - Avoid circular reference [#69](https://github.com/savonrb/gyoku/pull/69), 
thanks [@ccarruitero]!
+  
+  ### Added
+  
+  - Unwrap specific keys [#54](https://github.com/savonrb/gyoku/pull/54), by 
[@rlburkes]. Documented by [@mahemoff]. Thanks to you both!
+  - Add `:pretty_print`, `:indent` and `:compact` options to allow prettified 
XML output. [#59](https://github.com/savonrb/gyoku/pull/59), by [@Jeiwan]. 
Thanks!
+  
+  ### Changed
+  
+  - Removed Rubinius support, by [@olleolleolle]
+  - Clean-up, CI setup, and changelog authoring, by [@olleolleolle]
+  
+  [@jpmoral]: https://github.com/jpmoral
+  [@ccarruitero]: https://github.com/ccarruitero
+  [@rlburkes]: https://github.com/rlburkes
+  [@mahemoff]: https://github.com/mahemoff
+  [@Jeiwan]: https://github.com/Jeiwan
+  [@olleolleolle]: https://github.com/olleolleolle
+  
+
+-------------------------------------------------------------------

Old:
----
  gyoku-1.3.1.gem

New:
----
  gyoku-1.4.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-gyoku.spec ++++++
--- /var/tmp/diff_new_pack.Ks0c2u/_old  2022-05-02 16:24:46.300784974 +0200
+++ /var/tmp/diff_new_pack.Ks0c2u/_new  2022-05-02 16:24:46.308784983 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-gyoku
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,7 +12,7 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-gyoku
-Version:        1.3.1
+Version:        1.4.0
 Release:        0
 %define mod_name gyoku
 %define mod_full_name %{mod_name}-%{version}
@@ -32,8 +32,8 @@
 BuildRequires:  %{ruby >= 1.9.2}
 BuildRequires:  %{rubygem gem2rpm}
 BuildRequires:  ruby-macros >= 5
-Url:            https://github.com/savonrb/gyoku
-Source:         http://rubygems.org/gems/%{mod_full_name}.gem
+URL:            https://github.com/savonrb/gyoku
+Source:         https://rubygems.org/gems/%{mod_full_name}.gem
 Source1:        gem2rpm.yml
 Summary:        Translates Ruby Hashes to XML
 License:        MIT

++++++ gyoku-1.3.1.gem -> gyoku-1.4.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/.github/workflows/ci.yml new/.github/workflows/ci.yml
--- old/.github/workflows/ci.yml        1970-01-01 01:00:00.000000000 +0100
+++ new/.github/workflows/ci.yml        2022-04-01 10:37:57.000000000 +0200
@@ -0,0 +1,30 @@
+name: CI
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  test:
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        ruby-version:
+          - 3.1
+          - "3.0"
+          - 2.7
+          - 2.6
+
+    steps:
+      - uses: actions/checkout@v3
+      - name: Set up Ruby ${{ matrix.ruby-version }}
+        uses: ruby/setup-ruby@v1
+        with:
+          ruby-version: ${{ matrix.ruby-version }}
+          bundler-cache: true # runs 'bundle install' and caches installed 
gems automatically
+      - name: Run tests
+        run: bundle exec rake
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml     2015-04-05 03:08:01.000000000 +0200
+++ new/.travis.yml     1970-01-01 01:00:00.000000000 +0100
@@ -1,9 +0,0 @@
-language: "ruby"
-script: "bundle exec rake"
-rvm:
-  - 1.9.3
-  - 2.0.0
-  - 2.1
-  - 2.2
-  - jruby-19mode
-  - rbx-2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2015-04-05 03:08:01.000000000 +0200
+++ new/CHANGELOG.md    2022-04-01 10:37:57.000000000 +0200
@@ -1,3 +1,29 @@
+# CHANGELOG
+
+## 1.4.0 (2022-04-01)
+
+### Fixed
+
+- Fix [Issue #56](https://github.com/savonrb/gyoku/issue/56) with PR 
[#57](https://github.com/savonrb/gyoku/pull/57). Thanks, [@jpmoral]!
+- Avoid circular reference [#69](https://github.com/savonrb/gyoku/pull/69), 
thanks [@ccarruitero]!
+
+### Added
+
+- Unwrap specific keys [#54](https://github.com/savonrb/gyoku/pull/54), by 
[@rlburkes]. Documented by [@mahemoff]. Thanks to you both!
+- Add `:pretty_print`, `:indent` and `:compact` options to allow prettified 
XML output. [#59](https://github.com/savonrb/gyoku/pull/59), by [@Jeiwan]. 
Thanks!
+
+### Changed
+
+- Removed Rubinius support, by [@olleolleolle]
+- Clean-up, CI setup, and changelog authoring, by [@olleolleolle]
+
+[@jpmoral]: https://github.com/jpmoral
+[@ccarruitero]: https://github.com/ccarruitero
+[@rlburkes]: https://github.com/rlburkes
+[@mahemoff]: https://github.com/mahemoff
+[@Jeiwan]: https://github.com/Jeiwan
+[@olleolleolle]: https://github.com/olleolleolle
+
 ## 1.3.1 (2015-04-05)
 
 * Feature: [#53](https://github.com/savonrb/gyoku/pull/53) Improved 
serialization of hashes nested in arrays. Thanks to @riburkes for this!
@@ -8,7 +34,7 @@
 
 ## 1.2.3 (2015-03-10)
 
-# Feature: [#52](https://github.com/savonrb/gyoku/pull/52) Adds an :unwrap 
option that allows an array of hashes to be unwrapped into a single array xml 
node, rather than one per hash.
+* Feature: [#52](https://github.com/savonrb/gyoku/pull/52) Adds an :unwrap 
option that allows an array of hashes to be unwrapped into a single array xml 
node, rather than one per hash.
 
 ## 1.2.2 (2014-09-22)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Gemfile new/Gemfile
--- old/Gemfile 2015-04-05 03:08:01.000000000 +0200
+++ new/Gemfile 2022-04-01 10:37:57.000000000 +0200
@@ -1,12 +1,6 @@
 source 'https://rubygems.org'
+
 gemspec
 
 gem 'simplecov', :require => false
 gem 'coveralls', :require => false
-
-platform :rbx do
-  gem 'json'
-  gem 'racc'
-  gem 'rubysl'
-  gem 'rubinius-coverage'
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2015-04-05 03:08:01.000000000 +0200
+++ new/README.md       2022-04-01 10:37:57.000000000 +0200
@@ -7,10 +7,10 @@
 # => "<findUser><id>123</id><v1:Key>api</v1:Key></findUser>"
 ```
 
-[![Build 
Status](https://secure.travis-ci.org/savonrb/gyoku.png?branch=master)](http://travis-ci.org/savonrb/gyoku)
-[![Gem 
Version](https://badge.fury.io/rb/gyoku.png)](http://badge.fury.io/rb/gyoku)
-[![Code 
Climate](https://codeclimate.com/github/savonrb/gyoku.png)](https://codeclimate.com/github/savonrb/gyoku)
-[![Coverage 
Status](https://coveralls.io/repos/savonrb/gyoku/badge.png?branch=master)](https://coveralls.io/r/savonrb/gyoku)
+[![Build 
status](https://github.com/savonrb/gyoku/actions/workflows/ci.yml/badge.svg)](https://github.com/savonrb/gyoku/actions/workflows/ci.yml)
+[![Gem 
Version](https://badge.fury.io/rb/gyoku.svg)](http://badge.fury.io/rb/gyoku)
+[![Code 
Climate](https://codeclimate.com/github/savonrb/gyoku.svg)](https://codeclimate.com/github/savonrb/gyoku)
+[![Coverage 
Status](https://coveralls.io/repos/savonrb/gyoku/badge.svg?branch=master)](https://coveralls.io/r/savonrb/gyoku)
 
 
 ## Installation
@@ -45,6 +45,16 @@
 # => "<CamelCase>key</CamelCase>"
 ```
 
+Custom key converters. You can use a lambda/Proc to provide customer key 
converters.
+This is a great way to leverage active support inflections for domain specific 
acronyms.
+
+``` ruby
+# Use camelize lower which will hook into active support if installed.
+Gyoku.xml({ acronym_abc: "value" }, key_converter: lambda { |key| 
key.camelize(:lower) })
+# => "<acronymABC>value</acronymABC>"
+
+```
+
 Hash key Strings are not converted and may contain namespaces.
 
 ``` ruby
@@ -62,6 +72,21 @@
 * These conventions are also applied to the return value of objects responding 
to :call
 * All other objects are converted to Strings using :to_s
 
+## Array values
+
+Array items are by default wrapped with the containiner tag, which may be 
unexpected.
+
+``` ruby
+> Gyoku.xml({languages: [{language: 'ruby'},{language: 'java'}]})
+# => 
"<languages><language>ruby</language></languages><languages><language>java</language></languages>"
+```
+
+You can set the `unwrap` option to remove this behavior.
+
+``` ruby
+> Gyoku.xml({languages: [{language: 'ruby'},{language: 'java'}]}, { unwrap: 
true})
+# => 
"<languages><language>ruby</language><language>java</language></languages>"
+```
 
 ## Special characters
 
@@ -152,6 +177,42 @@
 # => "<foo name=\"bar\">gyoku</foo><foo name=\"baz\" 
some=\"attr\">rocks!</foo>"
 ```
 
+Unwrapping Arrays. You can specify an optional `unwrap` argument to modify the 
default Array
+behavior. `unwrap` accepts a boolean flag (false by default) or an Array 
whitelist of keys to unwrap.
+``` ruby
+# Default Array behavior
+Gyoku.xml({
+  "foo" => [
+    {:is => 'great' },
+    {:is => 'awesome'}
+  ]
+})
+# => "<foo><is>great</is></foo><foo><is>awesome</is></foo>"
+
+# Unwrap Array behavior
+Gyoku.xml({
+  "foo" => [
+    {:is => 'great' },
+    {:is => 'awesome'}
+  ]
+}, unwrap: true)
+# => "<foo><is>great</is><is>awesome</is></foo>"
+
+# Unwrap Array, whitelist.
+# foo is not unwrapped, bar is.
+Gyoku.xml({
+  "foo" => [
+    {:is => 'great' },
+    {:is => 'awesome'}
+  ],
+  "bar" => [
+      {:is => 'rad' },
+      {:is => 'cool'}
+  ]
+}, unwrap: [:bar])
+# => 
"<foo><is>great</is></foo><foo><is>awesome</is></foo><bar><is>rad</is><is>cool</is></bar>"
+```
+
 Naturally, it would ignore :content! if tag is self-closing:
 
 ``` ruby
@@ -190,3 +251,63 @@
 
 Notice that we have the attribute "lang" defined twice.
 The `@lang` value takes precedence over the `:attribute![:subtitle]["lang"]` 
value.
+
+## Pretty Print
+
+You can prettify the output XML to make it more readable. Use these options:
+* `pretty_print` ??? controls pretty mode (default: `false`)
+* `indent` ??? specifies indentation in spaces (default: `2`)
+* `compact` ?????controls compact mode (default: `true`)
+
+**This feature is not available for XML documents generated from arrays with 
unwrap option set to false as such documents are not valid**
+
+**Examples**
+
+``` ruby
+puts Gyoku.xml({user: { name: 'John', job: { title: 'Programmer' }, :@status 
=> 'active' }}, pretty_print: true)
+#<user status='active'>
+#  <name>John</name>
+#  <job>
+#    <title>Programmer</title>
+#  </job>
+#</user>
+```
+
+``` ruby
+puts Gyoku.xml({user: { name: 'John', job: { title: 'Programmer' }, :@status 
=> 'active' }}, pretty_print: true, indent: 4)
+#<user status='active'>
+#    <name>John</name>
+#    <job>
+#        <title>Programmer</title>
+#    </job>
+#</user>
+```
+
+``` ruby
+puts Gyoku.xml({user: { name: 'John', job: { title: 'Programmer' }, :@status 
=> 'active' }}, pretty_print: true, compact: false)
+#<user status='active'>
+#  <name>
+#    John
+#  </name>
+#  <job>
+#    <title>
+#      Programmer
+#    </title>
+#  </job>
+#</user>
+```
+
+**Generate XML from an array with `unwrap` option set to `true`**
+``` ruby
+puts Gyoku::Array.to_xml(["john", "jane"], "user", true, {}, pretty_print: 
true, unwrap: true)
+#<user>
+#  <user>john</user>
+#  <user>jane</user>
+#</user>
+```
+
+**Generate XML from an array with `unwrap` option unset (`false` by default)**
+``` ruby
+puts Gyoku::Array.to_xml(["john", "jane"], "user", true, {}, pretty_print: 
true)
+#<user>john</user><user>jane</user>
+```
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gyoku.gemspec new/gyoku.gemspec
--- old/gyoku.gemspec   2015-04-05 03:08:01.000000000 +0200
+++ new/gyoku.gemspec   2022-04-01 10:37:57.000000000 +0200
@@ -12,16 +12,16 @@
   s.description = "Gyoku translates Ruby Hashes to XML"
   s.required_ruby_version = '>= 1.9.2'
 
-  s.rubyforge_project = "gyoku"
   s.license = "MIT"
 
   s.add_dependency "builder", ">= 2.1.2"
+  s.add_dependency "rexml", "~> 3.0"
 
   s.add_development_dependency "rake"
   s.add_development_dependency "rspec"
 
   s.files         = `git ls-files`.split("\n")
   s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
-  s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| 
File.basename(f) }
+
   s.require_paths = ["lib"]
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/gyoku/array.rb new/lib/gyoku/array.rb
--- old/lib/gyoku/array.rb      2015-04-05 03:08:01.000000000 +0200
+++ new/lib/gyoku/array.rb      2022-04-01 10:37:57.000000000 +0200
@@ -1,6 +1,6 @@
 require "builder"
 
-require "gyoku/hash"
+require "gyoku/prettifier.rb"
 require "gyoku/xml_value"
 
 module Gyoku
@@ -8,12 +8,25 @@
 
     NESTED_ELEMENT_NAME = "element"
 
+    # Builds XML and prettifies it if +pretty_print+ option is set to +true+
+    def self.to_xml(array, key, escape_xml = true, attributes = {}, options = 
{})
+      xml = build_xml(array, key, escape_xml, attributes, options)
+
+      if options[:pretty_print] && options[:unwrap]
+        Prettifier.prettify(xml, options)
+      else
+        xml
+      end
+    end
+
+  private
+
     # Translates a given +array+ to XML. Accepts the XML +key+ to add the 
elements to,
     # whether to +escape_xml+ and an optional Hash of +attributes+.
-    def self.to_xml(array, key, escape_xml = true, attributes = {}, options = 
{})
+    def self.build_xml(array, key, escape_xml = true, attributes = {}, options 
= {})
 
       self_closing = options.delete(:self_closing)
-      unwrap = options[:unwrap] || false 
+      unwrap =  unwrap?(options.fetch(:unwrap, false), key)
 
       iterate_with_xml array, key, attributes, options do |xml, item, attrs, 
index|
         if self_closing
@@ -24,10 +37,10 @@
               if unwrap
                 xml << Hash.to_xml(item, options)
               else
-                xml.tag!(key, attrs) { xml << Hash.to_xml(item, options) }
+                xml.tag!(key, attrs) { xml << Hash.build_xml(item, options) }
               end
             when ::Array      then 
-              xml.tag!(key, attrs) { xml << Array.to_xml(item, 
NESTED_ELEMENT_NAME) }
+              xml.tag!(key, attrs) { xml << Array.build_xml(item, 
NESTED_ELEMENT_NAME) }
             when NilClass     then 
               xml.tag!(key, "xsi:nil" => "true")
             else              
@@ -37,17 +50,15 @@
       end
     end
 
-  private
-
     # Iterates over a given +array+ with a Hash of +attributes+ and yields a 
builder +xml+
     # instance, the current +item+, any XML +attributes+ and the current 
+index+.
     def self.iterate_with_xml(array, key, attributes, options, &block)
 
       xml = Builder::XmlMarkup.new
-      unwrap = options[:unwrap] || false
+      unwrap =  unwrap?(options.fetch(:unwrap, false), key)
 
-      if (unwrap)
-        xml.tag!(key) { iterate_array(xml, array, attributes, &block) }
+      if unwrap
+        xml.tag!(key, attributes) { iterate_array(xml, array, attributes, 
&block) }
       else
         iterate_array(xml, array, attributes, &block)
       end
@@ -85,5 +96,9 @@
       end
     end
 
+    def self.unwrap?(unwrap, key)
+      unwrap.kind_of?(::Array) ? unwrap.include?(key.to_sym) : unwrap
+    end
+
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/gyoku/hash.rb new/lib/gyoku/hash.rb
--- old/lib/gyoku/hash.rb       2015-04-05 03:08:01.000000000 +0200
+++ new/lib/gyoku/hash.rb       2022-04-01 10:37:57.000000000 +0200
@@ -1,5 +1,6 @@
 require "builder"
 
+require "gyoku/prettifier.rb"
 require "gyoku/array"
 require "gyoku/xml_key"
 require "gyoku/xml_value"
@@ -7,8 +8,21 @@
 module Gyoku
   class Hash
 
-    # Translates a given +hash+ with +options+ to XML.
+    # Builds XML and prettifies it if +pretty_print+ option is set to +true+
     def self.to_xml(hash, options = {})
+      xml = build_xml(hash, options)
+
+      if options[:pretty_print]
+        Prettifier.prettify(xml, options)
+      else
+        xml
+      end
+    end
+
+  private
+
+    # Translates a given +hash+ with +options+ to XML.
+    def self.build_xml(hash, options = {})
       iterate_with_xml hash do |xml, key, value, attributes|
         self_closing = key.to_s[-1, 1] == "/"
         escape_xml = key.to_s[-1, 1] != "!"
@@ -16,8 +30,8 @@
 
         case
           when :content! === key  then xml << XMLValue.create(value, 
escape_xml, options)
-          when ::Array === value  then xml << Array.to_xml(value, xml_key, 
escape_xml, attributes, options.merge(:self_closing => self_closing))
-          when ::Hash === value   then xml.tag!(xml_key, attributes) { xml << 
Hash.to_xml(value, options) }
+          when ::Array === value  then xml << Array.build_xml(value, xml_key, 
escape_xml, attributes, options.merge(:self_closing => self_closing))
+          when ::Hash === value   then xml.tag!(xml_key, attributes) { xml << 
build_xml(value, options) }
           when self_closing       then xml.tag!(xml_key, attributes)
           when NilClass === value then xml.tag!(xml_key, "xsi:nil" => "true")
           else                         xml.tag!(xml_key, attributes) { xml << 
XMLValue.create(value, escape_xml, options) }
@@ -25,8 +39,6 @@
       end
     end
 
-  private
-
     # Iterates over a given +hash+ and yields a builder +xml+ instance, the 
current
     # Hash +key+ and any XML +attributes+.
     #
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/gyoku/prettifier.rb new/lib/gyoku/prettifier.rb
--- old/lib/gyoku/prettifier.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/gyoku/prettifier.rb 2022-04-01 10:37:57.000000000 +0200
@@ -0,0 +1,29 @@
+require 'rexml/document'
+
+module Gyoku
+  class Prettifier
+    DEFAULT_INDENT = 2
+    DEFAULT_COMPACT = true
+
+    attr_accessor :indent, :compact
+
+    def self.prettify(xml, options = {})
+      new(options).prettify(xml)
+    end
+
+    def initialize(options = {})
+      @indent = options[:indent] || DEFAULT_INDENT
+      @compact = options[:compact].nil? ? DEFAULT_COMPACT : options[:compact]
+    end
+
+    # Adds intendations and newlines to +xml+ to make it more readable
+    def prettify(xml)
+      result = ''
+      formatter = REXML::Formatters::Pretty.new indent
+      formatter.compact = compact
+      doc = REXML::Document.new xml
+      formatter.write doc, result
+      result
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/gyoku/version.rb new/lib/gyoku/version.rb
--- old/lib/gyoku/version.rb    2015-04-05 03:08:01.000000000 +0200
+++ new/lib/gyoku/version.rb    2022-04-01 10:37:57.000000000 +0200
@@ -1,3 +1,3 @@
 module Gyoku
-  VERSION = '1.3.1'
+  VERSION = '1.4.0'
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2015-04-05 03:08:01.000000000 +0200
+++ new/metadata        2022-04-01 10:37:57.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: gyoku
 version: !ruby/object:Gem::Version
-  version: 1.3.1
+  version: 1.4.0
 platform: ruby
 authors:
 - Daniel Harrington
-autorequire: 
+autorequire:
 bindir: bin
 cert_chain: []
-date: 2015-04-05 00:00:00.000000000 Z
+date: 2022-04-01 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: builder
@@ -25,6 +25,20 @@
       - !ruby/object:Gem::Version
         version: 2.1.2
 - !ruby/object:Gem::Dependency
+  name: rexml
+  requirement: !ruby/object:Gem::Requirement
+    requirements:
+    - - "~>"
+      - !ruby/object:Gem::Version
+        version: '3.0'
+  type: :runtime
+  prerelease: false
+  version_requirements: !ruby/object:Gem::Requirement
+    requirements:
+    - - "~>"
+      - !ruby/object:Gem::Version
+        version: '3.0'
+- !ruby/object:Gem::Dependency
   name: rake
   requirement: !ruby/object:Gem::Requirement
     requirements:
@@ -58,9 +72,9 @@
 extensions: []
 extra_rdoc_files: []
 files:
+- ".github/workflows/ci.yml"
 - ".gitignore"
 - ".rspec"
-- ".travis.yml"
 - CHANGELOG.md
 - Gemfile
 - MIT-LICENSE
@@ -70,11 +84,13 @@
 - lib/gyoku.rb
 - lib/gyoku/array.rb
 - lib/gyoku/hash.rb
+- lib/gyoku/prettifier.rb
 - lib/gyoku/version.rb
 - lib/gyoku/xml_key.rb
 - lib/gyoku/xml_value.rb
 - spec/gyoku/array_spec.rb
 - spec/gyoku/hash_spec.rb
+- spec/gyoku/prettifier_spec.rb
 - spec/gyoku/xml_key_spec.rb
 - spec/gyoku/xml_value_spec.rb
 - spec/gyoku_spec.rb
@@ -83,7 +99,7 @@
 licenses:
 - MIT
 metadata: {}
-post_install_message: 
+post_install_message:
 rdoc_options: []
 require_paths:
 - lib
@@ -98,14 +114,14 @@
     - !ruby/object:Gem::Version
       version: '0'
 requirements: []
-rubyforge_project: gyoku
-rubygems_version: 2.2.2
-signing_key: 
+rubygems_version: 3.2.7
+signing_key:
 specification_version: 4
 summary: Translates Ruby Hashes to XML
 test_files:
 - spec/gyoku/array_spec.rb
 - spec/gyoku/hash_spec.rb
+- spec/gyoku/prettifier_spec.rb
 - spec/gyoku/xml_key_spec.rb
 - spec/gyoku/xml_value_spec.rb
 - spec/gyoku_spec.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/gyoku/array_spec.rb new/spec/gyoku/array_spec.rb
--- old/spec/gyoku/array_spec.rb        2015-04-05 03:08:01.000000000 +0200
+++ new/spec/gyoku/array_spec.rb        2022-04-01 10:37:57.000000000 +0200
@@ -45,6 +45,17 @@
       expect(to_xml(array, "value", :escape_xml, :active => true)).to 
eq(result)
     end
 
+    it "adds attributes to tags when :unwrap is true" do
+      array = [{:item=>"abc"}]
+      key = "items"
+      escape_xml = :escape_xml
+      attributes = { "amount"=>"1" }
+      options = { :unwrap => true }
+      result = "<items amount=\"1\"><item>abc</item></items>"
+
+      expect(to_xml(array, key, escape_xml, attributes, options)).to eq result
+    end
+
     it "adds attributes to duplicate tags" do
       array = ["adam", "eve"]
       result = '<value id="1">adam</value><value id="2">eve</value>'
@@ -65,6 +76,44 @@
 
       expect(to_xml(array, "value")).to eq(result)
     end
+
+    context "when :pretty_print option is set to true" do
+      context "when :unwrap option is set to true" do
+        it "returns prettified xml" do
+          array = ["one", "two", {"three" => "four"}]
+          options = { pretty_print: true, unwrap: true }
+          result = "<test>\n  <test>one</test>\n  <test>two</test>\n  
<three>four</three>\n</test>"
+          expect(to_xml(array, "test", true, {}, options)).to eq(result)
+        end
+
+        context "when :indent option is specified" do
+          it "returns prettified xml with specified indent" do
+            array = ["one", "two", {"three" => "four"}]
+            options = { pretty_print: true, indent: 3, unwrap: true }
+            result = "<test>\n   <test>one</test>\n   <test>two</test>\n   
<three>four</three>\n</test>"
+            expect(to_xml(array, "test", true, {}, options)).to eq(result)
+          end
+        end
+
+        context "when :compact option is specified" do
+          it "returns prettified xml with specified compact mode" do
+            array = ["one", {"two" => "three"}]
+            options = { pretty_print: true, compact: false, unwrap: true }
+            result = "<test>\n  <test>\n    one\n  </test>\n  <two>\n     
three \n  </two>\n</test>"
+            expect(to_xml(array, "test", true, {}, options)).to eq(result)
+          end
+        end
+      end
+
+      context "when :unwrap option is not set" do
+        it "returns non-prettified xml" do
+          array = ["one", "two", {"three" => "four"}]
+          options = { pretty_print: true }
+          result = 
"<test>one</test><test>two</test><test><three>four</three></test>"
+          expect(to_xml(array, "test", true, {}, options)).to eq(result)
+        end
+      end
+    end
   end
 
   def to_xml(*args)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/gyoku/hash_spec.rb new/spec/gyoku/hash_spec.rb
--- old/spec/gyoku/hash_spec.rb 2015-04-05 03:08:01.000000000 +0200
+++ new/spec/gyoku/hash_spec.rb 2022-04-01 10:37:57.000000000 +0200
@@ -52,6 +52,33 @@
         expect(to_xml(:some => [{ :new => "user" }, { :old => "gorilla" }])).
           to eq("<some><new>user</new></some><some><old>gorilla</old></some>")
       end
+
+      context "when :pretty_print option is set to true" do
+        it "returns prettified xml" do
+          hash = { some: { user: { name: "John", groups: ["admin", "editor"] } 
} }
+          options = { pretty_print: true }
+          result = "<some>\n  <user>\n    <name>John</name>\n    
<groups>admin</groups>\n    <groups>editor</groups>\n  </user>\n</some>"
+          expect(to_xml(hash, options)).to eq(result)
+        end
+
+        context "when :indent option is specified" do
+          it "returns prettified xml with specified indent" do
+            hash = { some: { user: { name: "John" } } }
+            options = { pretty_print: true, indent: 4 }
+            result = "<some>\n    <user>\n        <name>John</name>\n    
</user>\n</some>"
+            expect(to_xml(hash, options)).to eq(result)
+          end
+        end
+
+        context "when :compact option is specified" do
+          it "returns prettified xml with specified compact mode" do
+            hash = { some: { user: { name: "John" } } }
+            options = { pretty_print: true, compact: false }
+            result = "<some>\n  <user>\n    <name>\n      John\n    </name>\n  
</user>\n</some>"
+            expect(to_xml(hash, options)).to eq(result)
+          end
+        end
+      end
     end
 
     it "converts Hash key Symbols to lowerCamelCase" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/gyoku/prettifier_spec.rb 
new/spec/gyoku/prettifier_spec.rb
--- old/spec/gyoku/prettifier_spec.rb   1970-01-01 01:00:00.000000000 +0100
+++ new/spec/gyoku/prettifier_spec.rb   2022-04-01 10:37:57.000000000 +0200
@@ -0,0 +1,39 @@
+require "spec_helper"
+
+describe Gyoku::Prettifier do
+  describe "#prettify" do
+    context "when xml is valid" do
+      let!(:xml) { Gyoku::Hash.build_xml(test: { pretty: "xml" }) }
+
+      it "returns prettified xml" do
+        expect(subject.prettify(xml)).to eql("<test>\n  
<pretty>xml</pretty>\n</test>")
+      end
+
+      context "when indent option is specified" do
+        it "returns prettified xml with indent" do
+          options = { indent: 3 }
+          subject = Gyoku::Prettifier.new(options)
+          expect(subject.prettify(xml)).to eql("<test>\n   
<pretty>xml</pretty>\n</test>")
+        end
+      end
+
+      context "when compact option is specified" do
+        it "returns prettified xml with indent" do
+          options = { compact: false }
+          subject = Gyoku::Prettifier.new(options)
+          expect(subject.prettify(xml)).to eql("<test>\n  <pretty>\n    xml\n  
</pretty>\n</test>")
+        end
+      end
+    end
+
+    context "when xml is not valid" do
+      let!(:xml) do
+        Gyoku::Array.build_xml(["one", "two"], "test")
+      end
+
+      it "raises an error" do
+        expect{ subject.prettify(xml) }.to raise_error REXML::ParseException
+      end
+    end
+  end
+end

Reply via email to