edn 1.0.0 → 1.0.1

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.
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+ - jruby-19mode # JRuby in 1.9 mode
7
+ # - "1.8.7"
8
+ # - jruby-18mode # JRuby in 1.8 mode
9
+ script: bundle exec rspec spec
@@ -1,3 +1,6 @@
1
+ # 1.0.1
2
+ * EDN.register defaults to the identity function when no handler is given
3
+
1
4
  # 0.9.4 (18 Sep 2012)
2
5
 
3
6
  * Require `set`
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # edn-ruby
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/relevance/edn-ruby.png)](http://travis-ci.org/relevance/edn-ruby)
4
+
5
+
3
6
  © 2012 Relevance Inc
4
7
 
5
8
  **edn-ruby** is a Ruby library to read and write [edn][edn] (extensible data notation), a subset of Clojure used for transferring data between applications, much like JSON, YAML, or XML.
@@ -61,7 +64,7 @@ r.count #=> 2
61
64
 
62
65
  **NOTE**: Comments requested on the following.
63
66
 
64
- In **edn**, you have _keywords_, which look like Ruby symbols and have the same meaning and purpose. These are converted to Ruby symbols.
67
+ In **edn**, you have _keywords_, which look like Ruby symbols and have the same meaning and purpose. These are converted to Ruby symbols.
65
68
 
66
69
  You have **edn** _symbols_, which generally reflect variable names, but have several purposes. We parse these and return `EDN::Type::Symbol` values for them, as they are not directly portable into Ruby. To create an **edn** symbol in Ruby, call `EDN::Type::Symbol.new` or `EDN.symbol` with a string argument, or use the convenience unary operator `~` like so: `~"elf/rings"`.
67
70
 
@@ -100,7 +103,7 @@ EDN.register("clinton/uri") do |uri|
100
103
  URI(uri)
101
104
  end
102
105
 
103
- EDN.register("clinton/date", lambda { |date_array| Date.new(*date_array) }
106
+ EDN.register("clinton/date", lambda { |date_array| Date.new(*date_array) })
104
107
 
105
108
  class Dog
106
109
  def initialize(name)
@@ -135,6 +138,22 @@ end
135
138
 
136
139
  This method calls `.to_edn` on the second argument and joins the arguments appropriately.
137
140
 
141
+ Other examples are:
142
+ ```
143
+ EDN.tagout("wolf/pack", {:alpha=>"Greybeard", :betas=>["Frostpaw", "Blackwind", "Bloodjaw"]})
144
+ => "#wolf/pack {:alpha \"Greybeard\", :betas [\"Frostpaw\" \"Blackwind\" \"Bloodjaw\"]}"
145
+
146
+ class Range
147
+ def to_edn
148
+ EDN.tagout("ruby/range", [self.begin, self.end, self.exclude_end?])
149
+ end
150
+ end
151
+
152
+ (0..9).to_edn
153
+ => "#ruby/range [0 9 false]"
154
+ ```
155
+
156
+
138
157
  ## Metadata
139
158
 
140
159
  Certain elements of **edn** can have *metadata*. Metadata is a map of values about the element, which must follow specific rules.
@@ -153,6 +172,7 @@ More than one piece of metadata can be applied to an element. Metadata is applie
153
172
  ## Contributors
154
173
 
155
174
  * Clinton N. Dreisbach (@crnixon)
175
+ * Michael Ficarra (@michaelficarra)
156
176
  * Gabriel Horner (@cldwalker)
157
177
 
158
178
  ## Contributing
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.add_development_dependency 'pry', '~> 0.9.10'
20
20
  gem.add_development_dependency 'rspec', '~> 2.11.0'
21
21
  gem.add_development_dependency 'rantly', '~> 0.3.1'
22
+ gem.add_development_dependency 'rake', '~> 10.0.3'
22
23
  end
data/lib/edn.rb CHANGED
@@ -35,7 +35,9 @@ module EDN
35
35
  func = block
36
36
  end
37
37
 
38
- raise "EDN.register requires a block or callable." if func.nil?
38
+ if func.nil?
39
+ func = lambda { |x| x }
40
+ end
39
41
 
40
42
  if func.is_a?(Class)
41
43
  @tags[tag] = lambda { |*args| func.new(*args) }
@@ -1,3 +1,3 @@
1
1
  module EDN
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -68,6 +68,13 @@ describe EDN do
68
68
  end
69
69
  end
70
70
 
71
+ context "#register" do
72
+ it "uses the identity function when no handler is given" do
73
+ EDN.register "some/tag"
74
+ EDN.read("#some/tag {}").class.should == Hash
75
+ end
76
+ end
77
+
71
78
  context "writing" do
72
79
  it "writes any valid element" do
73
80
  elements = rant(RantlyHelpers::ELEMENT)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 0.3.1
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 10.0.3
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 10.0.3
78
94
  description: ! '''edn implements a reader for Extensible Data Notation by Rich Hickey.'''
79
95
  email:
80
96
  - clinton@thinkrelevance.com
@@ -83,6 +99,7 @@ extensions: []
83
99
  extra_rdoc_files: []
84
100
  files:
85
101
  - .gitignore
102
+ - .travis.yml
86
103
  - CHANGELOG.md
87
104
  - Gemfile
88
105
  - LICENSE
@@ -123,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
140
  version: '0'
124
141
  segments:
125
142
  - 0
126
- hash: -2141916682632630907
143
+ hash: 2104386366038822837
127
144
  required_rubygems_version: !ruby/object:Gem::Requirement
128
145
  none: false
129
146
  requirements:
@@ -132,10 +149,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
149
  version: '0'
133
150
  segments:
134
151
  - 0
135
- hash: -2141916682632630907
152
+ hash: 2104386366038822837
136
153
  requirements: []
137
154
  rubyforge_project:
138
- rubygems_version: 1.8.23
155
+ rubygems_version: 1.8.24
139
156
  signing_key:
140
157
  specification_version: 3
141
158
  summary: ! '''edn implements a reader for Extensible Data Notation by Rich Hickey.'''