Giter Club home page Giter Club logo

builder's People

Contributors

barttenbrinke avatar benlovell avatar binki avatar drbrain avatar hadley avatar hderms avatar indirect avatar jhulten avatar jimweirich avatar lathanh avatar nikitug avatar sanemat avatar voxik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

builder's Issues

Excluding & passing in xml

require 'builder'

builder = ::Builder::XmlMarkup.new(:target=>@output, :indent=>2)
builder.result{
builder.total_prospects "1"
builder.prospect { |b|
b.text << "Test & Me";
b.welcome << "Welcome & You";
}
}
print builder
OUTPUT:
screenshot from 2018-07-12 19-18-41

Can you help how should I do this.
Need text in a tag but as you can see it is not coming with in tags

Add option to make xml.tag! handle nil values like rails ActiveRecord::Base#to_xml

Nil values are handled differently in this gem versus rendering in the rails controller like:

render xml: @object

I think it would be nice if there was some way of instructing Builder to do something similar. More specifically, instead of a tag (foo) with a nil value being rendered like

<foo />

We could get something like:

<foo nil="true"/>

Having the option of representing nil values explicitly, without the user having to do the checks themselves would be nice.

Tests fail with 'uninitialized constant Test (NameError)'

This is a fresh git clone from github. I see the following problem:

tim@tim-desktop:~/workspace/builder$ rake --trace
(in /home/tim/workspace/builder)
** Invoke default (first_time)
** Invoke test_all (first_time)
** Invoke test_units (first_time)
** Execute test_units
./test/test_eventbuilder.rb:1: uninitialized constant Test (NameError)
    from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
    from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
    from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 -I"lib" "/usr/lib/ruby/ge...]
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:995:in `sh'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `sh'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1094:in `sh'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1029:in `ruby'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1094:in `ruby'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/testtask.rb:117:in `define'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1112:in `verbose'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/testtask.rb:102:in `define'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Improper indentation for raw text

Quoted from this question http://stackoverflow.com/questions/6845697/railsbuilder-generate-xml-output-without-entities


xml.RodzajPaczki {|t| t << 'całość' }
Unfortunately when you pass a block to the RodzajPaczki element, Builder assumes that there will be some inner xml, so it adds a new line and applies the indent. Of course in our case there is only inner text and no xml so we get some unsightly output like:

<RodzajPaczki>
całość </RodzajPaczki>


Is there a proper way for adding just text without needing to patch builder or configure it with zero indentation ?

git tags out of sync with rubygems

it would be great to push git tags for all versions published on rubygems.
Could you please push a 3.2.3 git tag an all future releases?
thanks

Change in Ruby's devault encoding breaks test suite with Ruby 2.0

$ testrb -I.:lib test
Run options: -I.:lib

# Running tests:

[107/108] TestXmlEscaping#test_utf8_verbatim = 0.00 s                                                                                 
  1) Failure:
test_utf8_verbatim(TestXmlEscaping) [/builddir/build/BUILD/rubygem-builder-3.1.4/usr/share/gems/gems/builder-3.1.4/test/test_xchar.rb:72]:
<"’"> expected but was
<"\xE2\x80\x99">.

Finished tests in 0.035375s, 3052.9897 tests/s, 5936.3689 assertions/s.
108 tests, 210 assertions, 1 failures, 0 errors, 0 skips

ruby -v: ruby 2.0.0dev (2013-02-14 trunk 39237) [x86_64-linux]

It can be fixed by adding encoding directive # encoding: us-ascii on the second line, not sure that is the right approach though.

Rake failure & how to run unit test

I want to run unit test for the development.
But I saw an error when I checked rake tasks.
Could you tell me how to do it?
Does Travis CI test work, though I could see .travis.yml?
We do not use bundler for the development?

$ git clone [email protected]:jimweirich/builder.git

$ cd builder

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.8)
bundler (1.12.5)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.9.0)
psych (2.0.17)
rake (11.2.2)
rdoc (4.2.1)

