active_record_stash 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 CHANGED
@@ -1,24 +1,4 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
1
+ *.gem
22
2
  .bundle
23
-
24
- *.sqlite3
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile CHANGED
@@ -1,10 +1,4 @@
1
- source :gemcutter
2
- gem 'rake'
3
- gem 'rspec'
4
- gem 'jeweler'
5
- gem 'activesupport', '3.0.0.beta4', :require => 'active_support'
6
- gem 'ruby-debug'
7
- gem 'activemodel', '3.0.0.beta4'
8
- gem 'activerecord', '3.0.0.beta4'
9
- gem "sqlite3-ruby", "~> 1.3.0", :require => 'sqlite3'
1
+ source "http://rubygems.org"
10
2
 
3
+ # Specify your gem's dependencies in active_record_stash.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,45 +1 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "active_record_stash"
8
- gem.summary = %Q{allow attributes stored in serialized columns to be first class active record attributes}
9
- gem.description = %Q{provide validations and form helper functionality to attributes stored in serialized ActiveRecord columns}
10
- gem.email = "stefan.penner@gmail.com"
11
- gem.homepage = "http://github.com/stefanpenner/active_record_stash"
12
- gem.authors = ["Stefan Penner"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
26
-
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
31
- end
32
-
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "active_record_stash #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
1
+ require "bundler/gem_tasks"
@@ -1,58 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "active_record_stash/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{active_record_stash}
8
- s.version = "0.1.1"
6
+ s.name = "active_record_stash"
7
+ s.version = ActiveRecordStash::VERSION
8
+ s.authors = ["Stefan Penner"]
9
+ s.email = ["stefan.penner@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Validations for serialized ActiveRecrd fields}
12
+ s.description = %q{ActiveRecordStash provides a helpful syntax, which faciliates active_model compliant attributes, which are stored within a single serialized attribute. Poor mans NoSQL with AR}
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Stefan Penner"]
12
- s.date = %q{2010-06-20}
13
- s.description = %q{provide validations and form helper functionality to attributes stored in serialized ActiveRecord columns}
14
- s.email = %q{stefan.penner@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "active_record_stash.gemspec",
29
- "init.rb",
30
- "lib/active_record_stash.rb",
31
- "spec/active_record_stash_spec.rb",
32
- "spec/spec.opts",
33
- "spec/spec_helper.rb"
34
- ]
35
- s.homepage = %q{http://github.com/stefanpenner/active_record_stash}
36
- s.rdoc_options = ["--charset=UTF-8"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.7}
39
- s.summary = %q{allow attributes stored in serialized columns to be first class active record attributes}
40
- s.test_files = [
41
- "spec/active_record_stash_spec.rb",
42
- "spec/spec_helper.rb"
43
- ]
14
+ s.rubyforge_project = "active_record_stash"
44
15
 
45
- if s.respond_to? :specification_version then
46
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
- s.specification_version = 3
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
48
20
 
49
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
51
- else
52
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
53
- end
54
- else
55
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
56
- end
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
57
24
  end
58
-
@@ -0,0 +1,3 @@
1
+ module ActiveRecordStash
2
+ VERSION = "0.1.2"
3
+ end
@@ -1,62 +1,62 @@
1
- module ActiveRecord
2
- module Stash
1
+ require "active_record_stash/version"
3
2
 
4
- extend ActiveSupport::Concern
3
+ module ActiveRecordStash
4
+ # Your code goes here...
5
+ extend ActiveSupport::Concern
5
6
 
6
- NO_TARGET_ERROR = "stashing needs a target serialized column. Supply an options hash with a :in key as the last argument (e.g. stash :apple, :in => :greeter)."
7
-
8
- included do
9
- class_inheritable_accessor :stashed_attributes
10
- self.stashed_attributes = Hash.new([])
7
+ NO_TARGET_ERROR = "stashing needs a target serialized column. Supply an options hash with a :in key as the last argument (e.g. stash :apple, :in => :greeter)."
11
8
 
12
- after_initialize :_load_stashed_attributes
13
- before_save :_stash_attributes
14
- end
15
-
16
- private
17
- def _load_stashed_attributes
18
- stashed_attributes.each_pair do |store_name,methods|
19
- store = send(store_name)
9
+ included do
10
+ class_attribute :stashed_attributes
11
+ self.stashed_attributes = Hash.new([])
12
+
13
+ after_initialize :_load_stashed_attributes
14
+ before_save :_stash_attributes
15
+ end
20
16
 
21
- next unless store
17
+ private
18
+ def _load_stashed_attributes
19
+ stashed_attributes.each_pair do |store_name,methods|
20
+ store = send(store_name)
22
21
 
23
- methods.each do |method|
24
- send :"#{method}=", store[method] unless send(method)
25
- end
22
+ next unless store
26
23
 
24
+ methods.each do |method|
25
+ send :"#{method}=", store[method] unless send(method)
27
26
  end
28
- end
29
27
 
30
- def _stash_attributes
31
- stashed_attributes.each_pair do |store_name,methods|
28
+ end
29
+ end
32
30
 
33
- eval "self.#{store_name} ||= {}"
31
+ def _stash_attributes
32
+ stashed_attributes.each_pair do |store_name,methods|
34
33
 
35
- methods.each do |method|
36
- send(store_name)[method] = send method
37
- end
34
+ eval "self.#{store_name} ||= {}"
38
35
 
36
+ methods.each do |method|
37
+ send(store_name)[method] = send method
39
38
  end
39
+
40
40
  end
41
+ end
42
+
43
+ module ClassMethods
41
44
 
42
- module ClassMethods
43
-
44
- def stash *methods
45
- options = methods.extract_options!
46
- options.assert_valid_keys(:in)
47
- options.symbolize_keys!
48
-
49
- unless serialized_column = options[:in]
50
- raise ArgumentError, NO_TARGET_ERROR
51
- end
52
-
53
- stashed_attributes[serialized_column] += methods.map(&:to_sym)
54
-
55
- serialize serialized_column
56
- attr_accessor *methods
45
+ def stash *methods
46
+ options = methods.extract_options!
47
+ options.assert_valid_keys(:in)
48
+ options.symbolize_keys!
49
+
50
+ unless serialized_column = options[:in]
51
+ raise ArgumentError, NO_TARGET_ERROR
57
52
  end
53
+
54
+ stashed_attributes[serialized_column] += methods.map(&:to_sym)
55
+
56
+ serialize serialized_column
57
+ attr_accessor *methods
58
58
  end
59
59
  end
60
60
  end
61
61
 
62
- ActiveRecord::Base.send(:include, ActiveRecord::Stash)
62
+ ActiveRecord::Base.send(:include, ActiveRecordStash)
metadata CHANGED
@@ -1,49 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_record_stash
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Stefan Penner
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-06-20 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 13
30
- segments:
31
- - 1
32
- - 2
33
- - 9
34
- version: 1.2.9
35
- type: :development
36
- version_requirements: *id001
37
- description: provide validations and form helper functionality to attributes stored in serialized ActiveRecord columns
38
- email: stefan.penner@gmail.com
12
+ date: 2012-01-23 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ActiveRecordStash provides a helpful syntax, which faciliates active_model
15
+ compliant attributes, which are stored within a single serialized attribute. Poor
16
+ mans NoSQL with AR
17
+ email:
18
+ - stefan.penner@gmail.com
39
19
  executables: []
40
-
41
20
  extensions: []
42
-
43
- extra_rdoc_files:
44
- - LICENSE
45
- - README.rdoc
46
- files:
21
+ extra_rdoc_files: []
22
+ files:
47
23
  - .document
48
24
  - .gitignore
49
25
  - Gemfile
@@ -55,43 +31,36 @@ files:
55
31
  - active_record_stash.gemspec
56
32
  - init.rb
57
33
  - lib/active_record_stash.rb
34
+ - lib/active_record_stash/version.rb
58
35
  - spec/active_record_stash_spec.rb
59
36
  - spec/spec.opts
60
37
  - spec/spec_helper.rb
61
- has_rdoc: true
62
- homepage: http://github.com/stefanpenner/active_record_stash
38
+ homepage: ''
63
39
  licenses: []
64
-
65
40
  post_install_message:
66
- rdoc_options:
67
- - --charset=UTF-8
68
- require_paths:
41
+ rdoc_options: []
42
+ require_paths:
69
43
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
44
+ required_ruby_version: !ruby/object:Gem::Requirement
71
45
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
79
- required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
51
  none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
88
56
  requirements: []
89
-
90
- rubyforge_project:
91
- rubygems_version: 1.3.7
57
+ rubyforge_project: active_record_stash
58
+ rubygems_version: 1.8.15
92
59
  signing_key:
93
60
  specification_version: 3
94
- summary: allow attributes stored in serialized columns to be first class active record attributes
95
- test_files:
61
+ summary: Validations for serialized ActiveRecrd fields
62
+ test_files:
96
63
  - spec/active_record_stash_spec.rb
64
+ - spec/spec.opts
97
65
  - spec/spec_helper.rb
66
+ has_rdoc: