Skip to content

Commit

Permalink
Axed do_ruby. Ported tinyurl_action to GnomeDo-Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Jones committed Nov 20, 2008
1 parent b4370ec commit d077126
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 74 deletions.
Empty file removed ruby/do_ruby/LICENSE
Empty file.
Empty file removed ruby/do_ruby/README
Empty file.
13 changes: 0 additions & 13 deletions ruby/do_ruby/do-ruby.gemspec

This file was deleted.

57 changes: 0 additions & 57 deletions ruby/do_ruby/lib/do_ruby.rb

This file was deleted.

8 changes: 4 additions & 4 deletions ruby/tinyurl_action.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
%w{rubygems json trollop net/http gnomedo-ruby}.each { |lib| require lib}
%w{rubygems trollop net/http gnomedo-ruby}.each { |lib| require lib}
class TinyUrlAction
attr_accessor :action_definition

Expand All @@ -16,11 +16,11 @@ def get_shortened_url_item(url)
http = Net::HTTP.start("tinyurl.com", 80)
response = http.get("/api-create.php?url=#{url}")
tinyurl = response.read_body
url_item = GnomeDo::TextItem.new :name => "TinyUrl Item", :description => url, :text => tinyurl
url_item = GnomeDo::TextItem.new :text => tinyurl, :description => url
end

def get_urls_from_json(json)
items = JSON.parse(json)
items = ActiveSupport::JSON.decode(json)
items.map { |item| item.select {|k,v| k=="Text" }.flatten[1] }
end

Expand All @@ -31,7 +31,7 @@ def ensure_urls_are_valid!(urls)
def print_tinyurl_json(json)
urls = get_urls_from_json(json)
ensure_urls_are_valid!(urls)
print urls.map {|url| get_shortened_url_item(url)}.to_json
puts urls.map {|url| get_shortened_url_item(url)}.to_json
end

end
Expand Down

0 comments on commit d077126

Please sign in to comment.