$ rake -T
rake aborted!
LoadError: cannot load such file -- rake/contrib/rubyforgepublisher
/home/jaruga/git/builder/rakelib/publish.rake:4:in `<top (required)>'
(See full trace by running task with --trace)

(Sometimes) breaks blankslate on ruby 1.9

Hi,

Using ruby 1.9, if builder is required before blankslate, blankslate no longer works:

# WORKS: require blankslate without builder, as expected  BlankSlate#methods is undefined
$ ruby-1.9.3-p0 -rblankslate -e 'puts BlankSlate.new.methods'
-e:1:in `<main>': undefined method `methods' for #<BlankSlate:0x007ffaa1931158> (NoMethodError)

# WORKS: require blankslate then builder, as expected BlankSlate#methods is undefined
$ ruby-1.9.3-p0 -rblankslate -rbuilder -e 'puts BlankSlate.new.methods'
-e:1:in `<main>': undefined method `methods' for #<BlankSlate:0x007ffaa1931158> (NoMethodError)

# DOESN'T WORK: require builder then blankslate, BlankSlate is no longer blank!
$ ruby-1.9.3-p0 -rblankslate -rbuilder -e 'puts BlankSlate.new.methods'
[... lists all 56 methods of Object...]

Turns out that builder puts a file "blankslate.rb" into the load path, so it gets loaded instead of the blankslate gem. But this version doesn't work with ruby 1.9 (Object#methods returning symbols vs strings).

This isn't a problem for builder on its own, since it doesn't require blankslate.rb with ruby 1.9. And you might argue that one should use BasiicObject rather than BlankSlate. But I have an app that's using two other gems, one of which requires builder and the other requires blankslate. Depending on what order bundler ends up sorting out the dependencies, the app breaks.

I was going to do a patch and pull request, but i see four possible solutions, not sure which you'd prefer:

  • Fix builder's blankslate.rb for ruby 1.9
  • Move builder's blankslate.rb out of the way, e.g. into "builder/blankslate"
  • Remove it entirely and add (implicit or explicit) dependency on blankslate gem for ruby 1.8
  • Remove it entirely and remove the BlankSlate class, just undefine the methods inline:
    instance_methods.each do |method| ;
    undef_method method unless method.start_with? "__" or method == 'instance_eval' ;
    end

Thanks

No character validation in CDATA tags

