Skip to content

Commit

Permalink
tweaked destroy and save to be a little less brittle
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.addictedtonew.com/public/gems/mirrored@176 fe7eae16-9a24-0410-a59d-9e59979e88be
  • Loading branch information
jnunemaker committed Feb 14, 2008
1 parent f0d0d47 commit 2dabc6e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 48 deletions.
3 changes: 3 additions & 0 deletions History.txt
@@ -1,3 +1,6 @@
0.1.5
* tweaked destroy and save to be a little less brittle

0.1.4
* screwed up 0.1.3, this correctly fixes hpricot issue

Expand Down
31 changes: 15 additions & 16 deletions License.txt
@@ -1,20 +1,19 @@
Copyright (c) 2007 John Nunemaker

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:
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 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.
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.
19 changes: 0 additions & 19 deletions MIT-LICENSE

This file was deleted.

15 changes: 7 additions & 8 deletions Manifest.txt
Expand Up @@ -20,12 +20,6 @@ setup.rb
tasks/deployment.rake
tasks/environment.rake
tasks/website.rake
test/test_base.rb
test/test_date.rb
test/test_helper.rb
test/test_post.rb
test/test_tag.rb
test/test_update.rb
test/fixtures/xml/add_post_done.xml
test/fixtures/xml/all_posts.xml
test/fixtures/xml/all_posts_by_tag.xml
Expand All @@ -42,6 +36,11 @@ test/fixtures/xml/recent_posts_by_tag.xml
test/fixtures/xml/recent_posts_by_tag_and_count.xml
test/fixtures/xml/tag_rename.xml
test/fixtures/xml/tags.xml
test/test_base.rb
test/test_date.rb
test/test_helper.rb
test/test_post.rb
test/test_tag.rb
test/test_update.rb
website/css/common.css
website/images
website/index.html
website/index.html
16 changes: 12 additions & 4 deletions lib/mirrored/post.rb
Expand Up @@ -65,8 +65,12 @@ def find(*args)
# Mirrored::Post.delete('http://microsoft.com') # => aliased version
def destroy(url)
doc = Hpricot::XML(connection.get('posts/delete', :url => url))
code = doc.at('result')['code']
code == 'done' ? true : false
if doc && doc.at('result')
code = doc.at('result')['code']
code == 'done' ? true : false
else
false
end
end
alias :delete :destroy
end
Expand All @@ -85,8 +89,12 @@ def save(replace=false)
attrs = to_h.merge((replace) ? {:replace => 'yes'} : {:replace => 'no'})
puts attrs.inspect
doc = Hpricot::XML(self.class.connection.get('posts/add', attrs))
@code = doc.at('result')['code']
(@code == 'done') ? true : false
if doc && doc.at('result')
@code = doc.at('result')['code']
(@code == 'done') ? true : false
else
false
end
end

def to_h #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/mirrored/version.rb
Expand Up @@ -2,7 +2,7 @@ module Mirrored #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 1
TINY = 4
TINY = 5

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down

0 comments on commit 2dabc6e

Please sign in to comment.