shaderize 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'mustache'
3
+ require 'digest/sha1'
3
4
 
4
5
 
5
6
  module Shaderize
@@ -34,9 +35,9 @@ module Shaderize
34
35
  source_mtime = [mtime(template), shaders_mtime, mtime(__FILE__)].max
35
36
  target = File.join(output_dir, File.basename(template, File.extname(template)))
36
37
  target_mtime = mtime(target)
37
- if source_mtime > target_mtime
38
- contents = Mustache.render(File.read(template), :shaders => shaders.values)
39
- File.open(target, "w") {|f| f.write(contents) }
38
+ target_data = Mustache.render(File.read(template), :shaders => shaders.values)
39
+ if source_mtime > target_mtime or different?(target, target_data)
40
+ File.open(target, "w") {|f| f.write(target_data) }
40
41
  puts "Shaderized: #{File.basename(target)}"
41
42
  end
42
43
  end
@@ -52,6 +53,21 @@ module Shaderize
52
53
  0
53
54
  end
54
55
 
56
+ def self.hash(filename)
57
+ hash = Digest::SHA1.new
58
+ open(filename, "r") do |io|
59
+ until io.eof
60
+ hash.update(io.readpartial(1024))
61
+ end
62
+ end
63
+ hash.hexdigest
64
+ end
65
+
66
+ def self.different?(filename, contents)
67
+ return true if File.size(filename) != contents.size
68
+ hash(filename) != Digest::SHA1.hexdigest(contents)
69
+ end
70
+
55
71
  end
56
72
  end
57
73
 
@@ -1,3 +1,3 @@
1
1
  module Shaderize
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shaderize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-08-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70303280519820 !ruby/object:Gem::Requirement
16
+ requirement: &70268563501660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70303280519820
24
+ version_requirements: *70268563501660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mustache
27
- requirement: &70303280519160 !ruby/object:Gem::Requirement
27
+ requirement: &70268563501040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70303280519160
35
+ version_requirements: *70268563501040
36
36
  description: A utility to help scaffold code from OpenGL ES 2 shaders.
37
37
  email:
38
38
  - pbhogan@gmail.com
@@ -66,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  segments:
68
68
  - 0
69
- hash: 165469644368526880
69
+ hash: -1177528489724511482
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  none: false
72
72
  requirements:
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  segments:
77
77
  - 0
78
- hash: 165469644368526880
78
+ hash: -1177528489724511482
79
79
  requirements: []
80
80
  rubyforge_project: shaderize
81
81
  rubygems_version: 1.8.8