Skip to content
Browse files

rename classes due to gem name conflicts

  • Loading branch information...
1 parent 4949176 commit 6f48bbb3bb9c194780de3c558e0c38b211b4771d @siuying committed
Showing with 33 additions and 32 deletions.
  1. +4 −4 README.md
  2. +2 −1 Rakefile
  3. +2 −2 bin/rquery
  4. +1 −1 lib/{rquery.rb → ruby_query.rb}
  5. +23 −23 spec/rquery/rquery_spec.rb
  6. +1 −1 spec/spec_helper.rb
View
8 README.md
@@ -1,4 +1,4 @@
-# RQuery
+# Ruby-Query
jQuery for command line and ruby. It make extract simple data fun and easy.
@@ -6,7 +6,7 @@
## Installation
- $ gem install rquery
+ $ gem install ruby-query
## Ruby Examples
@@ -14,14 +14,14 @@
Extract an attribute from a webpage:
require 'open-uri'
- require 'rquery'
+ require 'ruby-query'
RQuery::Query.query(open("http://twitter.com"), "a#logo img", "attr", "alt")
=> "Twitter"
Extract a form input value :
- require 'rquery'
+ require 'ruby-query'
RQuery::Query.query('<input type="text" value="tj@vision-media.ca"/>', "input", "val")
=> "tj@vision-media.ca"
View
3 Rakefile
@@ -12,8 +12,9 @@ require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
- gem.name = "rquery"
+ gem.name = "ruby-query"
gem.files = ["lib/*.rb", "lib/**/*.rb", "bin/*"]
+ gem.autorequire = 'ruby-query'
gem.executables = ['rquery']
gem.homepage = "http://github.com/siuying/rquery"
gem.license = "MIT"
View
4 bin/rquery
@@ -1,5 +1,5 @@
-require 'rquery'
+require 'ruby_query'
html = STDIN.read
-puts RQuery::Query.query(html, *ARGV)
+puts RubyQuery::Query.query(html, *ARGV)
View
2 lib/rquery.rb → lib/ruby_query.rb
@@ -1,6 +1,6 @@
require 'nokogiri'
-module RQuery
+module RubyQuery
class QueryError < StandardError
attr_accessor :context, :command_name, :command_type, :param, :message
def initialize(context, name, type, param, msg)
View
46 spec/rquery/rquery_spec.rb
@@ -1,65 +1,65 @@
require 'spec_helper'
-describe RQuery do
+describe RubyQuery do
HTML_SIMPLE = "<html><body><a href='test' id='logo'><img src='1.gif' alt='Test'/></a><ul class='list'><li>point a</li><li>point b</li></ul></body></html>"
HTML_LIST = "<ul><li>Apple</li><li>Orange</li><li>Cat</li></ul>"
it "extract using class" do
- RQuery::Query.query(HTML_SIMPLE, ".list li", "first", "text").should == "point a"
+ RubyQuery::Query.query(HTML_SIMPLE, ".list li", "first", "text").should == "point a"
end
it "extract using id" do
- RQuery::Query.query(HTML_SIMPLE, "a#logo img", "attr", "alt").should == "Test"
+ RubyQuery::Query.query(HTML_SIMPLE, "a#logo img", "attr", "alt").should == "Test"
end
it "should return empty if a match is not found" do
- RQuery::Query.query(HTML_SIMPLE, "a#logo #qk").should be_empty
- RQuery::Query.query(HTML_SIMPLE, "a#logo #qk", "attr", "alt").should be_empty
+ RubyQuery::Query.query(HTML_SIMPLE, "a#logo #qk").should be_empty
+ RubyQuery::Query.query(HTML_SIMPLE, "a#logo #qk", "attr", "alt").should be_empty
end
it "nested extraction" do
- logo = RQuery::Query.query(HTML_SIMPLE, "a#logo")
- RQuery::Query.query(logo, "img", "attr", "alt").should == "Test"
+ logo = RubyQuery::Query.query(HTML_SIMPLE, "a#logo")
+ RubyQuery::Query.query(logo, "img", "attr", "alt").should == "Test"
end
it "check if a class is present" do
- logo = RQuery::Query.query(HTML_SIMPLE, "a")
- RQuery::Query.query(logo.to_s, "img", "attr", "alt").should be_true
+ logo = RubyQuery::Query.query(HTML_SIMPLE, "a")
+ RubyQuery::Query.query(logo.to_s, "img", "attr", "alt").should be_true
end
it "grab width or height attributes" do
- RQuery::Query.query('<div class="user" width="300"></div>', "div.user", "width").should == "300"
- RQuery::Query.query('<div class="user" width="300" height="150"></div>', "div.user", "height").should == "150"
+ RubyQuery::Query.query('<div class="user" width="300"></div>', "div.user", "width").should == "300"
+ RubyQuery::Query.query('<div class="user" width="300" height="150"></div>', "div.user", "height").should == "150"
end
it "output element text and inner html" do
- RQuery::Query.query('<p>very <em>slick</em></p>', "p", "text").should == "very slick"
- RQuery::Query.query('<p>very <em>slick</em></p>', "p", "inner_html").should == "very <em>slick</em>"
+ RubyQuery::Query.query('<p>very <em>slick</em></p>', "p", "text").should == "very slick"
+ RubyQuery::Query.query('<p>very <em>slick</em></p>', "p", "inner_html").should == "very <em>slick</em>"
end
it "get value" do
- RQuery::Query.query('<input type="text" value="tj@vision-media.ca"/>', "input", "val").should == "tj@vision-media.ca"
- RQuery::Query.query('<input type="text" value="tj@vision-media.ca"/>', "input", "value").should == "tj@vision-media.ca"
+ RubyQuery::Query.query('<input type="text" value="tj@vision-media.ca"/>', "input", "val").should == "tj@vision-media.ca"
+ RubyQuery::Query.query('<input type="text" value="tj@vision-media.ca"/>', "input", "value").should == "tj@vision-media.ca"
end
it "get second li's text" do
- RQuery::Query.query(HTML_LIST, "ul li", "get", "1", "text").should == "Orange"
- RQuery::Query.query(HTML_LIST, "ul li", "get", "10", "text").should be_nil
+ RubyQuery::Query.query(HTML_LIST, "ul li", "get", "1", "text").should == "Orange"
+ RubyQuery::Query.query(HTML_LIST, "ul li", "get", "10", "text").should be_nil
end
it "get third li's text using next" do
- RQuery::Query.query(HTML_LIST, "ul li", "get", "1", "next", "text").should == "Cat"
+ RubyQuery::Query.query(HTML_LIST, "ul li", "get", "1", "next", "text").should == "Cat"
end
it "get length" do
- RQuery::Query.query(HTML_LIST, "li", "len").should == 3
- RQuery::Query.query(HTML_LIST, "li", "length").should == 3
+ RubyQuery::Query.query(HTML_LIST, "li", "len").should == 3
+ RubyQuery::Query.query(HTML_LIST, "li", "length").should == 3
end
it "should handl html or text" do
- RQuery::Query.query(HTML_LIST, "li", "first", "text").should == "Apple"
- RQuery::Query.query(HTML_LIST, "li", "first", "html").should == "<li>Apple</li>\n"
- RQuery::Query.query(HTML_LIST, "li", "html").should == "<li>Apple</li>\n<li>Orange</li>\n<li>Cat</li>"
+ RubyQuery::Query.query(HTML_LIST, "li", "first", "text").should == "Apple"
+ RubyQuery::Query.query(HTML_LIST, "li", "first", "html").should == "<li>Apple</li>\n"
+ RubyQuery::Query.query(HTML_LIST, "li", "html").should == "<li>Apple</li>\n<li>Orange</li>\n<li>Cat</li>"
end
end
View
2 spec/spec_helper.rb
@@ -4,7 +4,7 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'rquery'
+require 'ruby_query'
require 'rspec'
require 'rspec/autorun'

0 comments on commit 6f48bbb

Please sign in to comment.
Something went wrong with that request. Please try again.