assetify 1.0.0.rc1 → 1.0.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/{Jsfile → Assetfile} +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -0
- data/README.md +3 -3
- data/Rakefile +24 -4
- data/VERSION +1 -1
- data/assetify.gemspec +36 -7
- data/bin/assetify +1 -1
- data/lib/assetify.rb +10 -129
- data/lib/assetify/asset.rb +31 -15
- data/lib/assetify/assetfile.rb +59 -0
- data/lib/assetify/cli.rb +75 -0
- data/lib/assetify/{tui → cli}/colored.rb +0 -0
- data/lib/assetify/{tui → cli}/term.rb +1 -1
- data/lib/assetify/constants.rb +17 -0
- data/lib/assetify/dsl.rb +11 -14
- data/lib/assetify/gui.rb +11 -0
- data/lib/assetify/gui/views/home.html.erb +1 -1
- data/lib/assetify/helpers.rb +11 -5
- data/lib/assetify/version.rb +3 -0
- data/spec/assetify/dsl_spec.rb +5 -3
- data/spec/assetify/helpers_spec.rb +1 -1
- data/spec/assetify_spec.rb +12 -12
- data/spec/spec_helper.rb +2 -2
- metadata +48 -15
data/{Jsfile → Assetfile}
RENAMED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,6 +9,8 @@ GEM
|
|
9
9
|
bundler (~> 1.0)
|
10
10
|
git (>= 1.2.5)
|
11
11
|
rake
|
12
|
+
libarchive (0.1.2)
|
13
|
+
rack (1.3.3)
|
12
14
|
rake (0.9.2)
|
13
15
|
rspec (2.6.0)
|
14
16
|
rspec-core (~> 2.6.0)
|
@@ -18,6 +20,10 @@ GEM
|
|
18
20
|
rspec-expectations (2.6.0)
|
19
21
|
diff-lcs (~> 1.1.2)
|
20
22
|
rspec-mocks (2.6.0)
|
23
|
+
sinatra (1.2.6)
|
24
|
+
rack (~> 1.1)
|
25
|
+
tilt (>= 1.2.2, < 2.0)
|
26
|
+
tilt (1.3.3)
|
21
27
|
webmock (1.7.6)
|
22
28
|
addressable (~> 2.2, > 2.2.5)
|
23
29
|
crack (>= 0.1.7)
|
@@ -28,5 +34,7 @@ PLATFORMS
|
|
28
34
|
DEPENDENCIES
|
29
35
|
bundler (>= 1.0.0)
|
30
36
|
jeweler
|
37
|
+
libarchive
|
31
38
|
rspec (>= 2.3.0)
|
39
|
+
sinatra
|
32
40
|
webmock
|
data/README.md
CHANGED
@@ -18,11 +18,11 @@ On any project`s root:
|
|
18
18
|
assetify
|
19
19
|
|
20
20
|
|
21
|
-
This will create a `
|
21
|
+
This will create a `Assetfile` if not found.
|
22
22
|
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
Assetfile
|
25
|
+
=========
|
26
26
|
|
27
27
|
Like a `Gemfile`, but you choose the filetype (or extension) before:
|
28
28
|
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'bundler'
|
5
|
+
require './lib/assetify/version'
|
5
6
|
begin
|
6
7
|
Bundler.setup(:default, :development)
|
7
8
|
rescue Bundler::BundlerError => e
|
@@ -18,9 +19,28 @@ Jeweler::Tasks.new do |gem|
|
|
18
19
|
gem.homepage = "http://github.com/nofxx/assetify"
|
19
20
|
gem.license = "MIT"
|
20
21
|
gem.summary = %Q{Downloads/updates assets. Any framework.}
|
21
|
-
gem.description = %Q{Downloads/updates assets based on
|
22
|
+
gem.description = %Q{Downloads/updates assets based on an Assetfile. Any framework.}
|
22
23
|
gem.email = "x@nofxx.com"
|
23
|
-
gem.authors = ["Marcos Piccinini"]
|
24
|
+
gem.authors = ["Marcos Piccinini", "Rafael Barbosa"]
|
25
|
+
gem.post_install_message = <<-POST_INSTALL_MESSAGE
|
26
|
+
|
27
|
+
A #{'-' * 60} A
|
28
|
+
|
29
|
+
* A S S E T I F Y *
|
30
|
+
|
31
|
+
Thank you for installing assetify-#{Assetify::VERSION}.
|
32
|
+
|
33
|
+
Here is a few optional gems:
|
34
|
+
|
35
|
+
* libarchive - For untar/unzip packages
|
36
|
+
* minimagick - For image transformations
|
37
|
+
* sass - For css2sass support
|
38
|
+
|
39
|
+
|
40
|
+
We hope `assetify` saves you some time!
|
41
|
+
|
42
|
+
A #{'-' * 60} A
|
43
|
+
POST_INSTALL_MESSAGE
|
24
44
|
# dependencies defined in Gemfile
|
25
45
|
end
|
26
46
|
Jeweler::RubygemsDotOrgTasks.new
|
@@ -38,8 +58,8 @@ end
|
|
38
58
|
|
39
59
|
task :default => :spec
|
40
60
|
|
41
|
-
require '
|
42
|
-
|
61
|
+
require 'rdoc/task'
|
62
|
+
RDoc::Task.new do |rdoc|
|
43
63
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
64
|
|
45
65
|
rdoc.rdoc_dir = 'rdoc'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0
|
1
|
+
1.0.0
|
data/assetify.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{assetify}
|
8
|
-
s.version = "1.0.0
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
11
|
-
s.authors = ["Marcos Piccinini"]
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Marcos Piccinini", "Rafael Barbosa"]
|
12
12
|
s.date = %q{2011-09-30}
|
13
13
|
s.default_executable = %q{assetify}
|
14
|
-
s.description = %q{Downloads/updates assets based on
|
14
|
+
s.description = %q{Downloads/updates assets based on an Assetfile. Any framework.}
|
15
15
|
s.email = %q{x@nofxx.com}
|
16
16
|
s.executables = ["assetify"]
|
17
17
|
s.extra_rdoc_files = [
|
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
22
|
".rspec",
|
23
|
+
"Assetfile",
|
23
24
|
"Gemfile",
|
24
25
|
"Gemfile.lock",
|
25
|
-
"Jsfile",
|
26
26
|
"README.md",
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
@@ -32,13 +32,18 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/assetify/asset.rb",
|
33
33
|
"lib/assetify/asset/pathfix.rb",
|
34
34
|
"lib/assetify/asset/pkg.rb",
|
35
|
+
"lib/assetify/assetfile.rb",
|
36
|
+
"lib/assetify/cli.rb",
|
37
|
+
"lib/assetify/cli/colored.rb",
|
38
|
+
"lib/assetify/cli/term.rb",
|
39
|
+
"lib/assetify/constants.rb",
|
35
40
|
"lib/assetify/dsl.rb",
|
36
41
|
"lib/assetify/extensions/string.rb",
|
42
|
+
"lib/assetify/gui.rb",
|
37
43
|
"lib/assetify/gui/server.rb",
|
38
44
|
"lib/assetify/gui/views/home.html.erb",
|
39
45
|
"lib/assetify/helpers.rb",
|
40
|
-
"lib/assetify/
|
41
|
-
"lib/assetify/tui/term.rb",
|
46
|
+
"lib/assetify/version.rb",
|
42
47
|
"spec/assetify/asset_spec.rb",
|
43
48
|
"spec/assetify/dsl_spec.rb",
|
44
49
|
"spec/assetify/helpers_spec.rb",
|
@@ -52,6 +57,24 @@ Gem::Specification.new do |s|
|
|
52
57
|
]
|
53
58
|
s.homepage = %q{http://github.com/nofxx/assetify}
|
54
59
|
s.licenses = ["MIT"]
|
60
|
+
s.post_install_message = %q{
|
61
|
+
A ------------------------------------------------------------ A
|
62
|
+
|
63
|
+
* A S S E T I F Y *
|
64
|
+
|
65
|
+
Thank you for installing assetify-1.0.0.
|
66
|
+
|
67
|
+
Here is a few optional gems:
|
68
|
+
|
69
|
+
* libarchive - For untar/unzip packages
|
70
|
+
* minimagick - For image transformations
|
71
|
+
* sass - For css2sass support
|
72
|
+
|
73
|
+
|
74
|
+
We hope `assetify` saves you some time!
|
75
|
+
|
76
|
+
A ------------------------------------------------------------ A
|
77
|
+
}
|
55
78
|
s.require_paths = ["lib"]
|
56
79
|
s.rubygems_version = %q{1.3.7}
|
57
80
|
s.summary = %q{Downloads/updates assets. Any framework.}
|
@@ -65,17 +88,23 @@ Gem::Specification.new do |s|
|
|
65
88
|
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
66
89
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
67
90
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
91
|
+
s.add_development_dependency(%q<sinatra>, [">= 0"])
|
92
|
+
s.add_development_dependency(%q<libarchive>, [">= 0"])
|
68
93
|
else
|
69
94
|
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
70
95
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
71
96
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
72
97
|
s.add_dependency(%q<webmock>, [">= 0"])
|
98
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
99
|
+
s.add_dependency(%q<libarchive>, [">= 0"])
|
73
100
|
end
|
74
101
|
else
|
75
102
|
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
76
103
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
77
104
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
78
105
|
s.add_dependency(%q<webmock>, [">= 0"])
|
106
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
107
|
+
s.add_dependency(%q<libarchive>, [">= 0"])
|
79
108
|
end
|
80
109
|
end
|
81
110
|
|
data/bin/assetify
CHANGED
data/lib/assetify.rb
CHANGED
@@ -1,139 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Opt = {
|
5
|
-
:vendor => "public/vendor",
|
6
|
-
:newname => true
|
7
|
-
}
|
8
|
-
|
9
|
-
TSIZE = 80
|
10
|
-
LINE = TUI.new
|
11
|
-
ASSETS_PATH = "vendor/assets"
|
12
|
-
ASSETS = [:javascripts, :stylesheets, :images]
|
13
|
-
ASSETS.each do |asset|
|
14
|
-
Opt.merge!(asset => "#{ASSETS_PATH}/#{asset}")
|
15
|
-
end
|
16
|
-
|
17
|
-
class NoJSFile < StandardError
|
18
|
-
end
|
19
|
-
end
|
1
|
+
# Options/Constants
|
2
|
+
require "assetify/constants"
|
20
3
|
|
21
4
|
# Ruby Extensions
|
22
5
|
require "assetify/extensions/string"
|
23
6
|
|
24
|
-
# Text Interface
|
25
|
-
require "assetify/tui/term"
|
26
|
-
require "assetify/tui/colored"
|
27
|
-
|
28
7
|
# Core
|
29
8
|
require "assetify/helpers"
|
9
|
+
require "assetify/assetfile"
|
30
10
|
require "assetify/asset"
|
31
11
|
require "assetify/dsl"
|
32
12
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# Jsfile stuff
|
38
|
-
#
|
39
|
-
def no_jsfile!
|
40
|
-
print "Jsfile not found, create one? [Y/n] "
|
41
|
-
res = gets.chomp
|
42
|
-
unless res =~ /n|N/
|
43
|
-
File.open("Jsfile", "w+") do |f|
|
44
|
-
f.print <<TXT
|
45
|
-
#
|
46
|
-
# #{Dir.pwd.split('/').last.capitalize} Jsfile
|
47
|
-
#
|
48
|
-
|
49
|
-
js :jquery, "http://jquery.com"
|
50
|
-
css :reset, "http://prefered/rset/url"
|
51
|
-
|
52
|
-
group :forms do
|
53
|
-
js :validator, "http://..."
|
54
|
-
end
|
55
|
-
|
56
|
-
TXT
|
57
|
-
end
|
58
|
-
puts "Jsfile created!"
|
59
|
-
exit 0
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def find_jsfile
|
64
|
-
no_jsfile! unless File.exists?("Jsfile")
|
65
|
-
end
|
66
|
-
|
67
|
-
def read_jsfile
|
68
|
-
file = File.open("Jsfile") # ruby 1.8/1.9 (ugly) fix
|
69
|
-
code = file.send(file.respond_to?(:lines) ? :lines : :readlines).map do |line|
|
70
|
-
# Parse options
|
71
|
-
if line =~ /^\w{2,3}path/
|
72
|
-
key, val = line.split(" ")
|
73
|
-
Opt[key.to_sym] = val
|
74
|
-
next
|
75
|
-
end
|
76
|
-
line
|
77
|
-
end.reject(&:nil?)
|
78
|
-
DSL.parse code.join("")
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Text Interface
|
83
|
-
#
|
84
|
-
|
85
|
-
def check_param params, string
|
86
|
-
unless string.include? params[0]
|
87
|
-
puts "Did you mean #{string}?"
|
88
|
-
exit 0
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# Fuzzy find files
|
93
|
-
def find_assets(filter = nil)
|
94
|
-
return @assets unless filter
|
95
|
-
@assets.select { |a| "#{a.name}#{a.pkg}" =~ /#{filter}/ }
|
96
|
-
end
|
97
|
-
|
98
|
-
def work_on params
|
99
|
-
case params.first
|
100
|
-
when /^i/, nil
|
101
|
-
check_param params, "install" if params[0]
|
102
|
-
find_assets(params[1]).map(&:install!)
|
103
|
-
when /^u/
|
104
|
-
check_param params, "update"
|
105
|
-
find_assets(params[1]).map { |a| a.install! :force }
|
106
|
-
when /^c/
|
107
|
-
check_param params, "check"
|
108
|
-
find_assets(params[1]).map { |a| a.check! }
|
109
|
-
when /^w/
|
110
|
-
check_param params, "web"
|
111
|
-
gui!
|
112
|
-
else
|
113
|
-
puts "Dunno how to #{params.join}."
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def bar
|
118
|
-
puts "-" * TSIZE
|
119
|
-
end
|
120
|
-
|
121
|
-
def gui!
|
122
|
-
require "assetify/gui/server"
|
123
|
-
Sinatra::Application.run!
|
124
|
-
end
|
125
|
-
|
126
|
-
def work!(params)
|
127
|
-
start = Time.now
|
128
|
-
puts "Assetify"
|
129
|
-
bar
|
130
|
-
find_jsfile
|
131
|
-
Asset.set_all @assets = read_jsfile
|
132
|
-
work_on params
|
133
|
-
bar
|
134
|
-
puts "Done in #{Time.now - start}s"
|
135
|
-
end
|
136
|
-
|
13
|
+
# Text Interface
|
14
|
+
require "assetify/cli/term"
|
15
|
+
require "assetify/cli/colored"
|
16
|
+
require "assetify/cli"
|
137
17
|
|
138
|
-
|
139
|
-
|
18
|
+
# Web Interface
|
19
|
+
require "assetify/gui/server"
|
20
|
+
require "assetify/gui"
|
data/lib/assetify/asset.rb
CHANGED
@@ -31,6 +31,13 @@ module Assetify
|
|
31
31
|
@filename = "#{name}.#{ext}"
|
32
32
|
end
|
33
33
|
|
34
|
+
def find_ext_for file
|
35
|
+
file.split(".").last[0,3]
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Find correct path to put me
|
40
|
+
#
|
34
41
|
def find_path_for txt
|
35
42
|
case txt
|
36
43
|
when /js/ then :javascripts
|
@@ -39,10 +46,6 @@ module Assetify
|
|
39
46
|
end
|
40
47
|
end
|
41
48
|
|
42
|
-
def find_ext_for file
|
43
|
-
file.split(".").last[0,3]
|
44
|
-
end
|
45
|
-
|
46
49
|
def path
|
47
50
|
args = if @to.empty?
|
48
51
|
tpath = Opt[find_path_for(type)]
|
@@ -62,22 +65,28 @@ module Assetify
|
|
62
65
|
File.exists? fullpath
|
63
66
|
end
|
64
67
|
|
65
|
-
def print_version
|
66
|
-
return "" unless ver
|
67
|
-
ver_str = ver.size > 10 ? ver[0..10] : ver[0]
|
68
|
-
"v#{ver_str} "
|
69
|
-
end
|
70
|
-
|
71
68
|
def data
|
72
69
|
# Get data, from a pkg or download directly
|
73
70
|
@data ||= @pkg ? @pkg.get(url, :force).values.first : get_data(url)
|
74
71
|
end
|
75
72
|
|
73
|
+
#
|
74
|
+
# Asset version
|
75
|
+
#
|
76
76
|
def ver
|
77
77
|
return nil unless @data
|
78
78
|
@ver ||= find_version(@data)
|
79
79
|
end
|
80
80
|
|
81
|
+
def print_version
|
82
|
+
return "" unless ver
|
83
|
+
ver_str = ver.size > 10 ? ver[0..10] : ver[0]
|
84
|
+
"v#{ver_str} "
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Prints info about the asset (TODO: move this to cli...)
|
89
|
+
#
|
81
90
|
def header
|
82
91
|
LINE.p "-> #{name}.#{type}"
|
83
92
|
end
|
@@ -92,6 +101,9 @@ module Assetify
|
|
92
101
|
end
|
93
102
|
end
|
94
103
|
|
104
|
+
#
|
105
|
+
# Write down asset to disk
|
106
|
+
#
|
95
107
|
def install!(force = false)
|
96
108
|
header
|
97
109
|
if !force && file_exists? # Return if file is on path
|
@@ -114,13 +126,17 @@ module Assetify
|
|
114
126
|
end
|
115
127
|
|
116
128
|
class << self
|
117
|
-
#
|
118
|
-
|
119
|
-
|
129
|
+
#
|
130
|
+
# Simple cache store, read Assetfile and dump it here to use.
|
131
|
+
#
|
132
|
+
def all
|
133
|
+
@all ||= Assetfile.read
|
120
134
|
end
|
121
|
-
|
122
|
-
|
135
|
+
|
136
|
+
def filter params
|
137
|
+
all.select { |a| "#{a.name}#{a.pkg}" =~ /#{params}/ }
|
123
138
|
end
|
139
|
+
|
124
140
|
end
|
125
141
|
|
126
142
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Assetify
|
2
|
+
class Assetfile
|
3
|
+
class << self
|
4
|
+
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assetfile stuff
|
8
|
+
#
|
9
|
+
def missing!
|
10
|
+
print "Assetfile not found, create one? [Y/n] "
|
11
|
+
res = $stdin.gets.chomp # dont forget stdin
|
12
|
+
unless res =~ /n|N/
|
13
|
+
File.open("Assetfile", "w+") do |f|
|
14
|
+
f.print <<TXT
|
15
|
+
#
|
16
|
+
# #{Dir.pwd.split('/').last.capitalize} Assetfile
|
17
|
+
#
|
18
|
+
|
19
|
+
js :jquery, "http://jquery.com"
|
20
|
+
css :reset, "http://prefered/rset/url"
|
21
|
+
|
22
|
+
group :forms do
|
23
|
+
js :validator, "http://..."
|
24
|
+
end
|
25
|
+
|
26
|
+
TXT
|
27
|
+
end
|
28
|
+
puts "Assetfile created!"
|
29
|
+
exit 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Assetfile find/read
|
35
|
+
#
|
36
|
+
#
|
37
|
+
def find
|
38
|
+
missing! unless File.exists?("Assetfile")
|
39
|
+
end
|
40
|
+
|
41
|
+
def read
|
42
|
+
file = File.open("Assetfile") # ruby 1.8/1.9 (ugly) fix
|
43
|
+
code = file.send(file.respond_to?(:lines) ? :lines : :readlines).map do |line|
|
44
|
+
# Parse options
|
45
|
+
if line =~ /^\w{2,3}path/
|
46
|
+
key, val = line.split(" ")
|
47
|
+
Opt[key.to_sym] = val
|
48
|
+
next
|
49
|
+
end
|
50
|
+
line
|
51
|
+
end.reject(&:nil?)
|
52
|
+
DSL.parse code.join("")
|
53
|
+
end
|
54
|
+
|
55
|
+
# def write
|
56
|
+
# end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/assetify/cli.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# To be refactored...
|
3
|
+
#
|
4
|
+
module Assetify
|
5
|
+
LINE = CLI.new
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
#
|
10
|
+
# Text Interface
|
11
|
+
#
|
12
|
+
def check_param params, string
|
13
|
+
unless string.include? params[0]
|
14
|
+
puts "Did you mean #{string}?"
|
15
|
+
exit 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Fuzzy find files
|
20
|
+
def find_assets(params = nil)
|
21
|
+
return Asset.all unless params
|
22
|
+
Asset.filter params
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# CLI Master case/switch!
|
27
|
+
#
|
28
|
+
# Destructive:
|
29
|
+
# i -> install
|
30
|
+
# u -> update
|
31
|
+
# x -> clean ? todo
|
32
|
+
#
|
33
|
+
# Safe:
|
34
|
+
# c -> check
|
35
|
+
# w -> web
|
36
|
+
#
|
37
|
+
def work_on params
|
38
|
+
case params.first
|
39
|
+
when /^i/, nil
|
40
|
+
check_param params, "install" if params[0]
|
41
|
+
find_assets(params[1]).map(&:install!)
|
42
|
+
when /^u/
|
43
|
+
check_param params, "update"
|
44
|
+
find_assets(params[1]).map { |a| a.install! :force }
|
45
|
+
when /^c/
|
46
|
+
check_param params, "check"
|
47
|
+
find_assets(params[1]).map { |a| a.check! }
|
48
|
+
when /^w/
|
49
|
+
check_param params, "web"
|
50
|
+
GUI.boot!
|
51
|
+
else
|
52
|
+
puts "Dunno how to #{params.join}."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Divider bar
|
58
|
+
#
|
59
|
+
def bar
|
60
|
+
puts "-" * TSIZE
|
61
|
+
end
|
62
|
+
|
63
|
+
def work!(params)
|
64
|
+
start = Time.now
|
65
|
+
Assetfile.find
|
66
|
+
puts "Assetify - #{Asset.all.size} assets"
|
67
|
+
bar
|
68
|
+
work_on params
|
69
|
+
bar
|
70
|
+
puts "Done in #{Time.now - start}s"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Assetify
|
2
|
+
|
3
|
+
Opt = {
|
4
|
+
:vendor => "public/vendor",
|
5
|
+
:newname => true
|
6
|
+
}
|
7
|
+
|
8
|
+
TSIZE = 80
|
9
|
+
ASSETS_PATH = "vendor/assets"
|
10
|
+
ASSETS = [:javascripts, :stylesheets, :images]
|
11
|
+
ASSETS.each do |asset|
|
12
|
+
Opt.merge!(asset => "#{ASSETS_PATH}/#{asset}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# class BadAssetfile < StandardError
|
16
|
+
# end
|
17
|
+
end
|
data/lib/assetify/dsl.rb
CHANGED
@@ -2,8 +2,7 @@ module Assetify
|
|
2
2
|
|
3
3
|
class DSL
|
4
4
|
attr_reader :assets
|
5
|
-
|
6
|
-
|
5
|
+
|
7
6
|
#
|
8
7
|
# Makes a pkg, a gz/tar/zip asset/
|
9
8
|
#
|
@@ -22,7 +21,6 @@ module Assetify
|
|
22
21
|
assets
|
23
22
|
end
|
24
23
|
|
25
|
-
|
26
24
|
#
|
27
25
|
# Makes a group, a namspace for the assets.
|
28
26
|
#
|
@@ -43,14 +41,12 @@ module Assetify
|
|
43
41
|
next if path =~ /\/$/ # dont let dirs get in... ugly
|
44
42
|
ext, *name = path.split(".").reverse
|
45
43
|
name = name.reverse.join(".").split("/").last
|
46
|
-
|
47
|
-
|
48
|
-
:to => to})# h.split(".").last, )
|
44
|
+
@assets ||= []
|
45
|
+
@assets << Asset.new(ext, name, path, nil, { :pkg => @pkg , :to => to } )
|
49
46
|
end
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
|
-
|
54
50
|
#
|
55
51
|
# Parse the assets.
|
56
52
|
#
|
@@ -62,7 +58,8 @@ module Assetify
|
|
62
58
|
opts = {:ns => @ns, :pkg => @pkg}
|
63
59
|
params.each { |hsh| opts.merge! hsh }
|
64
60
|
ver = ver[0]
|
65
|
-
|
61
|
+
@assets ||= []
|
62
|
+
@assets << Asset.new(method.to_sym, name, uri, ver, opts)
|
66
63
|
end
|
67
64
|
|
68
65
|
#
|
@@ -71,12 +68,12 @@ module Assetify
|
|
71
68
|
# a "jquery", "http://...jquery.js"
|
72
69
|
#
|
73
70
|
def a name, url, *params
|
74
|
-
|
75
|
-
send(
|
71
|
+
extension = url.split(".").last
|
72
|
+
send(extension, name, url)
|
76
73
|
end
|
77
74
|
|
78
|
-
|
79
|
-
# Create
|
75
|
+
#
|
76
|
+
# Create Assetfile assets path setters
|
80
77
|
#
|
81
78
|
# javascript "new/path"
|
82
79
|
# ...
|
@@ -94,9 +91,9 @@ module Assetify
|
|
94
91
|
# DSL.parse()
|
95
92
|
#
|
96
93
|
def self.parse chunk
|
97
|
-
# puts "Assetify - Error Parsing '
|
94
|
+
# puts "Assetify - Error Parsing 'Assetfile'."
|
98
95
|
# Instance eval with 2nd, 3rd args to the rescue
|
99
|
-
new.instance_eval(chunk, "
|
96
|
+
new.instance_eval(chunk, "Assetfile", 1)
|
100
97
|
end
|
101
98
|
|
102
99
|
end
|
data/lib/assetify/gui.rb
ADDED
data/lib/assetify/helpers.rb
CHANGED
@@ -8,7 +8,12 @@ module Assetify
|
|
8
8
|
#
|
9
9
|
def find_version(txt)
|
10
10
|
return unless txt
|
11
|
-
txt.binary?
|
11
|
+
if txt.binary?
|
12
|
+
find_version_from_bin(txt)
|
13
|
+
else
|
14
|
+
v = find_version_from_txt(txt)
|
15
|
+
v && v[0] =~ /(\d+)\.(\d+).*/ ? v : find_version_from_bin(txt)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
private
|
@@ -24,14 +29,15 @@ module Assetify
|
|
24
29
|
Digest::MD5.hexdigest blob
|
25
30
|
end
|
26
31
|
|
32
|
+
#
|
33
|
+
# Downloads assets
|
34
|
+
#
|
27
35
|
def download url_str, limit = 10
|
28
36
|
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
|
29
37
|
uri = URI.parse url_str
|
30
|
-
# # response = ""
|
31
38
|
http = Net::HTTP.start(uri.host, :use_ssl => url_str =~ /https/)# do |http|
|
32
39
|
response = http.get(uri.path.empty? ? "/" : uri.path)
|
33
|
-
|
34
|
-
# response = Net::HTTP.get_response(URI.parse(url_str) )# ,:use_ssl => url_str =~ /https/ )
|
40
|
+
|
35
41
|
case response
|
36
42
|
when Net::HTTPSuccess then @data = response
|
37
43
|
when Net::HTTPRedirection then download(redirect_url(response), limit - 1)
|
@@ -49,7 +55,7 @@ module Assetify
|
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
52
|
-
def write
|
58
|
+
def write binary
|
53
59
|
FileUtils.mkdir_p path unless Dir.exists?(path)
|
54
60
|
File.open(fullpath, "w") { |f| f.puts(binary) }
|
55
61
|
end
|
data/spec/assetify/dsl_spec.rb
CHANGED
@@ -51,10 +51,10 @@ describe DSL do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should accept a especific location with :to" do
|
54
|
-
Dir.should_receive(:pwd).and_return("/home/
|
54
|
+
Dir.should_receive(:pwd).and_return("/home/user/git/assetify")
|
55
55
|
a = Assetify::DSL.parse("rb 'foo', 'foolink', :to => 'spec/rock'")[0]
|
56
56
|
a.should be_an Asset
|
57
|
-
a.fullpath.should eql("/home/
|
57
|
+
a.fullpath.should eql("/home/user/git/assetify/spec/rock/foo.rb")
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should not fail with symbols" do
|
@@ -127,10 +127,12 @@ describe DSL do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should read from pkg the regex" do
|
130
|
+
Dir.should_receive(:pwd).and_return("/home/user/git/assetify")
|
131
|
+
|
130
132
|
as = Assetify::DSL.parse "pkg 'complex', 'http://complex.tgz' do; dir 'images/', :to => 'images/complex/'; end"
|
131
133
|
as[0].name.should eql("two")
|
132
134
|
as[0].ext.should eql("png")
|
133
|
-
as[0].fullpath.should eql("/home/
|
135
|
+
as[0].fullpath.should eql("/home/user/git/assetify/images/complex/two.png")
|
134
136
|
end
|
135
137
|
|
136
138
|
end
|
@@ -34,7 +34,7 @@ describe Helpers do
|
|
34
34
|
|
35
35
|
it "should rescue fine if there isn`t version" do
|
36
36
|
find_version("/* -------------------------------------------------------------- reset.css * Resets default browser CSS.").
|
37
|
-
should
|
37
|
+
should eql("d356b6a91b0d16e456c7b4f79302d051")
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
data/spec/assetify_spec.rb
CHANGED
@@ -2,33 +2,33 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe Assetify do
|
4
4
|
|
5
|
-
it "shoud
|
6
|
-
|
7
|
-
|
5
|
+
it "shoud read_assetfile" do
|
6
|
+
mock_assetfile
|
7
|
+
Assetfile.read.should have(1).asset
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should skip comments" do
|
11
|
-
|
12
|
-
|
11
|
+
mock_assetfile("#\n# Oi\n#\n")
|
12
|
+
Assetfile.read.should be_nil
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should work with versions url" do
|
16
|
-
|
17
|
-
|
16
|
+
mock_assetfile("#\n# Oi\n#\njs 'down', 'http://js.com/down-{VERSION}.js', '1.6'")
|
17
|
+
Assetfile.read.first.url.should eql("http://js.com/down-1.6.js")
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "read css" do
|
21
21
|
before do
|
22
|
-
|
22
|
+
mock_assetfile("#\n# CSS\n#\ncss 'grid', 'http://grid.com/down'")
|
23
23
|
end
|
24
|
-
let(:asset) {
|
24
|
+
let(:asset) { Assetfile.read[0] }
|
25
25
|
|
26
26
|
it "should read css" do
|
27
|
-
|
27
|
+
Assetfile.read.should have(1).asset
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should read css" do
|
31
|
-
|
31
|
+
Assetfile.read.first.type.should eql(:css)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should have fullpath" do
|
@@ -39,7 +39,7 @@ describe Assetify do
|
|
39
39
|
|
40
40
|
describe "readjs" do
|
41
41
|
|
42
|
-
let(:asset) {
|
42
|
+
let(:asset) { mock_assetfile; Assetfile.read[0] }
|
43
43
|
|
44
44
|
it "should be an asset" do
|
45
45
|
asset.should be_an Assetify::Asset
|
data/spec/spec_helper.rb
CHANGED
@@ -7,8 +7,8 @@ require 'assetify'
|
|
7
7
|
include Assetify
|
8
8
|
|
9
9
|
|
10
|
-
def
|
11
|
-
File.should_receive(:open).once.with("
|
10
|
+
def mock_assetfile(d = 'js "cool", "http://cool.js/down"')
|
11
|
+
File.should_receive(:open).once.with("Assetfile").and_return(d)
|
12
12
|
end
|
13
13
|
|
14
14
|
# Requires supporting files with custom matchers and macros, etc,
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assetify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
|
10
|
-
- 1
|
11
|
-
version: 1.0.0.rc1
|
9
|
+
version: 1.0.0
|
12
10
|
platform: ruby
|
13
11
|
authors:
|
14
12
|
- Marcos Piccinini
|
13
|
+
- Rafael Barbosa
|
15
14
|
autorequire:
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
@@ -75,7 +74,33 @@ dependencies:
|
|
75
74
|
type: :development
|
76
75
|
prerelease: false
|
77
76
|
version_requirements: *id004
|
78
|
-
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: sinatra
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
type: :development
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: *id005
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: libarchive
|
92
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
type: :development
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: *id006
|
103
|
+
description: Downloads/updates assets based on an Assetfile. Any framework.
|
79
104
|
email: x@nofxx.com
|
80
105
|
executables:
|
81
106
|
- assetify
|
@@ -86,9 +111,9 @@ extra_rdoc_files:
|
|
86
111
|
files:
|
87
112
|
- .document
|
88
113
|
- .rspec
|
114
|
+
- Assetfile
|
89
115
|
- Gemfile
|
90
116
|
- Gemfile.lock
|
91
|
-
- Jsfile
|
92
117
|
- README.md
|
93
118
|
- Rakefile
|
94
119
|
- VERSION
|
@@ -98,13 +123,18 @@ files:
|
|
98
123
|
- lib/assetify/asset.rb
|
99
124
|
- lib/assetify/asset/pathfix.rb
|
100
125
|
- lib/assetify/asset/pkg.rb
|
126
|
+
- lib/assetify/assetfile.rb
|
127
|
+
- lib/assetify/cli.rb
|
128
|
+
- lib/assetify/cli/colored.rb
|
129
|
+
- lib/assetify/cli/term.rb
|
130
|
+
- lib/assetify/constants.rb
|
101
131
|
- lib/assetify/dsl.rb
|
102
132
|
- lib/assetify/extensions/string.rb
|
133
|
+
- lib/assetify/gui.rb
|
103
134
|
- lib/assetify/gui/server.rb
|
104
135
|
- lib/assetify/gui/views/home.html.erb
|
105
136
|
- lib/assetify/helpers.rb
|
106
|
-
- lib/assetify/
|
107
|
-
- lib/assetify/tui/term.rb
|
137
|
+
- lib/assetify/version.rb
|
108
138
|
- spec/assetify/asset_spec.rb
|
109
139
|
- spec/assetify/dsl_spec.rb
|
110
140
|
- spec/assetify/helpers_spec.rb
|
@@ -119,7 +149,12 @@ has_rdoc: true
|
|
119
149
|
homepage: http://github.com/nofxx/assetify
|
120
150
|
licenses:
|
121
151
|
- MIT
|
122
|
-
post_install_message:
|
152
|
+
post_install_message: "\n\
|
153
|
+
A ------------------------------------------------------------ A\n\n * A S S E T I F Y *\n\n\
|
154
|
+
Thank you for installing assetify-1.0.0.\n\n\
|
155
|
+
Here is a few optional gems:\n\n * libarchive - For untar/unzip packages\n * minimagick - For image transformations\n * sass - For css2sass support\n\n\n\
|
156
|
+
We hope `assetify` saves you some time!\n\n\
|
157
|
+
A ------------------------------------------------------------ A\n"
|
123
158
|
rdoc_options: []
|
124
159
|
|
125
160
|
require_paths:
|
@@ -129,20 +164,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
164
|
requirements:
|
130
165
|
- - ">="
|
131
166
|
- !ruby/object:Gem::Version
|
132
|
-
hash:
|
167
|
+
hash: 4282977214519276665
|
133
168
|
segments:
|
134
169
|
- 0
|
135
170
|
version: "0"
|
136
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
172
|
none: false
|
138
173
|
requirements:
|
139
|
-
- - "
|
174
|
+
- - ">="
|
140
175
|
- !ruby/object:Gem::Version
|
141
176
|
segments:
|
142
|
-
-
|
143
|
-
|
144
|
-
- 1
|
145
|
-
version: 1.3.1
|
177
|
+
- 0
|
178
|
+
version: "0"
|
146
179
|
requirements: []
|
147
180
|
|
148
181
|
rubyforge_project:
|