rubbr 1.1.1 → 1.1.2
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.
- data/History.txt +4 -0
- data/Manifest.txt +1 -0
- data/lib/rubbr.rb +1 -1
- data/lib/rubbr/change.rb +49 -0
- metadata +2 -1
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/lib/rubbr.rb
CHANGED
data/lib/rubbr/change.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Rubbr
|
2
|
+
|
3
|
+
# Checks if source files have changed since last time they was accessed by
|
4
|
+
# computing and storing a hash of their contents.
|
5
|
+
class Change
|
6
|
+
extend Rubbr::Cli
|
7
|
+
require 'digest/md5'
|
8
|
+
require 'yaml'
|
9
|
+
|
10
|
+
def self.d?
|
11
|
+
sums = inventory
|
12
|
+
if changes?(sums)
|
13
|
+
write_inventory sums
|
14
|
+
true
|
15
|
+
else
|
16
|
+
notice "No changes in #{Rubbr.options[:build_dir]} since last build"
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.inventory
|
24
|
+
source_files = Dir["#{Rubbr.options[:source_dir]}/*.tex"]
|
25
|
+
source_files.collect do |f|
|
26
|
+
[f, digest(File.read(f))]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.write_inventory(sums)
|
31
|
+
File.open(Rubbr.options[:inventory_file], 'w') do |f|
|
32
|
+
f.write(sums.to_yaml)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.read_inventory
|
37
|
+
YAML.load_file(Rubbr.options[:inventory_file])
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.changes?(sums)
|
41
|
+
return true unless File.exists?(Rubbr.options[:inventory_file])
|
42
|
+
sums != read_inventory
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.digest(contents)
|
46
|
+
Digest::MD5.hexdigest contents
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubbr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eivind Uggedal
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- bin/rubbr
|
40
40
|
- lib/rubbr.rb
|
41
41
|
- lib/rubbr/builder.rb
|
42
|
+
- lib/rubbr/change.rb
|
42
43
|
- lib/rubbr/cli.rb
|
43
44
|
- lib/rubbr/options.rb
|
44
45
|
- lib/rubbr/runner.rb
|