Jazzez · pdf-reader · Prawn · Ruby · Ruby 1.9 · ruby excercise · watir

Convert Webpage into PDF files using Ruby gems — Watir-Webdriver + Prawn

Installation : 

1. Install Ruby 1.8.7 or 1.9.2

2. Install WatirWebdriver — Refer  http://rubygems.org/gems/watir-webdriver

a. CMD>gem install watir-webdriver

3. Install Prawn Library

a. CMD>gem install prawn

Sample Code:

require 'rubygems'
require 'watir-webdriver'
require 'prawn'

ff=Watir::Browser.new :ff

ff.goto("https://raveendran.wordpress.com")

Prawn::Document.generate('c:\\test123\\hello.pdf') do |pdf|
pdf.text(ff.text)
end

ff.close

Output:

hello PDF  file contains all the TEXT from Webpage

 

Open Issues:

Alignment issue occurs depends upon web page Design. But You wont miss to collect all the Text from Webpage.

Advertisements
Jazzez · Ruby

jazzez 1.1.1 released

Home page –> http://rubyforge.org/projects/jazzez/

Installation:

>gem install jazzez

Documentation for Jazzez Version 1.1.1 gem:

1. Get the links from URL

Ex.

require ‘jazzez’
output= Jazzez.new
puts output.links(“google.com\”)

Output:

http://images.google.com/imghp?hl=en&tab=wi
http://maps.google.com/maps?hl=en&tab=wl
http://news.google.com/nwshp?hl=en&tab=wn
http://video.google.com/?hl=en&tab=wv
http://mail.google.com/mail/?hl=en&tab=wm
http://www.google.com/intl/en/options/
https://www.google.com/accounts/Login?continue=http://66.249.89.44/&hl=en
http://google.com/advanced_search?hl=en
http://google.com/preferences?hl=en
http://google.com/language_tools?hl=en
http://google.com/intl/en/ads/
http://google.com/services/
http://google.com/intl/en/about.html
http://www.google.com/ncr
http://google.com/intl/en/privacy.html

Usage:

1. Get the URL from User.
2. Make sure to check whether it is valid or not.
3. If it is valid, then get the source code for that page with the help of Mechanize gem.
4. Get all the <a> tags & collect only HREF Values in that page with the help of Mechanize gem
5. If the href values not having the domains then add a URL(homepage) + Href value.
6. return the results to User as an array

2. Get the Second level links

Ex.

require ‘jazzez’
output= Jazzez.new
puts output.links_level2(“google.com\”)

Output:

It gives the Second level outputs.