Builder can generate invalid XML when creating a CDATA tag with a string that contains characters that XML considers invalid (per http://www.w3.org/TR/REC-xml/#charsets).

This example will create invalid XML:

xml = Builder::XmlMarkup.new
xml.cdata!("\x00")

We should allow separate utf8 and XML Control Character (ampersand and brackets) escaping in String#to_xs.

diff --git a/lib/builder/xchar.rb b/lib/builder/xchar.rb
index 4578c2a..220d23f 100644
--- a/lib/builder/xchar.rb
+++ b/lib/builder/xchar.rb
@@ -92,10 +92,17 @@ class Fixnum
   # XML escaped version of chr. When escape is set to false
   # the CP1252 fix is still applied but utf-8 characters are not
   # converted to character entities.
-  def xchr(escape=true)
+  def xchr(escape_utf8=true, escape_markup_delimiters=true)
     n = XChar::CP1252[self] || self
     case n when *XChar::VALID
-      XChar::PREDEFINED[n] or (n<128 ? n.chr : (escape ? "&##{n};" : [n].pack('U*')))
+      if escape_markup_delimiters && XChar::PREDEFINED.key?(n)
+        XChar::PREDEFINED[n]
+      else
+        if n<128 then n.chr
+        elsif escape_utf8 then "&##{n};"
+        else [n].pack('U*')
+        end
+      end
     else
       '*'
     end
@@ -111,8 +118,8 @@ class String
   # XML escaped version of to_s. When escape is set to false
   # the CP1252 fix is still applied but utf-8 characters are not
   # converted to character entities.
-  def to_xs(escape=true)
-    unpack('U*').map {|n| n.xchr(escape)}.join # ASCII, UTF-8
+  def to_xs(escape_utf8=true, escape_markup_delimiters=true)
+    unpack('U*').map {|n| n.xchr(escape_utf8, escape_markup_delimiters)}.join # ASCII, UTF-8
   rescue
     unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252
   end
diff --git a/lib/builder/xmlmarkup.rb b/lib/builder/xmlmarkup.rb
index 8483bed..d904c2f 100644
--- a/lib/builder/xmlmarkup.rb
+++ b/lib/builder/xmlmarkup.rb
@@ -280,7 +280,7 @@ module Builder
     def _special(open, close, data=nil, attrs=nil, order=[])
       _indent
       @target << open
-      @target << data if data
+      @target << data.to_xs(false, false) if data
       _insert_attributes(attrs, order) if attrs
       @target << close
       _newline
diff --git a/test/test_markupbuilder.rb b/test/test_markupbuilder.rb
index cae34ea..67dce33 100644
--- a/test/test_markupbuilder.rb
+++ b/test/test_markupbuilder.rb
@@ -351,6 +351,11 @@ class TestSpecialMarkup < Test::Unit::TestCase
     @xml.cdata!("TEST&CHECK")
     assert_equal "\n", @xml.target!
   end
+
+  def test_cdata_with_invalid_characters
+    @xml.cdata!("\x00")
+    assert_equal "\n", @xml.target!
+  end
 end
 
 class TestIndentedXmlMarkup < Test::Unit::TestCase

why generating a xml, fills my logs with `- - "new"` message ?

part of my service dose this :

products = Product.search(JSON.parse(@campaign.q))
xml = Builder::XmlMarkup.new
xml << @campaign.wrapper_begin
products.each do |product|
     @campaign.root_elements.each do |element|
       xml.tag!(element.tag, element.xml_attributes(product)) do
         element.decorators.each do |decorator|
           element.cdata ? xml.cdata!(decorator.print_code(product).to_s) : xml << decorator.print_code(product).to_s
         end

         element.childs.each do |child|
           xml.tag!(child.tag, child.xml_attributes(product)) do
             child.decorators.each do |decorator|
               child.cdata ? xml.cdata!(decorator.print_code(product).to_s) : xml << decorator.print_code(product).to_s
             end
           end
         end
       end
     end
   end
   xml << @campaign.wrapper_end

image

how is this keep loging ? is there a way to disable this - my logs are humongous because of this :)

image-2017-09-04-12-01-42-044

Using text! introduces unwanted whitespace

I am not sure if I am reporting a code or a documentation issue. I am trying to create an XML file for import into a third party system and other than using :indent => 0 (which makes the file unreadable to humans), I can't see how to get around Builder introducing extra whitespace around the content of a tag.

If I have "xml.language1('en-US')", I get what I want: <language1>en-US</language1> but if I use tag! + text! to get the same thing, I get an extra new line and some spaces: xml.tag!("language2"){ xml.text!('en-US') }

    <language2>                                                                                                         
en-US    </language2>

The reason I am using tag! + text! is that I have tags with colons in them. A stripped down rake script that demonstrates the issue is:

require 'builder'

namespace :export do
  desc "Export articles into XML - in Wordpress's modified RSS format"
  task :example do
    FILEDIR = "/tmp"
    EXP_FILE = "#{FILEDIR}/example.xml"

    File.open(EXP_FILE, 'w') { |file|
      xml = Builder::XmlMarkup.new(:target => file, :indent => 2)
      xml.instruct! :xml, :version=>"1.0"
      xml.rss(:version=>"2.0", "xmlns:wp" => "http://wordpress.org/export/1.2/", "xmlns:excerpt" => "http://wordpress.org/export/1.2/excerpt/", "xmlns:content" => "http://purl.org/rss/1.0/modules/content/" , "xmlns:dc" => "http://purl.org/dc/elements/1.1/", "xmlns:wfw" => "http://wellformedweb.org/CommentAPI/") {

        xml.channel {
          xml.title("News")
          xml.pubDate(Time.new.strftime("%a, %d %b %Y %H:%M:%S %z"))
          xml.description()
          xml.language1('en-US')
          xml.tag!("language2"){ xml.text!('en-US') }
          xml.tag!("wp:wxr_version"){ xml.text!('1.2') }
          xml.wp :wxr_version do xml.text!('2.1') end

        } # close channel                                                                                               
      } # close rss                                                                                                     
    } # close File                                                                                                      
  end
