ruby_dictionary 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38ecfaba82284e4a4ce77623fd1e47669c2721a7
4
- data.tar.gz: f238b5e29403e852e937896ead724ee49a195e92
3
+ metadata.gz: 726009a710d2757a8af209455ad32957cd7700a0
4
+ data.tar.gz: 8e716afe4575d9970b6c3032923aa6e60f164593
5
5
  SHA512:
6
- metadata.gz: b8d4edcda9073f65e951913d4ff9410065a830dbd565f04e6018a4151869bee7e6b03dec6a7e2addb2a6dbd7b395858db3e129559fd848e4d31dc868b0ee0316
7
- data.tar.gz: 158cf03a06539b2f39019ef304d5a557aff2831e01bf882e854e5c3c4ec2faec213973358b1e0f92cb489558cac736ed59d996c38ad59fdace7fbb72af18f65f
6
+ metadata.gz: cfbdf983ed6a19f97ff24b161b0c09bdb092650c3469e1f61f3dba3d9e78f1838a3a8c5f47b72f7968bff0b530e21c900972478b1f2d807d747318c2b5824f35
7
+ data.tar.gz: 7876ef9864c171c1635a9fc52a3cad8dca21273ca166026d48045029234dcc43e7bb0041e9745a080e04c9d8b5931cb461c7cde289bf6c760677d501cc871468
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_dictionary (0.1.0)
4
+ ruby_dictionary (1.0.0)
5
5
  nokogiri
6
6
 
7
7
  GEM
@@ -36,7 +36,7 @@ PLATFORMS
36
36
 
37
37
  DEPENDENCIES
38
38
  bundler (~> 1.16)
39
- pry
39
+ pry (~> 0)
40
40
  rake (~> 10.0)
41
41
  rspec (~> 3.0)
42
42
  ruby_dictionary!
@@ -5,4 +5,4 @@ require "bundler/setup"
5
5
  require "ruby_dictionary"
6
6
 
7
7
 
8
- CLI.new.call
8
+ RubyDictionary::CLI.new.call
@@ -1,9 +1,9 @@
1
1
  # CLI Controller
2
2
  require 'pry'
3
- class CLI
3
+ class RubyDictionary::CLI
4
4
 
5
5
  def call
6
- Scraper.scrape_index
6
+ RubyDictionary::Scraper.scrape_index
7
7
  puts "Welcome to the Ruby Dictionary!"
8
8
  scrape_slow_classes
9
9
  list_klasses
@@ -12,14 +12,14 @@ class CLI
12
12
  end
13
13
 
14
14
  def scrape_slow_classes
15
- @array = Klass.list[0]
16
- Scraper.scrape_klass(@array)
17
- @enum = Klass.list[2]
18
- Scraper.scrape_klass(@enum)
15
+ @array = RubyDictionary::Klass.list[0]
16
+ RubyDictionary::Scraper.scrape_klass(@array)
17
+ @enum = RubyDictionary::Klass.list[2]
18
+ RubyDictionary::Scraper.scrape_klass(@enum)
19
19
  end
20
20
 
21
21
  def list_klasses
22
- Klass.all.each.with_index{|k,i| puts "#{i + 1}. #{k.name}"}
22
+ RubyDictionary::Klass.all.each.with_index{|k,i| puts "#{i + 1}. #{k.name}"}
23
23
  puts "\nEnter the Class or Mixin you would like to explore, or type 'exit' to quit"
24
24
  end
25
25
 
@@ -34,6 +34,8 @@ class CLI
34
34
  when input == "i" || input == "instance"
35
35
  klass.list_inst_methods
36
36
  puts "\n"
37
+ when input == "more" || input == "next"
38
+ klass.list_inst_methods
37
39
  when input == "c" || input == "class"
38
40
  klass.list_klass_methods
39
41
  puts "\n"
@@ -57,6 +59,7 @@ class CLI
57
59
  puts "\n#{method.description}"
58
60
  if method.examples != ""
59
61
  puts "\nExamples:\n#{method.examples}\n"
62
+ puts "\nEnter 'i' to see a list of public instance methods\nEnter 'c' to see a list of public class methods\nEnter 'all' to see all public methods available\nEnter the name of a method to learn more\nEnter 'menu' or 'back' to go back to the list of Classes and Mixins\nOr enter 'exit' to quit"
60
63
  end
61
64
  end
62
65
  end
@@ -74,34 +77,34 @@ class CLI
74
77
  when /array(s)?\b|1/
75
78
  klass_menu(@array)
76
79
  when /dir(s)?\b|2/
77
- @dir = Klass.list[1]
78
- Scraper.scrape_klass(@dir)
80
+ @dir = RubyDictionary::Klass.list[1]
81
+ RubyDictionary::Scraper.scrape_klass(@dir)
79
82
  klass_menu(@dir)
80
83
  when /enumerable(s)?\b|3/
81
84
  klass_menu(@enum)
82
85
  when /hash(es)?\b|4/
83
- @hash = Klass.list[3]
84
- Scraper.scrape_klass(@hash)
86
+ @hash = RubyDictionary::Klass.list[3]
87
+ RubyDictionary::Scraper.scrape_klass(@hash)
85
88
  klass_menu(@hash)
86
89
  when /numeric(s)?\b|5/