http://64.233.183.18
http://adwords.google.com/select/Login?http://adwords.google.com/select/Login?sourceid=awo&subid=us-en-et-bizsol-0-biz1-all&medium=link&hl=en_US
http://adwords.google.com/select/Login?sourceid=awo&subid=us-en-et-bizsol-0-biz1-all&medium=link&hl=en_US
http://books.google.com/
http://checkout.google.com/sell?promo=sbs&utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://code.google.com/appengine/privacy.html
http://desktop.google.com/privacypolicy.html
http://gmail.google.com/gmail/help/privacy.html
http://google.com../
http://google.com/
http://google.com/a/help/intl/en/users/privacy.html
http://google.com/about.html
http://google.com/accounts/TOS
http://google.com/advanced_search?hl=en
http://google.com/bsd
http://google.com/chrome/intl/en/privacy.html
http://google.com/codesearch?hl=en
http://google.com/goog411/privacy.html
http://google.com/google-d-s/privacy.html
http://google.com/googlecalendar/privacy_policy.html
http://google.com/help/customize.html#searchlang
http://google.com/help/privacy_fusionph.html
http://google.com/ig/usgov
http://google.com/intl/en-US/health/about/privacy.html
http://google.com/intl/en/about.html
http://google.com/intl/en/ads/
http://google.com/intl/en/help/customize.html
http://google.com/intl/en/help/customize.html#safe
http://google.com/intl/en/privacy.html
http://google.com/intl/en/sketchup/3dwh/privacy.html
http://google.com/language_tools?hl=en
http://google.com/linux
http://google.com/mac
http://google.com/mail/help/tasks/privacy.html
http://google.com/microsoft
http://google.com/mobile/android/privacy.html
http://google.com/options/universities.html
http://google.com/preferences?hl=en
http://google.com/searchhistory/privacy.html
http://google.com/services/
http://google.com/support/bin/request.py?form_type=user&stage=fm&user_type=user&contact_type=privacy&hl=en
http://google.com/support/toolbar/?quick=privacy
http://google.com/support?hl=en
http://google.com/talk/privacy.html
http://google.com/tools/firefox/extensions_privacy.html
http://google.comabout.html
http://google.comads/
http://google.comcontact/
http://google.comcookies.html
http://google.comcorporate/
http://google.comhelp/features.html
http://google.comhelp/refinesearch.html
http://google.comjobs/
http://google.comoptions/
http://google.compress/
http://google.comprivacy.html
http://google.comprivacy_ads.html
http://google.comprivacy_blogs.html
http://google.comprivacy_faq.html
http://google.comprivacy_glossary.html
http://google.comprivacy_highlights.html
http://google.comprivacy_moderator.html
http://google.comprivacy_terms.html
http://google.comprivacypolicy.html
http://google.comservices/
http://google.comstickers.html
http://google.comsubmit_content.html
http://google.comwebmasters/
http://googleblog.blogspot.com
http://groups-beta.google.com/googlegroups/privacy.html
http://images.google.com/imghp?hl=en&tab=wi
http://investor.google.com
http://labs.google.com/
http://mail.google.com/mail/?hl=en&tab=wm
http://maps.google.com/help/privacy_maps.html
http://maps.google.com/maps?hl=en&tab=wl
http://mobile.google.com/privacy.html
http://news.google.com/archivesearch
http://news.google.com/nwshp?hl=en&tab=wn
http://picasa.google.com/web/privacy.html
http://scholar.google.com/
http://services.google.com/ads_inquiry/en
http://services.google.com/tcbin/tc.py
http://video.google.com/?hl=en&tab=wv
http://webaccelerator.google.com/privacy.html
http://www.blogger.com/privacy
http://www.google.ad
http://www.google.ae
http://www.google.am
http://www.google.as
http://www.google.at
http://www.google.az
http://www.google.ba
http://www.google.be
http://www.google.bg
http://www.google.bi
http://www.google.bs
http://www.google.ca
http://www.google.cd
http://www.google.cg
http://www.google.ch
http://www.google.ci
http://www.google.cl
http://www.google.cn
http://www.google.co.bw
http://www.google.co.ck
http://www.google.co.cr
http://www.google.co.id
http://www.google.co.il
http://www.google.co.in
http://www.google.co.jp
http://www.google.co.ke
http://www.google.co.kr
http://www.google.co.ls
http://www.google.co.ma
http://www.google.co.mz
http://www.google.co.nz
http://www.google.co.th
http://www.google.co.tz
http://www.google.co.ug
http://www.google.co.uk
http://www.google.co.uk/help/merchantsearchbeta/privacy.html
http://www.google.co.uz
http://www.google.co.ve
http://www.google.co.vi
http://www.google.co.za
http://www.google.co.zm
http://www.google.co.zw
http://www.google.com
http://www.google.com.af
http://www.google.com.ag
http://www.google.com.ai
http://www.google.com.ar
http://www.google.com.au
http://www.google.com.bd
http://www.google.com.bh
http://www.google.com.bn
http://www.google.com.bo
http://www.google.com.br
http://www.google.com.by
http://www.google.com.bz
http://www.google.com.co
http://www.google.com.cu
http://www.google.com.do
http://www.google.com.ec
http://www.google.com.eg
http://www.google.com.et
http://www.google.com.fj
http://www.google.com.gh
http://www.google.com.gi
http://www.google.com.gt
http://www.google.com.hk
http://www.google.com.jm
http://www.google.com.kh
http://www.google.com.kw
http://www.google.com.lb
http://www.google.com.ly
http://www.google.com.mt
http://www.google.com.mx
http://www.google.com.my
http://www.google.com.na
http://www.google.com.nf
http://www.google.com.ng
http://www.google.com.ni
http://www.google.com.np
http://www.google.com.om
http://www.google.com.pa
http://www.google.com.pe
http://www.google.com.ph
http://www.google.com.pk
http://www.google.com.pr
http://www.google.com.py
http://www.google.com.qa
http://www.google.com.sa
http://www.google.com.sb
http://www.google.com.sg
http://www.google.com.sl
http://www.google.com.sv
http://www.google.com.tj
http://www.google.com.tr
http://www.google.com.tw
http://www.google.com.ua
http://www.google.com.uy
http://www.google.com.vc
http://www.google.com.vn
http://www.google.com/a/?utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.com/admanager?utm_source=bizsol_us&utm_medium=et&utm_campaign=bizsol
http://www.google.com/adsense/?hl=en_US&sourceid=aso&subid=ww-en-et-ads-0-adsC-all&hl=en_us
http://www.google.com/adserving/index.html#utm_source=ads&utm_medium=et&utm_campaign=ads-en-us
http://www.google.com/analytics#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1_top_img&utm_campaign=en
http://www.google.com/analytics#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1_top_link&utm_campaign=en
http://www.google.com/analytics/#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.com/base/?utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.com/chrome/index.html?brand=CHMH&utm_source=ww-et-abt&utm_medium=abt&utm_campaign=en
http://www.google.com/enterprise/geospatial.html#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.com/enterprise/public_search.html#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.com/friendconnect/?utm_medium=et&utm_campaign=en&utm_source=en-et-na-us-bizsol
http://www.google.com/intl/af/
http://www.google.com/intl/am/
http://www.google.com/intl/ar/
http://www.google.com/intl/az/
http://www.google.com/intl/be/
http://www.google.com/intl/bg/
http://www.google.com/intl/bh/
http://www.google.com/intl/bn/
http://www.google.com/intl/br/
http://www.google.com/intl/bs/
http://www.google.com/intl/ca/
http://www.google.com/intl/co/
http://www.google.com/intl/cs/
http://www.google.com/intl/cy/
http://www.google.com/intl/da/
http://www.google.com/intl/de/
http://www.google.com/intl/el/
http://www.google.com/intl/en/
http://www.google.com/intl/en/about.html
http://www.google.com/intl/en/options/
http://www.google.com/intl/eo/
http://www.google.com/intl/es/
http://www.google.com/intl/et/
http://www.google.com/intl/eu/
http://www.google.com/intl/fa/
http://www.google.com/intl/fi/
http://www.google.com/intl/fo/
http://www.google.com/intl/fr/
http://www.google.com/intl/fy/
http://www.google.com/intl/ga/
http://www.google.com/intl/gd/
http://www.google.com/intl/gl/
http://www.google.com/intl/gn/
http://www.google.com/intl/gu/
http://www.google.com/intl/ha/
http://www.google.com/intl/hi/
http://www.google.com/intl/hr/
http://www.google.com/intl/hu/
http://www.google.com/intl/hy/
http://www.google.com/intl/ia/
http://www.google.com/intl/id/
http://www.google.com/intl/is/
http://www.google.com/intl/it/
http://www.google.com/intl/iw/
http://www.google.com/intl/ja/
http://www.google.com/intl/jw/
http://www.google.com/intl/ka/
http://www.google.com/intl/kk/
http://www.google.com/intl/km/
http://www.google.com/intl/kn/
http://www.google.com/intl/ko/
http://www.google.com/intl/ku/
http://www.google.com/intl/ky/
http://www.google.com/intl/la/
http://www.google.com/intl/ln/
http://www.google.com/intl/lo/
http://www.google.com/intl/lt/
http://www.google.com/intl/lv/
http://www.google.com/intl/mg/
http://www.google.com/intl/mi/
http://www.google.com/intl/mk/
http://www.google.com/intl/ml/
http://www.google.com/intl/mn/
http://www.google.com/intl/mo/
http://www.google.com/intl/mr/
http://www.google.com/intl/ms/
http://www.google.com/intl/mt/
http://www.google.com/intl/ne/
http://www.google.com/intl/nl/
http://www.google.com/intl/nn/
http://www.google.com/intl/no/
http://www.google.com/intl/oc/
http://www.google.com/intl/om/
http://www.google.com/intl/or/
http://www.google.com/intl/pa/
http://www.google.com/intl/pl/
http://www.google.com/intl/ps/
http://www.google.com/intl/pt-BR/
http://www.google.com/intl/pt-PT/
http://www.google.com/intl/qu/
http://www.google.com/intl/rm/
http://www.google.com/intl/rn/
http://www.google.com/intl/ro/
http://www.google.com/intl/ru/
http://www.google.com/intl/rw/
http://www.google.com/intl/sd/
http://www.google.com/intl/sh/
http://www.google.com/intl/si/
http://www.google.com/intl/sk/
http://www.google.com/intl/sl/
http://www.google.com/intl/sn/
http://www.google.com/intl/so/
http://www.google.com/intl/sq/
http://www.google.com/intl/sr-ME/
http://www.google.com/intl/sr/
http://www.google.com/intl/st/
http://www.google.com/intl/su/
http://www.google.com/intl/sv/
http://www.google.com/intl/sw/
http://www.google.com/intl/ta/
http://www.google.com/intl/te/
http://www.google.com/intl/tg/
http://www.google.com/intl/th/
http://www.google.com/intl/ti/
http://www.google.com/intl/tk/
http://www.google.com/intl/tl/
http://www.google.com/intl/to/
http://www.google.com/intl/tr/
http://www.google.com/intl/tt/
http://www.google.com/intl/tw/
http://www.google.com/intl/ug/
http://www.google.com/intl/uk/
http://www.google.com/intl/ur/
http://www.google.com/intl/uz/
http://www.google.com/intl/vi/
http://www.google.com/intl/xh/
http://www.google.com/intl/xx-bork/
http://www.google.com/intl/xx-elmer/
http://www.google.com/intl/xx-hacker/
http://www.google.com/intl/xx-klingon/
http://www.google.com/intl/xx-pirate/
http://www.google.com/intl/yi/
http://www.google.com/intl/yo/
http://www.google.com/intl/zh-CN/
http://www.google.com/intl/zh-TW/
http://www.google.com/intl/zu/
http://www.google.com/local/add/login?utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en&hl=en_US&gl=US
http://www.google.com/ncr
http://www.google.com/postini/index.html#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.com/sites/help/intl/en/privacy_policy.html
http://www.google.com/sitesearch#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.com/support/bin/answer.py?answer=29508
http://www.google.com/tools/firefox/toolbar/FT3/intl/en/index.html?utm_source=ww-en-et-about&utm_medium=et&utm_campaign=en
http://www.google.com/transconsole
http://www.google.com/webhp?hl=en
http://www.google.com/webmasters/#utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
http://www.google.cz
http://www.google.de
http://www.google.dj
http://www.google.dk
http://www.google.dm
http://www.google.dz
http://www.google.ee
http://www.google.es
http://www.google.fi
http://www.google.fm
http://www.google.fr
http://www.google.ge
http://www.google.gg
http://www.google.gl
http://www.google.gm
http://www.google.gp
http://www.google.gr
http://www.google.gy
http://www.google.hn
http://www.google.hr
http://www.google.ht
http://www.google.hu
http://www.google.ie
http://www.google.im
http://www.google.is
http://www.google.it
http://www.google.it.ao
http://www.google.je
http://www.google.jo
http://www.google.kg
http://www.google.ki
http://www.google.kz
http://www.google.la
http://www.google.li
http://www.google.lk
http://www.google.lt
http://www.google.lu
http://www.google.lv
http://www.google.md
http://www.google.me
http://www.google.mg
http://www.google.mn
http://www.google.ms
http://www.google.mu
http://www.google.mv
http://www.google.mw
http://www.google.nl
http://www.google.no
http://www.google.nr
http://www.google.nu
http://www.google.pl
http://www.google.pn
http://www.google.pt
http://www.google.ro
http://www.google.rs
http://www.google.ru
http://www.google.rw
http://www.google.sc
http://www.google.se
http://www.google.sh
http://www.google.si
http://www.google.sk
http://www.google.sm
http://www.google.sn
http://www.google.st
http://www.google.tk
http://www.google.tl
http://www.google.tm
http://www.google.to
http://www.google.tt
http://www.google.vg
http://www.google.vu
http://www.google.ws
http://www.googlestore.com
http://www.googlestore.com/privacy.asp
http://www.orkut.com/privacy.aspx
http://www.postini.com/legal/privacy.php
http://www.youtube.com/t/privacy
https://adwords.google.com/select/Login?sourceid=awo&subid=us-en-et-bizsol-0-biz1-all&medium=link&hl=en_US
https://adwords.google.com/select/Login?sourceid=awo&subid=ww-en-et-about_page&medium=link
https://adwords.google.com/select/Login?sourceid=awo&subid=ww-en-et-ads-0-adsC-all&hl=en_us
https://adwords.google.com/select/StartNewAccount?sourceid=awo&subid=us-en-et-bizsol-0-biz1-all&medium=link&hl=en_US
https://adwords.google.com/select/starter/signup/ForkAuth?sourceid=awo&subid=ww-en-et-ads-0-adsC-all&hl=en_us
https://checkout.google.com/files/privacy.html
https://knol.google.com/k/knol-help/-/si57lahl1w25/15#view
https://www.google.com/accounts/Login?continue=http://64.233.183.18/language_tools%3Fhl%3Den&hl=en
https://www.google.com/accounts/Login?continue=http://64.233.183.81/preferences%3Fhl%3Den&hl=en
https://www.google.com/accounts/Login?continue=http://72.14.203.102/advanced_search%3Fhl%3Den&hl=en
https://www.google.com/accounts/Login?continue=http://72.14.235.83/&hl=en
https://www.google.com/accounts/ServiceLogin?continue=http://64.233.183.81/preferences%3Fhl%3Den
https://www.google.com/accounts/ServiceLogin?service=websiteoptimizer&hl=en&continue=https%3A%2F%2Fwww.google.com%2Fanalytics%2Fsiteopt%2F%3Fet%3Dreset%26hl%3Den&utm_medium=et&utm_source=us-en-et-bizsol-0-biz1-all&utm_campaign=en
https://www.google.com/adsense/?sourceid=aso&subid=us-en-et-bizsol-0-biz1-all&medium=link&hl=en_US
https://www.google.com/adsense/?sourceid=aso&subid=ww-en-et-bizsol-biz1_top_img&hl=en_us
https://www.google.com/adsense/?sourceid=aso&subid=ww-en-et-bizsol-biz1_top_link&hl=en_us
https://www.google.com/adsense/g-app-single-1?hl=en_US&sourceid=aso&subid=ww-en-et-ads-0-adsC-all&hl=en_us
https://www.google.com/voice/help/privacy

