cheat 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -3
- data/lib/cheat.rb +20 -7
- data/lib/cheat/version.rb +30 -1
- metadata +13 -9
data/README
CHANGED
data/lib/cheat.rb
CHANGED
@@ -23,14 +23,16 @@ module Cheat
|
|
23
23
|
|
24
24
|
uri = "http://#{cheat_uri}/y/"
|
25
25
|
|
26
|
-
if
|
27
|
-
|
28
|
-
|
26
|
+
if @offline
|
27
|
+
return process(File.read(cache_file)) if File.exists?(cache_file) rescue clear_cache if cache_file
|
28
|
+
else
|
29
|
+
if %w[sheets all recent].include? @sheet
|
30
|
+
uri = uri.sub('/y/', @sheet == 'recent' ? '/yr/' : '/ya/')
|
31
|
+
return open(uri, headers) { |body| process(body.read) }
|
32
|
+
end
|
33
|
+
return process(File.read(cache_file)) if File.exists?(cache_file) rescue clear_cache if cache_file
|
34
|
+
fetch_sheet(uri + @sheet) if @sheet
|
29
35
|
end
|
30
|
-
|
31
|
-
return process(File.read(cache_file)) if File.exists?(cache_file) rescue clear_cache if cache_file
|
32
|
-
|
33
|
-
fetch_sheet(uri + @sheet) if @sheet
|
34
36
|
end
|
35
37
|
|
36
38
|
def fetch_sheet(uri, try_to_cache = true)
|
@@ -59,10 +61,14 @@ module Cheat
|
|
59
61
|
|
60
62
|
show_versions(args.first) if args.delete('--versions')
|
61
63
|
|
64
|
+
list if args.delete('--list')
|
65
|
+
|
62
66
|
add(args.shift) and return if args.delete('--add')
|
63
67
|
incoming_file = true if @edit = args.delete('--edit')
|
64
68
|
|
65
69
|
@execute = true if args.delete("--execute") || args.delete("-x")
|
70
|
+
# use offline (use cached versions only) if no active connection to internet
|
71
|
+
@offline = true if args.delete("--local") || args.delete("-l")
|
66
72
|
@sheet = args.shift
|
67
73
|
|
68
74
|
clear_cache_file if incoming_file
|
@@ -129,6 +135,13 @@ module Cheat
|
|
129
135
|
end
|
130
136
|
end
|
131
137
|
|
138
|
+
def list
|
139
|
+
if cache_dir
|
140
|
+
d = Dir.glob "#{cache_dir}/#{@sheet}*.yml"
|
141
|
+
d.each {|f| puts File.basename(f, ".yml")}
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
132
145
|
def show(sheet_yaml)
|
133
146
|
sheet = YAML.load(sheet_yaml).to_a.first
|
134
147
|
sheet[-1] = sheet.last.join("\n") if sheet[-1].is_a?(Array)
|
data/lib/cheat/version.rb
CHANGED
@@ -1,3 +1,32 @@
|
|
1
1
|
module Cheat
|
2
|
-
|
2
|
+
class Version
|
3
|
+
class << self
|
4
|
+
|
5
|
+
# @return [Integer]
|
6
|
+
def major
|
7
|
+
1
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [Integer]
|
11
|
+
def minor
|
12
|
+
3
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Integer]
|
16
|
+
def patch
|
17
|
+
3
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String, NilClass]
|
21
|
+
def pre
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def to_s
|
27
|
+
[major, minor, patch, pre].compact.join('.')
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
3
32
|
end
|
metadata
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
name: cheat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.3.
|
5
|
+
version: 1.3.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chris Wanstrath
|
9
|
+
- Erik Michaels-Ober
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-16 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +28,11 @@ dependencies:
|
|
27
28
|
- !ruby/object:Gem::Version
|
28
29
|
version: '1.0'
|
29
30
|
none: false
|
30
|
-
description:
|
31
|
-
|
32
|
-
email:
|
31
|
+
description: cheat prints cheat sheets from cheat.errtheblog.com, a wiki-like repository
|
32
|
+
of programming knowledge.
|
33
|
+
email:
|
34
|
+
- chris@ozmm.org
|
35
|
+
- sferik@gmail.com
|
33
36
|
executables:
|
34
37
|
- cheat
|
35
38
|
extensions: []
|
@@ -37,6 +40,7 @@ extra_rdoc_files: []
|
|
37
40
|
files:
|
38
41
|
- README
|
39
42
|
- LICENSE
|
43
|
+
- bin/cheat
|
40
44
|
- lib/ambition/init.rb
|
41
45
|
- lib/ambition/lib/ambition/count.rb
|
42
46
|
- lib/ambition/lib/ambition/enumerable.rb
|
@@ -66,9 +70,9 @@ files:
|
|
66
70
|
- lib/cheat/version.rb
|
67
71
|
- lib/cheat/wrap.rb
|
68
72
|
- lib/cheat.rb
|
69
|
-
- bin/cheat
|
70
73
|
homepage: http://cheat.errtheblog.com
|
71
|
-
licenses:
|
74
|
+
licenses:
|
75
|
+
- MIT
|
72
76
|
post_install_message:
|
73
77
|
rdoc_options: []
|
74
78
|
require_paths:
|
@@ -83,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
87
|
requirements:
|
84
88
|
- - ! '>='
|
85
89
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
90
|
+
version: 1.3.6
|
87
91
|
none: false
|
88
92
|
requirements: []
|
89
93
|
rubyforge_project:
|
@@ -92,4 +96,4 @@ signing_key:
|
|
92
96
|
specification_version: 3
|
93
97
|
summary: cheat prints cheat sheets from cheat.errtheblog.com
|
94
98
|
test_files: []
|
95
|
-
has_rdoc:
|
99
|
+
has_rdoc:
|