check_everything 0.1.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -9
  3. data/lib/check_everything.rb +73 -12
  4. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b122d8de6966ddd03792e3f87a831eb038f5a854
4
- data.tar.gz: e59a49a8025d318948e6984e2314f12fe6913120
3
+ metadata.gz: 4780781db8fef0b550c8f5030cc4739377a73a4b
4
+ data.tar.gz: 4fc4ea0c7abe0afb8e083bcad632ee8c3dc3392c
5
5
  SHA512:
6
- metadata.gz: 485ab37271e244ed4efb6eee554acedea3ecb22d5178ef0df91c5c8790222593b3bf0af53f9809e102f2709c678a18952b06e32806d04c7a84ed093503de432c
7
- data.tar.gz: 73c5f8693e0ff0c78bcdefad56d265b1905753ea8b8c44c210a06f8d6b7b784e936f1ad0b9bc604058848cf868b41c13d83f24554b5ab748cddb46080033e7df
6
+ metadata.gz: 2015d412a6e590c2c69f6f7b3b1fc8682c5917fc00c825aee9166863866078db14595738e2fcd02f3668ea6727cbcabb169ffff44ddc329ec5f204a462a22e26
7
+ data.tar.gz: 1cc5bc85325ae4f2d906fb0d2d624c1815f0b1e60208eb1fb63320e9b8bad0981df8ddba317c40e5912628434e5f1f6fe20b8c70b91f0d29f6a0be82dcc4a487
data/README.md CHANGED
@@ -1,31 +1,46 @@
1
1
  # check_everything
2
2
 
3
3
  ## Open frequently accessed websites from your command line, in one go!
4
+ ####(Also includes the ability to find documentation for the Ruby core classes)
4
5
 
5
6
  ### Install
6
7
 
7
- Type 'gem install check_everything' into the command line.
8
+ Type `gem install check_everything` into the command line.
8
9
 
9
10
  ### Run
10
11
 
11
- Type 'check_everything' into the command line to pull up the default URLs.
12
+ Type `check_everything` into the command line to pull up the default URLs.
12
13
 
13
14
  You can add the following tags (listed in order of precedence; only the first
14
15
  will be evaluated):
15
16
 
16
17
  | Tag | Result |
17
18
  |-----|-----|
18
- | \-h, \-\-help | display the help message |
19
- | \-l, \-\-links | view/edit links and categories |
20
- | \-c, \-\-categories | view the currently defined categories|
21
- | \-a, \-\-all | open all websites |
22
- | <category> | open a specific site group |
19
+ | \-h, \-\-help | display the help message |
20
+ | \-l, \-\-links | view/edit links and categories |
21
+ | \-r, \-\-ruby | install Ruby Documentation functionality |
22
+ | \-c, \-\-categories | view the currently defined categories |
23
+ | \-a, \-\-all | open all websites |
24
+ | <category> | open a specific site group |
25
+ | <Ruby class> | open Ruby documentation (if feature is installed) |
23
26
 
24
27
 
25
28
  ### Configure
26
29
 
27
- Input your URLs and customize your categories! Input 'check_everything -l' and
28
- check out the instructions in the configuration file.
30
+ On your first run, you will be asked to do 2 things:
31
+
32
+ 1. Choose whether to install Ruby Documentation lookup functionality. This will
33
+ give you command-line access to Ruby Documentation for the Core classes. For
34
+ example, to see documentation for array, type `check_everything array`
35
+
36
+ 2. Input your URLs and customize your categories! Check out the instructions in
37
+ the configuration file.
38
+
39
+ ### Update Your Bash Profile (optional)
40
+
41
+ You can update your Bash profile (~/.bash_profile) with:
42
+ ```alias check="check_everything"```
43
+ to just type `check` instead of `check_everything` and make things even simpler!
29
44
 
30
45
  ### Enjoy!
31
46
 