3. Get the Html tags

Ex.

require ‘jazzez’
output= Jazzez.new
puts output.tagdetails(“google.com\”)

Output:

1<html tag(s)
1</html> tag(s)
1<head tag(s)
1</head> tag(s)
1<body tag(s)
1</body> tag(s)
2<table tag(s)
2</table> tag(s)
3<tr tag(s)
3</tr> tag(s)
9<td tag(s)
9</td> tag(s)
0<th tag(s)
0</th> tag(s)
0<l tag(s)
0</l> tag(s)
0<link tag(s)
1<p tag(s)
1</p> tag(s)
4<div tag(s)
4</div> tag(s)
0<span tag(s)
0</span> tag(s)
4<script tag(s)
4</script> tag(s)
0<ul tag(s)
0</ul> tag(s)
0<ol tag(s)
0</ol> tag(s)
16<a tag(s)
15</a> tag(s)
0<h1 tag(s)
0</h1> tag(s)
0<h2 tag(s)
0</h2> tag(s)
0<h3 tag(s)
0</h3> tag(s)
0<h4 tag(s)
0</h4> tag(s)
0<h5 tag(s)
0</h5> tag(s)
0<h6 tag(s)
0</h6> tag(s)
4<font tag(s)
4</font> tag(s)
0<select tag(s)
0</select> tag(s)
0<option tag(s)
0</option> tag(s)

Usage:

Easy to answer the below questions

How many tables in your code ?
How many table rows/coloums in your code ?
How Many div tags opened and how many div tags closed ?
Are you sure your html tags were properly closed ?

More functions available in next version.

Any queries just send a mail to jazzezravi@gmail.com.

gosu

Gosu – Ruby Gem (Game application in Ruby)

Gosu – Game Application in Ruby:

1. Installation:

>gem install gosu

2. code:

begin

  # In case you use Gosu via RubyGems.

  require ‘rubygems’

rescue LoadError

  # In case you don’t.

end

 

require ‘gosu’

 

class MyWindow < Gosu::Window

  def initialize

    super(640, 640,false, 100)

    self.caption = ‘jazzez’

  end

end

 

w = MyWindow.new

w.show

3. output

Output looks like

gosu

 

For more referrence,

http://www.libgosu.org/