slim-attributes 0.6.4 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README +15 -8
- data/Rakefile +1 -0
- data/VERSION.yml +1 -1
- data/ext/extconf.rb +17 -2
- data/test/slim_attributes_test.rb +11 -3
- metadata +15 -9
data/README
CHANGED
@@ -11,14 +11,12 @@ Measuring with just ActiveRecord code - fetching stuff from the database - we se
|
|
11
11
|
Installation
|
12
12
|
============
|
13
13
|
|
14
|
-
Slim attributes works with ruby 1.8.
|
15
|
-
|
16
|
-
You're going to need the mysql headers for this to work.
|
14
|
+
Slim attributes works with ruby 1.8.x. Ruby 1.9 support exists, but a bug in rails prevents it working (see Bugs for further info).
|
17
15
|
|
18
16
|
Try:
|
19
|
-
gem install slim-attributes
|
17
|
+
sudo gem install slim-attributes
|
20
18
|
or:
|
21
|
-
gem install slim-attributes
|
19
|
+
sudo gem install slim-attributes -- --with-mysql-config
|
22
20
|
|
23
21
|
then add this to environment.rb:
|
24
22
|
require 'slim_attributes'
|
@@ -38,10 +36,19 @@ So this is an alternative implementation of all_hashes that returns a 'fake hash
|
|
38
36
|
The field contents are then instantiated into Ruby strings on demand - ruby strings are only made if you need them. Note that if you always look at all the columns when you fetch data from the database then this won't necessarily be faster that the unpatched mysql adapter. But it won't be much slower either, and we do expect that most times not all the columns from a result set are accessed.
|
39
37
|
|
40
38
|
|
41
|
-
|
39
|
+
Bugs
|
40
|
+
====
|
41
|
+
|
42
|
+
Slim attributes will not work correctly with rails and ruby 1.9.1 until Rails 2.3.5 is released due to this ticket:
|
43
|
+
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3156-mysql_adapterrb-redefines-all_hashes-multiple-times-under-ruby-19
|
44
|
+
|
45
|
+
|
46
|
+
Warranty
|
47
|
+
========
|
42
48
|
|
43
|
-
No warranty - this gem has been tested, but not in all environments.
|
44
|
-
|
49
|
+
No warranty - this gem has been extensively tested, but not in all environments.
|
50
|
+
We are using it in our production environment with very good results.
|
51
|
+
Please report bugs to sdsykes at symbol gmail pip com or via the github issue tracking system.
|
45
52
|
|
46
53
|
|
47
54
|
Credits
|
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ begin
|
|
13
13
|
s.files = FileList["[A-Z]*", "{ext,lib,test}/**/*"]
|
14
14
|
s.extensions = "ext/extconf.rb"
|
15
15
|
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
16
17
|
rescue LoadError
|
17
18
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://
|
18
19
|
gems.github.com"
|
data/VERSION.yml
CHANGED
data/ext/extconf.rb
CHANGED
@@ -1,12 +1,27 @@
|
|
1
|
-
# this code
|
1
|
+
# this code was originally borrowed from Mysql/Ruby, credit to TOMITA Masahiro
|
2
2
|
# it works for me under OS X and Fedora, hope it works for you also
|
3
3
|
|
4
4
|
require 'mkmf'
|
5
5
|
|
6
|
+
# Improved detection of mysql_config
|
7
|
+
# Code from DataObjects do_mysql adapter
|
8
|
+
# All instances of mysql_config on PATH ...
|
9
|
+
def mysql_config_paths
|
10
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).collect do |path|
|
11
|
+
[ "#{path}/mysql_config", "#{path}/mysql_config5" ].
|
12
|
+
detect { |bin| File.exist?(bin) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# The first mysql_config binary on PATH ...
|
17
|
+
def default_mysql_config_path
|
18
|
+
mysql_config_paths.compact.first
|
19
|
+
end
|
20
|
+
|
6
21
|
if /mswin32/ =~ RUBY_PLATFORM
|
7
22
|
inc, lib = dir_config('mysql')
|
8
23
|
exit 1 unless have_library("libmysql")
|
9
|
-
elsif mc = with_config('mysql-config') then
|
24
|
+
elsif mc = with_config('mysql-config', default_mysql_config_path) then
|
10
25
|
mc = 'mysql_config' if mc == true
|
11
26
|
cflags = `#{mc} --cflags`.chomp
|
12
27
|
exit 1 if $? != 0
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'active_record'
|
6
6
|
require 'active_record/version'
|
7
|
-
require 'slim_attributes'
|
7
|
+
require File.dirname(__FILE__) + '/../lib/slim_attributes'
|
8
8
|
require 'test/unit'
|
9
9
|
require File.dirname(__FILE__) + "/products"
|
10
10
|
require File.dirname(__FILE__) + "/slim_db_test_utils"
|
@@ -16,6 +16,11 @@ class SlimAttributesTest < Test::Unit::TestCase
|
|
16
16
|
Product.make_some_products
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_slim_attributes_is_proxying_results
|
20
|
+
x = Product.find(:first)
|
21
|
+
assert_equal Mysql::Result::RowHash, x.instance_variable_get(:@attributes).class
|
22
|
+
end
|
23
|
+
|
19
24
|
def test_finds_all
|
20
25
|
items = Product.find(:all)
|
21
26
|
assert items.size == 100, "must find all 100 items"
|
@@ -138,8 +143,11 @@ class SlimAttributesTest < Test::Unit::TestCase
|
|
138
143
|
item1.name = "bar"
|
139
144
|
assert_equal "product_0", item3.name, "name must be original from cached query"
|
140
145
|
item2.name << "_test"
|
141
|
-
# unmodified rails fails this test,
|
142
|
-
#
|
146
|
+
# unmodified rails fails this test because the attributes are not dupped, only the
|
147
|
+
# hash containing them is
|
148
|
+
# but this test is useful - it shows that the rowhash has not been made
|
149
|
+
# into a real hash before dup in called in the query cache code
|
150
|
+
check_attributes_for(item3, 0)
|
143
151
|
end
|
144
152
|
end
|
145
153
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Sykes
|
@@ -9,11 +9,13 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-10 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: |-
|
17
|
+
Slim attributes boosts speed in Rails/Mysql ActiveRecord Models by avoiding
|
18
|
+
instantiating Hashes for each result row, and lazily instantiating attributes as needed.
|
17
19
|
email: sdsykes@gmail.com
|
18
20
|
executables: []
|
19
21
|
|
@@ -23,8 +25,8 @@ extra_rdoc_files:
|
|
23
25
|
- README
|
24
26
|
files:
|
25
27
|
- MIT_LICENCE
|
26
|
-
- Rakefile
|
27
28
|
- README
|
29
|
+
- Rakefile
|
28
30
|
- VERSION.yml
|
29
31
|
- ext/extconf.rb
|
30
32
|
- ext/slim_attrib_ext.c
|
@@ -36,9 +38,10 @@ files:
|
|
36
38
|
- test/slim_db_test_utils.rb
|
37
39
|
has_rdoc: true
|
38
40
|
homepage: http://github.com/sdsykes/slim-attributes
|
41
|
+
licenses: []
|
42
|
+
|
39
43
|
post_install_message:
|
40
44
|
rdoc_options:
|
41
|
-
- --inline-source
|
42
45
|
- --charset=UTF-8
|
43
46
|
require_paths:
|
44
47
|
- lib
|
@@ -57,9 +60,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
60
|
requirements: []
|
58
61
|
|
59
62
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.3.
|
63
|
+
rubygems_version: 1.3.5
|
61
64
|
signing_key:
|
62
|
-
specification_version:
|
65
|
+
specification_version: 3
|
63
66
|
summary: Slim-attributes - lazy instantiation of attributes for ActiveRecord
|
64
|
-
test_files:
|
65
|
-
|
67
|
+
test_files:
|
68
|
+
- test/benchmark.rb
|
69
|
+
- test/products.rb
|
70
|
+
- test/slim_attributes_test.rb
|
71
|
+
- test/slim_db_test_utils.rb
|