npm_assets 0.0.2 → 0.0.3
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/README.markdown +14 -21
- data/lib/npm_assets/version.rb +1 -1
- data/lib/tasks/npm_assets.rake +5 -1
- metadata +4 -4
data/README.markdown
CHANGED
@@ -10,33 +10,26 @@ javascript world for distributing and packaging libraries (think rubygems). How
|
|
10
10
|
just use that, rather than have to go make asset gems for each javascript library we
|
11
11
|
want to use?
|
12
12
|
|
13
|
+
## Prerequisites
|
14
|
+
|
15
|
+
You'll need npm and node installed for this all to work.
|
16
|
+
|
13
17
|
## How?
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
"version": "0.0.1",
|
21
|
-
"dependencies": {
|
22
|
-
"coffeekup": "",
|
23
|
-
"backbone": ""
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
Then,
|
19
|
+
In your app, to actually bring in the codez, we've added a new directive to indicate which
|
20
|
+
npms your application requires. Use it just like reuiqre
|
21
|
+
|
22
|
+
#= require_npm underscore
|
23
|
+
#= require_npm backbone
|
28
24
|
|
29
|
-
|
25
|
+
Next, to actually grab those npms, we have rake task which creates or modifies a package.json file
|
26
|
+
and does an "npm install":
|
27
|
+
|
28
|
+
$ rake npm_assets:install
|
30
29
|
|
31
30
|
This will grab the dependencies and pop em in a node_modules directory. This gem
|
32
31
|
will then come along and add the appropriate directories from within
|
33
|
-
each module to the asset path
|
34
|
-
|
35
|
-
In your app, to actually bring in the codez, it's just a normal require
|
36
|
-
directive:
|
37
|
-
|
38
|
-
//= require underscore
|
39
|
-
//= require backbone
|
32
|
+
each module to the asset path.
|
40
33
|
|
41
34
|
## Why not?
|
42
35
|
|
data/lib/npm_assets/version.rb
CHANGED
data/lib/tasks/npm_assets.rake
CHANGED
@@ -10,7 +10,11 @@ namespace :npm_assets do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
puts npms.inspect
|
13
|
-
|
13
|
+
if File.exist?("package.json")
|
14
|
+
pkg = ActiveSupport::JSON.decode(File.read("package.json"))
|
15
|
+
else
|
16
|
+
pkg = {"name" => Rails.application.class.parent.to_s, "version" => "0.0.1", "dependencies" => {}}
|
17
|
+
end
|
14
18
|
npms.each do |npm|
|
15
19
|
pkg["dependencies"][npm] = "*" unless pkg["dependencies"].keys.include?(npm)
|
16
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: npm_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-04 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153444080 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '3.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153444080
|
26
26
|
description:
|
27
27
|
email:
|
28
28
|
- chris@gaslightsoftware.com
|