linner 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 585082427c02565f16f135a1f1cc56a284ee92c3
4
- data.tar.gz: 7f7e21241ec1504e63073b952e4c818b62709923
3
+ metadata.gz: 23a2780b01c0a039f16e2c30ca97c7dbcb383673
4
+ data.tar.gz: c5f70fa15527c208f8bab35ff64a03009bbd0e2c
5
5
  SHA512:
6
- metadata.gz: 92642b5fdca72bac9283cdd9b9e8b97f537cfeabcd29a7ebe8a4c2e523fa6fe9cf591e912e9b903cedf756afe46ec64f69092c7fefc7cf6755aae596f45467cc
7
- data.tar.gz: 05d9d83205b4ba55c49cc97864285a54cf5166f30ff7ed44783f28fccbd1c8649cf2b5d1765603333973d0180f73346b8ae3256c21b04f0e67e3fe80d2a9443d
6
+ metadata.gz: 6cccf5a5ac4175c46267f9ff1985ebd0deefdd13697f107ad43e3d544879ed597661b79176d878066c1eb57c079c6737064f1ebac5d4439988338e17b6ed8e9c
7
+ data.tar.gz: 745643de1507e32f3c35f3cf38ee41039c490716de0c6dced3e1e275b7851067e02321971cd67fad0ef59f8d2445a11e93afb37a9130a4676f6c78769b5cac9e
data/CHANGELOG CHANGED
@@ -1,5 +1,10 @@
1
+ v0.6.2
2
+ - fix bin-packing algo problem
3
+ - add auto reload environment support
4
+ - add native path bundle support
5
+
1
6
  v0.6.1
2
- - use `hpricot` to instead of `nokogiri`, because `nokogiri` has parse problem when `revision`.
7
+ - use `hpricot` to instead of `nokogiri`, because `nokogiri` has parse problem when `revision`
3
8
 
4
9
  v0.6.0
5
10
  - add sprites support
data/lib/linner.rb CHANGED
@@ -20,18 +20,20 @@ Encoding.default_internal = Encoding::UTF_8
20
20
  module Linner
21
21
  extend self
22
22
 
23
- attr_accessor :compile
23
+ attr_accessor :env, :compile
24
24
 
25
25
  def root
26
26
  @root ||= Pathname('.').expand_path
27
27
  end
28
28
 
29
+ def config_file
30
+ linner_file = root.join("Linnerfile")
31
+ config_file = root.join("config.yml")
32
+ File.exist?(linner_file) ? linner_file : config_file
33
+ end
34
+
29
35
  def env
30
- @env ||= Environment.new begin
31
- linner_file = root.join("Linnerfile")
32
- config_file = root.join("config.yml")
33
- File.exist?(linner_file) ? linner_file : config_file
34
- end
36
+ @env ||= Environment.new config_file
35
37
  end
36
38
 
37
39
  def cache
@@ -42,8 +44,19 @@ module Linner
42
44
  @manifest ||= begin
43
45
  hash = {}
44
46
  env.groups.each do |config|
45
- config["concat"].to_h.each do |dest, pattern|
47
+ concat_assets = template_assets = copy_assets = []
48
+ concat_assets = config["concat"].keys if config["concat"]
49
+ template_assets = config["template"].keys if config["template"]
50
+ config["copy"].each do |dest, pattern|
51
+ copy_assets = Dir.glob(pattern).map do |path|
52
+ logical_path = Asset.new(path).logical_path
53
+ dest_path = File.join(dest, logical_path)
54
+ end
55
+ end if config["copy"]
56
+
57
+ (concat_assets + template_assets + copy_assets).uniq.each do |dest|
46
58
  asset = Asset.new(File.join env.public_folder, dest)
59
+ next unless asset.revable?
47
60
  hash[dest] = asset.relative_digest_path
48
61
  asset.revision!
49
62
  end
@@ -137,7 +150,7 @@ module Linner
137
150
  end
138
151
 
139
152
  name = File.basename(dest).sub(/[^.]+\z/, "png")
140
- path = File.join(env.public_folder, env.sprites["path"], File.basename(dest).sub(/[^.]+\z/, "png"))
153
+ path = File.join(env.public_folder, env.sprites["path"], name)
141
154
  FileUtils.mkdir_p File.dirname(path)
142
155
  map.save path
143
156
 
data/lib/linner/asset.rb CHANGED
@@ -28,6 +28,10 @@ module Linner
28
28
  digest_path.gsub /#{Linner.env.public_folder}/, ""
29
29
  end
30
30
 
31
+ def revable?
32
+ javascript? or stylesheet?
33
+ end
34
+
31
35
  def revision!
32
36
  File.rename path, digest_path
33
37
  end
@@ -1,3 +1,4 @@
1
+ require "uri"
1
2
  require "digest"
2
3
  require "fileutils"
