jsontrim 0.1.1 → 0.1.2

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.
data/Rakefile CHANGED
@@ -13,6 +13,8 @@ begin
13
13
  gem.add_development_dependency "thoughtbot-shoulda"
14
14
  gem.add_dependency "json"
15
15
  end
16
+
17
+ Jeweler::GemcutterTasks.new
16
18
  rescue LoadError
17
19
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
20
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/jsontrim.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jsontrim}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Levin Alexander"]
12
- s.date = %q{2009-10-09}
12
+ s.date = %q{2009-10-28}
13
13
  s.description = %q{remove unimportant elements from a json object}
14
14
  s.email = %q{mail@levinalex.net}
15
15
  s.extra_rdoc_files = [
data/lib/jsontrim.rb CHANGED
@@ -51,9 +51,10 @@ class JSONTrim
51
51
  end
52
52
 
53
53
  js = JSON.pretty_generate(obj)
54
- js = js.gsub('"IGN_HSH"', "{ ... }")
55
- js = js.gsub('"IGN_ARY"', "[ ... ]")
56
- js = js.gsub('"IGN"', "...")
54
+ js = js.gsub('"IGN_HSH"', "{ /*...*/ }")
55
+ js = js.gsub('"IGN_ARY"', "[ /*...*/ ]")
56
+ js = js.gsub('"IGN_CDR"', "// ...")
57
+ js = js.gsub('"IGN"', '"..."')
57
58
  end
58
59
 
59
60
  # recursively prune the current ruby object with the given rules
@@ -76,7 +77,7 @@ class JSONTrim
76
77
  end if data[name]
77
78
  elsif key =~ /^\+$/
78
79
  if Array === data
79
- data = [data.first, "IGN"]
80
+ data = [data.first, "IGN_CDR"]
80
81
  end
81
82
  elsif key =~ /^\*$/
82
83
  if Array === data
@@ -22,35 +22,35 @@ class JsontrimTest < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  should "distinguish between arrays and hashes" do
25
- assert_equal %Q({\n "foo": { ... }\n}),
25
+ assert_equal %Q({\n "foo": { /*...*/ }\n}),
26
26
  JSONTrim.cut(%q({"foo" : { "bar": "fred"}}), :ignore => ["!foo"])
27
- assert_equal %Q({\n "foo": [ ... ]\n}),
27
+ assert_equal %Q({\n "foo": [ /*...*/ ]\n}),
28
28
  JSONTrim.cut(%q({"foo" : [ "bar", "fred"]}), :ignore => ["!foo"])
29
- assert_equal %Q({\n "foo": ...\n}),
29
+ assert_equal %Q({\n "foo": "..."\n}),
30
30
  JSONTrim.cut(%q({"foo" : 3}), :ignore => ["!foo"])
31
31
  end
32
32
 
33
33
  should "work for nested attributes" do
34
- assert_equal %Q({\n "foo": {\n "bar": { ... }\n }\n}),
34
+ assert_equal %Q({\n "foo": {\n "bar": { /*...*/ }\n }\n}),
35
35
  JSONTrim.cut(%q({"foo" : { "bar": {"f":3}}}), :ignore => ["foo:!bar"])
36
36
 
37
- assert_equal %Q({\n "foo": {\n "bar": ...\n }\n}),
37
+ assert_equal %Q({\n "foo": {\n "bar": "..."\n }\n}),
38
38
  JSONTrim.cut(%q({"foo" : { "bar": 3}}), :ignore => ["foo:!bar"])
39
39
  end
40
40
 
41
41
  should "not alter json if ignored thing does not exist" do
42
- assert_equal %Q({\n "foo": { ... }\n}),
42
+ assert_equal %Q({\n "foo": { /*...*/ }\n}),
43
43
  JSONTrim.cut(%q({"foo" : { "bar": "fred"}}),
44
44
  :ignore => ["!foo", "!doesnotexist", "foo:!doesnotexist"])
45
45
  end
46
46
 
47
47
  should "allow ignoring of subelements of arrays" do
48
- assert_equal_ws %Q({"foo":[{"bar": { ... }},{"bar": ...}]}),
48
+ assert_equal_ws %Q({"foo":[{"bar": { /*...*/ }},{"bar": "..."}]}),
49
49
  JSONTrim.cut(%q({"foo" : [{ "bar": {"baz":3}}, {"bar":3}]}), :ignore => ["foo:*:!bar"])
50
50
  end
51
51
 
52
52
  should "allow ignoring of arrays" do
53
- assert_equal %Q({\n "foo": [\n "bar",\n ...\n ]\n}),
53
+ assert_equal %Q({\n "foo": [\n "bar",\n // ...\n ]\n}),
54
54
  JSONTrim.cut(%q({"foo": ["bar", "baz", "fred"]}),
55
55
  :ignore => ["foo:+"])
56
56
  end
@@ -73,18 +73,18 @@ class JsontrimTest < Test::Unit::TestCase
73
73
  expected = <<-EOF
74
74
  {
75
75
  "foo": {
76
- "two": ...,
76
+ "two": "...",
77
77
  "three": {
78
- "b": [ ... ]
78
+ "b": [ /*...*/ ]
79
79
  },
80
80
  "one": {
81
81
  "a": 1,
82
- "b": { ... }
82
+ "b": { /*...*/ }
83
83
  }
84
84
  },
85
85
  "bar": [
86
86
  1,
87
- ...
87
+ // ...
88
88
  ]
89
89
  }
90
90
  EOF
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsontrim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levin Alexander
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-09 00:00:00 +02:00
12
+ date: 2009-10-28 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency