Skip to content

Commit

Permalink
change to 0.0.3, integrating new methods, helped, search and tag search
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Jul 11, 2008
1 parent 88cd3b9 commit 81f39fa
Show file tree
Hide file tree
Showing 23 changed files with 771 additions and 15 deletions.
6 changes: 6 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
== 0.0.3 2008-11-05

* 1 major enhancement:
* new methods in base
*new methods in base.rb, helped , tag(), and search()

== 0.0.2 2008-07-05

* 1 major enhancement:
Expand Down
10 changes: 10 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ add help, pass need id and text

<pre>login.add_help(need.id,'text')</pre>

new methods

helped needs
<pre> login.helped </pre>

search by tag
<pre> login.tag("tag") </pre>

simple search
<pre> login.search("term") </pre>


== REQUIREMENTS:
Expand Down
19 changes: 15 additions & 4 deletions lib/needish/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,23 @@ def helps(id)
helps_data(request("needs/helps/#{id}.xml", :auth => true))
end

#Returns up to 100 recent needs helped by the authenticating user, ordered by descending date of creation of the need. def helped(id)
def helped
needs_generic_data(request("needs/helped.xml", :auth => true))
end

#Returns up to 100 recent needs matching the terms sent, ordered by descending date of creation.
def tag(tag)
needs_generic_data(request("needs/tag/#{tag}.xml", :auth => true))
end

def search(term)
needs_generic_data(request("needs/search/#{term}.xml", :auth => true))
end

# Send data


# Post a new Need for the authenticating user.

#Send data
# Post a new Need for the authenticating user
# http://api.needish.com/needs/add.format
def add_need(subject, text)
url = URI.parse("http://#{@@api_url}/needs/add.xml#{@config[:apikey]}")
Expand Down
45 changes: 35 additions & 10 deletions lib/needish/need.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module Needish
class Need
include EasyClassMaker

attributes :id,:created,:city,:timediff,:helps,:status,:subject,:text
attributes :id,:created,:city,:timediff,:helps,:status,:subject,:text,
:user_id,:user_name,:user_lastname,:user_nickname,:pictureurl,:displayname,:attachments,:biography,
:attachment_id, :attachment_fileurl,:attachment_type,:attachment_actualurl,:attachment_name



class << self
Expand Down Expand Up @@ -50,12 +53,40 @@ def generic_from_xml(xml)
u.timediff = need[:timediff]
u.status = need[:status]

(need/:subject).each do |subject|


(need/:subject).each do |subject|
u.subject = subject.inner_html
end
(need/:text).each do |text|
u.text = text.inner_html
end


#si hay attachment
if(need/:attachment)
(need/:attachment).each do |attch|
u.attachment_id = attch[:id]
u.attachment_fileurl = attch[:fileurl]
u.attachment_type = attch[:type]
u.attachment_actualurl = attch[:actualurl]
u.attachment_name = (attch/:name).inner_html
end
end

#cargamos al user para helped si existe
if(need/:user)
(need/:user).each do |user|
u.user_id = user[:id]
u.user_name = user[:name]
u.user_lastname = user[:lastname]
u.pictureurl = user[:pictureurl]
u.user_nickname = user[:user_nickname]
u.biography = (user/:biography).inner_html
# u.attachments = user[:attachments]
end
end

result << u
end
end
Expand All @@ -66,9 +97,6 @@ def generic_from_xml(xml)

def generic_view_from_xml(xml)
result = []
#:help_id, :help_created, :help_stars, :help_timediff,:help_text,
# :help_user_id,:help_user_name,:help_user_nickname,:help_user_picture_url,:help_user_displayname,:help_user_text


xml.search("need").each do |need|

Expand All @@ -84,10 +112,7 @@ def generic_view_from_xml(xml)
end

u.text = need.search('text').first.inner_html





result << u
end
end
Expand All @@ -96,7 +121,7 @@ def generic_view_from_xml(xml)




