hana 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
- === 1.0.0 / 2012-09-05
1
+ Fri Sep 7 18:54:17 2012 Aaron Patterson <aaron@tenderlovemaking.com>
2
2
 
3
- * 1 major enhancement
3
+ * Bumping the version.
4
4
 
5
- * Birthday!
5
+ Fri Sep 7 18:53:16 2012 Aaron Patterson <aaron@tenderlovemaking.com>
6
+
7
+ * validate commands an raise an exception Just In Case
6
8
 
@@ -1,7 +1,7 @@
1
1
  .autotest
2
2
  CHANGELOG.rdoc
3
3
  Manifest.txt
4
- README.rdoc
4
+ README.md
5
5
  Rakefile
6
6
  lib/hana.rb
7
7
  test/helper.rb
@@ -1,38 +1,38 @@
1
- = hana
1
+ # hana
2
2
 
3
3
  * http://github.com/tenderlove/hana
4
4
 
5
- == DESCRIPTION:
5
+ ## DESCRIPTION:
6
6
 
7
- Implementation of JSON Patch and JSON Pointer drafts.
7
+ Implementation of [JSON Patch][1] and [JSON Pointer][2] drafts.
8
8
 
9
- == FEATURES/PROBLEMS:
9
+ ## FEATURES/PROBLEMS:
10
10
 
11
- Implements draft specs of the JSON Patch and JSON pointer spec:
11
+ Implements draft specs of the [JSON Patch][1] and [JSON pointer][2] spec:
12
12
 
13
- * http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-01
14
- * http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03
15
13
 
16
14
  These are drafts, so it could change. This works against Ruby objects, so you
17
15
  should load the JSON to Ruby, process it, then emit as JSON again.
18
16
 
19
- == SYNOPSIS:
17
+ ## SYNOPSIS:
20
18
 
21
- patch = Hana::Patch.new [
22
- { 'add' => '/baz', 'value' => 'qux' }
23
- ]
24
-
25
- patch.apply('foo' => 'bar') # => {'baz' => 'qux', 'foo' => 'bar'}
19
+ ```ruby
20
+ patch = Hana::Patch.new [
21
+ { 'add' => '/baz', 'value' => 'qux' }
22
+ ]
26
23
 
27
- == REQUIREMENTS:
24
+ patch.apply('foo' => 'bar') # => {'baz' => 'qux', 'foo' => 'bar'}
25
+ ```
26
+
27
+ ## REQUIREMENTS:
28
28
 
29
29
  * Ruby
30
30
 
31
- == INSTALL:
31
+ ## INSTALL:
32
32
 
33
- * gem install hana
33
+ $ gem install hana
34
34
 
35
- == LICENSE:
35
+ ## LICENSE:
36
36
 
37
37
  (The MIT License)
38
38
 
@@ -56,3 +56,6 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
56
56
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
57
57
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
58
58
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
59
+
60
+ [1]: http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03
61
+ [2]: http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-01
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ Hoe.plugin :git # `gem install hoe-git`
10
10
 
11
11
  Hoe.spec 'hana' do
12
12
  developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
13
- self.readme_file = 'README.rdoc'
13
+ self.readme_file = 'README.md'
14
14
  self.history_file = 'CHANGELOG.rdoc'
15
15
  self.extra_rdoc_files = FileList['*.rdoc']
16
16
  end
@@ -1,5 +1,5 @@
1
1
  module Hana
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
 
4
4
  class Pointer
5
5
  include Enumerable
@@ -12,9 +12,7 @@ module Hana
12
12
  @path.each { |x| yield x }
13
13
  end
14
14
 
15
- def to_a
16
- @path.dup
17
- end
15
+ def to_a; @path.dup; end
18
16
 
19
17
  def eval object
20
18
  Pointer.eval @path, object
@@ -39,12 +37,14 @@ module Hana
39
37
  @is = is
40
38
  end
41
39
 
40
+ VALID = Hash[%w{ add move test replace remove }.map { |x| [x,x]}] # :nodoc:
41
+
42
42
  def apply doc
43
- doc = doc.dup
44
- @is.each { |ins|
45
- send ins.keys.sort.first, ins, doc
43
+ @is.each_with_object(doc) { |ins, doc|
44
+ send VALID.fetch(ins.keys.sort.first) { |k|
45
+ raise Exception, "bad method `#{k}`"
46
+ }, ins, doc
46
47
  }
47
- doc
48
48
  end
49
49
 
50
50
  private
@@ -78,7 +78,7 @@ module Hana
78
78
  dest = Pointer.eval(to, doc)
79
79
 
80
80
  if Array === dest
81
- dest.insert(to_key.to_i, obj)
81
+ dest.insert to_key.to_i, obj
82
82
  else
83
83
  dest[to_key] = obj
84
84
  end
@@ -2,6 +2,15 @@ require 'helper'
2
2
 
3
3
  module Hana
4
4
  class TestPatch < TestCase
5
+ def test_no_eval
6
+ patch = Hana::Patch.new [
7
+ { 'eval' => '1' }
8
+ ]
9
+ assert_raises(Hana::Patch::Exception) do
10
+ patch.apply('foo' => 'bar')
11
+ end
12
+ end
13
+
5
14
  def test_add_member
6
15
  patch = Hana::Patch.new [
7
16
  { 'add' => '/baz', 'value' => 'qux' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hana
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-05 00:00:00.000000000 Z
12
+ date: 2012-09-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '3.3'
21
+ version: '3.4'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '3.3'
29
+ version: '3.4'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rdoc
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.0'
62
- description: Implementation of JSON Patch and JSON Pointer drafts.
62
+ description: Implementation of [JSON Patch][1] and [JSON Pointer][2] drafts.
63
63
  email:
64
64
  - aaron@tenderlovemaking.com
65
65
  executables: []
@@ -67,12 +67,11 @@ extensions: []
67
67
  extra_rdoc_files:
68
68
  - CHANGELOG.rdoc
69
69
  - Manifest.txt
70
- - README.rdoc
71
70
  files:
72
71
  - .autotest
73
72
  - CHANGELOG.rdoc
74
73
  - Manifest.txt
75
- - README.rdoc
74
+ - README.md
76
75
  - Rakefile
77
76
  - lib/hana.rb
78
77
  - test/helper.rb
@@ -84,7 +83,7 @@ licenses: []
84
83
  post_install_message:
85
84
  rdoc_options:
86
85
  - --main
87
- - README.rdoc
86
+ - README.md
88
87
  require_paths:
89
88
  - lib
90
89
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -104,7 +103,7 @@ rubyforge_project: hana
104
103
  rubygems_version: 1.8.24
105
104
  signing_key:
106
105
  specification_version: 3
107
- summary: Implementation of JSON Patch and JSON Pointer drafts.
106
+ summary: Implementation of [JSON Patch][1] and [JSON Pointer][2] drafts.
108
107
  test_files:
109
108
  - test/test_hana.rb
110
109
  - test/test_patch.rb