zassets 0.2.10 → 0.2.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7744be16bae574b350ba874a1bb0e3cd5591f07
4
- data.tar.gz: 8b4da81c7eb6ee792c6760b9f59a8e5720d4f434
3
+ metadata.gz: 323d8d4e0b559e1f3914ff27117143f15a17d24d
4
+ data.tar.gz: b2dfb8c562c3e615403b58a329289d15d373e061
5
5
  SHA512:
6
- metadata.gz: d97295f205196173b4d4eb36ceada670e7880826593724cc1460c3cf520a816624f42b4215234b3ae107e1b820dac84c79ba66b2b6041c02d913a0fb93cd11b0
7
- data.tar.gz: 95cf5e5c8a2204b5277627fc910d13a4d7ccf34b6b2d299501b26cff20107c1cbd04d758d2f3f5aaab2dbf024fbac663dbf88b67823f6790ccd35570007377ef
6
+ metadata.gz: d7899d48b1de3c145349c3c06d529284458948279e88815b23cef0a83974aed41968ed8a0f86bc37a73956577787cfc5b4e4f90904ab00472502986aa6f40798
7
+ data.tar.gz: cce98925320625cf2fc87fdb478f2cb42f7db99d04d108cbe519e40f598d59598f55a45f13a11c5d62c4e37a8a7fa2b5b40de929e87423c9562c689f2943dca9
@@ -1,11 +1,10 @@
1
- require 'zassets/version'
2
1
  require 'coffee_script'
2
+ require 'sass'
3
3
 
4
- module ZAssets
5
- autoload :CLI, 'zassets/cli'
6
- autoload :Builder, 'zassets/builder'
7
- autoload :Config, 'zassets/config'
8
- autoload :MemoryFile, 'zassets/memory_file'
9
- autoload :Server, 'zassets/server'
10
- autoload :SprocketsEnv, 'zassets/sprockets_env'
11
- end
4
+ require 'zassets/builder'
5
+ require 'zassets/cli'
6
+ require 'zassets/config'
7
+ require 'zassets/memory_file'
8
+ require 'zassets/server'
9
+ require 'zassets/sprockets_env'
10
+ require 'zassets/version'
@@ -2,16 +2,16 @@ require 'sprockets'
2
2
 
3
3
  module ZAssets
4
4
  class Builder
5
- MANIFEST_FILENAME = 'manifest.json'
5
+ MANIFEST_FILENAME = 'manifest.json'.freeze
6
6
 
7
7
  attr_writer :manifest
8
8
 
9
- def initialize(config)
9
+ def initialize config
10
10
  @config = config
11
11
  end
12
12
 
13
13
  def build
14
- manifest.compile(@config[:build])
14
+ manifest.compile @config[:build]
15
15
  end
16
16
 
17
17
  def manifest
@@ -2,41 +2,38 @@ require 'optparse'
2
2
 
3
3
  module ZAssets
4
4
  class CLI
5
- ACTIONS = %w(build serve)
5
+ ACTIONS = %w[build serve].freeze
6
6
 
7
7
  attr_reader :options, :action
8
8
 
9
- def initialize(args, stdout = $stdout)
9
+ def initialize args, stdout = $stdout
10
10
  @stdout = stdout
11
11
  @action = :build
12
12
  args_parse! args
13
13
  end
14
14
 
15
15
  def config
16
- @config ||= Config.new @options
16
+ @config ||= Config.new(@options)
17
17
  end
18
18
 
19
19
  def run
20
20
  case @action
21
- when :serve
22
- server.run
23
- when :build
24
- builder.build
21
+ when :serve then server.run
22
+ when :build then builder.build
25
23
  end
26
24
  end
27
25
 
28
26
  def builder
29
- @builder ||= Builder.new config
27
+ @builder ||= Builder.new(config)
30
28
  end
31
29
 
32
30
  def server
33
- @server ||= Server.new config
31
+ @server ||= Server.new(config)
34
32
  end
35
33
 
34
+ private
36
35
 
37
- private
38
-
39
- def args_parse!(args)
36
+ def args_parse! args
40
37
  options = {}
41
38
  parser = OptionParser.new do |o|
42
39
  o.banner = "Usage: #{File.basename $0} [options] [build|serve]"
@@ -2,7 +2,7 @@ require 'yaml'
2
2
 
3
3
  module ZAssets
4
4
  class Config
5
- DEFAULT_CONFIG_PATH = 'config/zassets.yaml'
5
+ DEFAULT_CONFIG_PATH = 'config/zassets.yaml'.freeze
6
6
 
