Permalink
Browse files

ready for a first release

  • Loading branch information...
1 parent 4badb2e commit 046afc2fea3f3eae26751b687871d23f3e62a39f @mattetti committed Sep 29, 2008
Showing with 99 additions and 14 deletions.
  1. +12 −0 README
  2. +2 −2 Rakefile
  3. +28 −0 dm-gvideo-adapter.gemspec
  4. +1 −1 lib/dm-gvideo-adapter.rb
  5. +21 −11 spec/dm-gvideo-adapter_spec.rb
  6. +35 −0 spec/spec_helper.rb
View
12 README
@@ -4,11 +4,23 @@ dm-gvideo-adapter
# dependencies
Gvideo: http://github.com/mattetti/gvideo
+install the dependency:
+
+ $ sudo gem install mattetti-gvideo
+
+install this adapter
+
+ $ sudo gem install mattetti-dm-gvideo-adapter
+
+
Usage:
# URI:
googlevideo://A005148908335059515423 # google video user id
+(or you can set the user_id in your database.yml)
+
+
Video.all # returns all the user's videos
Video.get("-2838281997424715962")
Video.first(:title => "The Illuminati - Secret societies")
View
@@ -4,7 +4,7 @@ require 'rubygems/specification'
require 'date'
GEM = "dm-gvideo-adapter"
-GEM_VERSION = "0.0.1"
+GEM_VERSION = "1.0.0"
AUTHOR = "Matt Aimonetti"
EMAIL = "mattaimonetti@gmail.com"
HOMEPAGE = "http://merbist.com"
@@ -23,7 +23,7 @@ spec = Gem::Specification.new do |s|
s.homepage = HOMEPAGE
# Uncomment this to add a dependency
- # s.add_dependency "foo"
+ # s.add_dependency "gvideo"
s.require_path = 'lib'
s.autorequire = GEM
View
@@ -0,0 +1,28 @@
+Gem::Specification.new do |s|
+ s.name = %q{dm-gvideo-adapter}
+ s.version = "1.0.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Matt Aimonetti"]
+ s.autorequire = %q{dm-gvideo-adapter}
+ s.date = %q{2008-09-28}
+ s.description = %q{A gem that provides...}
+ s.email = %q{mattaimonetti@gmail.com}
+ s.extra_rdoc_files = ["README", "LICENSE", "TODO"]
+ s.files = ["LICENSE", "README", "Rakefile", "TODO", "lib/dm-gvideo-adapter.rb", "lib/gvideo_model.rb"]
+ s.has_rdoc = true
+ s.homepage = %q{http://merbist.com}
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.2.0}
+ s.summary = %q{A gem that provides...}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 2
+
+ if current_version >= 3 then
+ else
+ end
+ else
+ end
+end
View
@@ -55,7 +55,7 @@ def read(query, set, arr = true)
end
# This is the core logic that handles the difference between all/first
- (results || []).each do |result|
+ results.each do |result|
props = props_from_result(properties_with_indexes, result, repository)
arr ? set.load(props) : (break set.load(props, query))
end
@@ -32,53 +32,63 @@
@videos.length.should == @gvideos.length
end
- it "should be able to retrieve itams using a title (string) condition" do
- videos = @videos.all(:title => "Durex: The Garden")
+ it "should be able to retrieve items using a title (string) condition" do
+ videos = Video.all(:title => "Durex: The Garden")
videos.length.should == 1
videos.first.title.should == "Durex: The Garden"
end
it "should be able to retrieve items using a title (regexp) condition" do
- videos = @videos.all(:title.like => "The Garden")
+ videos = Video.all(:title.like => "The Garden")
videos.length.should == 1
videos.first.title.should == "Durex: The Garden"
end
it "should be able to retrieve items using a duration (integer) condition (seconds)" do
- videos = @videos.all(:duration => 12)
+ videos = Video.all(:duration => 12)
videos.length.should == 2
end
it "should be able to retrieve items using a duration condition :gte " do
- videos = @videos.all(:duration.gte => 13)
+ videos = Video.all(:duration.gte => 13)
videos.length.should < @gvideos.length
end
it "should be able to retrieve items using a duration condition :lte " do
- videos = @videos.all(:duration.lte => 12)
+ videos = Video.all(:duration.lte => 12)
videos.length.should < @gvideos.length
(@videos.all(:duration.gte => 13).length + @videos.all(:duration.lte => 12).length).should == @gvideos.length
end
it "should be able to use 2 duration conditions" do
- videos = @videos.all(:duration.lte => 12, :duration.gte => 12)
+ videos = Video.all(:duration.lte => 12, :duration.gte => 12)
videos.length.should == @videos.all(:duration => 12).length
end
end
describe "getting one resource" do
- before(:all) do
- @video = Video.first
- end
it "should have all the attributes of a video" do
+ video = Video.first
methods = %W{docid title video_url duration duration_in_minutes thumbnail_url embed_player}
methods.each do |meth|
- @video.send(meth.to_sym).should_not be_nil
+ video.send(meth.to_sym).should_not be_nil
end
end
+ it "should be able to retrieve an item using a title (string) condition" do
+ video = Video.first(:title => "Durex: The Garden")
+ video.should be_an_instance_of(Video)
+ video.title.should == "Durex: The Garden"
+ end
+
+ it "should be able to retrieve items using a title (regexp) condition" do
+ video = Video.first(:title.like => "The Garden")
+ video.should be_an_instance_of(Video)
+ video.title.should == "Durex: The Garden"
+ end
+
end
View
@@ -19,5 +19,40 @@ class Video
property :thumbnail_url, String
property :embed_player, String
+ ##
+ # Simulates Array#first by returning the first entry (when
+ # there are no arguments), or transforms the collection's query
+ # by applying :limit => n when you supply an Integer. If you
+ # provide a conditions hash, or a Query object, the internal
+ # query is scoped and a new collection is returned
+ #
+ # @param [Integer, Hash[Symbol, Object], Query] args
+ #
+ # @return [DataMapper::Resource, DataMapper::Collection] The
+ # first resource in the entries of this collection, or
+ # a new collection whose query has been merged
+ #
+ # @api public
+ def first(*args)
+
+ # # TODO: this shouldn't be a kicker if scoped_query() is called
+ # if loaded?
+ # if args.empty?
+ # return super
+ # elsif args.size == 1 && args.first.kind_of?(Integer)
+ # limit = args.shift
+ # return self.class.new(scoped_query(:limit => limit)) { |c| c.replace(super(limit)) }
+ # end
+ # end
+ #
+ # query = args.last.respond_to?(:merge) ? args.pop : {}
+ # query = scoped_query(query.merge(:limit => args.first || 1))
+ #
+ # if args.any?
+ # query.repository.read_many(query)
+ # else
+ # query.repository.read_one(query)
+ # end
+ end
end

0 comments on commit 046afc2

Please sign in to comment.