assetify 2.0.1 → 3.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b4005c1682c1cff55d0313f562b681e700c8cecb
4
+ data.tar.gz: f29115ecf527d63aef20aa751658b259e1d2c99b
5
+ SHA512:
6
+ metadata.gz: b1aacdb842207167e97ff3601348b08a6a8980dcc19adc6de3e70fe007e7dff0e32ca1928cfd98ca495b161fdf0c8b6782363666a919f13c59cce3643eda4d0b
7
+ data.tar.gz: 8250e7adc718a62f4d87092782a248a8e57767620fa922dfafbf52d7eb25c9d312b25811cf3c6c28ba0e31ff147d89972837a9bdd9f419d75274224a05556398
data/README.md CHANGED
@@ -1,3 +1,17 @@
1
+
2
+ ```
3
+ ░█▀▀█ █▀▀ █▀▀ █▀▀ ▀▀█▀▀ ░▀░ █▀▀ █░░█
4
+ ▒█▄▄█ ▀▀█ ▀▀█ █▀▀ ░▒█░░ ▀█▀ █▀▀ █▄▄█
5
+ ▒█░▒█ ▀▀▀ ▀▀▀ ▀▀▀ ░▒█░░ ▀▀▀ ▀░░ ▄▄▄█
6
+ ```
7
+
8
+ [![Gem Version](https://badge.fury.io/rb/assetify.svg)](http://badge.fury.io/rb/assetify)
9
+ [![Code Climate](https://codeclimate.com/github/nofxx/assetify.svg)](https://codeclimate.com/github/nofxx/assetify)
10
+ [![Coverage Status](https://coveralls.io/repos/nofxx/assetify/badge.svg?branch=master)](https://coveralls.io/r/nofxx/assetify?branch=master)
11
+ [![Dependency Status](https://gemnasium.com/nofxx/assetify.svg)](https://gemnasium.com/nofxx/assetify)
12
+ [![Build Status](https://travis-ci.org/nofxx/assetify.svg?branch=master)](https://travis-ci.org/nofxx/assetify)
13
+
14
+
1
15
  Assetify
2
16
  ========
3
17
 
@@ -29,36 +43,36 @@ Assetfile
29
43
  Like a `Gemfile`, but with fewer chars. Only one actually.
30
44
 
31
45
 
32
- Behold the 'a'
46
+ Behold the `a`
33
47
  --------------
34
48
 
35
- a "tipsy", "http://...tipsy.js"
36
- a "tipsy", "http://...tipsy.css"
37
- a "video", "http://...video.mpeg"
49
+ a 'tipsy', 'http://...tipsy.js'
50
+ a 'tipsy', 'http://...tipsy.css'
51
+ a 'video', 'http://...video.mpeg'
38
52
 
39
53
 
40
- There's also an alias 'asset' for 'a', if you enjoy typing.
54
+ There's also an alias `asset` for `a`, if you enjoy typing:
41
55
 
42
56
 
43
- asset "tipsy", "http://...tipsy.js"
57
+ asset 'tipsy', 'http://...tipsy.js'
44
58
 
45
59
 
46
60
 
47
61
  You can choose the filetype (or extension) before too:
48
62
 
49
- type "name", "url", <"version"> or <:options>
63
+ type 'name', 'url', <'version'> or <:options>
50
64
 
51
- js "jquery", "http://code.jquery.com/jquery-{VERSION}.min.js", "1.6"
52
- js "tipsy", "https://github.com/jaz303/tipsy/.../jquery.tipsy.js"
65
+ js 'jquery', 'http://code.jquery.com/jquery-{VERSION}.min.js', '1.6'
66
+ js 'tipsy', 'https://github.com/jaz303/tipsy/.../jquery.tipsy.js'
53
67
 
54
68
 
55
69
  Stylesheets:
56
70
 
57
- css "tipsy", "https://github.com/jaz303/tipsy/.../jquery.tipsy.css"
71
+ css 'tipsy', 'https://github.com/jaz303/tipsy/.../jquery.tipsy.css'
58
72
 
59
73
  Any file:
60
74
 
61
- mp3 "alert", "http://link/to/audio"
75
+ mp3 'alert', 'http://link/to/audio'
62
76
 
63
77
 
64
78
  Now just run `assetify` to make sure everything is installed/up-to-date.
@@ -69,20 +83,20 @@ Groups
69
83
 
70
84
  Use groups/namespaces to group related assets together:
71
85
 
72
- group "forms" do
73
- js "validator", url
74
- js "textmask", url
86
+ group 'forms' do
87
+ js 'validator', url
88
+ js 'textmask', url
75
89
  end
76
90
 
77
91
 
78
- This will install as "vendor/assets/javascripts/forms/validator.js"
92
+ This will install as `vendor/assets/javascripts/forms/validator.js`
79
93
 
80
94
  You can nest groups too:
81
95
 
82
- group "forms" do
83
- js "validator", url
84
- group "extra" do
85
- js "another", url
96
+ group 'forms' do
97
+ js 'validator', url
98
+ group 'extra' do
99
+ js 'another', url
86
100
  end
87
101
  end
88
102
 
@@ -92,27 +106,26 @@ Pkgs
92
106
 
93
107
  Big projects makes you download tons of files for some .min files and css.
94
108
 
95
- pkg "fancy", "http://to.tgz.or.zip" do
96
- js "cool", "internal/js/cool.js"
97
- css "cool", "internal/css/cool.css"
109
+ pkg 'fancy', 'http://to.tgz.or.zip' do
110
+ js 'cool', 'internal/js/cool.js'
111
+ css 'cool', 'internal/css/cool.css'
98
112
  end
99
113
 
100
- This downloads and 'cherry pick' the files.
101
- Files will be written with the namespace "fancy":
114
+ This downloads and "cherry picks" the files.
115
+ Files will be written with the namespace `fancy`:
102
116
 
103
117
  /javascripts/fancy/cool.js
104
118
 
105
- You can pass :shallow => true to avoid the namespace:
119
+ You can pass `shallow: true` to avoid the namespace:
106
120
 
107
- pkg "fancy", "http://to.tgz.or.zip", shallow: true do
121
+ pkg 'fancy', 'http://to.tgz.or.zip', shallow: true do
108
122
 
109
123
  Results in:
110
124
 
111
125
  /javascript/cool.js
112
126
 
113
127
 
114
- Also, please check out the note about link inside pkgs below.
115
-
128
+ Also, please check out the note about links inside pkgs below.
116
129
 
117
130
 
118
131
  Dir
@@ -121,15 +134,15 @@ ___
121
134
  You can resource a full directory of files, too. Very useful when
122
135
  dealing with pkgs:
123
136
 
124
- pkg "complexfw", "link" do
125
- js "complex.min.js"
126
- dir "images/", to: "images/complexfw"
137
+ pkg 'complexfw', 'link' do
138
+ js 'complex.min.js'
139
+ dir 'images/', to: 'images/complexfw'
127
140
  # Another option, treat`em all as filetype:
128
- dir "src/", :as => :js
141
+ dir 'src/', as: :js
129
142
  end
130
143
 
131
- All files inside images will be copied to "images/complexfw" and
132
- all files in 'src' to 'javascripts' (or whatever else jspath is).
144
+ All files inside images will be copied to `images/complexfw` and
145
+ all files in `src` to `javascripts` (or whatever else jspath is).
133
146
 
134
147
 
135
148
  Note: Have in mind that the "link" inside dir/packages *is a regex*
@@ -151,10 +164,10 @@ And every path corrected to use the pipeline.
151
164
 
152
165
  Jquery Mobile example:
153
166
 
154
- pkg :mobile, "http://code.jquery.com....zip", shallow: true do
155
- js "mobile", "mobile.js"
156
- css "mobile", "mobile.css", :as => :sass
157
- dir "images/*"
167
+ pkg :mobile, 'http://code.jquery.com....zip', shallow: true do
168
+ js 'mobile', 'mobile.js'
169
+ css 'mobile', 'mobile.css', as: :sass
170
+ dir 'images/*'
158
171
  end
159
172
 
160
173
  You just need:
@@ -163,9 +176,8 @@ You just need:
163
176
 
164
177
  On application.css and application.js.
165
178
 
166
- Images will be in 'vendor/assets/mobile/*', and the paths inside
167
- mobile.css corrected to 'image-url(mobile/*)', or <%%> if I`ve had
168
- choose erb.
179
+ Images will be in `vendor/assets/mobile/*`, and the paths inside
180
+ mobile.css corrected to `image-url(mobile/*)`, or `<%%>` if it's erb.
169
181
 
170
182
  This means you can have any third party library in the format
171
183
  you like, always up-to-date. Easy to copy and customize parts
@@ -177,12 +189,12 @@ foo2bar
177
189
 
178
190
  You can convert your assets to coffescript, sass or scss:
179
191
 
180
- js "fulib", "http....", :as => :coffee
181
- css "1140", "http....", :as => :sass
182
- css "1140", "http....", :as => :scss
192
+ js 'fulib', 'http....', as: :coffee
193
+ css '1140', 'http....', as: :sass
194
+ css '1140', 'http....', as: :scss
183
195
 
184
196
  Note: You do need aditional stuff for this.
185
- Gem 'sass' and/or node`s 'js2coffee' (install via npm).
197
+ Gem `sass` and/or node's `js2coffee` (install via npm).
186
198
 
187
199
 
188
200
  minimagick
@@ -191,10 +203,10 @@ minimagick
191
203
  Preprocess images is also possible:
192
204
 
193
205
 
194
- png "logo", "http....", :as => :jpg, :quality => 75
206
+ png 'logo', 'http....', as: :jpg, quality: 75
195
207
 
196
208
 
197
- Note: Need to install 'imagemagick' and 'minimagick' gem for this.
209
+ Note: Need to install `imagemagick` and `minimagick` gem for this.
198
210
 
199
211
  Versions
200
212
  --------
@@ -210,10 +222,10 @@ Other
210
222
  Set a different location per file:
211
223
 
212
224
 
213
- js "other", "http://lib.../other.js", to: "different/path"
225
+ js 'other', 'http://lib.../other.js', to: 'different/path'
214
226
 
215
227
  Filename will be: ./different/path/other.js
216
- This works for namespaces too, change "to" with "ns".
228
+ This works for namespaces too, use `ns` instead of `to`.
217
229
 
218
230
 
219
231
 
@@ -223,15 +235,15 @@ Options
223
235
  Change some default settings:
224
236
 
225
237
  newname true || false
226
- javascripts "public/javascripts"
227
- stylesheets "public/stylesheets"
228
- images "public/images"
238
+ javascripts 'public/javascripts'
239
+ stylesheets 'public/stylesheets'
240
+ images 'public/images'
229
241
 
230
242
  If newname is set to true (default) the file will be renamed. Ex:
231
243
 
232
- js "validator", "http//.../jquery.validator.min.js"
244
+ js 'validator', 'http//.../jquery.validator.min.js'
233
245
 
234
- Filename will be: "validator.js"
246
+ Filename will be: `validator.js`
235
247
 
236
248
 
237
249
 
@@ -265,6 +277,6 @@ Contributing
265
277
  Copyright
266
278
  ---------
267
279
 
268
- Copyright (c) 2011 Marcos Piccinini. See LICENSE.txt for
269
- further details.
270
-
280
+ Copyright (c) 2011 Marcos Piccinini.
281
+ See LICENSE.txt for further details.
282
+ ASCII Art by [FSymbols](http://fsymbols.com/generators/tarty)
data/Rakefile CHANGED
@@ -1,50 +1 @@
1
- # encoding: utf-8
2
- require 'bundler'
3
- Bundler.setup
4
-
5
- #require "rake"
6
- # require "rdoc/task"
7
- # require "rspec"
8
- # require "rspec/core/rake_task"
9
-
10
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
11
- require "assetify/version"
12
-
13
- task :gem => :build
14
- task :build do
15
- system "gem build assetify.gemspec"
16
- end
17
-
18
- task :install => :build do
19
- system "sudo gem install assetify-#{Assetify::VERSION}.gem"
20
- end
21
-
22
- task :release => :build do
23
- system "git tag -a v#{Assetify::VERSION} -m 'Tagging #{Assetify::VERSION}'"
24
- system "git push --tags"
25
- system "gem push assetify-#{Assetify::VERSION}.gem"
26
- end
27
-
28
-
29
- # require 'rspec/core'
30
- # require 'rspec/core/rake_task'
31
- # RSpec::Core::RakeTask.new(:spec) do |spec|
32
- # spec.pattern = FileList['spec/**/*_spec.rb']
33
- # end
34
-
35
- # RSpec::Core::RakeTask.new(:rcov) do |spec|
36
- # spec.pattern = 'spec/**/*_spec.rb'
37
- # spec.rcov = true
38
- # end
39
-
40
- # task :default => :spec
41
-
42
- # require 'rdoc/task'
43
- # RDoc::Task.new do |rdoc|
44
- # version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
-
46
- # rdoc.rdoc_dir = 'rdoc'
47
- # rdoc.title = "assetify #{version}"
48
- # rdoc.rdoc_files.include('README*')
49
- # rdoc.rdoc_files.include('lib/**/*.rb')
50
- # end
1
+ require 'bundler/gem_tasks'
@@ -5,10 +5,10 @@ require 'optparse'
5
5
  require 'assetify'
6
6
 
7
7
  opt = OptionParser.new do |o|
8
- o.banner = <<BANNER
8
+ o.banner = <<BANNER
9
9
  This is Assetify! What we`re going to do?
10
10
 
11
- Usage: #{File.basename($0)} command [args]
11
+ Usage: #{File.basename($PROGRAM_NAME)} command [args]
12
12
 
13
13
  Commands:
14
14
 
@@ -22,13 +22,11 @@ Options:
22
22
 
23
23
  BANNER
24
24
 
25
-
26
- o.on('-h', "Show help") { puts o; exit }
27
- o.on('-d', "Verbose (Debug)") { Assetify::Opt[:debug] = true }
25
+ o.on('-h', 'Show help') { puts o; exit }
26
+ o.on('-d', 'Verbose (Debug)') { Assetify::Opt[:debug] = true }
28
27
  o.parse!
29
28
  end
30
29
 
31
-
32
30
  begin
33
31
  Assetify.work!(ARGV)
34
32
  rescue Interrupt => e
@@ -36,5 +34,3 @@ rescue Interrupt => e
36
34
  puts e.backtrace.join("\n")
37
35
  exit 1
38
36
  end
39
-
40
-
@@ -1,20 +1,20 @@
1
1
  # Options/Constants
2
- require "assetify/constants"
2
+ require 'assetify/constants'
3
3
 
4
4
  # Ruby Extensions
5
- require "assetify/extensions/string"
5
+ require 'assetify/extensions/string'
6
6
 
7
7
  # Core
8
- require "assetify/helpers"
9
- require "assetify/assetfile"
10
- require "assetify/asset"
11
- require "assetify/dsl"
8
+ require 'assetify/helpers'
9
+ require 'assetify/assetfile'
10
+ require 'assetify/asset'
11
+ require 'assetify/dsl'
12
12
 
13
13
  # Text Interface
14
- require "assetify/cli/term"
15
- require "assetify/cli/colored"
16
- require "assetify/cli"
14
+ require 'assetify/cli/term'
15
+ require 'assetify/cli/colored'
16
+ require 'assetify/cli'
17
17
 
18
18
  # Web Interface
19
- require "assetify/gui/server"
20
- require "assetify/gui"
19
+ require 'assetify/gui/server'
20
+ require 'assetify/gui'
@@ -1,28 +1,33 @@
1
- require "net/http"
2
- require "fileutils"
3
- require "assetify/asset/pkg"
4
- require "assetify/asset/pathfix"
1
+ require 'net/http'
2
+ require 'fileutils'
3
+ require 'assetify/asset/pkg'
4
+ require 'assetify/asset/pathfix'
5
5
 
6
6
  module Assetify
7
-
7
+ #
8
+ # What's an Asset?
9
+ #
8
10
  class Asset
9
11
  include Helpers
10
12
  attr_accessor :type, :name, :url, :ns, :pkg, :ver, :ext, :as
11
13
 
12
- def initialize(type, name, url, ver = nil, params={})
13
- raise "NoType" unless type
14
- raise "NoName" unless name
15
- raise "NoURL" unless url
16
- @type, @name = type, name.to_s
14
+ def initialize(type, name, url, ver = nil, params = {})
15
+ raise 'NoType' unless type
16
+ raise 'NoName' unless name
17
+ raise 'NoURL' unless url
18
+ @type = type
19
+ @name = name.to_s
17
20
  @url = (@ver = ver) ? url.gsub(/{VERSION}/, @ver) : url
18
21
  if @name =~ /\./
19
- @name, @ext = name.split(".")
22
+ @name, @ext = name.split('.')
20
23
  else
21
24
  @ext = @type == :img ? find_ext_for(url) : @type
22
25
  end
23
26
 
24
- @pkg, @as, @ns = params[:pkg], params[:as], params[:ns]
25
- @to = params[:to] || ""
27
+ @pkg = params[:pkg]
28
+ @as = params[:as]
29
+ @ns = params[:ns]
30
+ @to = params[:to] || ''
26
31
  end
27
32
 
28
33
  def filename
@@ -32,14 +37,14 @@ module Assetify
32
37
  @filename
33
38
  end
34
39
 
35
- def find_ext_for file
36
- file.split(".").last[0,3]
40
+ def find_ext_for(file)
41
+ file.split('.').last[0, 3]
37
42
  end
38
43
 
39
44
  #
40
45
  # Find correct path to put me
41
46
  #
42
- def find_path_for txt
47
+ def find_path_for(txt)
43
48
  case txt
44
49
  when /js/ then :javascripts
45
50
  when /css|style/ then :stylesheets
@@ -49,12 +54,12 @@ module Assetify
49
54
 
50
55
  def path
51
56
  args = if @to.empty?
52
- tpath = Opt[find_path_for(type)]
53
- raise "Don`t know where to put #{type} files..." unless tpath
54
- [tpath, @ns ? @ns.to_s : ""]
55
- else
56
- [Dir.pwd, @to]
57
- end
57
+ tpath = Opt[find_path_for(type)]
58
+ raise "Don`t know where to put #{type} files..." unless tpath
59
+ [tpath, @ns ? @ns.to_s : '']
60
+ else
61
+ [Dir.pwd, @to]
62
+ end
58
63
  @path = File.join(args)
59
64
  end
60
65
 
@@ -63,7 +68,7 @@ module Assetify
63
68
  end
64
69
 
65
70
  def file_exists?
66
- File.exists? fullpath
71
+ File.exist? fullpath
67
72
  end
68
73
 
69
74
  def data
@@ -77,6 +82,17 @@ module Assetify
77
82
  @data
78
83
  end
79
84
 
85
+ def read_data
86
+ @data = File.read(fullpath)
87
+ end
88
+
89
+ #
90
+ # Prints info about the asset (TODO: move this to cli...)
91
+ #
92
+ def header
93
+ "-> #{name}.#{type}"
94
+ end
95
+
80
96
  #
81
97
  # Asset version
82
98
  #
@@ -86,50 +102,20 @@ module Assetify
86
102
  end
87
103
 
88
104
  def print_version
89
- return "" unless ver
105
+ return '' unless ver
106
+ # chop to only first 10 chars if it's big hash
90
107
  ver_str = ver.size > 10 ? ver[0..10] : ver[0]
91
108
  "v#{ver_str}"
92
109
  end
93
110
 
94
- #
95
- # Prints info about the asset (TODO: move this to cli...)
96
- #
97
- def header
98
- LINE.p "-> #{name}.#{type}"
99
- end
100
-
101
- def check!
102
- header
103
- if file_exists? # Return if file is on path
104
- @data = File.read(fullpath)
105
- LINE.f "#{print_version}Installed"
106
- else
107
- LINE.f "Not Found", :red
108
- end
109
- end
110
-
111
111
  #
112
112
  # Write down asset to disk
113
113
  #
114
- def install!(force = false)
115
- header
116
- if !force && file_exists? # Return if file is on path
117
- @data = File.read(fullpath)
118
- return LINE.f "#{print_version}Installed"
119
- end
120
- begin
121
- # Creates a thread to insert dots while downloading
122
- points = Thread.new { loop do; LINE.p "."; sleep 1; end }
123
-
124
- write data
125
- LINE.f "#{print_version}ok"
126
- rescue => e
127
- LINE.f :FAIL, :red
128
- p "Fail: #{e} #{e.backtrace}"
129
- ensure
130
- points.kill
131
- end
132
-
114
+ def install!(_force = false)
115
+ write data
116
+ rescue => e
117
+ LINE.f :FAIL, :red
118
+ p "Fail: #{e} #{e.backtrace}"
133
119
  end
134
120
 
135
121
  class << self
@@ -140,15 +126,12 @@ module Assetify
140
126
  @all ||= Assetfile.read
141
127
  end
142
128
 
143
- def filter params
129
+ def filter(params)
144
130
  all.select do |a|
145
131
  blob = "#{a.name}#{a.pkg.name if a.pkg}"
146
132
  blob.include? params
147
133
  end
148
134
  end
149
-
150
135
  end
151
-
152
136
  end
153
-
154
137
  end