active-keso 0.1.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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
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
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Darwin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = active-keso
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Darwin. See LICENSE for details.
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "active-keso"
8
+ gem.summary = %Q{A way to get cottage cheese out off activerecord}
9
+ gem.description = %Q{A way to get cottage cheese out off activerecord}
10
+ gem.email = "darwin.git@marianna.se"
11
+ gem.homepage = "http://github.com/bjornblomqvist/active-keso"
12
+ gem.authors = ["Darwin"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "sqlite3-ruby"
15
+ gem.add_dependency "activerecord", ">= 2.3.5"
16
+ gem.add_dependency "keso", ">= 0.1.3"
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ task :spec => :check_dependencies
24
+
25
+ task :default => :spec
26
+
27
+ require 'rake/rdoctask'
28
+ Rake::RDocTask.new do |rdoc|
29
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
30
+
31
+ rdoc.rdoc_dir = 'rdoc'
32
+ rdoc.title = "active-keso #{version}"
33
+ rdoc.rdoc_files.include('README*')
34
+ rdoc.rdoc_files.include('lib/**/*.rb')
35
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,64 @@
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{active-keso}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Darwin"]
12
+ s.date = %q{2010-10-29}
13
+ s.description = %q{A way to get cottage cheese out off activerecord}
14
+ s.email = %q{darwin.git@marianna.se}
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
+ "active-keso.gemspec",
27
+ "lib/active-keso.rb",
28
+ "spec/active-keso_spec.rb",
29
+ "spec/spec.opts",
30
+ "spec/spec_helper.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/bjornblomqvist/active-keso}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.7}
36
+ s.summary = %q{A way to get cottage cheese out off activerecord}
37
+ s.test_files = [
38
+ "spec/active-keso_spec.rb",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
48
+ s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
49
+ s.add_runtime_dependency(%q<activerecord>, [">= 2.3.5"])
50
+ s.add_runtime_dependency(%q<keso>, [">= 0.1.3"])
51
+ else
52
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
53
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
54
+ s.add_dependency(%q<activerecord>, [">= 2.3.5"])
55
+ s.add_dependency(%q<keso>, [">= 0.1.3"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
60
+ s.add_dependency(%q<activerecord>, [">= 2.3.5"])
61
+ s.add_dependency(%q<keso>, [">= 0.1.3"])
62
+ end
63
+ end
64
+
@@ -0,0 +1,37 @@
1
+
2
+ require 'active_record'
3
+ require 'keso'
4
+
5
+ class Array
6
+ def to_keso nil_fix = {}
7
+
8
+ tuples = []
9
+
10
+ self.each do |value|
11
+ if value.is_a? ActiveRecord::Base
12
+ tuple = Tuple.new
13
+ value.attribute_names.each do |column_name|
14
+
15
+ v = value[column_name]
16
+ v = nil_fix[column_name.to_sym] unless v
17
+
18
+ tuple = tuple.add(column_name.to_sym => v)
19
+ end
20
+ tuples.push tuple
21
+ else
22
+ throw "Sorry but this is only for active record =/"
23
+ end
24
+ end
25
+
26
+ return Relation.new if tuples.length == 0 # FIXME, it should return a relation with the correct heading
27
+
28
+ to_return = Relation.new tuples.first.heading
29
+
30
+ tuples.each do |tuple|
31
+ to_return = to_return.add tuple
32
+ end
33
+
34
+ to_return
35
+
36
+ end
37
+ end
@@ -0,0 +1,103 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'rubygems'
4
+ require 'active_record'
5
+ require 'active-keso'
6
+
7
+ class User < ActiveRecord::Base
8
+ end
9
+
10
+ describe "ActiveKeso" do
11
+ it "should return a keso relation" do
12
+
13
+ #
14
+ # setup
15
+ #
16
+ ActiveRecord::Base.establish_connection(
17
+ :adapter => 'sqlite3',
18
+ :database => '/tmp/keso_test.sqlite3',
19
+ :pool => 5,
20
+ :timeout => 5000)
21
+
22
+ ActiveRecord::Schema.define :version => 0 do
23
+ create_table :users, :force => true do |t|
24
+ t.string :name
25
+ end
26
+ end
27
+
28
+ User.create :name => 'Tedy bear'
29
+
30
+ #
31
+ # The test
32
+ #
33
+
34
+ User.first.name.should eql('Tedy bear')
35
+
36
+ User.all.to_keso.should be_an_instance_of Relation
37
+
38
+ User.all.to_keso.should eql Relation.new(Tuple.new(:id => 1,:name => 'Tedy bear'))
39
+
40
+
41
+ end
42
+
43
+ it 'should work when using find_by_sql' do
44
+
45
+ #
46
+ # setup
47
+ #
48
+ ActiveRecord::Base.establish_connection(
49
+ :adapter => 'sqlite3',
50
+ :database => '/tmp/keso_test.sqlite3',
51
+ :pool => 5,
52
+ :timeout => 5000)
53
+
54
+ ActiveRecord::Schema.define :version => 0 do
55
+ create_table :users, :force => true do |t|
56
+ t.string :name
57
+ end
58
+ end
59
+
60
+ User.create! :name => 'Tedy bear'
61
+
62
+ #
63
+ # The test
64
+ #
65
+
66
+ puts User.find_by_sql("select name from \"users\";").first.attribute_names.inspect
67
+
68
+ User.find_by_sql("select name from \"users\";").to_keso.should eql Relation.new(Tuple.new(:name => 'Tedy bear'))
69
+
70
+ end
71
+
72
+ it "should be able to handle nil in the activerecord" do
73
+
74
+ #
75
+ # setup
76
+ #
77
+ ActiveRecord::Base.establish_connection(
78
+ :adapter => 'sqlite3',
79
+ :database => '/tmp/keso_test.sqlite3',
80
+ :pool => 5,
81
+ :timeout => 5000)
82
+
83
+ ActiveRecord::Schema.define :version => 0 do
84
+ create_table :users, :force => true do |t|
85
+ t.string :name
86
+ end
87
+ end
88
+
89
+ User.create! :name => nil
90
+
91
+ #
92
+ # The test
93
+ #
94
+
95
+ User.first.name.should be_nil
96
+
97
+ User.all.to_keso(:name => "").should be_an_instance_of Relation
98
+
99
+ User.all.to_keso(:name => '').should eql Relation.new(Tuple.new(:id => 1,:name => ''))
100
+
101
+
102
+ end
103
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'active-keso'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active-keso
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - Darwin
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-29 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 2
31
+ - 9
32
+ version: 1.2.9
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: sqlite3-ruby
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: activerecord
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 2
58
+ - 3
59
+ - 5
60
+ version: 2.3.5
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: keso
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ - 1
74
+ - 3
75
+ version: 0.1.3
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ description: A way to get cottage cheese out off activerecord
79
+ email: darwin.git@marianna.se
80
+ executables: []
81
+
82
+ extensions: []
83
+
84
+ extra_rdoc_files:
85
+ - LICENSE
86
+ - README.rdoc
87
+ files:
88
+ - .document
89
+ - .gitignore
90
+ - LICENSE
91
+ - README.rdoc
92
+ - Rakefile
93
+ - VERSION
94
+ - active-keso.gemspec
95
+ - lib/active-keso.rb
96
+ - spec/active-keso_spec.rb
97
+ - spec/spec.opts
98
+ - spec/spec_helper.rb
99
+ has_rdoc: true
100
+ homepage: http://github.com/bjornblomqvist/active-keso
101
+ licenses: []
102
+
103
+ post_install_message:
104
+ rdoc_options:
105
+ - --charset=UTF-8
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ requirements: []
125
+
126
+ rubyforge_project:
127
+ rubygems_version: 1.3.7
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: A way to get cottage cheese out off activerecord
131
+ test_files:
132
+ - spec/active-keso_spec.rb
133
+ - spec/spec_helper.rb