lazy_attributes 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8bf395ec4389966e4dad936c0fa8094fd39c625
4
- data.tar.gz: 13fe587729ebaaaec642692eb01b524635eb1d56
3
+ metadata.gz: 6b08ca4b2f37b3915592910de0ada36a9d246049
4
+ data.tar.gz: 00a2e4d07c7999591d9abc6b5c5d1dd81af5be5e
5
5
  SHA512:
6
- metadata.gz: ee918019f8d72321362217300e9a1c62a62f05f2bc4e90a406ab029743a2cdbb58c235ba0d1893881067116baab1691e3b94f55d955dbc8cce2efc3d8108481a
7
- data.tar.gz: f70019113a657950c15dd9090de4297cca2b326aa743084fedab4af302236e54afc8f972de4f15988a9d4d249cb4e32346741b5debf60e6cd259662094ebfab2
6
+ metadata.gz: bc2ef56348371beb13886ced937ef44802fc721f9ea0f889c00c9184681c399932a2d7325f1adcc368842c918ccea06bbc9ef1f6c3030454a689c119bd02d38c
7
+ data.tar.gz: bc3a80e96a5407302e72fb970d3ba1f97d5a5c5fb02eab1bf8006a71755027b33f9f1836ccb36c85cedc6e1805c8a5a628ce28bf958e1e0d13d8926131f91b6f
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.1
6
+ - ruby-head
7
+ - jruby-19mode
8
+ gemfile:
9
+ - gemfiles/activerecord_3.2.18.gemfile
10
+ - gemfiles/activerecord_4.0.5.gemfile
11
+ - gemfiles/activerecord_4.1.1.gemfile
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
15
+ - rvm: jruby-19mode
16
+ before_install: gem update --remote bundler
17
+ script:
18
+ - bundle exec rake spec
data/Appraisals ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ %w{ 4.1.1 4.0.5 3.2.18 }.each do |version|
4
+ appraise "activerecord-#{version}" do
5
+ gem 'activerecord', version
6
+ gem 'jdbc-sqlite3', platform: :jruby
7
+ end
8
+ end
data/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # LazyAttributes
2
2
 
