view_assets 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/view_assets/assets_finder.rb +3 -0
- data/lib/view_assets/directives.rb +3 -1
- data/lib/view_assets/js_assets.rb +1 -1
- data/lib/view_assets/version.rb +1 -1
- data/lib/view_assets.rb +9 -9
- data/readme.md +23 -6
- data/test/dummy/log/development.log +90 -0
- data/test/dummy/public/app/javascripts/application.js +1 -1
- data/test/dummy/public/app/stylesheets/application.css +1 -3
- metadata +2 -2
@@ -128,6 +128,7 @@ module ViewAssets
|
|
128
128
|
|
129
129
|
private
|
130
130
|
|
131
|
+
# start point of parsing dependent assets
|
131
132
|
def retrieve_assets_from(manifest)
|
132
133
|
assets = []
|
133
134
|
directive = Directive.new(asset_type)
|
@@ -135,6 +136,7 @@ module ViewAssets
|
|
135
136
|
Pathname.new(manifest).each_line do |line|
|
136
137
|
# break if directive.ending_directive?(l) # TODO add ending_directive support
|
137
138
|
next unless directive.legal_directive?(line)
|
139
|
+
|
138
140
|
assets.concat(analyze(*directive.parse(line)))
|
139
141
|
end
|
140
142
|
|
@@ -175,6 +177,7 @@ module ViewAssets
|
|
175
177
|
#
|
176
178
|
# NOTE: All assets returned will be "unabsolutely_pathized" here. That
|
177
179
|
# means each string of file path does not contain any root path info.
|
180
|
+
# todo BUG => can't retrieve assets with slash-asterisk(/*= xxx */) directive.
|
178
181
|
def meta_retrieve(manifest_path, manifest)
|
179
182
|
single_file_lib = absolutely_pathize("#{ manifest_path }/#{ manifest }")
|
180
183
|
|
@@ -83,6 +83,8 @@ module ViewAssets
|
|
83
83
|
#
|
84
84
|
# TODO refactor: use reasonable and effective regular expression
|
85
85
|
# TODO use "require_app" as app asset directive and make "require" as a relative directive
|
86
|
+
# TODO BUG => rspec examples is unqualified on slash-asterisk syntax for css
|
87
|
+
# can't detect mistakes like this: `^/\*=\s#{requiring_type}\s(?<path_params>.*)*\s\*/$`
|
86
88
|
def generate_formula(requiring_type = 'require')
|
87
89
|
if javascript? asset_type
|
88
90
|
%r{
|
@@ -96,7 +98,7 @@ module ViewAssets
|
|
96
98
|
%r{
|
97
99
|
^\s\*=\s#{requiring_type}\s(?<path_params>.*)$ # space-asterisk syntax
|
98
100
|
|
|
99
|
-
^/\*=\s#{requiring_type}\s(?<path_params>.*)
|
101
|
+
^/\*=\s#{requiring_type}\s(?<path_params>.*)\s\*/$ # slash-asterisk syntax
|
100
102
|
}x
|
101
103
|
end
|
102
104
|
end
|
data/lib/view_assets/version.rb
CHANGED
data/lib/view_assets.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
##
|
2
|
-
#
|
2
|
+
# Introduction is in readme.md
|
3
3
|
module ViewAssets
|
4
|
-
#
|
5
|
-
#
|
4
|
+
# TODO figure out why can't use require in this case
|
5
|
+
# TODO find another way to include rake tasks, this method seems weird.
|
6
6
|
load 'tasks/view_assets_tasks.rake' if defined?(Rake)
|
7
|
-
|
7
|
+
|
8
8
|
require 'pathname'
|
9
9
|
|
10
10
|
require 'view_assets/error'
|
@@ -16,16 +16,16 @@ module ViewAssets
|
|
16
16
|
##
|
17
17
|
# To verify all assets and throw exception when find out inexistent asset
|
18
18
|
# Defaults to turn off. DO NOT use it in production.
|
19
|
-
#
|
19
|
+
# TODO find out how to document constant.
|
20
20
|
TO_VERIFY = false
|
21
|
-
|
21
|
+
|
22
22
|
attr_accessor :js_assets, :css_assets
|
23
|
-
|
24
|
-
# TODO need a new controller-action configuring interface, try to configure them in helper instead of view files
|
23
|
+
|
24
|
+
# TODO need a new controller-action configuring interface, try to configure them in helper instead of view files.
|
25
25
|
def include_assets_with_assets_mvc(controller, action)
|
26
26
|
@va_controller = controller
|
27
27
|
@va_action = action
|
28
|
-
|
28
|
+
|
29
29
|
raw [css_assets.all, js_assets.all].flatten.uniq.join("\n ")
|
30
30
|
end
|
31
31
|
|
data/readme.md
CHANGED
@@ -1,16 +1,33 @@
|
|
1
1
|
# ViewAssets
|
2
|
+
A new method to manage assets in a rails project.
|
3
|
+
Instead of using the default assets managing style in rails 3.2, this gem will introduce a new way to manage your assets.
|
4
|
+
This is only a prototype of the whole project, the fullfledged version will publish soon.
|
5
|
+
It works like assetpipeline, but comes with different conventions. It doesn't include all your assets simply even if you have view/page or controller specific assets. It is page-specific.
|
2
6
|
|
3
|
-
##
|
7
|
+
## Conventions/Rules
|
4
8
|
|
5
|
-
|
9
|
+
According to ViewAssets, there are three folders in `/public` folder:
|
6
10
|
|
7
|
-
|
11
|
+
* vendor
|
12
|
+
* lib
|
13
|
+
* app
|
8
14
|
|
9
|
-
|
15
|
+
Each sence of them are the same as in rails3 assetpipeline.
|
16
|
+
|
17
|
+
## DIRECTIVES
|
18
|
+
|
19
|
+
for javascript
|
20
|
+
double-slash syntax => "//= require_vendor xxx"
|
21
|
+
space-asterisk syntax => " *= require_vendor xxx"
|
22
|
+
slash-asterisk syntax => "/*= require_vendor xxx */"
|
23
|
+
|
24
|
+
for stylesheets
|
25
|
+
space-asterisk syntax => " *= require_vendor xxx"
|
26
|
+
slash-asterisk syntax => "/*= require_vendor xxx */"
|
10
27
|
|
11
28
|
## Usage
|
12
29
|
|
13
|
-
|
30
|
+
First, include `ViewAssets` in `helpers/application_helper.rb`
|
14
31
|
|
15
32
|
```ruby
|
16
33
|
module ApplicationHelper
|
@@ -26,4 +43,4 @@ Add some other codes in your `views/layouts/application.html.rb`
|
|
26
43
|
|
27
44
|
If some of your controllers use their own layout file, and following rules in ViewAssets, then you should add that code above too.
|
28
45
|
|
29
|
-
This project rocks and uses MIT-LICENSE.
|
46
|
+
This project rocks and uses MIT-LICENSE.
|
@@ -1544,3 +1544,93 @@ Started GET "/foo/index" for 127.0.0.1 at 2013-01-03 15:33:55 +0800
|
|
1544
1544
|
Processing by FooController#index as HTML
|
1545
1545
|
Rendered foo/index.html.erb within layouts/application (0.0ms)
|
1546
1546
|
Completed 200 OK in 4ms (Views: 4.1ms | ActiveRecord: 0.0ms)
|
1547
|
+
|
1548
|
+
|
1549
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-03 16:21:52 +0800
|
1550
|
+
Connecting to database specified by database.yml
|
1551
|
+
Processing by FooController#index as HTML
|
1552
|
+
Rendered foo/index.html.erb within layouts/application (2.9ms)
|
1553
|
+
Completed 200 OK in 25ms (Views: 24.3ms | ActiveRecord: 0.0ms)
|
1554
|
+
|
1555
|
+
|
1556
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-03 16:24:48 +0800
|
1557
|
+
Processing by FooController#index as HTML
|
1558
|
+
Rendered foo/index.html.erb within layouts/application (0.0ms)
|
1559
|
+
Completed 200 OK in 4ms (Views: 4.1ms | ActiveRecord: 0.0ms)
|
1560
|
+
|
1561
|
+
|
1562
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-03 16:25:51 +0800
|
1563
|
+
Connecting to database specified by database.yml
|
1564
|
+
Processing by FooController#index as HTML
|
1565
|
+
Rendered foo/index.html.erb within layouts/application (2.6ms)
|
1566
|
+
Completed 200 OK in 56ms (Views: 55.1ms | ActiveRecord: 0.0ms)
|
1567
|
+
|
1568
|
+
|
1569
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-03 16:26:22 +0800
|
1570
|
+
Processing by FooController#index as HTML
|
1571
|
+
Rendered foo/index.html.erb within layouts/application (0.0ms)
|
1572
|
+
Completed 200 OK in 4ms (Views: 4.2ms | ActiveRecord: 0.0ms)
|
1573
|
+
|
1574
|
+
|
1575
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 10:56:39 +0800
|
1576
|
+
Connecting to database specified by database.yml
|
1577
|
+
Processing by FooController#index as HTML
|
1578
|
+
Rendered foo/index.html.erb within layouts/application (66.8ms)
|
1579
|
+
Completed 200 OK in 396ms (Views: 396.0ms | ActiveRecord: 0.0ms)
|
1580
|
+
|
1581
|
+
|
1582
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 10:58:26 +0800
|
1583
|
+
Processing by FooController#index as HTML
|
1584
|
+
Rendered foo/index.html.erb within layouts/application (0.0ms)
|
1585
|
+
Completed 200 OK in 4ms (Views: 3.9ms | ActiveRecord: 0.0ms)
|
1586
|
+
|
1587
|
+
|
1588
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 10:58:33 +0800
|
1589
|
+
Connecting to database specified by database.yml
|
1590
|
+
Processing by FooController#index as HTML
|
1591
|
+
Rendered foo/index.html.erb within layouts/application (40.4ms)
|
1592
|
+
Completed 200 OK in 56ms (Views: 55.2ms | ActiveRecord: 0.0ms)
|
1593
|
+
|
1594
|
+
|
1595
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 11:02:01 +0800
|
1596
|
+
Processing by FooController#index as HTML
|
1597
|
+
Rendered foo/index.html.erb within layouts/application (0.0ms)
|
1598
|
+
Completed 200 OK in 5ms (Views: 4.9ms | ActiveRecord: 0.0ms)
|
1599
|
+
|
1600
|
+
|
1601
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 11:03:03 +0800
|
1602
|
+
Processing by FooController#index as HTML
|
1603
|
+
Rendered foo/index.html.erb within layouts/application (0.0ms)
|
1604
|
+
Completed 200 OK in 4ms (Views: 3.7ms | ActiveRecord: 0.0ms)
|
1605
|
+
|
1606
|
+
|
1607
|
+
Started GET "/bar/index" for 127.0.0.1 at 2013-01-04 11:03:12 +0800
|
1608
|
+
Processing by BarController#index as HTML
|
1609
|
+
Rendered bar/index.html.erb within layouts/application (0.4ms)
|
1610
|
+
Completed 200 OK in 6ms (Views: 5.4ms | ActiveRecord: 0.0ms)
|
1611
|
+
|
1612
|
+
|
1613
|
+
Started GET "/bar/index" for 127.0.0.1 at 2013-01-04 11:03:42 +0800
|
1614
|
+
Connecting to database specified by database.yml
|
1615
|
+
Processing by BarController#index as HTML
|
1616
|
+
Rendered bar/index.html.erb within layouts/application (2.6ms)
|
1617
|
+
Completed 200 OK in 18ms (Views: 17.0ms | ActiveRecord: 0.0ms)
|
1618
|
+
|
1619
|
+
|
1620
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 15:35:14 +0800
|
1621
|
+
Processing by FooController#index as HTML
|
1622
|
+
Rendered foo/index.html.erb within layouts/application (23.7ms)
|
1623
|
+
Completed 200 OK in 216ms (Views: 202.3ms | ActiveRecord: 0.0ms)
|
1624
|
+
|
1625
|
+
|
1626
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 15:40:36 +0800
|
1627
|
+
Connecting to database specified by database.yml
|
1628
|
+
Processing by FooController#index as HTML
|
1629
|
+
Rendered foo/index.html.erb within layouts/application (2.9ms)
|
1630
|
+
Completed 200 OK in 47ms (Views: 46.0ms | ActiveRecord: 0.0ms)
|
1631
|
+
|
1632
|
+
|
1633
|
+
Started GET "/foo/index" for 127.0.0.1 at 2013-01-04 15:40:41 +0800
|
1634
|
+
Processing by FooController#index as HTML
|
1635
|
+
Rendered foo/index.html.erb within layouts/application (0.1ms)
|
1636
|
+
Completed 200 OK in 4ms (Views: 3.9ms | ActiveRecord: 0.0ms)
|
@@ -1,2 +1,2 @@
|
|
1
1
|
//= require_vendor vendor1
|
2
|
-
|
2
|
+
/*= require_lib lib1 */
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
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: 2013-01-
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|