check_everything 0.2.9 → 0.3.1

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 +7 -7
  2. data/README.md +9 -0
  3. data/lib/check_everything.rb +59 -13
  4. metadata +34 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- data.tar.gz: d1257de9a87a8f8aaa7d30d7bd7f1c46983ebb7b
4
- metadata.gz: 4e81e774e5f48b9372544d309a3f1aad9319b8db
5
- SHA512:
6
- data.tar.gz: 4c10dc3ffb70357d32e31ed27236cbdb5d51c247b4a583d306c1f56eafede40dad7ab3dc63238ccc43ead73177932c7fa23912edbad6bdcfc962cf59a19c1ee1
7
- metadata.gz: 1dfc325bb4eddda3b81273089640d8a6a2860cefcefe0684bab317818e566285b18a23c7724cdae8c776dc4e90bb6e73658186e054db9245aaaf3562dd2b66ab
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8bfae1799343f128c618b226f00b9f4009112e19
4
+ data.tar.gz: 27a40cd1d9fd13f11f5a428c00c6bfda5ac9e239
5
+ SHA512:
6
+ metadata.gz: bae0d73b76dc55968a2efdc877a960ea37205f7f50eae48043bd431db2863a329e5a653b0883c45b2d08405c37e2d5dc900c408db15ac7342ec2d07c0f393c79
7
+ data.tar.gz: b2f311014e19ecfc8fa12e5c5b783937b30f825cef7a12dcdea328d3ff80ecdfb1336b52fd50e40bd08a5fd62569d8fa915229ade25af263b61a00f74cf69be4
data/README.md CHANGED
@@ -10,6 +10,8 @@ Type `gem install check_everything` into the command line.
10
10
  ### Run
11
11
 
12
12
  Type `check_everything` into the command line to pull up the default URLs.
13
+ Type `check_everything` followed by one or more categories to open specific
14
+ groups of sites.
13
15
 
14
16
  You can add the following tags (listed in order of precedence; only the first
15
17
  will be evaluated):
@@ -24,6 +26,13 @@ will be evaluated):
24
26
  | <category> | open a specific site group |
25
27
  | <Ruby class> | open Ruby documentation (if feature is installed) |
26
28
 