3
- TODO: Write a gem description
3
+ lazy_attributes is an ActiveRecord plugin. lazy_attributes loads lazily
4
+ specified attributes.
5
+
6
+ [![Build
7
+ Status](https://travis-ci.org/eitoball/lazy_attributes.svg?branch=master)](https://travis-ci.org/eitoball/lazy_attributes) [![Gem Version](https://badge.fury.io/rb/lazy_attributes.svg)](http://badge.fury.io/rb/lazy_attributes)
8
+
9
+ This gem is heavily inspired by
10
+ [lazy_columns](https://github.com/jorgemanrubia/lazy_columns).
4
11
 
5
12
  ## Installation
6
13
 
@@ -18,7 +25,30 @@ Or install it yourself as:
18
25
 
19
26
  ## Usage
20
27
 
21
- TODO: Write usage instructions here
28
+ In Active Record model, specify attributes that are needed to be loaded
29
+ lazyly with `lazy_attributes`:
30
+
31
+ ```ruby
32
+ class User < ActiveRecord::Base
33
+ lazy_attributes :profile
34
+ lazy_attributes :address, :bio
35
+ end
36
+ ```
37
+
38
+ When model with lazyly-loaded attributes is associated with another
39
+ model, you need specify `select` option in association with
40
+ '.column_symbols_without_lazy'.
41
+
42
+ ```ruby
43
+ class Group < ActiveRecord::Base
44
+ has_many :users, select: User.column_symbols_without_lazy
45
+ end
46
+ ```
47
+
48
+ ## TODO
49
+
50
+ * Reload only attribute that is referenced
51
+ * Clean up code and specs
22
52
 
23
53
  ## Contributing
24
54
 
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "3.2.18"
6
+ gem "jdbc-sqlite3", :platform => :jruby
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ lazy_attributes (0.0.2)
5
+ activerecord (>= 3.2, < 5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (3.2.18)
11
+ activesupport (= 3.2.18)
12
+ builder (~> 3.0.0)
13
+ activerecord (3.2.18)
14
+ activemodel (= 3.2.18)
15
+ activesupport (= 3.2.18)
16
+ arel (~> 3.0.2)
17
+ tzinfo (~> 0.3.29)
18
+ activesupport (3.2.18)
19
+ i18n (~> 0.6, >= 0.6.4)
20
+ multi_json (~> 1.0)
21
+ appraisal (1.0.0)
22
+ bundler
23
+ rake
24
+ thor (>= 0.14.0)
25
+ arel (3.0.3)
26
+ builder (3.0.4)
27
+ database_cleaner (1.3.0)
28
+ diff-lcs (1.2.5)
29
+ i18n (0.6.9)
30
+ multi_json (1.10.1)
31
+ rake (10.3.2)
32
+ rspec (3.0.0)
33
+ rspec-core (~> 3.0.0)
34
+ rspec-expectations (~> 3.0.0)
35
+ rspec-mocks (~> 3.0.0)
36
+ rspec-core (3.0.0)
37
+ rspec-support (~> 3.0.0)
38
+ rspec-expectations (3.0.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.0.0)
41
+ rspec-mocks (3.0.0)
42
+ rspec-support (~> 3.0.0)
43
+ rspec-support (3.0.0)
44
+ sqlite3 (1.3.9)
45
+ thor (0.19.1)
46
+ tzinfo (0.3.39)
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ activerecord (= 3.2.18)
53
+ appraisal (~> 1.0.0)
54
+ bundler (~> 1.6)
55
+ database_cleaner
56
+ jdbc-sqlite3
57
+ lazy_attributes!
58
+ rake
59
+ rspec
60
+ sqlite3
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "4.0.5"
6
+ gem "jdbc-sqlite3", :platform => :jruby
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ lazy_attributes (0.0.2)
5
+ activerecord (>= 3.2, < 5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (4.0.5)
11
+ activesupport (= 4.0.5)
12
+ builder (~> 3.1.0)
13
+ activerecord (4.0.5)
14
+ activemodel (= 4.0.5)
15
+ activerecord-deprecated_finders (~> 1.0.2)
16
+ activesupport (= 4.0.5)
17
+ arel (~> 4.0.0)
18
+ activerecord-deprecated_finders (1.0.3)
19
+ activesupport (4.0.5)
20
+ i18n (~> 0.6, >= 0.6.9)
21
+ minitest (~> 4.2)
22
+ multi_json (~> 1.3)
23
+ thread_safe (~> 0.1)
24
+ tzinfo (~> 0.3.37)
25
+ appraisal (1.0.0)
26
+ bundler
27
+ rake
28
+ thor (>= 0.14.0)
29
+ arel (4.0.2)
30
+ builder (3.1.4)
31
+ database_cleaner (1.3.0)
32
+ diff-lcs (1.2.5)
33
+ i18n (0.6.9)
34
+ minitest (4.7.5)
35
+ multi_json (1.10.1)
36
+ rake (10.3.2)
37
+ rspec (3.0.0)
38
+ rspec-core (~> 3.0.0)
39
+ rspec-expectations (~> 3.0.0)
40
+ rspec-mocks (~> 3.0.0)
41
+ rspec-core (3.0.0)
42
+ rspec-support (~> 3.0.0)
43
+ rspec-expectations (3.0.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.0.0)
46
+ rspec-mocks (3.0.0)
47
+ rspec-support (~> 3.0.0)
48
+ rspec-support (3.0.0)
49
+ sqlite3 (1.3.9)
50
+ thor (0.19.1)
51
+ thread_safe (0.3.4)
52
+ tzinfo (0.3.39)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ activerecord (= 4.0.5)
59
+ appraisal (~> 1.0.0)
60
+ bundler (~> 1.6)
61
+ database_cleaner
62
+ jdbc-sqlite3
63
+ lazy_attributes!
64
+ rake
65
+ rspec
66
+ sqlite3
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "4.1.1"
6
+ gem "jdbc-sqlite3", :platform => :jruby
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ lazy_attributes (0.0.2)
5
+ activerecord (>= 3.2, < 5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (4.1.1)
11
+ activesupport (= 4.1.1)
12
+ builder (~> 3.1)
13
+ activerecord (4.1.1)
14
+ activemodel (= 4.1.1)
15
+ activesupport (= 4.1.1)
16
+ arel (~> 5.0.0)
17
+ activesupport (4.1.1)
18
+ i18n (~> 0.6, >= 0.6.9)
19
+ json (~> 1.7, >= 1.7.7)
20
+ minitest (~> 5.1)
21
+ thread_safe (~> 0.1)
22
+ tzinfo (~> 1.1)
23
+ appraisal (1.0.0)
24
+ bundler
25
+ rake
26
+ thor (>= 0.14.0)
27
+ arel (5.0.1.20140414130214)
28
+ builder (3.2.2)
29
+ database_cleaner (1.3.0)
30
+ diff-lcs (1.2.5)
31
+ i18n (0.6.9)
32
+ json (1.8.1)
33
+ minitest (5.3.4)
34
+ rake (10.3.2)
35
+ rspec (3.0.0)
36
+ rspec-core (~> 3.0.0)
37
+ rspec-expectations (~> 3.0.0)
38
+ rspec-mocks (~> 3.0.0)
39
+ rspec-core (3.0.0)
40
+ rspec-support (~> 3.0.0)
41
+ rspec-expectations (3.0.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.0.0)
44
+ rspec-mocks (3.0.0)
45
+ rspec-support (~> 3.0.0)
46
+ rspec-support (3.0.0)
47
+ sqlite3 (1.3.9)
48
+ thor (0.19.1)
49
+ thread_safe (0.3.4)
50
+ tzinfo (1.2.1)
51
+ thread_safe (~> 0.1)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ activerecord (= 4.1.1)
58
+ appraisal (~> 1.0.0)
59
+ bundler (~> 1.6)
60
+ database_cleaner
61
+ jdbc-sqlite3
62
+ lazy_attributes!
63
+ rake
64
+ rspec
65
+ sqlite3
@@ -1,11 +1,10 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'lazy_attributes/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "lazy_attributes"
8
- spec.version = LazyAttributes::VERSION
7
+ spec.version = '0.0.2'
9
8
  spec.authors = ["Eito Katagiri"]
10
9
  spec.email = ["eitoball@gmail.com"]
11
10
  spec.summary = %q{ActiveRecord plugin to load specified attributes lazyly}
@@ -20,9 +19,14 @@ Gem::Specification.new do |spec|
20
19
 
21
20
  spec.add_dependency 'activerecord', '>= 3.2', '< 5'
22
21
 
23
- spec.add_development_dependency 'database_cleaner'
22
+ spec.add_development_dependency 'appraisal', '~> 1.0.0'
24
23
  spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'database_cleaner'
25
25
  spec.add_development_dependency 'rake'
26
26
  spec.add_development_dependency 'rspec'
27
- spec.add_development_dependency 'sqlite3'
27
+ unless RUBY_PLATFORM == 'jruby'
28
+ spec.add_development_dependency 'sqlite3'
29
+ else
30
+ spec.add_development_dependency 'jdbc-sqlite3'
31
+ end
28
32
  end
@@ -1,5 +1,3 @@
1
- require 'lazy_attributes/version'
2
-
3
1
  module LazyAttributes
4
2
  extend ActiveSupport::Concern
5
3
 
data/spec/spec_helper.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w{ .. lib }))
4
4
  require 'rspec'
5
5
  require 'active_record'
6
+ require 'logger'
6
7
  require 'lazy_attributes'
7
- require 'database_cleaner'
8
8
 
9
9
  ActiveRecord::Base.establish_connection(
10
10
  adapter: 'sqlite3',
@@ -26,11 +26,6 @@ class CreateTables < ActiveRecord::Migration
26
26
  end
27
27
 
28
28
  RSpec.configure do |config|
29
- config.before(:suite) do
30
- DatabaseCleaner.strategy = :truncation
31
- DatabaseCleaner.clean_with(:truncation)
32
- end
33
-
34
29
  config.before(:all) do
35
30
  CreateTables.new.up unless ActiveRecord::Base.connection.table_exists?('users')
36
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eito Katagiri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-06 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -31,19 +31,19 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
- name: database_cleaner
34
+ name: appraisal
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: 1.0.0
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: 1.0.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.6'
61
+ - !ruby/object:Gem::Dependency
62
+ name: database_cleaner
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: rake
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -108,13 +122,20 @@ extensions: []
108
122
  extra_rdoc_files: []
109
123
  files:
110
124
  - ".gitignore"
125
+ - ".travis.yml"
126
+ - Appraisals
111
127
  - Gemfile
112
128
  - LICENSE.txt
113
129
  - README.md
114
130
  - Rakefile
131
+ - gemfiles/activerecord_3.2.18.gemfile
132
+ - gemfiles/activerecord_3.2.18.gemfile.lock
133
+ - gemfiles/activerecord_4.0.5.gemfile
134
+ - gemfiles/activerecord_4.0.5.gemfile.lock
135
+ - gemfiles/activerecord_4.1.1.gemfile
136
+ - gemfiles/activerecord_4.1.1.gemfile.lock
115
137
  - lazy_attributes.gemspec
116
138
  - lib/lazy_attributes.rb
117
- - lib/lazy_attributes/version.rb
118
139
  - spec/lazy_attributes_spec.rb
119
140
  - spec/spec_helper.rb
120
141
  homepage: ''
@@ -1,3 +0,0 @@
1
- module LazyAttributes
2
- VERSION = '0.0.1'
3
- end