check_everything 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/check_everything +5 -0
- data/lib/check_everything/links.txt +54 -0
- data/lib/check_everything.rb +141 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dc321e9d48815361175d0bca12bbc7de57c1d85a
|
4
|
+
data.tar.gz: a03b134b666c3aff6171d3e18ff5e4341961fa92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce60b8c1621402422d9249d10d7f492b3e81317d613dc11ca4ee677b73e8141669e3aa86ede861cf12767d8f9c560721568d494dba9b204f752f6febc965aefc
|
7
|
+
data.tar.gz: 98ab2d3f340dbeeeb960d14eb7750a3b6d9173efed4d88534b48caa6a0830303906a6c12b9b23b1d3d88616d3e7583e8130c1868d5ef7802aa5f36f6eda59b17
|
@@ -0,0 +1,54 @@
|
|
1
|
+
YOUR INSTRUCTIONS
|
2
|
+
|
3
|
+
This file contains your favorite websites! I've included some samples,
|
4
|
+
but you should change this and make it your own.
|
5
|
+
|
6
|
+
Categories start with "&&" whereas websites are prefaced with "--". For
|
7
|
+
your convenience, category names are not case-sensitive and will ignore
|
8
|
+
whitespace, as I have illustrated. Each website must have its own line.
|
9
|
+
|
10
|
+
You can use multiple category names separated by semicolons (;) to assign
|
11
|
+
websites to multiple groups. Anything marked with "default" will open if
|
12
|
+
no tags are specified.
|
13
|
+
|
14
|
+
Put your websites down here:
|
15
|
+
|
16
|
+
=======================================================================
|
17
|
+
|
18
|
+
&& NEWS; DEFAULT; MORNING
|
19
|
+
--www.news.google.com
|
20
|
+
--http://nytimes.com
|
21
|
+
|
22
|
+
&& NEWS
|
23
|
+
(This is interesting, but I only want it to pop up when I ask
|
24
|
+
check_everything to display the news. I don't want to see it
|
25
|
+
in the morning, or by default.)
|
26
|
+
--www.reuters.com/news/oddlyEnough
|
27
|
+
|
28
|
+
&& comics
|
29
|
+
--www.xkcd.com
|
30
|
+
--http://phdcomics.com
|
31
|
+
|
32
|
+
&& Blogs
|
33
|
+
--amcaplan.blogspot.com
|
34
|
+
--www.amcaplan.github.io
|
35
|
+
|
36
|
+
&& PreTtY_PictUrEs
|
37
|
+
--http://inspire.2ia.pl/random
|
38
|
+
--http://www.1designperday.com/
|
39
|
+
|
40
|
+
&& twitter
|
41
|
+
--http://twitter.com/amcaplan
|
42
|
+
--twitter.com/nasa
|
43
|
+
--https://twitter.com/WhatsTrending
|
44
|
+
-- twitter.com
|
45
|
+
|
46
|
+
&& SOCIAL; defauLt
|
47
|
+
--facebook.com
|
48
|
+
--twitter.com
|
49
|
+
|
50
|
+
&&EMAIL;DefauLT;morning
|
51
|
+
--gmail.com
|
52
|
+
|
53
|
+
&& weather; morning
|
54
|
+
--https://www.google.com/search?q=weather
|
@@ -0,0 +1,141 @@
|
|
1
|
+
class CheckEverything
|
2
|
+
KNOWN_TAGS = {
|
3
|
+
:help => ['-h','--help'],
|
4
|
+
:links => ['-l','--links'],
|
5
|
+
:categories => ['-c', '--categories'],
|
6
|
+
:all => ['-a', '--all']
|
7
|
+
}
|
8
|
+
LINKFILE = "#{File.expand_path('~')}/.check_everything_links"
|
9
|
+
|
10
|
+
def self.run
|
11
|
+
# Create a new link file if none has been created yet
|
12
|
+
unless File.exists?(LINKFILE)
|
13
|
+
system("cp #{File.dirname(__FILE__)}/check_everything/links.txt #{LINKFILE}")
|
14
|
+
end
|
15
|
+
# Assume no problems with the link file.
|
16
|
+
@link_space, @link_dash = false, false
|
17
|
+
|
18
|
+
@argv = ARGV.map(&:downcase)
|
19
|
+
extract_links
|
20
|
+
|
21
|
+
# First check for unknown arguments and print out a helpful message.
|
22
|
+
known_tags = KNOWN_TAGS.values.flatten + @links.keys
|
23
|
+
unmatched_args = @argv.select{ |arg| !known_tags.include?(arg)}
|
24
|
+
if !unmatched_args.empty?
|
25
|
+
puts "\nUnknown option#{@argv.size > 1 ? "s" : nil}: " +
|
26
|
+
"#{unmatched_args.join(" ")}"
|
27
|
+
print "usage: check_everything"
|
28
|
+
KNOWN_TAGS.values.flatten.each {|tag| print " [#{tag}]"}
|
29
|
+
puts "\n\nHint: Enter 'check_everything --help' to see the options!"
|
30
|
+
puts "\n"
|
31
|
+
|
32
|
+
# Print out a help message.
|
33
|
+
elsif @argv.any? {|arg| KNOWN_TAGS[:help].include?(arg)}
|
34
|
+
help
|
35
|
+
|
36
|
+
# Edit the tags and links.
|
37
|
+
elsif @argv.any? {|arg| KNOWN_TAGS[:links].include?(arg)}
|
38
|
+
system("open #{LINKFILE}")
|
39
|
+
|
40
|
+
# Check for errors; don't allow the user to see bad categories or open up
|
41
|
+
# websites if the categories are not formatted properly.
|
42
|
+
elsif @link_space
|
43
|
+
puts "Your link file includes a category with a space in it; " +
|
44
|
+
"please fix by entering 'check_everything -l' into your command line."
|
45
|
+
elsif @link_dash
|
46
|
+
puts "Your link file includes a category with a dash, which is " +
|
47
|
+
"not allowed; please fix by entering 'check_everything -l' into your command line."
|
48
|
+
|
49
|
+
# View the categories the user has defined.
|
50
|
+
elsif @argv.any? {|arg| KNOWN_TAGS[:categories].include?(arg)}
|
51
|
+
view_categories
|
52
|
+
|
53
|
+
# Open up the websites!
|
54
|
+
else
|
55
|
+
open
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def self.help
|
61
|
+
puts "\n'check_everything' will open all sites labeled with the 'default' tag."
|
62
|
+
puts
|
63
|
+
puts "Available tags:"
|
64
|
+
puts " -h, --help display the help message"
|
65
|
+
puts " -l, --links, view/edit links and categories"
|
66
|
+
puts " -c, --categories view the currently defined categories"
|
67
|
+
puts " -a, --all open all websites"
|
68
|
+
puts " <tags> open a specific site group"
|
69
|
+
puts
|
70
|
+
puts "Note: The first tag in this list will be the only tag evaluated."
|
71
|
+
puts
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.view_categories
|
75
|
+
puts "You have currently defined the following categories:\n\n"
|
76
|
+
@links.keys.sort.each {|key| puts " #{key}"}
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.open
|
80
|
+
@argv << "default" if @argv.empty?
|
81
|
+
|
82
|
+
# If -a or --all is specified, select all links. Otherwise, select specified
|
83
|
+
# links, or the default links if none are specified.
|
84
|
+
if @argv.any?{|arg| KNOWN_TAGS[:all].include?(arg)}
|
85
|
+
links = @links.values.flatten.uniq
|
86
|
+
else
|
87
|
+
links = @argv.map{|tag| @links[tag]}.flatten.compact.uniq
|
88
|
+
end
|
89
|
+
|
90
|
+
links.each do |url|
|
91
|
+
url = "http://" << url if !url.start_with?("http")
|
92
|
+
system("open #{url}")
|
93
|
+
end
|
94
|
+
|
95
|
+
puts "\nIt's been a pleasure serving up your favorite websites!"
|
96
|
+
puts "Did you know you can use categories to open specific site groups? " +
|
97
|
+
"Enter 'check_everything --links' for details.\n" if ARGV.empty?
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.read_file(file_name)
|
101
|
+
file = File.open(file_name, "r")
|
102
|
+
data = file.read
|
103
|
+
file.close
|
104
|
+
data
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.extract_links
|
108
|
+
link_file = read_file(LINKFILE).split("\n")
|
109
|
+
cur_tags = []
|
110
|
+
|
111
|
+
@links = {}
|
112
|
+
link_file.each do |line|
|
113
|
+
if line.start_with?("&&")
|
114
|
+
# add tags as keys in @links, and assign to cur_tags
|
115
|
+
cur_tags = add_tag(line[2..-1].strip).flatten
|
116
|
+
elsif line.start_with?("--")
|
117
|
+
# add links to each relevant tag in @links
|
118
|
+
cur_tags.each { |tag|
|
119
|
+
@links[tag] << line[2..-1].strip
|
120
|
+
}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Recursive helper method for extract_links
|
126
|
+
def self.add_tag(line)
|
127
|
+
line.downcase!
|
128
|
+
# Add multiple tags, if separated by semicolons.
|
129
|
+
if line.include?(";")
|
130
|
+
line.split(";").map(&:strip).each do |tag|
|
131
|
+
add_tag(tag.strip)
|
132
|
+
end
|
133
|
+
else
|
134
|
+
# Note to raise an error if there is an invalid link.
|
135
|
+
@link_space = true if line.match(/ /)
|
136
|
+
@link_dash = true if line.match(/-/)
|
137
|
+
@links[line] ||= []
|
138
|
+
[line]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: check_everything
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ariel Caplan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Open Frequently Used Websites from the Command Line!
|
14
|
+
email: ariel.caplan@flatironschool.com
|
15
|
+
executables:
|
16
|
+
- check_everything
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/check_everything
|
21
|
+
- lib/check_everything.rb
|
22
|
+
- lib/check_everything/links.txt
|
23
|
+
homepage: http://rubygems.org/gems/check_everything
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.2.1
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Check Everything
|
47
|
+
test_files: []
|