dm-fql-adapter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/Gemfile +92 -0
- data/Gemfile.lock +125 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +31 -0
- data/VERSION +1 -0
- data/dm-fql-adapter.gemspec +77 -0
- data/lib/dm-fql-adapter/adapter.rb +33 -0
- data/lib/dm-fql-adapter/spec/setup.rb +18 -0
- data/lib/dm-fql-adapter.rb +4 -0
- data/spec/adapter_spec.rb +47 -0
- data/spec/rcov.opts +5 -0
- data/spec/resources/user.rb +6 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/local_gemfile.rake +16 -0
- data/tasks/spec.rake +41 -0
- data/tasks/yard.rake +9 -0
- data/tasks/yardstick.rake +19 -0
- metadata +152 -0
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# If you're working on more than one datamapper gem at a time, then it's
|
2
|
+
# recommended to create a local Gemfile and use this instead of the git
|
3
|
+
# sources. This will make sure that you are developing against your
|
4
|
+
# other local datamapper sources that you currently work on. Gemfile.local
|
5
|
+
# will behave identically to the standard Gemfile apart from the fact that
|
6
|
+
# it fetches the gems from local paths. This means that you can use the
|
7
|
+
# same environment variables, like ADAPTER when running bundle commands.
|
8
|
+
# Gemfile.local is added to .gitignore, so you don't need to worry about
|
9
|
+
# accidentally checking local development paths into git.
|
10
|
+
#
|
11
|
+
# bundle exec rake local_gemfile
|
12
|
+
#
|
13
|
+
# will give you a Gemfile.local file that points to your local clones of
|
14
|
+
# the various datamapper gems. It's assumed that all datamapper repo clones
|
15
|
+
# reside in the same directory. You can use the Gemfile.local like so for
|
16
|
+
# running any bundle command:
|
17
|
+
#
|
18
|
+
# BUNDLE_GEMFILE=Gemfile.local bundle foo
|
19
|
+
#
|
20
|
+
# To speed up running bundle tasks, it's recommended to run
|
21
|
+
#
|
22
|
+
# bundle lock
|
23
|
+
#
|
24
|
+
# after running 'bundle install' for the first time. This will make 'bundle exec' run
|
25
|
+
# a lot faster compared to the unlocked version. With an unlocked bundle you would
|
26
|
+
# typically just run 'bundle install' from time to time to fetch the latest sources from
|
27
|
+
# upstream. When you locked your bundle, you need to run
|
28
|
+
#
|
29
|
+
# bundle install --relock
|
30
|
+
#
|
31
|
+
# to make sure to fetch the latest updates and then lock the bundle again. Gemfile.lock
|
32
|
+
# is added to the .gitignore file, so you don't need to worry about accidentally checking
|
33
|
+
# it into version control.
|
34
|
+
|
35
|
+
source 'http://rubygems.org'
|
36
|
+
|
37
|
+
DATAMAPPER = 'git://github.com/datamapper'
|
38
|
+
DM_VERSION = '~> 1.0.2'
|
39
|
+
|
40
|
+
group :runtime do # Runtime dependencies (as in the gemspec)
|
41
|
+
|
42
|
+
gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
|
43
|
+
|
44
|
+
gem 'sqldsl', '~> 1.4.6'
|
45
|
+
gem 'mini_fb', '~> 1.1.3'
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
group(:development) do # Development dependencies (as in the gemspec)
|
50
|
+
|
51
|
+
gem 'rake', '~> 0.8.7'
|
52
|
+
gem 'rspec', '~> 1.3', :git => 'git://github.com/snusnu/rspec', :branch => 'heckle_fix_plus_gemfile'
|
53
|
+
gem 'jeweler', '~> 1.4'
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
group(:autotest) do # Test dependencies (Mac-specific)
|
58
|
+
|
59
|
+
gem 'autotest'
|
60
|
+
gem 'autotest-growl'
|
61
|
+
gem 'autotest-fsevent'
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
group :datamapper do # We need this because we want to pin these dependencies to their git master sources
|
66
|
+
|
67
|
+
if ENV['EXTLIB']
|
68
|
+
gem 'extlib', '~> 0.9.15', :git => "#{DATAMAPPER}/extlib.git", :require => nil
|
69
|
+
else
|
70
|
+
gem 'activesupport', '~> 3.0.0', :git => 'git://github.com/rails/rails.git', :branch => '3-0-stable', :require => nil
|
71
|
+
end
|
72
|
+
|
73
|
+
plugins = ENV['PLUGINS'] || ENV['PLUGIN']
|
74
|
+
plugins = plugins.to_s.tr(',', ' ').split.uniq
|
75
|
+
|
76
|
+
plugins.each do |plugin|
|
77
|
+
gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
group :quality do # These gems contain rake tasks that check the quality of the source code
|
83
|
+
|
84
|
+
gem 'metric_fu', '~> 1.3'
|
85
|
+
gem 'rcov', '~> 0.9.7'
|
86
|
+
gem 'reek', '~> 1.2.7'
|
87
|
+
gem 'roodi', '~> 2.1'
|
88
|
+
gem 'yard', '~> 0.5'
|
89
|
+
gem 'yardstick', '~> 0.1'
|
90
|
+
|
91
|
+
end
|
92
|
+
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/datamapper/dm-core.git
|
3
|
+
revision: a68434e6e1d92a1fc3ef4fdcc2deaf20b6561b5c
|
4
|
+
specs:
|
5
|
+
dm-core (1.0.2)
|
6
|
+
addressable (~> 2.2)
|
7
|
+
extlib (~> 0.9.15)
|
8
|
+
|
9
|
+
GIT
|
10
|
+
remote: git://github.com/datamapper/extlib.git
|
11
|
+
revision: f54d775f868941ceb2c43d154e719c73e9366596
|
12
|
+
specs:
|
13
|
+
extlib (0.9.16)
|
14
|
+
|
15
|
+
GIT
|
16
|
+
remote: git://github.com/snusnu/rspec
|
17
|
+
revision: daa261ae5798d56e6c9688e9d1e016b831fcd529
|
18
|
+
branch: heckle_fix_plus_gemfile
|
19
|
+
specs:
|
20
|
+
rspec (1.3.0)
|
21
|
+
|
22
|
+
GEM
|
23
|
+
remote: http://rubygems.org/
|
24
|
+
specs:
|
25
|
+
Saikuro (1.1.0)
|
26
|
+
activesupport (3.0.0)
|
27
|
+
addressable (2.2.1)
|
28
|
+
arrayfields (4.7.4)
|
29
|
+
autotest (4.3.2)
|
30
|
+
autotest-fsevent (0.2.3)
|
31
|
+
sys-uname
|
32
|
+
autotest-growl (0.2.5)
|
33
|
+
chronic (0.2.3)
|
34
|
+
hoe (>= 1.2.1)
|
35
|
+
churn (0.0.12)
|
36
|
+
chronic (~> 0.2.3)
|
37
|
+
hirb
|
38
|
+
json_pure
|
39
|
+
main
|
40
|
+
ruby_parser (~> 2.0.4)
|
41
|
+
sexp_processor (~> 3.0.3)
|
42
|
+
fattr (2.1.0)
|
43
|
+
flay (1.4.1)
|
44
|
+
ruby_parser (~> 2.0)
|
45
|
+
sexp_processor (~> 3.0)
|
46
|
+
flog (2.5.0)
|
47
|
+
ruby_parser (~> 2.0)
|
48
|
+
sexp_processor (~> 3.0)
|
49
|
+
gemcutter (0.6.1)
|
50
|
+
git (1.2.5)
|
51
|
+
hashie (0.4.0)
|
52
|
+
hirb (0.3.3)
|
53
|
+
hoe (2.6.2)
|
54
|
+
rake (>= 0.8.7)
|
55
|
+
rubyforge (>= 2.0.4)
|
56
|
+
jeweler (1.4.0)
|
57
|
+
gemcutter (>= 0.1.0)
|
58
|
+
git (>= 1.2.5)
|
59
|
+
rubyforge (>= 2.0.0)
|
60
|
+
json_pure (1.4.6)
|
61
|
+
main (4.2.0)
|
62
|
+
arrayfields (>= 4.7.4)
|
63
|
+
fattr (>= 2.1.0)
|
64
|
+
metric_fu (1.5.1)
|
65
|
+
Saikuro (>= 1.1.0)
|
66
|
+
activesupport (>= 2.0.0)
|
67
|
+
chronic (>= 0.2.3)
|
68
|
+
churn (>= 0.0.7)
|
69
|
+
flay (>= 1.2.1)
|
70
|
+
flog (>= 2.2.0)
|
71
|
+
rails_best_practices (>= 0.3.16)
|
72
|
+
rcov (>= 0.8.3.3)
|
73
|
+
reek (>= 1.2.6)
|
74
|
+
roodi (>= 2.1.0)
|
75
|
+
mime-types (1.16)
|
76
|
+
mini_fb (1.1.3)
|
77
|
+
hashie
|
78
|
+
rest-client
|
79
|
+
rails_best_practices (0.4.0)
|
80
|
+
ruby2ruby (>= 1.2.4)
|
81
|
+
ruby_parser (>= 2.0.4)
|
82
|
+
rake (0.8.7)
|
83
|
+
rcov (0.9.8)
|
84
|
+
reek (1.2.8)
|
85
|
+
ruby2ruby (~> 1.2)
|
86
|
+
ruby_parser (~> 2.0)
|
87
|
+
sexp_processor (~> 3.0)
|
88
|
+
rest-client (1.6.1)
|
89
|
+
mime-types (>= 1.16)
|
90
|
+
roodi (2.1.0)
|
91
|
+
ruby_parser
|
92
|
+
ruby2ruby (1.2.5)
|
93
|
+
ruby_parser (~> 2.0)
|
94
|
+
sexp_processor (~> 3.0)
|
95
|
+
ruby_parser (2.0.5)
|
96
|
+
sexp_processor (~> 3.0)
|
97
|
+
rubyforge (2.0.4)
|
98
|
+
json_pure (>= 1.1.7)
|
99
|
+
sexp_processor (3.0.5)
|
100
|
+
sqldsl (1.4.6)
|
101
|
+
sys-uname (0.8.4)
|
102
|
+
yard (0.6.1)
|
103
|
+
yardstick (0.1.0)
|
104
|
+
yard (~> 0.2)
|
105
|
+
|
106
|
+
PLATFORMS
|
107
|
+
ruby
|
108
|
+
|
109
|
+
DEPENDENCIES
|
110
|
+
autotest
|
111
|
+
autotest-fsevent
|
112
|
+
autotest-growl
|
113
|
+
dm-core (~> 1.0.2)!
|
114
|
+
extlib (~> 0.9.15)!
|
115
|
+
jeweler (~> 1.4)
|
116
|
+
metric_fu (~> 1.3)
|
117
|
+
mini_fb (~> 1.1.3)
|
118
|
+
rake (~> 0.8.7)
|
119
|
+
rcov (~> 0.9.7)
|
120
|
+
reek (~> 1.2.7)
|
121
|
+
roodi (~> 2.1)
|
122
|
+
rspec (~> 1.3)!
|
123
|
+
sqldsl (~> 1.4.6)
|
124
|
+
yard (~> 0.5)
|
125
|
+
yardstick (~> 0.1)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Gabor Ratky
|
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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= dm-fql-adapter
|
2
|
+
|
3
|
+
A DataMapper adapter for querying Facebook using FQL. Work in progress.
|
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 Gabor Ratky, Secret Sauce Partners, Inc. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = 'dm-fql-adapter'
|
10
|
+
gem.summary = 'FQL Adapter for DataMapper'
|
11
|
+
gem.description = gem.summary
|
12
|
+
gem.email = 'gabor@secretsaucepartners.com'
|
13
|
+
gem.homepage = 'http://github.com/sspinc/%s' % gem.name
|
14
|
+
gem.authors = [ 'Gabor Ratky' ]
|
15
|
+
gem.has_rdoc = 'yard'
|
16
|
+
|
17
|
+
gem.rubyforge_project = 'datamapper'
|
18
|
+
|
19
|
+
gem.add_dependency 'dm-core', '~> 1.0.2'
|
20
|
+
gem.add_dependency 'sqldsl', '~> 1.4.6'
|
21
|
+
gem.add_dependency 'mini_fb', '~> 1.1.3'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'rspec', '~> 1.3'
|
24
|
+
end
|
25
|
+
|
26
|
+
Jeweler::GemcutterTasks.new
|
27
|
+
|
28
|
+
FileList['tasks/**/*.rake'].each { |task| import task }
|
29
|
+
rescue LoadError
|
30
|
+
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
|
31
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,77 @@
|
|
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{dm-fql-adapter}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Gabor Ratky"]
|
12
|
+
s.date = %q{2010-09-13}
|
13
|
+
s.description = %q{FQL Adapter for DataMapper}
|
14
|
+
s.email = %q{gabor@secretsaucepartners.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
|
+
"dm-fql-adapter.gemspec",
|
29
|
+
"lib/dm-fql-adapter.rb",
|
30
|
+
"lib/dm-fql-adapter/adapter.rb",
|
31
|
+
"lib/dm-fql-adapter/spec/setup.rb",
|
32
|
+
"spec/adapter_spec.rb",
|
33
|
+
"spec/rcov.opts",
|
34
|
+
"spec/resources/user.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb",
|
37
|
+
"tasks/local_gemfile.rake",
|
38
|
+
"tasks/spec.rake",
|
39
|
+
"tasks/yard.rake",
|
40
|
+
"tasks/yardstick.rake"
|
41
|
+
]
|
42
|
+
s.has_rdoc = %q{yard}
|
43
|
+
s.homepage = %q{http://github.com/sspinc/dm-fql-adapter}
|
44
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
45
|
+
s.require_paths = ["lib"]
|
46
|
+
s.rubyforge_project = %q{datamapper}
|
47
|
+
s.rubygems_version = %q{1.3.7}
|
48
|
+
s.summary = %q{FQL Adapter for DataMapper}
|
49
|
+
s.test_files = [
|
50
|
+
"spec/adapter_spec.rb",
|
51
|
+
"spec/resources/user.rb",
|
52
|
+
"spec/spec_helper.rb"
|
53
|
+
]
|
54
|
+
|
55
|
+
if s.respond_to? :specification_version then
|
56
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
57
|
+
s.specification_version = 3
|
58
|
+
|
59
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.2"])
|
61
|
+
s.add_runtime_dependency(%q<sqldsl>, ["~> 1.4.6"])
|
62
|
+
s.add_runtime_dependency(%q<mini_fb>, ["~> 1.1.3"])
|
63
|
+
s.add_development_dependency(%q<rspec>, ["~> 1.3"])
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
|
66
|
+
s.add_dependency(%q<sqldsl>, ["~> 1.4.6"])
|
67
|
+
s.add_dependency(%q<mini_fb>, ["~> 1.1.3"])
|
68
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
69
|
+
end
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
|
72
|
+
s.add_dependency(%q<sqldsl>, ["~> 1.4.6"])
|
73
|
+
s.add_dependency(%q<mini_fb>, ["~> 1.1.3"])
|
74
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module DataMapper
|
2
|
+
module Adapters
|
3
|
+
class FqlAdapter < AbstractAdapter
|
4
|
+
|
5
|
+
def initialize(name, options={})
|
6
|
+
super
|
7
|
+
self.resource_naming_convention = DataMapper::NamingConventions::Resource::Underscored
|
8
|
+
end
|
9
|
+
|
10
|
+
def session
|
11
|
+
@session ||= options[:session] || MiniFB::OAuthSession.new(options[:access_token], options[:locale] || 'en_US')
|
12
|
+
end
|
13
|
+
|
14
|
+
def compile(query)
|
15
|
+
Select[query.fields.map(&:name)].from[query.model.storage_name(name).to_sym].where do
|
16
|
+
query.conditions.each do |condition|
|
17
|
+
case condition
|
18
|
+
when Query::Conditions::EqualToComparison then equal condition.subject.name, condition.value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end.to_sql
|
22
|
+
end
|
23
|
+
|
24
|
+
def read(query)
|
25
|
+
DataMapper.logger.debug(statement = compile(query))
|
26
|
+
session.fql(statement)
|
27
|
+
end
|
28
|
+
|
29
|
+
end # class FqlAdapter
|
30
|
+
|
31
|
+
const_added(:FqlAdapter)
|
32
|
+
end # module Adapters
|
33
|
+
end # module DataMapper
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'dm-fql-adapter'
|
2
|
+
require 'dm-core/spec/setup'
|
3
|
+
|
4
|
+
module DataMapper
|
5
|
+
module Spec
|
6
|
+
module Adapters
|
7
|
+
|
8
|
+
class FqlAdapter < Adapter
|
9
|
+
def connection_uri
|
10
|
+
"https://graph.facebook.com"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
use FqlAdapter
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DataMapper::Adapters::FqlAdapter do
|
4
|
+
let(:adapter) { DataMapper.setup(:default, :adapter => :fql) }
|
5
|
+
let(:repository) { DataMapper.repository(adapter.name) }
|
6
|
+
subject { adapter }
|
7
|
+
|
8
|
+
context 'when setting up with an options hash' do
|
9
|
+
subject { DataMapper.setup(:default, :adapter => :fql, :access_token => 'abcdef' ) }
|
10
|
+
|
11
|
+
its(:session) { should be_instance_of(MiniFB::OAuthSession) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when setting up with an existing session' do
|
15
|
+
let(:session) { MiniFB::OAuthSession.new('token') }
|
16
|
+
subject { DataMapper.setup(:default, :adapter => :fql, :session => session) }
|
17
|
+
|
18
|
+
its(:session) { should be_equal(session) }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#compile' do
|
22
|
+
context 'when querying for a single resource' do
|
23
|
+
let(:query) { DataMapper::Query.new(repository, User, :conditions => { :uid => 1 }) }
|
24
|
+
subject { adapter.compile(query) }
|
25
|
+
|
26
|
+
it { should == "select uid, name from user where uid = 1" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#read' do
|
31
|
+
let(:session) { mock(MiniFB::OAuthSession) }
|
32
|
+
let(:adapter) { DataMapper.setup(:default, :adapter => :fql, :session => session) }
|
33
|
+
|
34
|
+
context 'when querying for a single resource' do
|
35
|
+
let(:query) { mock(DataMapper::Query) }
|
36
|
+
let(:fql) { 'select uid, name from user where uid = 1' }
|
37
|
+
subject { adapter.read(query) }
|
38
|
+
|
39
|
+
before do
|
40
|
+
adapter.should_receive(:compile).with(query).and_return(fql)
|
41
|
+
session.should_receive(:fql).with(fql).and_return([Hashie::Mash.new({:uid => 1, :name => 'Gabor Ratky'})])
|
42
|
+
end
|
43
|
+
|
44
|
+
it { should == [ { 'uid' => 1, 'name' => 'Gabor Ratky' }]}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/rcov.opts
ADDED
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'dm-core'
|
2
|
+
require 'dm-core/spec/shared/adapter_spec'
|
3
|
+
|
4
|
+
require 'dm-fql-adapter/spec/setup'
|
5
|
+
|
6
|
+
# Requires test resources in ./resources/ and its subdirectories.
|
7
|
+
Dir["#{File.dirname(__FILE__)}/resources/**/*.rb"].each {|f| require f}
|
8
|
+
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle foo)"
|
2
|
+
task :local_gemfile do |t|
|
3
|
+
|
4
|
+
root = Pathname(__FILE__).dirname.parent
|
5
|
+
datamapper = root.parent
|
6
|
+
|
7
|
+
root.join('Gemfile.local').open('w') do |f|
|
8
|
+
root.join('Gemfile').open.each do |line|
|
9
|
+
line.sub!(/DATAMAPPER = 'git:\/\/github.com\/datamapper'/, "DATAMAPPER = '#{datamapper}'")
|
10
|
+
line.sub!(/:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, ':path => "#{DATAMAPPER}/\1"')
|
11
|
+
line.sub!(/do_options\[:git\] = \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, 'do_options[:path] = "#{DATAMAPPER}/\1"')
|
12
|
+
f.puts line
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
spec_defaults = lambda do |spec|
|
2
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
3
|
+
spec.libs << 'lib' << 'spec'
|
4
|
+
spec.spec_opts << '--options' << 'spec/spec.opts'
|
5
|
+
end
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
|
10
|
+
Spec::Rake::SpecTask.new(:spec, &spec_defaults)
|
11
|
+
rescue LoadError
|
12
|
+
task :spec do
|
13
|
+
abort 'rspec is not available. In order to run spec, you must: gem install rspec'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'rcov'
|
19
|
+
require 'spec/rake/verify_rcov'
|
20
|
+
|
21
|
+
Spec::Rake::SpecTask.new(:rcov) do |rcov|
|
22
|
+
spec_defaults.call(rcov)
|
23
|
+
rcov.rcov = true
|
24
|
+
rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
|
25
|
+
end
|
26
|
+
|
27
|
+
RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
|
28
|
+
rcov.threshold = 100
|
29
|
+
end
|
30
|
+
rescue LoadError
|
31
|
+
%w[ rcov verify_rcov ].each do |name|
|
32
|
+
task name do
|
33
|
+
abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
task :spec => :check_dependencies
|
39
|
+
task :rcov => :check_dependencies
|
40
|
+
|
41
|
+
task :default => :spec
|
data/tasks/yard.rake
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'pathname'
|
3
|
+
require 'yardstick/rake/measurement'
|
4
|
+
require 'yardstick/rake/verify'
|
5
|
+
|
6
|
+
# yardstick_measure task
|
7
|
+
Yardstick::Rake::Measurement.new
|
8
|
+
|
9
|
+
# verify_measurements task
|
10
|
+
Yardstick::Rake::Verify.new do |verify|
|
11
|
+
verify.threshold = 100
|
12
|
+
end
|
13
|
+
rescue LoadError
|
14
|
+
%w[ yardstick_measure verify_measurements ].each do |name|
|
15
|
+
task name.to_s do
|
16
|
+
abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dm-fql-adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gabor Ratky
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-13 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
type: :runtime
|
24
|
+
name: dm-core
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 19
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
- 2
|
35
|
+
version: 1.0.2
|
36
|
+
requirement: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
39
|
+
type: :runtime
|
40
|
+
name: sqldsl
|
41
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 11
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 4
|
50
|
+
- 6
|
51
|
+
version: 1.4.6
|
52
|
+
requirement: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
type: :runtime
|
56
|
+
name: mini_fb
|
57
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 21
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 1
|
66
|
+
- 3
|
67
|
+
version: 1.1.3
|
68
|
+
requirement: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
prerelease: false
|
71
|
+
type: :development
|
72
|
+
name: rspec
|
73
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 9
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 3
|
82
|
+
version: "1.3"
|
83
|
+
requirement: *id004
|
84
|
+
description: FQL Adapter for DataMapper
|
85
|
+
email: gabor@secretsaucepartners.com
|
86
|
+
executables: []
|
87
|
+
|
88
|
+
extensions: []
|
89
|
+
|
90
|
+
extra_rdoc_files:
|
91
|
+
- LICENSE
|
92
|
+
- README.rdoc
|
93
|
+
files:
|
94
|
+
- .document
|
95
|
+
- .gitignore
|
96
|
+
- Gemfile
|
97
|
+
- Gemfile.lock
|
98
|
+
- LICENSE
|
99
|
+
- README.rdoc
|
100
|
+
- Rakefile
|
101
|
+
- VERSION
|
102
|
+
- dm-fql-adapter.gemspec
|
103
|
+
- lib/dm-fql-adapter.rb
|
104
|
+
- lib/dm-fql-adapter/adapter.rb
|
105
|
+
- lib/dm-fql-adapter/spec/setup.rb
|
106
|
+
- spec/adapter_spec.rb
|
107
|
+
- spec/rcov.opts
|
108
|
+
- spec/resources/user.rb
|
109
|
+
- spec/spec.opts
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- tasks/local_gemfile.rake
|
112
|
+
- tasks/spec.rake
|
113
|
+
- tasks/yard.rake
|
114
|
+
- tasks/yardstick.rake
|
115
|
+
has_rdoc: yard
|
116
|
+
homepage: http://github.com/sspinc/dm-fql-adapter
|
117
|
+
licenses: []
|
118
|
+
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options:
|
121
|
+
- --charset=UTF-8
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: 3
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
142
|
+
requirements: []
|
143
|
+
|
144
|
+
rubyforge_project: datamapper
|
145
|
+
rubygems_version: 1.3.7
|
146
|
+
signing_key:
|
147
|
+
specification_version: 3
|
148
|
+
summary: FQL Adapter for DataMapper
|
149
|
+
test_files:
|
150
|
+
- spec/adapter_spec.rb
|
151
|
+
- spec/resources/user.rb
|
152
|
+
- spec/spec_helper.rb
|