docpeeker 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 471e8b024954b10da41f3fab2570d872ff469be9
4
+ data.tar.gz: a681ab6f941047d589b4c79e70dc831ab26730fc
5
+ SHA512:
6
+ metadata.gz: e6772a99c5caa5346efecbc93f0da716e0ad0c5cbc4b43f6b2649b472d5565a08866637c45410936add59e6f838fb7252085fc13f64de3f85ec9c148dca1c443
7
+ data.tar.gz: eb0ddf0354f55b687722cb54579dfb37281785babcae268497818767c5675d16e941b91738ee430770418efee1bfed37476264d945585ba03c36a74a0203fb07
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in docpeeker.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Connor Harwood
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Docpeeker
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'docpeeker'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install docpeeker
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/docpeeker/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/docpeeker.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'docpeeker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "docpeeker"
8
+ spec.version = Docpeeker::VERSION
9
+ spec.authors = ["Connor Harwood", "Kevin Lee", "Simon Zhang", "Tuan Duong"]
10
+ spec.email = ["harwood.connor@gmail.com"]
11
+ spec.summary = %q{Quickly find a method in Roby-docs!}
12
+ spec.description = %q{Accepts a string and searches Ruby-docs for methods matching that string. It will open tabs in your browser for each match it finds.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>= 1.8.7'
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+
25
+ spec.add_dependency 'nokogiri'
26
+ # spec.add_dependency 'open-uri'
27
+ end
@@ -0,0 +1,3 @@
1
+ module Docpeeker
2
+ VERSION = "0.0.1"
3
+ end
data/lib/docpeeker.rb ADDED
@@ -0,0 +1,72 @@
1
+ require "docpeeker/version"
2
+ require 'nokogiri'
3
+
4
+ module Docpeeker
5
+
6
+ RUBYDOC_URLS = ["http://www.ruby-doc.org/core-2.1.1/Enumerable.html",
7
+ "http://www.ruby-doc.org/core-2.1.1/Array.html",
8
+ "http://www.ruby-doc.org/core-2.1.1/Hash.html",
9
+ "http://www.ruby-doc.org/core-2.1.1/String.html",
10
+ "http://www.ruby-doc.org/stdlib-2.1.1/libdoc/set/rdoc/Set.html",
11
+ "http://www.ruby-doc.org/core-2.1.1/Bignum.html",
12
+ "http://www.ruby-doc.org/core-2.1.1/Object.html",
13
+ "http://www.ruby-doc.org/core-2.1.1/Module.html",
14
+ "http://www.ruby-doc.org/core-2.1.1/Class.html",
15
+ "http://www.ruby-doc.org/core-2.1.1/Numeric.html",
16
+ "http://www.ruby-doc.org/core-2.1.1/Float.html",
17
+ "http://www.ruby-doc.org/core-2.1.1/File.html",
18
+ "http://www.ruby-doc.org/core-2.1.1/IO.html",
19
+ "http://www.ruby-doc.org/core-2.1.1/Fixnum.html",
20
+ "http://www.ruby-doc.org/core-2.1.1/Range.html",
21
+ "http://www.ruby-doc.org/core-2.1.1/Regexp.html",
22
+ "http://www.ruby-doc.org/core-2.1.1/Symbol.html",
23
+ "http://www.ruby-doc.org/core-2.1.1/Time.html"
24
+ ]
25
+
26
+ def self.lookup(method_name)
27
+ RUBYDOC_URLS.each do |base_url|
28
+ page = objectify_page(base_url)
29
+ a_array = create_a_array(page)
30
+ method_append_pairs = pair_down_a_array(a_array)
31
+ append = find_url_append(method_name, method_append_pairs)
32
+ final_url = create_final_url(base_url, append)
33
+ puts "Opening a tab..." if open_tab(final_url)
34
+ end
35
+ puts "Done!"
36
+ end
37
+
38
+ private
39
+
40
+ def self.objectify_page(url)
41
+ Nokogiri::HTML(open("#{url}")) # => creates a nokogiri object of a url
42
+ end
43
+
44
+ def self.create_a_array(nokogiri_page_object)
45
+ nokogiri_page_object.css('div#method-list-section').css('a') # => creates an array of <a> elements(as nokogiri objects)
46
+ end
47
+
48
+ def self.grab_method_and_link(a_object)
49
+ [a_object.text, a_object[:href]] # => creates 2 element array of <a>'s method(as a string, without # in front) and the url-append
50
+ end
51
+
52
+ def self.pair_down_a_array(a_array)
53
+ text_link_pairs = []
54
+ a_array.each { |a| text_link_pairs << grab_method_and_link(a) } # => reduces an array of <a> objects to sub-arrays of their method and url-append
55
+ text_link_pairs
56
+ end
57
+
58
+ def self.find_url_append(desired_method, method_append_pairs)
59
+ method_append_pairs.each do |pair|
60
+ return pair[1] if (pair[0] == "##{desired_method}")
61
+ end
62
+ false
63
+ end
64
+
65
+ def self.create_final_url(base_url, append)
66
+ append ? base_url + append : false
67
+ end
68
+
69
+ def self.open_tab(url)
70
+ `open #{url};` if url
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docpeeker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Connor Harwood
8
+ - Kevin Lee
9
+ - Simon Zhang
10
+ - Tuan Duong
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2014-05-11 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.6'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: nokogiri
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ description: Accepts a string and searches Ruby-docs for methods matching that string.
59
+ It will open tabs in your browser for each match it finds.
60
+ email:
61
+ - harwood.connor@gmail.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - ".gitignore"
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - docpeeker.gemspec
72
+ - lib/docpeeker.rb
73
+ - lib/docpeeker/version.rb
74
+ homepage: ''
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 1.8.7
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Quickly find a method in Roby-docs!
98
+ test_files: []