##
end
end
end
2 changes: 1 addition & 1 deletion lib/needish/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Needish
module VERSION #:nodoc:
MAJOR = 0
MINOR = 0
TINY = 2
TINY = 3

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down
Binary file added pkg/needish-0.0.3.gem
Binary file not shown.
Binary file added pkg/needish-0.0.3.tgz
Binary file not shown.
16 changes: 16 additions & 0 deletions pkg/needish-0.0.3/History.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
== 0.0.3 2008-11-05

* 1 major enhancement:
* new methods in base
*new methods in base.rb, helped , tag(), and search()

== 0.0.2 2008-07-05

* 1 major enhancement:
* @@apikey desapears
*The apikey passes to the method initialize, now is not a global variable, (security issues)

== 0.0.1 2008-07-05

* 1 major enhancement:
* Initial release
20 changes: 20 additions & 0 deletions pkg/needish-0.0.3/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2008 Miguel Michelson Martinez

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions pkg/needish-0.0.3/Manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
History.txt
License.txt
Manifest.txt
PostInstall.txt
README.txt
Rakefile
lib/needish.rb
lib/needish/version.rb
lib/needish/base.rb
lib/needish/easy_class_maker.rb
lib/needish/friend.rb
lib/needish/help.rb
lib/needish/need.rb
lib/needish/user.rb
test/test_helper.rb
test/test_needish.rb

9 changes: 9 additions & 0 deletions pkg/needish-0.0.3/PostInstall.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Instalation Success!!

For more information on needish gem, see http://animalita.cl/needish-gem

cheers!




112 changes: 112 additions & 0 deletions pkg/needish-0.0.3/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
= needish

* FIX (url)

== DESCRIPTION:

This Gems provides basic methods to access the Nedish.com api

== FEATURES/PROBLEMS:

lists the user profile, user friends , needs and helps from a need
sends needs, helps

-problems.
no detected yet!

-todo
search methods
make friends etc..

== SYNOPSIS:

*examples

login to needish
pass to login user and pass AND apikey!! (since 0.0.2)

<pre>login = Needish::Base.new('miguelmichelson@gmail.com','********' ,'apikey2234455566')</pre>

obtain the user logged data

<pre>miguel = login.me</pre>

obtain the user id

<pre>miguel.id</pre>

obtain the user friends

<pre>login.user_friends(miguel.id)</pre>

obtain the needs

<pre>login.user_needs(me.id)</pre>

obtain the needs helps

<pre>login.helps(user_needs(me.id)[0].id)</pre>

Other methods

add need, pass subject and text

<pre>login.add_need('subject','text')</pre>

add help, pass need id and text

<pre>login.add_help(need.id,'text')</pre>

new methods

helped needs
<pre> login.helped </pre>

search by tag
<pre> login.tag("tag") </pre>

simple search
<pre> login.search("term") </pre>


== REQUIREMENTS:

this gem requires hricot,

sudo gem install hpricot


== INSTALL:

to install this gem simply do :

git clone git://github.com/michelson/needish-gem.git

cd needish-gem

sudo install gem pkg/needish-0.0.1.gem

== LICENSE:

(The MIT License)

Copyright (c) 2008 FIXME full name

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 4 additions & 0 deletions pkg/needish-0.0.3/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'config/requirements'
require 'config/hoe' # setup Hoe + all gem configuration

Dir['tasks/**/*.rake'].each { |rake| load rake }
14 changes: 14 additions & 0 deletions pkg/needish-0.0.3/lib/needish.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
%w(uri cgi net/http yaml rubygems hpricot active_support).each { |f| require f }

$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))



require 'needish/version'
require 'needish/easy_class_maker'
require 'needish/base'
require 'needish/user'
require 'needish/friend'
require 'needish/need'
require 'needish/help'
Loading

0 comments on commit 81f39fa

Please sign in to comment.