@@ -1,19 +1,42 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+
1
4
  class CheckEverything
2
5
  KNOWN_TAGS = {
3
6
  :help => ['-h','--help'],
4
7
  :links => ['-l','--links'],
8
+ :ruby => ['-r','--ruby'],
5
9
  :categories => ['-c', '--categories'],
6
10
  :all => ['-a', '--all']
7
11
  }
8
- LINKFILE = "#{File.expand_path('~')}/.check_everything_links"
12
+ LINKPATH = "#{File.expand_path('~')}/.check_everything_links"
13
+ LINKFILE = "#{LINKPATH}/links.txt"
14
+ RUBYFILE = "#{LINKPATH}/ruby.txt"
9
15
 
10
16
  def self.run
11
17
  @argv = ARGV.map(&:downcase)
18
+ until ARGV.empty?
19
+ ARGV.pop
20
+ end
21
+ # Only assemble Ruby development library if requested to.
22
+ @ruby_dev_assemble = false
12
23
  # Create a new link file if none has been created yet
13
- unless File.exists?(LINKFILE)
14
- system("cp #{File.dirname(__FILE__)}/check_everything/links.txt #{LINKFILE}")
24
+ if !File.exists?(LINKFILE)
25
+ # If a previous version created a file rather than a directory, move it into
26
+ # the new directory.
27
+ if File.exists?(LINKPATH)
28
+ system("mv #{LINKPATH} #{LINKPATH}2")
29
+ system("mkdir #{LINKPATH}")
30
+ system("mv #{LINKPATH}2 #{LINKFILE}")
31
+ else
32
+ system("mkdir #{LINKPATH}")
33
+ system("cp #{File.dirname(__FILE__)}/check_everything/links.txt #{LINKFILE}")
34
+ end
15
35
  @argv = ["-l"]
16
- puts "Please customize your installation.",
36
+ print "Are you a Ruby Dev who will want documentation-checking ",
37
+ "functionality? [Y/n] "
38
+ @ruby_dev_assemble = true unless gets.strip.downcase == 'n'
39
+ puts "\nPlease customize your installation.",
17
40
  "This message will only be shown once.",
18
41
  "To open again and customize, just enter 'check_everything -l' to open",
19
42
  "the link file."
@@ -24,8 +47,10 @@ class CheckEverything
24
47
  extract_links
25
48
 
26
49
  # First check for unknown arguments and print out a helpful message.
27
- known_tags = KNOWN_TAGS.values.flatten + @links.keys
28
- unmatched_args = @argv.select{ |arg| !known_tags.include?(arg)}
50
+ known_tags = KNOWN_TAGS.values.flatten + @links.keys + @ruby_links
51
+ unmatched_args = @argv.select do |arg|
52
+ !known_tags.any?{|known_tag| known_tag.downcase == arg.downcase}
53
+ end
29
54
  if !unmatched_args.empty?
30
55
  puts "\nUnknown option#{@argv.size > 1 ? "s" : nil}: " +
31
56
  "#{unmatched_args.join(" ")}"
@@ -40,8 +65,14 @@ class CheckEverything
40
65
 
41
66
  # Edit the tags and links.
42
67
  elsif @argv.any? {|arg| KNOWN_TAGS[:links].include?(arg)}
68
+ # If asked to build the Ruby Dev file, build it!
69
+ assemble_ruby_docs_file if @ruby_dev_assemble
70
+
43
71
  system("open #{LINKFILE}")
44
72
 
73
+ elsif @argv.any? {|arg| KNOWN_TAGS[:ruby].include?(arg)}
74
+ assemble_ruby_docs_file
75
+
45
76
  # Check for errors; don't allow the user to see bad categories or open up
46
77
  # websites if the categories are not formatted properly.
47
78
  elsif @category_space
@@ -57,7 +88,7 @@ class CheckEverything
57
88
 
58
89
  # Open up the websites!
59
90
  else
60
- open
91
+ open_links
61
92
  end
62
93
  end
63
94
 
@@ -67,9 +98,10 @@ class CheckEverything
67
98
  puts
68
99
  puts "Available tags:"
69
100
  puts " -h, --help display the help message"
70
- puts " -l, --links, view/edit links and categories"
101
+ puts " -l, --links view/edit links and categories"
102
+ puts " -r, --ruby install Ruby Documentation functionality"
71
103
  puts " -c, --categories view the currently defined categories"
72
- puts " -a, --all open all websites"
104
+ puts " -a, --all open all websites (will override documentation lookup)"
73
105
  puts " <tags> open a specific site group"
74
106
  puts " (multiple are allowed, separated by spaces)"
75
107
  puts
@@ -82,7 +114,20 @@ class CheckEverything
82
114
  @links.keys.sort.each {|key| puts " #{key}"}
83
115
  end
84
116
 
85
- def self.open
117
+ def self.assemble_ruby_docs_file
118
+ ruby_doc = Nokogiri::HTML(open("http://ruby-doc.org/core/"))
119
+ class_names = []
120
+ ruby_doc.css("p.class a").each{|class_name| class_names << class_name.text}
121
+ class_names.map!{|class_name| class_name.gsub(/::/,"/")}
122
+
123
+ system("touch #{File.dirname(__FILE__)}/ruby_doc")
124
+ File.open("#{File.dirname(__FILE__)}/ruby_doc", 'w') { |f|
125
+ f.print class_names.join("\n")
126
+ }
127
+ system("cp #{File.dirname(__FILE__)}/ruby_doc #{RUBYFILE}")
128
+ end
129
+
130
+ def self.open_links
86
131
  @argv << "default" if @argv.empty?
87
132
 
88
133
  # If -a or --all is specified, select all links. Otherwise, select specified
@@ -90,7 +135,17 @@ class CheckEverything
90
135
  if @argv.any?{|arg| KNOWN_TAGS[:all].include?(arg)}
91
136
  links = @links.values.flatten.uniq
92
137
  else
93
- links = @argv.map{|tag| @links[tag]}.flatten.compact.uniq
138
+ links = @argv.map{|category| @links[category]}.flatten.compact.uniq
139
+ # If a Ruby class name has been specified, open documentation for that class.
140
+ if File.exists?(RUBYFILE)
141
+ classes = read_file(RUBYFILE).split
142
+ class_matches = classes.map { |class_name|
143
+ class_name if @argv.any? {|name| class_name.downcase == name.downcase}
144
+ }.compact
145
+ if class_matches.size > 0
146
+ class_matches.each {|link| links << "ruby-doc.org/core/#{link}.html"}
147
+ end
148
+ end
94
149
  end
95
150
 
96
151
  links.each do |url|
@@ -98,7 +153,7 @@ class CheckEverything
98
153
  system("open #{url}")
99
154
  end
100
155
 
101
- puts "\nIt's been a pleasure serving up your favorite websites!"
156
+ puts "\nIt's been a pleasure serving up your websites!"
102
157
  puts "Did you know you can use categories to open specific site groups? " +
103
158
  "Enter 'check_everything --links' for details.\n" if ARGV.empty?
104
159
  end
@@ -126,6 +181,12 @@ class CheckEverything
126
181
  }
127
182
  end
128
183
  end
184
+
185
+ @ruby_links = []
186
+ if File.exists?(RUBYFILE)
187
+ classes = read_file(RUBYFILE).split
188
+ classes.each {|class_name| @ruby_links << class_name}
189
+ end
129
190
  end
130
191
 
131
192
  # Recursive helper method for extract_links
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_everything
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Caplan
@@ -9,7 +9,27 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-02-12 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.6.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.1
13
33
  description: Open Frequently Used Websites from the Command Line!
14
34
  email: ariel.caplan@flatironschool.com
15
35
  executables: