grabass 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/grabass +16 -14
- data/lib/grabass.rb +22 -5
- metadata +2 -2
data/bin/grabass
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../lib/grabass'
|
4
4
|
|
5
|
-
commands = ['install', 'help']
|
5
|
+
commands = ['install', 'update', 'help']
|
6
6
|
command = ARGV.shift if commands.include? ARGV[0]
|
7
7
|
command ||= commands[0]
|
8
8
|
|
@@ -12,10 +12,17 @@ options[:quiet] = (ARGV.delete '--quiet') || (ARGV.delete '-q')
|
|
12
12
|
options[:help] = (ARGV.delete '--help') || (ARGV.delete '-h')
|
13
13
|
options[:version] = (ARGV.delete '--version') || (ARGV.delete '-v')
|
14
14
|
|
15
|
-
|
16
|
-
manifest = Grabass::AssetManifest.new manifest || 'assets.json'
|
15
|
+
options[:force] = true if command == 'update'
|
17
16
|
|
18
|
-
|
17
|
+
manifest = (ARGV.shift if not ARGV[0].nil? and File.exists? ARGV[0]) || 'assets.json'
|
18
|
+
|
19
|
+
options[:query] = ARGV.map do |arg|
|
20
|
+
Regexp.new(".*#{arg}.*", Regexp::IGNORECASE) || /.*/
|
21
|
+
end
|
22
|
+
|
23
|
+
options[:query] = [/.*/] if options[:query].length == 0
|
24
|
+
|
25
|
+
manifest = Grabass::AssetManifest.new manifest
|
19
26
|
|
20
27
|
unless options[:quiet]
|
21
28
|
started = Time.now
|
@@ -23,16 +30,11 @@ end
|
|
23
30
|
|
24
31
|
case command
|
25
32
|
when 'help'
|
26
|
-
puts '
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
else
|
32
|
-
# Grab the given destinations
|
33
|
-
puts 'TODO: Install specific destinations from the command line'
|
34
|
-
exit
|
35
|
-
end
|
33
|
+
puts 'Try `grabass assets.json`.'
|
34
|
+
|
35
|
+
when 'install', 'update'
|
36
|
+
# Grab entire manifest
|
37
|
+
results = manifest.install options
|
36
38
|
end
|
37
39
|
|
38
40
|
unless options[:quiet] or results.nil?
|
data/lib/grabass.rb
CHANGED
@@ -15,6 +15,8 @@ class Grabass
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class Source
|
18
|
+
attr_accessor :location
|
19
|
+
|
18
20
|
def initialize(location)
|
19
21
|
@location = location
|
20
22
|
|
@@ -87,7 +89,7 @@ class Grabass
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def clone_git_repo(options = {})
|
90
|
-
puts
|
92
|
+
puts "Temporarily cloning #{@location}" unless options[:quiet]
|
91
93
|
`git clone --quiet #{@location} #{temp_dir}`
|
92
94
|
end
|
93
95
|
|
@@ -158,6 +160,8 @@ class Grabass
|
|
158
160
|
end
|
159
161
|
|
160
162
|
class Asset
|
163
|
+
attr_accessor :source
|
164
|
+
|
161
165
|
def initialize(source, selections)
|
162
166
|
@source = Source.new(source)
|
163
167
|
|
@@ -190,6 +194,7 @@ class Grabass
|
|
190
194
|
end
|
191
195
|
|
192
196
|
class Comment
|
197
|
+
attr_accessor :content
|
193
198
|
def initialize(content)
|
194
199
|
@content = content
|
195
200
|
end
|
@@ -230,12 +235,24 @@ class Grabass
|
|
230
235
|
results = {:pass => 0, :fail => 0}
|
231
236
|
|
232
237
|
@assets.each do |asset|
|
238
|
+
match = true
|
233
239
|
if asset.is_a? Comment
|
234
|
-
|
240
|
+
match = options[:query].any? do |query|
|
241
|
+
asset.content =~ query
|
242
|
+
end
|
243
|
+
|
244
|
+
asset.display options if match
|
235
245
|
elsif asset.is_a? Asset
|
236
|
-
|
237
|
-
|
238
|
-
|
246
|
+
match = options[:query].any? do |query|
|
247
|
+
asset.source.location =~ query
|
248
|
+
end
|
249
|
+
|
250
|
+
if match
|
251
|
+
puts asset.source.location
|
252
|
+
asset_results = asset.install options
|
253
|
+
results[:pass] += asset_results[:pass]
|
254
|
+
results[:fail] += asset_results[:fail]
|
255
|
+
end
|
239
256
|
end
|
240
257
|
end
|
241
258
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grabass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Grab static assets and put them somewhere
|
15
15
|
email: brian.carstensen@gmail.com
|