json_response 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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{json_response}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["kazuyoshi tlacaelel"]
12
+ s.date = %q{2010-06-11}
13
+ s.description = %q{A simple object that keeps json responses clean and organized.}
14
+ s.email = %q{kazu.dev@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "json_response.gemspec",
27
+ "lib/json_response.rb",
28
+ "test/helper.rb",
29
+ "test/test_json_response.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/ktlacaelel/json_response}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{Json Response wrapper}
36
+ s.test_files = [
37
+ "test/helper.rb",
38
+ "test/test_json_response.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
47
+ else
48
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
49
+ end
50
+ else
51
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
52
+ end
53
+ end
54
+
@@ -1,13 +1,16 @@
1
+ require 'activesupport'
2
+
1
3
  class JsonResponse
2
4
 
3
5
  attr_reader :status
4
6
 
5
7
  def initialize
6
8
  @status = false
9
+ @data = {}
7
10
  end
8
11
 
9
12
  def serialize
10
- { :status => @status }.to_json
13
+ { :status => @status, :data => @data }.to_json
11
14
  end
12
15
 
13
16
  def to_js(callback)
@@ -22,4 +25,8 @@ class JsonResponse
22
25
  @status = false
23
26
  end
24
27
 
28
+ def append(key, value)
29
+ @data[key] = value
30
+ end
31
+
25
32
  end
@@ -1,7 +1,18 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestJsonResponse < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
4
+
5
+ context 'JsonResponse' do
6
+
7
+ setup do
8
+ @jr = JsonResponse.new
9
+ end
10
+
11
+ should 'generate a json string with appropriate data' do
12
+ @jr.append('key', 'value')
13
+ assert_equal @jr.to_js('test'), 'test({"data":{"key":"value"},"status":false});'
14
+ end
15
+
6
16
  end
17
+
7
18
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_response
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - kazuyoshi tlacaelel
@@ -48,6 +48,7 @@ files:
48
48
  - README.rdoc
49
49
  - Rakefile
50
50
  - VERSION
51
+ - json_response.gemspec
51
52
  - lib/json_response.rb
52
53
  - test/helper.rb
53
54
  - test/test_json_response.rb