linner 0.3.2 → 0.4.0

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: a828ea61a82b07f330f0d595bd99c4584ba9c5dc
4
- data.tar.gz: 50321b435438150ab81e60619d7556527305a70e
3
+ metadata.gz: ad0db2767b837ef41fc611523a7208c1ae2eb7dc
4
+ data.tar.gz: 0b0171fa4c551709cd155859cc9723033a2ef3b6
5
5
  SHA512:
6
- metadata.gz: 1889066c24c0ef266440e90103d2c97b1741f92ce7319a2b1796b98451f2b8a0fdb16e49c7c99987513a815c5f46e4f0383db1b463c7d2b54eef102adb881333
7
- data.tar.gz: 1bb6b864afe6c9d335ff0a23011266518fa38301440194a75a9b2c9e1a3bb18e1fd48c601938f13027bc216d703c514a720e279005423a7ab13ba93eb5f296c7
6
+ metadata.gz: 6a505783f236a3a1ea6a9390a5b40dc9d62de55798aa2cc2cf83a9d3e4b695ec5af96dcf267c70b2d72d64ed8bdd2b01a42c096d2a5cd4944b9e7aac0727908f
7
+ data.tar.gz: 7b8751ebbbafd8ec0db858d793d80ab1e16513be93331bd14e363cdd77a294867807a140d9814abb057f05724a4368cc196d44867aad676d3ffde81637872d43
data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ v 0.4.0
2
+ - revision support
3
+ - fix memory leak in `cache_miss?`
4
+ - quit `fsevent` process when `ctrl + c` triggered
5
+
6
+ v 0.3.2
7
+ - fix Celluiod logger bug
8
+ - suggest windows user to use jruby instead
9
+
1
10
  v 0.3.1
2
11
  - add `livereload` support
3
12
 
data/README.md CHANGED
@@ -4,6 +4,10 @@ Linner is a full-featured HTML5 application assembler.
4
4
 