87
- @num = Klass.list[4]
88
- Scraper.scrape_klass(@num)
90
+ @num = RubyDictionary::Klass.list[4]
91
+ RubyDictionary::Scraper.scrape_klass(@num)
89
92
  klass_menu(@num)
90
93
  when /proc(s)?\b|6/
91
- @prok = Klass.list[5]
92
- Scraper.scrape_klass(@prok)
94
+ @prok = RubyDictionary::Klass.list[5]
95
+ RubyDictionary::Scraper.scrape_klass(@prok)
93
96
  klass_menu(@prok)
94
97
  when /range(s)?\b|7/
95
- @range = Klass.list[6]
96
- Scraper.scrape_klass(@range)
98
+ @range = RubyDictionary::Klass.list[6]
99
+ RubyDictionary::Scraper.scrape_klass(@range)
97
100
  klass_menu(@range)
98
101
  when /string(s)?\b|8/
99
- @string = Klass.list[7]
100
- Scraper.scrape_klass(@string)
102
+ @string = RubyDictionary::Klass.list[7]
103
+ RubyDictionary::Scraper.scrape_klass(@string)
101
104
  klass_menu(@string)
102
105
  when /symbol(s)?\b|9/
103
- @symbol = Klass.list[8]
104
- Scraper.scrape_klass(@symbol)
106
+ @symbol = RubyDictionary::Klass.list[8]
107
+ RubyDictionary::Scraper.scrape_klass(@symbol)
105
108
  klass_menu(@symbol)
106
109
  else
107
110
  if input != "exit"
@@ -1,4 +1,4 @@
1
- class Klass
1
+ class RubyDictionary::Klass
2
2
  include Findable::InstanceMethods
3
3
  attr_accessor :name, :definition, :url, :method
4
4
  @@all = []
@@ -43,11 +43,11 @@ class Klass
43
43
  end
44
44
 
45
45
  def list_inst_methods
46
- @all_methods.each{|m| puts m.name if m.method_type == "Instance"}
46
+ @inst_methods.each{|m| puts m.name}
47
47
  end
48
48
 
49
49
  def list_klass_methods
50
- @all_methods.each{|m| puts m.name if m.method_type == "Class"}
50
+ @klass_methods.each{|m| puts m.name}
51
51
  end
52
52
 
53
53
  def list_all_methods
@@ -1,4 +1,4 @@
1
- class RubyMethod
1
+ class RubyDictionary::Method
2
2
  include Findable::InstanceMethods
3
3
  attr_accessor :name, :callseq, :description, :examples, :method_type, :klass
4
4
  @@all = []
@@ -2,19 +2,19 @@ require 'nokogiri'
2
2
  require 'uri'
3
3
  require 'pry'
4
4
 
5
- class Scraper
5
+ class RubyDictionary::Scraper
6
6
 
7
7
  def self.scrape_index
8
8
  doc = Nokogiri::HTML(open("http://ruby-doc.org/core-2.4.2/"))
9
9
  klass_list = doc.css("#class-index .entries p")
10
10
  klass_list.each do |k|
11
11
  if k.css("a").text.match(/(Array\b|Dir\b|Enumerable|Hash|Numeric|Proc\b|Range\b|String|Symbol)/) != nil
12
- klass = Klass.new
12
+ klass = RubyDictionary::Klass.new
13
13
  klass.name = k.css("a").text.gsub(/"/,"")
14
14
  href = k.css("a")[0]["href"]
15
15
  page_url = "http://ruby-doc.org/core-2.4.2/"
16
16
  klass.url = URI.join(page_url,href)
17
- Klass.all << klass
17
+ RubyDictionary::Klass.all << klass
18
18
  end
19
19
  end
20
20
  end
@@ -32,7 +32,7 @@ class Scraper
32
32
  method_list = doc.css("#method-list-section ul.link-list li")
33
33
 
34
34
  method_list.each do |mn|
35
- method = RubyMethod.new
35
+ method = RubyDictionary::Method.new
36
36
  if mn.css("a").text.start_with?(":")
37
37
  method.method_type = "Class"
38
38
  klass.add_klass_method(method)
@@ -1,3 +1,3 @@
1
1
  module RubyDictionary
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
Binary file
@@ -26,8 +26,9 @@ Gem::Specification.new do |spec|
26
26
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
27
  f.match(%r{^(test|spec|features)/})
28
28
  end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ #spec.bindir = "exe"
30
+ #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.executables << "ruby-dictionary"
31
32
  spec.require_paths = ["lib"]
32
33
 
33
34
  spec.add_development_dependency "bundler", "~> 1.16"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_dictionary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Boujoukos
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-15 00:00:00.000000000 Z
11
+ date: 2017-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,7 +84,8 @@ description: This gem allows the user to look up useful information on public me
84
84
  right from the command line.
85
85
  email:
86
86
  - cboujoukos@gmail.com
87
- executables: []
87
+ executables:
88
+ - ruby-dictionary
88
89
  extensions: []
89
90
  extra_rdoc_files: []
90
91
  files:
@@ -108,6 +109,7 @@ files:
108
109
  - lib/ruby_dictionary/method.rb
109
110
  - lib/ruby_dictionary/scraper.rb
110
111
  - lib/ruby_dictionary/version.rb
112
+ - ruby_dictionary-0.1.0.gem
111
113
  - ruby_dictionary.gemspec
112
114
  - spec.md
113
115
  - tring_methods