7
7
  DEFAULT_OPTIONS = {
8
8
  verbose: false,
@@ -16,9 +16,9 @@ module ZAssets
16
16
  public_path: 'public',
17
17
  build_path: 'public/assets',
18
18
  build: []
19
- }
19
+ }.freeze
20
20
 
21
- def initialize(options = {})
21
+ def initialize **options
22
22
  o = default_options
23
23
  o.merge! load_options if default_config_file?
24
24
  o.merge! load_options(options[:config_file]) if options[:config_file]
@@ -31,36 +31,34 @@ module ZAssets
31
31
  DEFAULT_OPTIONS.dup
32
32
  end
33
33
 
34
- def load_options(filepath = DEFAULT_CONFIG_PATH)
34
+ def load_options filepath = DEFAULT_CONFIG_PATH
35
35
  return {} unless options = YAML.load_file(filepath)
36
36
  symbolize_keys options
37
37
  end
38
38
 
39
39
  def default_config_file?
40
- File.exist? DEFAULT_CONFIG_PATH
40
+ File.exist?(DEFAULT_CONFIG_PATH)
41
41
  end
42
42
 
43
43
  def register_plugins!
44
44
  return unless load_plugins!
45
-
46
45
  ::ZAssets::Plugins.constants.each do |plugin_module_name|
47
46
  plugin_module = ::ZAssets::Plugins.const_get(plugin_module_name)
48
47
  plugin_module::Registrant.new(self).register
49
48
  end
50
49
  end
51
50
 
52
- def [](key)
51
+ def [] key
53
52
  @options[key]
54
53
  end
55
54
 
56
- def []=(key, value)
55
+ def []= key, value
57
56
  @options[key] = value
58
57
  end
59
58
 
59
+ private
60
60
 
61
- private
62
-
63
- def symbolize_keys(hash)
61
+ def symbolize_keys hash
64
62
  case hash
65
63
  when Hash
66
64
  Hash[hash.map do |k, v|
@@ -80,7 +78,6 @@ module ZAssets
80
78
  when Symbol, String then plugin
81
79
  end
82
80
  end
83
-
84
81
  ::ZAssets.const_defined? :Plugins
85
82
  end
86
83
  end
@@ -1,3 +1,4 @@
1
1
  module ZAssets
2
- class ArgumentError < ::ArgumentError; end
2
+ Error = Class.new(StandardError)
3
+ ArgumentError = Class.new(Error)
3
4
  end
@@ -1,6 +1,6 @@
1
1
  module ZAssets
2
2
  class MemoryFile
3
- def initialize(file)
3
+ def initialize file
4
4
  @file = file
5
5
  end
6
6
 
@@ -15,7 +15,7 @@ module ZAssets
15
15
  @content ||= @file.read
16
16
  end
17
17
 
18
- def call(env)
18
+ def call _env
19
19
  [200, headers, [body]]
20
20
  end
21
21
  end
@@ -2,13 +2,13 @@ require 'rack'
2
2
 
3
3
  module ZAssets
4
4
  class Server
5
- def initialize(config)
5
+ def initialize config
6
6
  @config = config
7
7
  end
8
8
 
9
9
  def run
10
10
  handler.run app, options do |server|
11
- [:INT, :TERM].each do |sig|
11
+ %i[INT TERM].each do |sig|
12
12
  trap(sig) { server.respond_to?(:stop!) ? server.stop! : server.stop }
13
13
  end
14
14
  end
@@ -39,7 +39,7 @@ module ZAssets
39
39
  end
40
40
 
41
41
  map '/' do
42
- static_files = Rack::File.new config[:public_path]
42
+ static_files = Rack::File.new(config[:public_path])
43
43
 
44
44
  if config[:public_file]
45
45
  run Rack::Cascade.new([
@@ -2,14 +2,11 @@ require 'sprockets'
2
2
 
3
3
  module ZAssets
4
4
  class SprocketsEnv < Sprockets::Environment
5
- def initialize(config)
5
+ def initialize config
6
6
  super '.'
7
-
8
7
  logger.level = Logger::DEBUG if config[:verbose]
9
-
10
8
  config[:engines].each { |ext, engine| register_engine ext, engine }
11
-
12
- config[:paths].each { |p| append_path p }
9
+ config[:paths].each { |p| append_path p }
13
10
  end
14
11
  end
15
12
  end
@@ -1,3 +1,3 @@
1
1
  module ZAssets
2
- VERSION = '0.2.10'
2
+ VERSION = '0.2.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zassets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
@@ -201,5 +201,6 @@ rubyforge_project:
201
201
  rubygems_version: 2.4.5
202
202
  signing_key:
203
203
  specification_version: 4
204
- summary: zassets-0.2.10
204
+ summary: zassets-0.2.11
205
205
  test_files: []
206
+ has_rdoc: