gemqs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +8 -0
- data/README +2 -0
- data/Rakefile +1 -0
- data/bin/gemqs +8 -0
- data/config/config.yml +7 -0
- data/gemqs.gemspec +29 -0
- data/lib/gemqs/version.rb +3 -0
- data/lib/gemqs.rb +69 -0
- metadata +100 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/gemqs
ADDED
data/config/config.yml
ADDED
data/gemqs.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gemqs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gemqs"
|
7
|
+
s.version = Gemqs::VERSION
|
8
|
+
s.authors = ["Dave Heitzman"]
|
9
|
+
s.email = ["daveheitzman@yahoo.com"]
|
10
|
+
s.homepage = "http://aptifuge.com"
|
11
|
+
s.summary = %q{Command line interface to search rubygems.org}
|
12
|
+
s.description = %q{Command line interface to search rubygems.org}
|
13
|
+
|
14
|
+
s.rubyforge_project = "gemqs"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "mechanize"
|
23
|
+
s.add_development_dependency "nokogiri"
|
24
|
+
s.add_development_dependency "rainbow"
|
25
|
+
|
26
|
+
|
27
|
+
s.add_development_dependency "nokogiri"
|
28
|
+
|
29
|
+
end
|
data/lib/gemqs.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.dirname( __FILE__ )+"/gemqs/version"
|
2
|
+
require 'mechanize'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module Gemqs
|
8
|
+
CONFIGURATION_FILE= File.dirname(__FILE__) + "/../config/config.yml"
|
9
|
+
def conf
|
10
|
+
if !@conf then
|
11
|
+
f=File.open CONFIGURATION_FILE
|
12
|
+
@conf = YAML::load( f )
|
13
|
+
@conf[:query]=''
|
14
|
+
@conf
|
15
|
+
else
|
16
|
+
@conf
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Scraper
|
21
|
+
attr_accessor :results
|
22
|
+
def initialize
|
23
|
+
#~ puts " gemqs (gem quick-search) "
|
24
|
+
#~ puts " by David Heitzman, 2012. http://aptifuge.com"
|
25
|
+
#~ puts
|
26
|
+
case ARGV.size
|
27
|
+
when 0
|
28
|
+
puts "usage: gemqs [search terms] "
|
29
|
+
else
|
30
|
+
print "gemqs "
|
31
|
+
query=ARGV.join("+")
|
32
|
+
conf[:terms] = query.split "+"
|
33
|
+
query = "/search?query="+query
|
34
|
+
conf[:query] = query
|
35
|
+
end
|
36
|
+
@results = []
|
37
|
+
end
|
38
|
+
def agent
|
39
|
+
@agent=Mechanize.new
|
40
|
+
end
|
41
|
+
def html_page
|
42
|
+
@html_page ||= Nokogiri::HTML( open( conf['urls']['rubygems']+conf[:query] ) )
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_page
|
46
|
+
if conf[:query].size > 0
|
47
|
+
puts " searching #{conf['urls'].map{|k,v| v }.join(', ')} on the terms: "+conf[:terms].join( " " )
|
48
|
+
rpage=html_page
|
49
|
+
ritems = rpage.css('div.gems.border>ol>li')
|
50
|
+
ritems.each do |rli|
|
51
|
+
self.results << [
|
52
|
+
rli.children[1].text.split(" ").first.gsub(",","").to_i,
|
53
|
+
rli.children[3].text.split("\n")[1],
|
54
|
+
rli.children[3].text.split("\n")[2],
|
55
|
+
rli.children[1].text.split(" ").first
|
56
|
+
]
|
57
|
+
end
|
58
|
+
results.sort{|a,b| b.first <=> a.first}.each do |i|
|
59
|
+
printf("%-40.40s %14.14s downloads #{ i[2] }\n",i[1],i[3])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Organizer
|
66
|
+
end
|
67
|
+
|
68
|
+
# Your code goes here...
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemqs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dave Heitzman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mechanize
|
16
|
+
requirement: &14895100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *14895100
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
requirement: &14892400 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *14892400
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rainbow
|
38
|
+
requirement: &14887900 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *14887900
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: &14885980 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *14885980
|
58
|
+
description: Command line interface to search rubygems.org
|
59
|
+
email:
|
60
|
+
- daveheitzman@yahoo.com
|
61
|
+
executables:
|
62
|
+
- gemqs
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- Gemfile
|
68
|
+
- README
|
69
|
+
- Rakefile
|
70
|
+
- bin/gemqs
|
71
|
+
- config/config.yml
|
72
|
+
- gemqs.gemspec
|
73
|
+
- lib/gemqs.rb
|
74
|
+
- lib/gemqs/version.rb
|
75
|
+
homepage: http://aptifuge.com
|
76
|
+
licenses: []
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project: gemqs
|
95
|
+
rubygems_version: 1.8.15
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: Command line interface to search rubygems.org
|
99
|
+
test_files: []
|
100
|
+
has_rdoc:
|