yarrow 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/yarrow +2 -2
- data/bin/yarrow-server +13 -0
- data/lib/yarrow/assets/manifest.rb +55 -1
- data/lib/yarrow/assets/pipeline.rb +9 -2
- data/lib/yarrow/server.rb +17 -0
- data/lib/yarrow/version.rb +2 -2
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b51706470a2ed364a5f75a8afd814d790377c37d
|
4
|
+
data.tar.gz: 429742706a961398946fec5082e0fcdec4bc0e43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b7fe451cbe5df3b2c2e5b38e99e3274a57118059099f7477ac2d577694edc5307bed004e8ab61d3e2580b803f318120b6001184df5a0a09a8168a25a5c97839
|
7
|
+
data.tar.gz: f80b00ea6ed50906e5d68b81c34564cea2e6a5664aeca76c95e0ef138133e50c035677c1948953f1151a88b5d608412eb6271508ea1f37b9b86db45edbfd111b
|
data/bin/yarrow
CHANGED
@@ -5,9 +5,9 @@ path = __FILE__
|
|
5
5
|
while File.symlink?(path)
|
6
6
|
path = File.expand_path(File.readlink(path), File.dirname(path))
|
7
7
|
end
|
8
|
-
$:.unshift(File.join(File.dirname(File.expand_path(path)),
|
8
|
+
$:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
|
9
9
|
|
10
|
-
require
|
10
|
+
require 'yarrow'
|
11
11
|
|
12
12
|
app = Yarrow::ConsoleRunner.new ARGV
|
13
13
|
app.run_application
|
data/bin/yarrow-server
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# load path annoyance
|
4
|
+
path = __FILE__
|
5
|
+
while File.symlink?(path)
|
6
|
+
path = File.expand_path(File.readlink(path), File.dirname(path))
|
7
|
+
end
|
8
|
+
$:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
|
9
|
+
|
10
|
+
require 'yarrow'
|
11
|
+
require 'yarrow/server'
|
12
|
+
|
13
|
+
Yarrow::Server.run
|
@@ -3,12 +3,23 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Yarrow
|
5
5
|
module Assets
|
6
|
-
|
7
6
|
##
|
8
7
|
# Provides access to the bundle of compiled CSS and JS assets.
|
8
|
+
#
|
9
|
+
# This is currently based on the output structure of the JSON manifest file
|
10
|
+
# generated by Sprockets, but this class isn't coupled to the Sprockets API
|
11
|
+
# so could be used as a generic manifest reader.
|
12
|
+
#
|
13
|
+
# - `logical_path` represents the core named path to an asset sans version, eg: `main.css`
|
14
|
+
# - `digest_path` represents the versioned instance of an asset with associated digest,
|
15
|
+
# eg: `main-4362eea15558e73d3663de653cdeb81e.css`
|
9
16
|
class Manifest
|
10
17
|
|
11
18
|
##
|
19
|
+
# Initializes the manifest from a Sprockets-style JSON file.
|
20
|
+
#
|
21
|
+
# If no assets directory is given, looks for a manifest in the main output directory.
|
22
|
+
#
|
12
23
|
# @param config [Yarrow::Configuration]
|
13
24
|
def initialize(config)
|
14
25
|
raise Yarrow::ConfigurationError if config.assets.nil?
|
@@ -29,42 +40,85 @@ module Yarrow
|
|
29
40
|
end
|
30
41
|
end
|
31
42
|
|
43
|
+
##
|
44
|
+
# True if the named asset exists.
|
45
|
+
#
|
46
|
+
# @param logical_path [String]
|
47
|
+
# @return Boolean
|
32
48
|
def exists?(logical_path)
|
33
49
|
@manifest_index['assets'].key? logical_path
|
34
50
|
end
|
35
51
|
|
52
|
+
##
|
53
|
+
# Returns the generated digest path to a named asset.
|
54
|
+
#
|
55
|
+
# @param logical_path [String]
|
56
|
+
# @return [String]
|
36
57
|
def digest_path(logical_path)
|
37
58
|
@manifest_index['assets'][logical_path]
|
38
59
|
end
|
39
60
|
|
61
|
+
##
|
62
|
+
# Returns a hash of file information for a generated asset.
|
63
|
+
#
|
64
|
+
# @param logical_path [String]
|
65
|
+
# @return [Hash]
|
40
66
|
def file(logical_path)
|
41
67
|
@manifest_index['files'][digest_path(logical_path)]
|
42
68
|
end
|
43
69
|
|
70
|
+
##
|
71
|
+
# Returns the list of named assets in the manifest.
|
72
|
+
#
|
73
|
+
# @return [Array<String>]
|
44
74
|
def logical_paths
|
45
75
|
@manifest_index['assets'].keys
|
46
76
|
end
|
47
77
|
|
78
|
+
##
|
79
|
+
# Returns the list of generated digest paths in the manifest.
|
80
|
+
#
|
81
|
+
# @return [Array<String>]
|
48
82
|
def digest_paths
|
49
83
|
@manifest_index['files'].keys
|
50
84
|
end
|
51
85
|
|
86
|
+
##
|
87
|
+
# Returns the list of generated files in the manifest.
|
88
|
+
#
|
89
|
+
# @return [Array<Hash>]
|
52
90
|
def files
|
53
91
|
@manifest_index['files'].values
|
54
92
|
end
|
55
93
|
|
94
|
+
##
|
95
|
+
# Returns the list of named CSS assets in the manifest.
|
96
|
+
#
|
97
|
+
# @return [Array<String>]
|
56
98
|
def css_logical_paths
|
57
99
|
select_by_extension(logical_paths, '.css')
|
58
100
|
end
|
59
101
|
|
102
|
+
##
|
103
|
+
# Returns the list of named JS assets in the manifest.
|
104
|
+
#
|
105
|
+
# @return [Array<String>]
|
60
106
|
def js_logical_paths
|
61
107
|
select_by_extension(logical_paths, '.js')
|
62
108
|
end
|
63
109
|
|
110
|
+
##
|
111
|
+
# Returns the list of generated CSS assets in the manifest.
|
112
|
+
#
|
113
|
+
# @return [Array<String>]
|
64
114
|
def css_digest_paths
|
65
115
|
select_by_extension(digest_paths, '.css')
|
66
116
|
end
|
67
117
|
|
118
|
+
##
|
119
|
+
# Returns the list of generated JS assets in the manifest.
|
120
|
+
#
|
121
|
+
# @return [Array<String>]
|
68
122
|
def js_digest_paths
|
69
123
|
select_by_extension(digest_paths, '.js')
|
70
124
|
end
|
@@ -5,7 +5,7 @@ require 'sprockets'
|
|
5
5
|
module Yarrow
|
6
6
|
module Assets
|
7
7
|
##
|
8
|
-
#
|
8
|
+
# Processes static assets using Sprockets.
|
9
9
|
class Pipeline
|
10
10
|
|
11
11
|
include Loggable
|
@@ -41,8 +41,10 @@ module Yarrow
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
##
|
44
45
|
# Compiles an asset manifest and processed output files from the given input bundles.
|
45
46
|
# Also generates a manifest linking each output bundle to its given input name.
|
47
|
+
#
|
46
48
|
# @param bundles [Array<String>]
|
47
49
|
def compile(bundles = [])
|
48
50
|
bundles.each do |bundle|
|
@@ -58,7 +60,9 @@ module Yarrow
|
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
63
|
+
##
|
61
64
|
# Copy the given files to the output path without processing or renaming.
|
65
|
+
#
|
62
66
|
# @param bundle [Array<String>]
|
63
67
|
def copy(bundles = [])
|
64
68
|
bundles.each do |bundle|
|
@@ -79,9 +83,12 @@ module Yarrow
|
|
79
83
|
manifest.clean(keep)
|
80
84
|
end
|
81
85
|
|
86
|
+
##
|
82
87
|
# Access instance of the Sprockets environment.
|
83
|
-
#
|
88
|
+
#
|
89
|
+
# @return [Sprockets::Environment]
|
84
90
|
def environment
|
91
|
+
# TODO: decouple dependency on Sprockets
|
85
92
|
@environment ||= create_environment
|
86
93
|
end
|
87
94
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
module Yarrow
|
4
|
+
##
|
5
|
+
# Little server for viewing the generated output as a local website.
|
6
|
+
class Server
|
7
|
+
|
8
|
+
def self.run
|
9
|
+
local_server = Rack::Builder.new do
|
10
|
+
run Rack::Directory.new(Dir.pwd)
|
11
|
+
end
|
12
|
+
|
13
|
+
Rack::Handler.default.run(local_server, :port => 8080)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/yarrow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yarrow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,10 +141,12 @@ description: Yarrow is a tool for generating well structured documentation from
|
|
127
141
|
email: me@maetl.net
|
128
142
|
executables:
|
129
143
|
- yarrow
|
144
|
+
- yarrow-server
|
130
145
|
extensions: []
|
131
146
|
extra_rdoc_files: []
|
132
147
|
files:
|
133
148
|
- bin/yarrow
|
149
|
+
- bin/yarrow-server
|
134
150
|
- lib/yarrow.rb
|
135
151
|
- lib/yarrow/assets.rb
|
136
152
|
- lib/yarrow/assets/manifest.rb
|
@@ -149,6 +165,7 @@ files:
|
|
149
165
|
- lib/yarrow/output/context.rb
|
150
166
|
- lib/yarrow/output/generator.rb
|
151
167
|
- lib/yarrow/output/mapper.rb
|
168
|
+
- lib/yarrow/server.rb
|
152
169
|
- lib/yarrow/tools/front_matter.rb
|
153
170
|
- lib/yarrow/version.rb
|
154
171
|
homepage: http://rubygemspec.org/gems/yarrow
|