5
5
  ![Linner](http://d.pr/i/bWPA+)
6
6
 
7
+ #### Screencast
8
+
9
+ [![Screencast](http://d.pr/i/MIyk+)](https://vimeo.com/71944672)
10
+
7
11
  * Fast!
8
12
  * Supports `Sass`, `Compass` and `Coffee`.
9
13
  * Supports OS X Lion and Mountaion Lion Notifications.
@@ -14,33 +18,43 @@ Linner is a full-featured HTML5 application assembler.
14
18
  * Supports `compress` by `$ linner build`.
15
19
  * Supports `LiveReload` with [LiveReload Chrome Extention](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei).
16
20
 
21
+ #### Documents
22
+
23
+ [https://github.com/SaitoWu/linner/tree/master/docs](https://github.com/SaitoWu/linner/tree/master/docs)
24
+
17
25
  ## Requirements
18
26
 
27
+ #### *nix
28
+
19
29
  * Ruby 2.0
20
30
 
31
+ #### Windows
32
+
33
+ * JRuby 1.7.4 with 2.0 mode (`set JRUBY_OPTS=--2.0`)
34
+
21
35
  ## Installation
22
36
 
23
37
  $ gem install linner
24
38
 
25
39
  ## Usage
26
40
 
27
- Skeleton:
41
+ #### Skeleton
28
42
 
29
43
  $ linner new webapp && cd webapp
30
44
 
31
- Watch:
45
+ #### Watch
32
46
 
33
47
  $ linner watch
34
48
 
35
- Server:
49
+ #### Server
36
50
 
37
51
  $ ./bin/server # or server if put "./bin" in your PATH
38
52
 
39
- Build:
53
+ #### Build
40
54
 
41
55
  $ linner build
42
56
 
43
- Clean:
57
+ #### Clean
44
58
 
45
59
  $ linner clean
46
60
 
data/docs/commands.md ADDED
@@ -0,0 +1,21 @@
1
+ # Command
2
+
3
+ ## `linner new <path>`
4
+
5
+ Create new brunch project.
6
+
7
+ ## `linner watch`
8
+
9
+ Watch linner directory and rebuild if something changed.
10
+
11
+ ## `linner build`
12
+
13
+ Build and Minify a linner project.
14
+
15
+ ## `linner clean`
16
+
17
+ Clean up linner public folder.
18
+
19
+ ## `server`
20
+
21
+ Start up a server at port 3000.
data/docs/config.md ADDED
@@ -0,0 +1,104 @@
1
+ # Configuration file
2
+
3
+ Linner use `config.yml` file to config your application.
4
+
5
+ ## `paths`
6
+
7
+ `paths` defines application paths, it contains `app`, `test`, `vendor` and `public` folders.
8
+
9
+ Default:
10
+
11
+ ```yaml
12
+ paths:
13
+ app: "app"
14
+ test: "test"
15
+ vendor: "vendor"
16
+ public: "public"
17
+ ```
18
+
19
+ `linner watch` command will watch `app`, `test` and `vendor` folders, and the builded file will be in `public` folder.
20
+
21
+ ## `groups`
22
+
23
+ `groups` defines application groups, you can define any type of groups in it.
24
+
25
+ Default:
26
+
27
+ ```yaml
28
+ groups:
29
+ scripts:
30
+ paths:
31
+ - "app/scripts"
32
+ order:
33
+ - "vendor/jquery-1.10.2.js"
34
+ - "..."
35
+ styles:
36
+ paths:
37
+ - "app/styles"
38
+ images:
39
+ paths:
40
+ - "app/images"
41
+ views:
42
+ paths:
43
+ - "app/views"
44
+ ```
45
+
46
+ the default configuration defines four groups: `scripts`, `styles`, `images` and `views` group.
47
+
48
+ `paths` defines where can linner find this group's files, It's a `Array`.
49
+
50
+ `concat` defines concatenation of files in Linner. the `Dir.glob` of `value` will be concat to `key` file.
51
+
52
+ `copy` defines copy strategy of files in Linner. The `Dir.glob` of `value` will be copy to `key` folder.
53
+
54
+ `order` defines the order of this group files, and It's very useful when you `concat` your files. for example:
55
+
56
+ ```yaml
57
+ order:
58
+ - "vendor/jquery-1.10.2.js"
59
+ - "..."
60
+ - "vendor/underscore.js"
61
+ ```
62
+
63
+ In the above example, if a group contains 5 files, `vendor/jquery-1.10.2.js` will be the first, and `vendor/underscore.js` will be the last file.
64
+
65
+ ## `modules`
66
+
67
+ `modules` defines application module strategy, The default wrapper is `cmd`.
68
+
69
+ Default:
70
+
71
+ ```yaml
72
+ modules:
73
+ wrapper: "cmd"
74
+ ignored: "vendor/**/*"
75
+ definition: "scripts/app.js"
76
+ ```
77
+
78
+ All of your code will be wrapped by `cmd`(Common Module Definition) except `ignored` glob pattern.
79
+
80
+ The definition file will prepend to `definition` field, which will join with `public` folder.
81
+
82
+ ## `revision`
83
+
84
+ `revision` defines application layout page, which contains `link` and `script` tags.
85
+
86
+ Default:
87
+
88
+ ```yaml
89
+ revision: "index.html"
90
+ ```
91
+
92
+ `index.html` will join with `public` folder. So, by default when you `build` your application, the `public/index.html` file will be rewrited with revision.
93
+
94
+ If you don't need `revision` support, it can be `false`.
95
+
96
+ ## `notification`
97
+
98
+ `notification` defines application error notification.
99
+
100
+ Default:
101
+
102
+ ```yaml
103
+ notification: true
104
+ ```
data/lib/linner.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require "nokogiri"
2
+
1
3
  require "linner/version"
2
4
  require "linner/command"
3
5
  require "linner/asset"
@@ -9,6 +11,9 @@ require "linner/notifier"
9
11
  require "linner/compressor"
10
12
  require "linner/environment"
11
13
 
14
+ Encoding.default_external = Encoding::UTF_8
15
+ Encoding.default_internal = Encoding::UTF_8
16
+
12
17
  module Linner
13
18
  extend self
14
19
 
@@ -40,9 +45,10 @@ module Linner
40
45
 
41
46
  def perform(*asset)
42
47
  env.groups.each do |config|
43
- concat(config) if config["concat"]
44
48
  copy(config) if config["copy"]
49
+ concat(config) if config["concat"]
45
50
  end
51
+ revision if compile? and env.revision
46
52
  end
47
53
 
48
54
  private
@@ -71,19 +77,30 @@ private
71
77
  end
72
78
  end
73
79
 
80
+ def revision
81
+ revision = File.join env.public_folder, env.revision
82
+ doc = Nokogiri::HTML.parse(File.read revision)
83
+ doc.search("script").each do |x|
84
+ next unless src = x.attributes["src"]
85
+ asset = Asset.new(File.join env.public_folder, src)
86
+ x.set_attribute "src", asset.revision!
87
+ end
88
+ doc.search("link").each do |x|
89
+ next unless href = x.attributes["href"]
90
+ asset = Asset.new(File.join env.public_folder, href)
91
+ x.set_attribute "href", asset.revision!
92
+ end
93
+ File.open(revision, "w") do |f|
94
+ f.write doc.to_html
95
+ end
96
+ end
97
+
74
98
  def cache_miss?(path)
75
99
  asset = Asset.new(path)
76
- if asset.stylesheet? and Tilt[path] != Tilt::CSSTemplate
77
- partials = Sass::Engine.for_file(path, sass_engine_options).dependencies.map{|m| m.options[:filename]}
78
- cache_missed = partials.select do |partial|
79
- partial_asset = Asset.new(partial)
80
- (cache[partial] and cache[partial].mtime == partial_asset.mtime) ? false : cache[partial] = partial_asset
81
- end
82
- unless cache_missed.empty?
83
- cache[path] = asset
84
- return true
85
- end
100
+ if cache[path] and cache[path].mtime == asset.mtime
101
+ false
102
+ else
103
+ cache[path] = asset
86
104
  end
87
- (cache[path] and cache[path].mtime == asset.mtime) ? false : cache[path] = asset
88
105
  end
89
106
  end
data/lib/linner/asset.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require "digest"
2
+
1
3
  module Linner
2
4
  class Asset
3
5
 
@@ -14,6 +16,20 @@ module Linner
14
16
  @mtime
15
17
  end
16
18
 
19
+ def extname
20
+ File.extname @path
21
+ end
22
+
23
+ def digest
24
+ Digest::MD5.hexdigest content
25
+ end
26
+
27
+ def revision!
28
+ revision = @path.chomp(extname) << "-#{digest}" << extname
29
+ File.rename @path, revision
30
+ revision.gsub /#{Linner.env.public_folder}/, ""
31
+ end
32
+
17
33
  def content
18
34
  return @content if @content
19
35
  source = begin
@@ -18,7 +18,10 @@ module Linner
18
18
  desc "build", "build assets"
19
19
  def build
20
20
  Linner.compile = true
21
- Notifier.info do
21
+
22
+ clean
23
+
24
+ Notifier.profile do
22
25
  Linner.perform
23
26
  end
24
27
  end
@@ -27,12 +30,14 @@ module Linner
27
30
  def watch
28
31
  trap :INT do
29
32
  Notifier.exit
30
- exit!
33
+ Process.kill("QUIT", 0)
31
34
  end
32
35
 
36
+ clean
37
+
33
38
  @proc = Proc.new do |modified, added, removed|
34
39
  begin
35
- Notifier.info{ Linner.perform }
40
+ Notifier.profile{ Linner.perform }
36
41
  rescue
37
42
  Notifier.error $!
38
43
  end
@@ -40,6 +45,10 @@ module Linner
40
45
  @proc.call
41
46
 
42
47
  Listen.to env.app_folder, env.vendor_folder, env.test_folder do |modified, added, removed|
48
+ is_include_partial_styles = (modified + added + removed).any? do |path|
49
+ Asset.new(path).stylesheet? and File.basename(path).start_with? "_"
50
+ end
51
+ Linner.cache.reject! {|k, v| v.stylesheet?} if is_include_partial_styles
43
52
  @proc.call
44
53
  end
45
54
 
@@ -19,6 +19,10 @@ module Linner
19
19
  end
20
20
  end
21
21
 
22
+ def revision
23
+ @env["revision"]
24
+ end
25
+
22
26
  def notification
23
27
  @env["notification"]
24
28
  end
@@ -3,7 +3,7 @@ require "terminal-notifier"
3
3
  module Linner
4
4
  class Notifier
5
5
  class << self
6
- def info
6
+ def profile
7
7
  time = Time.now
8
8
  yield
9
9
  puts "🍜 : Done in #{'%.3f' % (Time.now - time)}s."
@@ -27,7 +27,7 @@ module Linner
27
27
 
28
28
  def route_request(connection, request)
29
29
  if request.url.start_with? "/livereload.js"
30
- return connection.respond :ok, File.read(File.join(File.dirname(__FILE__), "../../vendor", "livereload.js"))
30
+ return connection.respond :ok, {"Content_Type" => 'application/ecmascript'}, File.read(File.join(File.dirname(__FILE__), "../../vendor", "livereload.js"))
31
31
  end
32
32
 
33
33
  path = File.join(Linner.environment.public_folder, request.url[1..-1])
@@ -19,4 +19,5 @@ groups:
19
19
  "/": "app/views/**/*.{html,hbs}"
20
20
  modules:
21
21
  wrapper: "cmd"
22
+ revision: "index.html"
22
23
  notification: true
@@ -1,3 +1,3 @@
1
1
  module Linner
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
data/linner.gemspec CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency "listen", "~> 1.2"
26
26
  spec.add_dependency "nio4r", "~> 0.5.0"
27
27
  spec.add_dependency "uglifier", "~> 2.1"
28
+ spec.add_dependency "nokogiri", "~> 1.6.0"
28
29
  spec.add_dependency "compass", "~> 0.12.2"
29
- spec.add_dependency "multi_json", "~> 1.7"
30
30
  spec.add_dependency "cssminify", "~> 1.0.2"
31
31
  spec.add_dependency "coffee-script", "~> 2.2"
32
32
  spec.add_dependency "terminal-notifier", "~> 1.4"
@@ -17,6 +17,7 @@ describe Environment do
17
17
  it "should equals default config" do
18
18
  @env.notification.should be_true
19
19
  @env.wrapper.should == "cmd"
20
+ @env.revision.should == false
20
21
  @env.groups.should respond_to(:each)
21
22
  end
22
23
  end
@@ -26,4 +26,6 @@ modules:
26
26
  ignored: "vendor/**/*"
27
27
  definition: "scripts/app.js"
28
28
 
29
+ revision: false
30
+
29
31
  notification: true
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.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2013-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reel
@@ -109,33 +109,33 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.1'
111
111
  - !ruby/object:Gem::Dependency
112
- name: compass
112
+ name: nokogiri
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 0.12.2
117
+ version: 1.6.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
- version: 0.12.2
124
+ version: 1.6.0
125
125
  - !ruby/object:Gem::Dependency
126
- name: multi_json
126
+ name: compass
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ~>
130
130
  - !ruby/object:Gem::Version
131
- version: '1.7'
131
+ version: 0.12.2
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ~>
137
137
  - !ruby/object:Gem::Version
138
- version: '1.7'
138
+ version: 0.12.2
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: cssminify
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -237,6 +237,8 @@ files:
237
237
  - README.md
238
238
  - Rakefile
239
239
  - bin/linner
240
+ - docs/commands.md
241
+ - docs/config.md
240
242
  - lib/linner.rb
241
243
  - lib/linner/asset.rb
242
244
  - lib/linner/command.rb
@@ -301,3 +303,4 @@ test_files:
301
303
  - spec/linner/template_spec.rb
302
304
  - spec/linner/wrapper_spec.rb
303
305
  - spec/spec_helper.rb
306
+ has_rdoc: