active_record_serialize_json 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.travis.yml +9 -0
- data/Gemfile +5 -0
- data/README.rdoc +21 -0
- data/Rakefile +21 -85
- data/VERSION +1 -1
- data/active_record_serialize_json.gemspec +41 -0
- data/lib/active_record/serialize_json.rb +4 -2
- data/lib/active_record/serialize_json/version.rb +7 -9
- metadata +64 -25
- data/README +0 -25
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
== Description
|
2
|
+
|
3
|
+
Allows serialization of ruby data structures into text columns before Rails
|
4
|
+
version 3.1.
|
5
|
+
|
6
|
+
== Installation
|
7
|
+
|
8
|
+
You can use rubygems to fetch the gem and install it for you:
|
9
|
+
|
10
|
+
# gem install active_record_serialize_json
|
11
|
+
|
12
|
+
You can also put this line into your Rails Gemfile file
|
13
|
+
|
14
|
+
gem 'active_record_serialize_json'
|
15
|
+
|
16
|
+
and install the gem via
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
|
data/Rakefile
CHANGED
@@ -1,86 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# vim: set filetype=ruby et sw=2 ts=2:
|
2
|
+
|
3
|
+
require 'gem_hadar'
|
4
|
+
|
5
|
+
GemHadar do
|
6
|
+
name 'active_record_serialize_json'
|
7
|
+
path_name 'active_record/serialize_json'
|
8
|
+
path_module 'ActiveRecord::SerializeJSON'
|
9
|
+
module_type :class
|
10
|
+
author 'Florian Frank'
|
11
|
+
email 'flori@ping.de'
|
12
|
+
homepage "http://github.com/flori/#{name}"
|
13
|
+
summary 'Serialize an ActiveRecord::Base attribute via JSON'
|
14
|
+
description "#{summary} in Ruby on Rails"
|
15
|
+
test_dir 'test'
|
16
|
+
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage', '.DS_Store'
|
17
|
+
readme 'README.rdoc'
|
18
|
+
|
19
|
+
dependency 'json', '~>1.6.0'
|
20
|
+
dependency 'activerecord', '<3.1'
|
21
|
+
dependency 'mysql2', '~>0.2.0'
|
4
22
|
end
|
5
|
-
require 'rake/clean'
|
6
|
-
require 'rbconfig'
|
7
|
-
include Config
|
8
|
-
|
9
|
-
PKG_NAME = 'active_record_serialize_json'
|
10
|
-
PKG_VERSION = File.read('VERSION').chomp
|
11
|
-
PKG_FILES = FileList['**/*'].exclude(/^(doc|CVS|pkg|coverage)/)
|
12
|
-
PKG_SUMMARY = 'Serialize an ActiveRecord::Base attribute via JSON'
|
13
|
-
PKG_RDOC_OPTIONS = [ '--main', 'README', '--title', PKG_SUMMARY ]
|
14
|
-
CLEAN.include 'coverage', 'doc'
|
15
|
-
|
16
|
-
desc "Testing library"
|
17
|
-
task :test do
|
18
|
-
ruby %{-Ilib test/serialize_json_test.rb}
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "Testing library (with coverage)"
|
22
|
-
task :coverage do
|
23
|
-
sh %{rcov -Ilib test/serialize_json_test.rb}
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "Installing library"
|
27
|
-
task :install do
|
28
|
-
ruby 'install.rb'
|
29
|
-
end
|
30
|
-
|
31
|
-
desc "Creating documentation"
|
32
|
-
task :doc do
|
33
|
-
sh 'rdoc', *(PKG_RDOC_OPTIONS + Dir['lib/**/*.rb'] + [ 'README' ])
|
34
|
-
end
|
35
|
-
|
36
|
-
if defined? Gem
|
37
|
-
spec = Gem::Specification.new do |s|
|
38
|
-
s.name = PKG_NAME
|
39
|
-
s.version = PKG_VERSION
|
40
|
-
s.summary = PKG_SUMMARY
|
41
|
-
s.description = PKG_SUMMARY + ' in Ruby on Rails'
|
42
|
-
|
43
|
-
s.files = PKG_FILES.to_a.sort
|
44
|
-
|
45
|
-
s.require_path = 'lib'
|
46
|
-
|
47
|
-
s.rdoc_options = PKG_RDOC_OPTIONS
|
48
|
-
s.extra_rdoc_files << 'README'
|
49
|
-
#s.test_files << 'test/serialize_json_test.rb'
|
50
|
-
|
51
|
-
s.author = "Florian Frank"
|
52
|
-
s.email = "flori@ping.de"
|
53
|
-
s.homepage = "http://flori.github.com/#{PKG_NAME}"
|
54
|
-
s.rubyforge_project = "#{PKG_NAME}"
|
55
|
-
s.add_dependency 'json', '~>1.0'
|
56
|
-
s.add_dependency 'activerecord'
|
57
|
-
end
|
58
|
-
|
59
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
60
|
-
pkg.need_tar = true
|
61
|
-
pkg.package_files += PKG_FILES
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
desc m = "Writing version information for #{PKG_VERSION}"
|
66
|
-
task :version do
|
67
|
-
puts m
|
68
|
-
File.open(File.join('lib', 'active_record', 'serialize_json', 'version.rb'), 'w') do |v|
|
69
|
-
v.puts <<EOT
|
70
|
-
module ActiveRecord
|
71
|
-
module SerializeJSON
|
72
|
-
# ActiveRecord::SerializeJSON version
|
73
|
-
VERSION = '#{PKG_VERSION}'
|
74
|
-
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
|
75
|
-
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
76
|
-
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
77
|
-
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
78
|
-
end
|
79
|
-
end
|
80
|
-
EOT
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
task :default => [ :version, :test ]
|
85
|
-
|
86
|
-
task :release => [ :clean, :version, :package ]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "active_record_serialize_json"
|
5
|
+
s.version = "0.1.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Florian Frank"]
|
9
|
+
s.date = "2011-12-09"
|
10
|
+
s.description = "Serialize an ActiveRecord::Base attribute via JSON in Ruby on Rails"
|
11
|
+
s.email = "flori@ping.de"
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/active_record/serialize_json/version.rb", "lib/active_record/serialize_json.rb", "lib/active_record_serialize_json.rb"]
|
13
|
+
s.files = [".gitignore", ".travis.yml", "CHANGES", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "active_record_serialize_json.gemspec", "lib/active_record/serialize_json.rb", "lib/active_record/serialize_json/version.rb", "lib/active_record_serialize_json.rb", "test/serialize_json_test.rb"]
|
14
|
+
s.homepage = "http://github.com/flori/active_record_serialize_json"
|
15
|
+
s.rdoc_options = ["--title", "ActiveRecordSerializeJson - Serialize an ActiveRecord::Base attribute via JSON", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubygems_version = "1.8.10"
|
18
|
+
s.summary = "Serialize an ActiveRecord::Base attribute via JSON"
|
19
|
+
s.test_files = ["test/serialize_json_test.rb"]
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.4"])
|
26
|
+
s.add_runtime_dependency(%q<json>, ["~> 1.6.0"])
|
27
|
+
s.add_runtime_dependency(%q<activerecord>, ["< 3.1"])
|
28
|
+
s.add_runtime_dependency(%q<mysql2>, ["~> 0.2.0"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<gem_hadar>, ["~> 0.1.4"])
|
31
|
+
s.add_dependency(%q<json>, ["~> 1.6.0"])
|
32
|
+
s.add_dependency(%q<activerecord>, ["< 3.1"])
|
33
|
+
s.add_dependency(%q<mysql2>, ["~> 0.2.0"])
|
34
|
+
end
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<gem_hadar>, ["~> 0.1.4"])
|
37
|
+
s.add_dependency(%q<json>, ["~> 1.6.0"])
|
38
|
+
s.add_dependency(%q<activerecord>, ["< 3.1"])
|
39
|
+
s.add_dependency(%q<mysql2>, ["~> 0.2.0"])
|
40
|
+
end
|
41
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
require 'active_record
|
1
|
+
require 'active_record'
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module ActiveRecord
|
5
5
|
class SerializeJSON
|
6
|
+
require 'active_record/serialize_json/version'
|
7
|
+
|
6
8
|
def initialize(attribute, opts = {})
|
7
9
|
@attribute = attribute.to_s.to_sym
|
8
10
|
@serialize = opts[:serialize] || {}
|
@@ -33,7 +35,7 @@ module ActiveRecord
|
|
33
35
|
|
34
36
|
def self.serialize(value, opts = {})
|
35
37
|
opts ||= {}
|
36
|
-
result = value
|
38
|
+
result = JSON(value, opts)
|
37
39
|
result =~ /\A\s*[{\[]/ and result
|
38
40
|
end
|
39
41
|
|
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
9
|
-
end
|
1
|
+
class ActiveRecord::SerializeJSON
|
2
|
+
# ActiveRecord::SerializeJSON version
|
3
|
+
VERSION = '0.1.2'
|
4
|
+
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
5
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
6
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
7
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
10
8
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_serialize_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Florian Frank
|
@@ -15,13 +15,28 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-12-09 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
21
|
+
name: gem_hadar
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 19
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 1
|
32
|
+
- 4
|
33
|
+
version: 0.1.4
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
40
|
none: false
|
26
41
|
requirements:
|
27
42
|
- - ~>
|
@@ -29,24 +44,42 @@ dependencies:
|
|
29
44
|
hash: 15
|
30
45
|
segments:
|
31
46
|
- 1
|
47
|
+
- 6
|
32
48
|
- 0
|
33
|
-
version:
|
49
|
+
version: 1.6.0
|
34
50
|
type: :runtime
|
35
|
-
version_requirements: *
|
51
|
+
version_requirements: *id002
|
36
52
|
- !ruby/object:Gem::Dependency
|
37
53
|
name: activerecord
|
38
54
|
prerelease: false
|
39
|
-
requirement: &
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
56
|
none: false
|
41
57
|
requirements:
|
42
|
-
- -
|
58
|
+
- - <
|
43
59
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
60
|
+
hash: 5
|
61
|
+
segments:
|
62
|
+
- 3
|
63
|
+
- 1
|
64
|
+
version: "3.1"
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: mysql2
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 23
|
45
76
|
segments:
|
46
77
|
- 0
|
47
|
-
|
78
|
+
- 2
|
79
|
+
- 0
|
80
|
+
version: 0.2.0
|
48
81
|
type: :runtime
|
49
|
-
version_requirements: *
|
82
|
+
version_requirements: *id004
|
50
83
|
description: Serialize an ActiveRecord::Base attribute via JSON in Ruby on Rails
|
51
84
|
email: flori@ping.de
|
52
85
|
executables: []
|
@@ -54,26 +87,32 @@ executables: []
|
|
54
87
|
extensions: []
|
55
88
|
|
56
89
|
extra_rdoc_files:
|
57
|
-
- README
|
90
|
+
- README.rdoc
|
91
|
+
- lib/active_record/serialize_json/version.rb
|
92
|
+
- lib/active_record/serialize_json.rb
|
93
|
+
- lib/active_record_serialize_json.rb
|
58
94
|
files:
|
95
|
+
- .gitignore
|
96
|
+
- .travis.yml
|
59
97
|
- CHANGES
|
60
|
-
-
|
98
|
+
- Gemfile
|
99
|
+
- README.rdoc
|
61
100
|
- Rakefile
|
62
101
|
- VERSION
|
102
|
+
- active_record_serialize_json.gemspec
|
63
103
|
- lib/active_record/serialize_json.rb
|
64
104
|
- lib/active_record/serialize_json/version.rb
|
65
105
|
- lib/active_record_serialize_json.rb
|
66
106
|
- test/serialize_json_test.rb
|
67
|
-
|
68
|
-
homepage: http://flori.github.com/active_record_serialize_json
|
107
|
+
homepage: http://github.com/flori/active_record_serialize_json
|
69
108
|
licenses: []
|
70
109
|
|
71
110
|
post_install_message:
|
72
111
|
rdoc_options:
|
73
|
-
- --main
|
74
|
-
- README
|
75
112
|
- --title
|
76
|
-
- Serialize an ActiveRecord::Base attribute via JSON
|
113
|
+
- ActiveRecordSerializeJson - Serialize an ActiveRecord::Base attribute via JSON
|
114
|
+
- --main
|
115
|
+
- README.rdoc
|
77
116
|
require_paths:
|
78
117
|
- lib
|
79
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -96,10 +135,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
135
|
version: "0"
|
97
136
|
requirements: []
|
98
137
|
|
99
|
-
rubyforge_project:
|
100
|
-
rubygems_version: 1.
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.8.10
|
101
140
|
signing_key:
|
102
141
|
specification_version: 3
|
103
142
|
summary: Serialize an ActiveRecord::Base attribute via JSON
|
104
|
-
test_files:
|
105
|
-
|
143
|
+
test_files:
|
144
|
+
- test/serialize_json_test.rb
|
data/README
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
== Description
|
2
|
-
|
3
|
-
== Download
|
4
|
-
|
5
|
-
The latest version of the <b>active_record_serialize_json</b> source archive can be
|
6
|
-
found at
|
7
|
-
|
8
|
-
* http://www.ping.de/~flori
|
9
|
-
|
10
|
-
== Installation
|
11
|
-
|
12
|
-
You can use rubygems to fetch the gem and install it for you:
|
13
|
-
|
14
|
-
# gem install active_record_serialize_json
|
15
|
-
|
16
|
-
You can also put this line into your Rails environment.rb file
|
17
|
-
|
18
|
-
config.gem 'active_record_serialize_json'
|
19
|
-
|
20
|
-
and install the gem via
|
21
|
-
|
22
|
-
$ rake gems:install
|
23
|
-
|
24
|
-
== Usage
|
25
|
-
|