end

The output I get from that is:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:wp="http://wordpress.org/export/1.2/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:excerpt="http:/\
/wordpress.org/export/1.2/excerpt/" version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="ht\
tp://purl.org/dc/elements/1.1/">
  <channel>
    <title>News</title>
    <pubDate>Mon, 28 Oct 2013 18:42:04 -0700</pubDate>
    <description/>
    <language1>en-US</language1>
    <language2>                                                                                                         
en-US    </language2>
    <wp:wxr_version>                                                                                                    
1.2    </wp:wxr_version>
    <wp:wxr_version>                                                                                                    
2.1    </wp:wxr_version>
  </channel>
</rss>

(NB the Markdown rendering is showing 2 newlines after the opening tag, but I only have one newline in the output)

Versions of things:
ruby 1.8.7 - quite old Ruby Enterprise Edition
builder (3.2.2)

This does seem to have been this way for a while - at least if I am reading this thread from Ruby Forum correctly. https://www.ruby-forum.com/topic/157276

Is this a bug? or should I be doing something differently?

Encoding::CompatibilityError with utf-16 and ruby-1.9.3-preview1

don't know if it's too early to open a ticket for this, but one of my tests if failing on ruby-1.9.3-preview1
and it seems to be a problem related to builder:

xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :encoding => "UTF-16") 

Encoding::CompatibilityError: incompatible encoding regexp match (US-ASCII regexp with UTF-16 string)
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlbase.rb:140:in `gsub'
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlbase.rb:140:in `_escape_quote'
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:320:in `_attr_value'
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:308:in `block in _insert_attributes'
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:306:in `each'
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:306:in `_insert_attributes'
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:284:in `_special'
    from /Users/rubiii/.rvm/gems/ruby-1.9.3-preview1/gems/builder-3.0.0/lib/builder/xmlmarkup.rb:250:in `instruct!'
    from (irb):3
    from /Users/rubiii/.rvm/rubies/ruby-1.9.3-preview1/bin/irb:16:in `<main>'

unicode utf-8 encoding causing issue for xml parser

Hi,
I am trying to chase down this issue and it comes down to Builder. Rails ActiveResource uses ActiveSupport's to_xml method which in return call Builder to generate the xml. Builder will generate the xml with encoding set to UTF-8 and showing the unicode without escaping to ascii entity. However, this is cause the receiving end xml parser to fail. The reason I believe is that if there are unicode in the xml, the encoding must be UTF-16. See: http://www.w3schools.com/xml/xml_encoding.asp . The only time it works is when encoding set to UTF-16. Thought?

In lib/builder/xmlmarkup.rb sometimes Symbol/Hash etc. are not available

I'm not sure if this is because of the usage of BlankSlate but if changing for example this line in lib/builder/xmlmarkup.rb:

sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)

to

sym = "#{sym}:#{args.shift}" if args.first.kind_of?(::Symbol)

everything works ok. It's difficult to say exactly when this happens, but the fix is to reference the objects prepended with :: (for top level I guess). Otherwise I just get: lib/builder/xmlbase.rb:40:in `method_missing': uninitialized constant Builder::XmlBase::Symbol (NameError).

Doc parse nit during rails 3.2.13.rc1 install

At the OS X terminal, I see this:

  • Parsing documentation for builder-3.0.4
    ruby-2.0.0-p0/lib/ruby/2.0.0/rdoc/parser.rb:87: warning: Unsupported encoding : ignored
    ruby-2.0.0-p0/lib/ruby/2.0.0/rdoc/parser.rb:87: warning: Unsupported encoding ignored

Additionally, the Builder installed with that rails is 3.0.2.

(Edit to fix copy/paste error)

"Instruct!" does not work

Step by step:

[2] pry(main)> require 'builder'
=> true
[3] pry(main)> xml = Builder::XmlMarkup.new
=>
[4] pry(main)> xml.instruct!
=> nil

xml.instruct! always returns nil, independently of the parameters passed to it.

builder 3.0.0 release includes a 3MB tags file

The TAGS file is 97% of the contents of the gem and just wastes space:

$ gem contents builder
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/CHANGES
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/README
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/README.rdoc
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/Rakefile
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/TAGS
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/doc/releases/builder-1.2.4.rdoc
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/doc/releases/builder-2.0.0.rdoc
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/doc/releases/builder-2.1.1.rdoc
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib/blankslate.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib/builder.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib/builder/blankslate.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib/builder/xchar.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib/builder/xmlbase.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib/builder/xmlevents.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib/builder/xmlmarkup.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/performance.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/preload.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/test_blankslate.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/test_cssbuilder.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/test_eventbuilder.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/test_markupbuilder.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/test_namecollision.rb
/Library/Ruby/Gems/1.8/gems/builder-3.0.0/test/test_xchar.rb
$ du -hcd1 /Library/Ruby/Gems/1.8/gems/builder-3.0.0
 12K    /Library/Ruby/Gems/1.8/gems/builder-3.0.0/doc
 44K    /Library/Ruby/Gems/1.8/gems/builder-3.0.0/lib
 48K    /Library/Ruby/Gems/1.8/gems/builder-3.0.0/test
2.9M    /Library/Ruby/Gems/1.8/gems/builder-3.0.0
2.9M    total
$ du -h /Library/Ruby/Gems/1.8/gems/builder-3.0.0/TAGS
2.8M    /Library/Ruby/Gems/1.8/gems/builder-3.0.0/TAGS

ERROR: While generating documentation for builder-3.0.0

ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2011.03

gem install rails --pre

Builder gem installs fine, but then....

Installing ri documentation for builder-3.0.0...
ERROR:  While generating documentation for builder-3.0.0
... MESSAGE:   Unhandled special: Special: type=17, text="<!-- HI -->"
... RDOC args: --ri --op /home/brian/.rvm/gems/ree-1.8.7-2011.03@railspre/doc/builder-3.0.0/ri --title Builder -- Easy XML Building --main README.rdoc --line-numbers lib CHANGES Rakefile README README.rdoc TAGS doc/releases/builder-1.2.4.rdoc doc/releases/builder-2.0.0.rdoc doc/releases/builder-2.1.1.rdoc --title builder-3.0.0 Documentation --quiet

Doc and license files missing in the distributed .gem

Hi,

in the last release (3.2.0) I cannot find the doc files, nor the new MIT license file. Is there a good reason to exclude those? Could you please at least keep the license file? When we package builder for Fedora we need to include the license file, so it's much easier if it comes along.

Thank you.

Add to_s

I've used Builder for several projects over the last few years and every time I make the same API mistake: I use #to_s to finalize the built document.

xml = Builder::XmlMarkup.new
xml.foo do
  xml.bar
end
return xml.to_s

Only to find that I've injected an extra, unwanted <to_s/> element. A naive approach might try this:

class Builder::XmlMarkup
  def to_s
    @target.to_s
  end
end

But I know you just require the :<< method, thus allowing direct IO, which can't convert to a String. Perhaps something like this:

class Builder::XmlMarkup
  def to_s
    raise ArgumentError, "Cannot coerce #{@target.class.name} to String" unless @target.is_a?(String)
    @target
  end
end

WDYT?

Warning on builder 3.0.2

Just updated builder to version 3.0.2 (3.1.0 is locked out from rails 3.2.8)

I'm seeing the following warning:

/snip/ruby-1.9.3-p194/gems/builder-3.0.2/lib/blankslate.rb:51: warning: undefining `object_id' may cause serious problems

Duplicated READMEs

Hi,

Your repository contains README and README.rdoc. They contain mostly the same information, but they also differ on several places. Would you mind to remove one of the READMEs? It would avoid possible confusion and simplify maintenance.

It seems that original intention was to rename README to README.rdoc, but the original README was never removed after that.

Thank you.

Dashed root syntax error (3.0.1 with 1.9.3-p194)

Rubygems.org currently has a failure on master when running with builder 3.0.1 and 1.9.3-p194 when generating XML output when the node root is supposed to be a name containing a dash. See below:

  rubygems.org git:(master)  rails c
Unable to load configuration from /Users/cmeiklejohn/Repositories/rubygems.org/config/newrelic.yml
Loading development environment (Rails 3.2.8)
irb(main):001:0> { :a => :b } 
=> {:a=>:b}
irb(main):002:0> { :a => :b }.to_xml
=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n  <a type=\"symbol\">b</a>\n</hash>\n"
irb(main):003:0> { :a => :b }.to_xml(:root => 'dashed-value')
SyntaxError: (eval):1: syntax error, unexpected '-', expecting ';' or '\n'
        def dashed-value(*args, &block)
                   ^
(eval):3: syntax error, unexpected keyword_end, expecting $end
    from /Users/cmeiklejohn/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/builder-3.0.1/lib/builder/xmlbase.rb:182:in `instance_eval'
    from /Users/cmeiklejohn/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/builder-3.0.1/lib/builder/xmlbase.rb:182:in `cache_method_call'
    from /Users/cmeiklejohn/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/builder-3.0.1/lib/builder/xmlbase.rb:85:in `method_missing'
    from /Users/cmeiklejohn/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/core_ext/hash/conversions.rb:82:in `to_xml'
    from (irb):3
    from /Users/cmeiklejohn/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
    from /Users/cmeiklejohn/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
    from /Users/cmeiklejohn/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Bad characters in README/README.rdoc

You seem to have rogue bad characters in the README:

$ gem install builder
Fetching: builder-3.0.0.gem (100%)
Successfully installed builder-3.0.0
1 gem installed
Installing ri documentation for builder-3.0.0...
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README, skipping
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping
Building YARD (yri) index for builder-3.0.0...
Installing RDoc documentation for builder-3.0.0...
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README, skipping
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping

Using cat to display the README in my UTF-8 terminal pinpoints the erroneous lines, which ironically are in the section about UTF-8 support:

Example:

  xml = Builder::Markup.new
  xml.sample("I�t�rn�ti�n�l")
  xml.target!  =>
    "<sample>I&#241;t&#235;rn&#226;ti&#244;n&#224;l</sample>"

You can get UTF-8 encoded output by making sure that the XML
encoding is set to "UTF-8" and that the $KCODE variable is set to
"UTF8".

  $KCODE = 'UTF8'
  xml = Builder::Markup.new
  xml.instruct!(:xml, :encoding => "UTF-8")
  xml.sample("I�t�rn�ti�n�l")
  xml.target!  =>
    "<sample>I�t�rn�ti�n�l</sample>"

A quick vim-based conversion of the file from ISO-8859-1 to UTF-8 should fix it.

'rake' doesn't work if 'rvm' is not installed

I see the following:

$ rake --tasks
rake aborted!
No such file or directory - rvm
/src/ws/baserock/me/import-rails/checkouts/ruby-gems_builder/rakelib/tags.rake:15:in ``'
/src/ws/baserock/me/import-rails/checkouts/ruby-gems_builder/rakelib/tags.rake:15:in `<module:Tags>'
/src/ws/baserock/me/import-rails/checkouts/ruby-gems_builder/rakelib/tags.rake:3:in `<top (required)>'
(See full trace by running task with --trace)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.