3
4
  require "open-uri"
@@ -52,15 +53,18 @@ module Linner
52
53
  def install_to_repository(url, path)
53
54
  FileUtils.mkdir_p File.dirname(path)
54
55
  File.open(path, "w") do |dist|
55
- open(url, "r:UTF-8") {|file| dist.write file.read}
56
+ if url =~ URI::regexp
57
+ open(url, "r:UTF-8") {|file| dist.write file.read}
58
+ else
59
+ dist.write(File.read Pathname(url).expand_path)
60
+ end
56
61
  end
57
62
  end
58
63
 
59
64
  def link_to_vendor(path, dist)
60
- if !File.exist?(dist) or Digest::MD5.file(path).hexdigest != Digest::MD5.file(dist).hexdigest
61
- FileUtils.mkdir_p File.dirname(dist)
62
- FileUtils.cp path, dist
63
- end
65
+ return if File.exist?(dist) and Digest::MD5.file(path).hexdigest == Digest::MD5.file(dist).hexdigest
66
+ FileUtils.mkdir_p File.dirname(dist)
67
+ FileUtils.cp path, dist
64
68
  end
65
69
  end
66
70
  end
@@ -47,6 +47,7 @@ module Linner
47
47
  clean
48
48
  Linner::Bundler.new(env.bundles).perform
49
49
  perform
50
+ watch_for_env
50
51
  watch_for_perform
51
52
  watch_for_reload
52
53
  sleep
@@ -92,6 +93,14 @@ module Linner
92
93
  end
93
94
  end
94
95
 
96
+ def watch_for_env
97
+ Listen.to Linner.root, filter: /(config\.yml|Linnerfile)$/ do |modified, added, removed|
98
+ Linner.env = Environment.new Linner.config_file
99
+ Linner::Bundler.new(env.bundles).perform
100
+ perform
101
+ end
102
+ end
103
+
95
104
  def exit!
96
105
  Notifier.exit
97
106
  Kernel::exit
@@ -5,8 +5,7 @@ module Linner
5
5
 
6
6
  def initialize(path)
7
7
  @env ||= (YAML::load(File.read path) || Hash.new)
8
- @convension = YAML::load File.read(File.join File.dirname(__FILE__), "../../vendor", "config.default.yml")
9
- @env = @convension.rmerge!(@env)
8
+ merge_with_convension
10
9
  end
11
10
 
12
11
  %w(app test vendor public).each do |method|
@@ -54,5 +53,11 @@ module Linner
54
53
  def groups
55
54
  @env["groups"].values
56
55
  end
56
+
57
+ private
58
+ def merge_with_convension
59
+ convension = YAML::load File.read(File.join File.dirname(__FILE__), "../../vendor", "config.default.yml")
60
+ @env = convension.rmerge!(@env)
61
+ end
57
62
  end
58
63
  end
data/lib/linner/sprite.rb CHANGED
@@ -73,7 +73,7 @@ module Linner
73
73
 
74
74
  def split_block(block, image)
75
75
  block[:used] = true
76
- block[:down] = {:x => block[:x], :y => block[:y] + image.width, :w => block[:w], :h => block[:h] - image.height}
76
+ block[:down] = {:x => block[:x], :y => block[:y] + image.height, :w => block[:w], :h => block[:h] - image.height}
77
77
  block[:right] = {:x => block[:x] + image.width, :y => block[:y], :w => block[:w] - image.width, :h => image.height}
78
78
  end
79
79
 
@@ -1,21 +1,22 @@
1
1
  <!DOCTYPE html>
2
- <head>
3
- <meta charset="utf-8">
4
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
- <title>Linner boilerplate</title>
6
- <meta name="description" content="">
7
- <meta name="viewport" content="width=device-width, initial-scale=1">
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title>Linner boilerplate</title>
7
+ <meta name="description" content="">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
9
 
9
- <link rel="stylesheet" href="/styles/app.css">
10
- </head>
11
- <body>
12
- <!--[if lt IE 7]>
13
- <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
14
- <![endif]-->
15
- <div class="icon-logo"></div>
16
- <script src="/scripts/vendor.js"></script>
17
- <script src="/scripts/app.js"></script>
18
- <script src="/scripts/templates.js"></script>
19
- <script>require("app")()</script>
20
- </body>
10
+ <link rel="stylesheet" href="/styles/app.css">
11
+ </head>
12
+ <body>
13
+ <!--[if lt IE 7]>
14
+ <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
15
+ <![endif]-->
16
+ <div class="icon-logo"></div>
17
+ <script src="/scripts/vendor.js"></script>
18
+ <script src="/scripts/app.js"></script>
19
+ <script src="/scripts/templates.js"></script>
20
+ <script>require("app")()</script>
21
+ </body>
21
22
  </html>
@@ -1,3 +1,3 @@
1
1
  module Linner
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reel