29
+ NOTE: in versions 0.3.0 and higher, you can check Ruby documentation in one of
30
+ two ways:
31
+ ----
32
+ 1. `check_everything array` (for the [class](http://www.ruby-doc.org/core-2.1.0/Array.html))
33
+ 2. `check_everything array#slice` (for the
34
+ [method](http://www.ruby-doc.org/core-2.1.0/Array.html#method-i-slice))
35
+ ----
27
36
 
28
37
  ### Configure
29
38
 
@@ -12,6 +12,24 @@ class CheckEverything
12
12
  LINKPATH = "#{File.expand_path('~')}/.check_everything_links"
13
13
  LINKFILE = "#{LINKPATH}/links.txt"
14
14
  RUBYFILE = "#{LINKPATH}/ruby.txt"
15
+ SUB_CHARS = {
16
+ '?' => '-3F-',
17
+ '!' => '-21-',
18
+ '|' => '-7C-',
19
+ ']' => '-5D-',
20
+ '[' => '-5B-',
21
+ '=' => '-3D-',
22
+ '+' => '-2B-',
23
+ '-' => '-2D-',
24
+ '*' => '-2A-',
25
+ '/' => '-2F-',
26
+ '%' => '-25-',
27
+ '~' => '-7E-',
28
+ '<' => '-3C-',
29
+ '>' => '-3E-',
30
+ '&' => '-26-',
31
+ '@' => '-40-'
32
+ }
15
33
 
16
34
  def self.run
17
35
  @argv = ARGV.map(&:downcase)
@@ -49,7 +67,9 @@ class CheckEverything
49
67
  # First check for unknown arguments and print out a helpful message.
50
68
  known_tags = KNOWN_TAGS.values.flatten + @links.keys + @ruby_links
51
69
  unmatched_args = @argv.select do |arg|
52
- !known_tags.any?{|known_tag| known_tag.downcase == arg.downcase}
70
+ !known_tags.any? do |known_tag|
71
+ known_tag.downcase == arg.split("#")[0]
72
+ end
53
73
  end
54
74
  if !unmatched_args.empty?
55
75
  puts "\nUnknown option#{@argv.size > 1 ? "s" : nil}: " +
@@ -136,27 +156,53 @@ class CheckEverything
136
156
  if @argv.any?{|arg| KNOWN_TAGS[:all].include?(arg)}
137
157
  links = @links.values.flatten.uniq
138
158
  else
159
+ # Get links for all recognized categories
139
160
  links = @argv.map{|category| @links[category]}.flatten.compact.uniq
140
161
  # If a Ruby class name has been specified, open documentation for that class.
162
+ links.concat(add_documentation_to_links)
163
+ end
164
+
165
+ urls = links.map { |url|
166
+ url.start_with?("http") ? url : url = "http://" << url
167
+ }.join(" ")
168
+ system("open #{urls}")
169
+
170
+ puts "\nIt's been a pleasure serving up your websites!"
171
+ puts "Did you know you can use categories to open specific site groups? " +
172
+ "Enter 'check_everything --links' for details.\n" if ARGV.empty?
173
+ end
174
+
175
+ def self.add_documentation_to_links
176
+ [].tap do |links|
141
177
  if File.exists?(RUBYFILE)
142
178
  classes = read_file(RUBYFILE).split
179
+
180
+ # Allow arguments of the form "array" or "array#collect"
181
+ class_argv = @argv.map {|arg| arg.split('#')}
143
182
  class_matches = classes.map { |class_name|
144
- class_name if @argv.any? {|name| class_name.downcase == name.downcase}
145
- }.compact
183
+ class_argv.map { |name|
184
+ # If a match is found, return an array with either 1 element (class)
185
+ # or 2 elements (class and method)
186
+ if class_name.downcase == name[0]
187
+ [class_name, name[1]].compact
188
+ end
189
+ }.compact
190
+ }.reject(&:empty?).flatten(1)
191
+
192
+ # If matches were found, serve them up!
146
193
  if class_matches.size > 0
147
- class_matches.each {|link| links << "ruby-doc.org/core-#{RUBY_VERSION}/#{link}.html"}
194
+ class_matches.each do |klass|
195
+ # Add a method name to the link only if one is specified.
196
+ method = klass[1] ? "#method-i-#{klass[1]}" : ""
197
+ method = method.gsub(/[#{SUB_CHARS.keys}\[\]]/,SUB_CHARS)
198
+ method = method.gsub('--','-')
199
+ method = method[0..-2] if method[-1] == '-'
200
+ method = method[1..-1] if method[0] == '-'
201
+ links << "ruby-doc.org/core-#{RUBY_VERSION}/#{klass[0]}.html#{method}"
202
+ end
148
203
  end
149
204
  end
150
205
  end
151
-
152
- links.each do |url|
153
- url = "http://" << url if !url.start_with?("http")
154
- system("open #{url}")
155
- end
156
-
157
- puts "\nIt's been a pleasure serving up your websites!"
158
- puts "Did you know you can use categories to open specific site groups? " +
159
- "Enter 'check_everything --links' for details.\n" if ARGV.empty?
160
206
  end
161
207
 
162
208
  def self.read_file(file_name)
metadata CHANGED
@@ -1,64 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: check_everything
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Ariel Caplan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2014-02-12 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
19
17
  - - ~>
20
- - !ruby/object:Gem::Version
18
+ - !ruby/object:Gem::Version
21
19
  version: 1.5.0
22
20
  type: :runtime
23
- version_requirements: *id001
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.5.0
24
27
  description: Open Frequently Used Websites from the Command Line!
25
28
  email: ariel.caplan@flatironschool.com
26
- executables:
29
+ executables:
27
30
  - check_everything
28
31
  extensions: []
29
-
30
- extra_rdoc_files:
32
+ extra_rdoc_files:
31
33
  - README.md
32
- files:
33
- - lib/check_everything.rb
34
- - lib/check_everything/links.txt
34
+ files:
35
35
  - README.md
36
36
  - bin/check_everything
37
+ - lib/check_everything.rb
38
+ - lib/check_everything/links.txt
37
39
  homepage: http://rubygems.org/gems/check_everything
38
- licenses:
40
+ licenses:
39
41
  - MIT
40
42
  metadata: {}
41
-
42
43
  post_install_message:
43
44
  rdoc_options: []
44
-
45
- require_paths:
45
+ require_paths:
46
46
  - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
48
- requirements:
49
- - &id002
50
- - ">="
51
- - !ruby/object:Gem::Version
52
- version: "0"
53
- required_rubygems_version: !ruby/object:Gem::Requirement
54
- requirements:
55
- - *id002
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
56
57
  requirements: []
57
-
58
58
  rubyforge_project:
59
- rubygems_version: 2.0.14
59
+ rubygems_version: 2.2.1
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Check Everything
63
63
  test_files: []
64
-