crack 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of crack might be problematic. Click here for more details.

@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.gem
data/History ADDED
@@ -0,0 +1,15 @@
1
+ == 0.1.3 2009-06-22
2
+ * 1 minor patch
3
+ * Parsing a text node with attributes stores them in the attributes method (tamalw)
4
+
5
+ == 0.1.2 2009-04-21
6
+ * 2 minor patches
7
+ * Correct unnormalization of attribute values (der-flo)
8
+ * Fix error in parsing YAML in the case where a hash value ends with backslashes, and there are subsequent values in the hash (deadprogrammer)
9
+
10
+ == 0.1.1 2009-03-31
11
+ * 1 minor patch
12
+ * Parsing empty or blank xml now returns empty hash instead of raising error.
13
+
14
+ == 0.1.0 2009-03-28
15
+ * Initial release.
@@ -20,3 +20,7 @@ Really simple JSON and XML parsing, ripped from Merb and Rails. The XML parser i
20
20
  == Copyright
21
21
 
22
22
  Copyright (c) 2009 John Nunemaker. See LICENSE for details.
23
+
24
+ == Docs
25
+
26
+ http://rdoc.info/projects/jnunemaker/crack
data/Rakefile CHANGED
@@ -46,42 +46,4 @@ rescue LoadError
46
46
  end
47
47
 
48
48
 
49
- task :default => :test
50
-
51
- begin
52
- require 'rake/contrib/sshpublisher'
53
- namespace :rubyforge do
54
-
55
- desc "Release gem and RDoc documentation to RubyForge"
56
- task :release => ["rubyforge:release:gem", "rubyforge:release:website", "rubyforge:release:docs"]
57
-
58
- namespace :release do
59
- desc "Publish RDoc to RubyForge."
60
- task :docs => [:rdoc] do
61
- config = YAML.load(
62
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
63
- )
64
-
65
- host = "#{config['username']}@rubyforge.org"
66
- remote_dir = "/var/www/gforge-projects/crack/rdoc"
67
- local_dir = 'rdoc'
68
-
69
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
70
- end
71
-
72
- task :website do
73
- config = YAML.load(
74
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
75
- )
76
-
77
- host = "#{config['username']}@rubyforge.org"
78
- remote_dir = "/var/www/gforge-projects/crack/"
79
- local_dir = 'website'
80
-
81
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
82
- end
83
- end
84
- end
85
- rescue LoadError
86
- puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
87
- end
49
+ task :default => :test
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 2
4
+ :patch: 3
@@ -0,0 +1,57 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{crack}
5
+ s.version = "0.1.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["John Nunemaker"]
9
+ s.date = %q{2009-06-30}
10
+ s.email = %q{nunemaker@gmail.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".gitignore",
17
+ "History",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION.yml",
22
+ "crack.gemspec",
23
+ "lib/crack.rb",
24
+ "lib/crack/core_extensions.rb",
25
+ "lib/crack/json.rb",
26
+ "lib/crack/xml.rb",
27
+ "test/crack_test.rb",
28
+ "test/data/twittersearch-firefox.json",
29
+ "test/data/twittersearch-ie.json",
30
+ "test/json_test.rb",
31
+ "test/test_helper.rb",
32
+ "test/xml_test.rb"
33
+ ]
34
+ s.has_rdoc = true
35
+ s.homepage = %q{http://github.com/jnunemaker/crack}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubyforge_project = %q{crack}
39
+ s.rubygems_version = %q{1.3.1}
40
+ s.summary = %q{Really simple JSON and XML parsing, ripped from Merb and Rails.}
41
+ s.test_files = [
42
+ "test/crack_test.rb",
43
+ "test/json_test.rb",
44
+ "test/test_helper.rb",
45
+ "test/xml_test.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 2
51
+
52
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
+ else
54
+ end
55
+ else
56
+ end
57
+ end
@@ -81,7 +81,10 @@ class REXMLUtilityNode #:nodoc:
81
81
  end
82
82
 
83
83
  if @text
84
- return { name => typecast_value( unnormalize_xml_entities( inner_html ) ) }
84
+ t = typecast_value( unnormalize_xml_entities( inner_html ) )
85
+ t.class.send(:attr_accessor, :attributes)
86
+ t.attributes = attributes
87
+ return { name => t }
85
88
  else
86
89
  #change repeating groups into an array
87
90
  groups = @children.inject({}) { |s,e| (s[e.name] ||= []) << e; s }
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require 'test_helper'
2
3
 
3
4
  class JsonTest < Test::Unit::TestCase
@@ -62,4 +63,4 @@ class JsonTest < Test::Unit::TestCase
62
63
  }.should_not raise_error(Crack::ParseError)
63
64
  end
64
65
 
65
- end
66
+ end
@@ -65,9 +65,40 @@ class XmlTest < Test::Unit::TestCase
65
65
  }
66
66
  }
67
67
  }
68
-
68
+
69
69
  Crack::XML.parse(xml).should == hash
70
70
  end
71
+
72
+ context "Parsing xml with text and attributes" do
73
+ setup do
74
+ xml =<<-XML
75
+ <opt>
76
+ <user login="grep">Gary R Epstein</user>
77
+ <user>Simon T Tyson</user>
78
+ </opt>
79
+ XML
80
+ @data = Crack::XML.parse(xml)
81
+ end
82
+
83
+ should "correctly parse text nodes" do
84
+ @data.should == {
85
+ 'opt' => {
86
+ 'user' => [
87
+ 'Gary R Epstein',
88
+ 'Simon T Tyson'
89
+ ]
90
+ }
91
+ }
92
+ end
93
+
94
+ should "be parse attributes for text node if present" do
95
+ @data['opt']['user'][0].attributes.should == {'login' => 'grep'}
96
+ end
97
+
98
+ should "default attributes to empty hash if not present" do
99
+ @data['opt']['user'][1].attributes.should == {}
100
+ end
101
+ end
71
102
 
72
103
  should "should typecast an integer" do
73
104
  xml = "<tag type='integer'>10</tag>"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-21 00:00:00 -04:00
12
+ date: 2009-06-30 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,10 +23,13 @@ extra_rdoc_files:
23
23
  - LICENSE
24
24
  - README.rdoc
25
25
  files:
26
+ - .gitignore
27
+ - History
26
28
  - LICENSE
27
29
  - README.rdoc
28
30
  - Rakefile
29
31
  - VERSION.yml
32
+ - crack.gemspec
30
33
  - lib/crack.rb
31
34
  - lib/crack/core_extensions.rb
32
35
  - lib/crack/json.rb