change 0.1.2 → 0.1.3

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/.gitignore CHANGED
@@ -1,9 +1,6 @@
1
1
  .DS_Store
2
2
  *.gem
3
3
  .bundle
4
- bin/murmur3
5
- ext/change/change
6
- ext/change/*.o
7
4
  Gemfile.lock
8
5
  pkg
9
6
  spec/tmp
data/README.md CHANGED
@@ -3,8 +3,6 @@ Change
3
3
 
4
4
  What files changed since last time?
5
5
 
6
- With dependency management and super fast hashing ([Murmur3](https://github.com/PeterScott/murmur3)).
7
-
8
6
  [![Build Status](https://secure.travis-ci.org/winton/change.png)](http://travis-ci.org/winton/change)
9
7
 
10
8
  Requirements
@@ -26,8 +24,8 @@ Calling `@change.d?` does the following:
26
24
 
27
25
  * Check if there is an entry for path in `.change.yml`
28
26
  * If yes, read file size and compare with entry
29
- * If file size matches, compare Murmur hash
30
- * If no, record file size and Murmur hash
27
+ * If file size matches, compare hash
28
+ * If no, record file size and hash
31
29
  * Look up path in dependency tree
32
30
  * If found, also mark all dependency parent paths as changed
33
31
 
data/Rakefile CHANGED
@@ -5,9 +5,4 @@ Spec::Rake::SpecTask.new(:spec) do |t|
5
5
  t.spec_files = FileList['spec/**/*_spec.rb']
6
6
  end
7
7
 
8
- task :default do
9
- Dir.chdir("ext/change") do
10
- system("make && make install")
11
- end
12
- Rake::Task['spec'].execute
13
- end
8
+ task :default => :spec
data/change.gemspec CHANGED
@@ -6,16 +6,15 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "change"
9
- s.version = '0.1.2'
9
+ s.version = '0.1.3'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'Winton Welsh' ]
12
12
  s.email = [ 'mail@wintoni.us' ]
13
13
  s.homepage = "http://github.com/winton/change"
14
14
  s.summary = %q{What files changed since last time?}
15
- s.description = %q{What files changed since last time? With dependency management and super fast hashing (Murmur3).}
15
+ s.description = %q{What files changed since last time? With dependency management.}
16
16
 
17
17
  s.executables = `cd #{root} && git ls-files bin/*`.split("\n").collect { |f| File.basename(f) }
18
- s.extensions = [ 'ext/change/extconf.rb' ]
19
18
  s.files = `cd #{root} && git ls-files`.split("\n")
20
19
  s.require_paths = %w(lib)
21
20
  s.test_files = `cd #{root} && git ls-files -- {features,test,spec}/*`.split("\n")
data/lib/change.rb CHANGED
@@ -21,10 +21,10 @@ class Change
21
21
  if @d && !reload
22
22
  @d
23
23
  else
24
- paths = Dir.chdir(@root) { Dir["**/*"] }
25
- add = paths - states.keys
26
- rem = states.keys - paths
27
- hashes = murmur_hashes(paths)
24
+ paths = Dir.chdir(@root) { Dir["**/*"] }
25
+ add = paths - states.keys
26
+ rem = states.keys - paths
27
+ hashes = file_hashes(paths)
28
28
 
29
29
  mod = paths.inject([]) do |array, path|
30
30
  hash = hashes[path]
@@ -48,7 +48,7 @@ class Change
48
48
 
49
49
  write!
50
50
 
51
- @d = { :add => add, :mod => mod, :rem => rem }
51
+ @d = { :add => add.sort, :mod => mod.sort, :rem => rem.sort }
52
52
  end
53
53
  end
54
54
 
@@ -83,15 +83,11 @@ class Change
83
83
  @data ||= (YAML.load(File.read("#{@root}/.change.yml")) rescue {})
84
84
  end
85
85
 
86
- def murmur_bin
87
- @murmur ||= File.expand_path('../../bin/murmur3', __FILE__)
88
- end
89
-
90
- def murmur_hashes(paths)
91
- hashes = Dir.chdir(@root) do
92
- `#{murmur_bin} #{paths.collect { |m| "'#{m}'" }.join(' ')}`
86
+ def file_hashes(paths)
87
+ paths.inject({}) do |memo, path|
88
+ memo[path] = Digest::MD5.hexdigest(File.read("#{@root}/#{path}"))
89
+ memo
93
90
  end
94
- Hash[paths.zip(hashes.split("\n"))]
95
91
  end
96
92
 
97
93
  def deps
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: change
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
12
+ date: 2013-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -43,14 +43,12 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: '1.0'
46
- description: What files changed since last time? With dependency management and super
47
- fast hashing (Murmur3).
46
+ description: What files changed since last time? With dependency management.
48
47
  email:
49
48
  - mail@wintoni.us
50
49
  executables:
51
50
  - change
52
- extensions:
53
- - ext/change/extconf.rb
51
+ extensions: []
54
52
  extra_rdoc_files: []
55
53
  files:
56
54
  - .gitignore
@@ -61,11 +59,6 @@ files:
61
59
  - Rakefile
62
60
  - bin/change
63
61
  - change.gemspec
64
- - ext/change/Makefile
65
- - ext/change/change.c
66
- - ext/change/extconf.rb
67
- - ext/change/murmur3.c
68
- - ext/change/murmur3.h
69
62
  - lib/change.rb
70
63
  - spec/change_spec.rb
71
64
  - spec/fixture/modify.txt
@@ -85,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
78
  version: '0'
86
79
  segments:
87
80
  - 0
88
- hash: -3219385140239568542
81
+ hash: 2222205960110125923
89
82
  required_rubygems_version: !ruby/object:Gem::Requirement
90
83
  none: false
91
84
  requirements:
@@ -94,10 +87,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
87
  version: '0'
95
88
  segments:
96
89
  - 0
97
- hash: -3219385140239568542
90
+ hash: 2222205960110125923
98
91
  requirements: []
99
92
  rubyforge_project:
100
- rubygems_version: 1.8.24
93
+ rubygems_version: 1.8.25
101
94
  signing_key:
102
95
  specification_version: 3
103
96
  summary: What files changed since last time?
data/ext/change/Makefile DELETED
@@ -1,8 +0,0 @@
1
- CFLAGS = -O2 -Wall
2
-
3
- all: change
4
- change: change.o murmur3.o
5
- install:
6
- rm *.o
7
- mv -f change ../../bin/murmur3
8
- chmod +x ../../bin/murmur3
data/ext/change/change.c DELETED
@@ -1,42 +0,0 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
3
- #include <stdint.h>
4
- #include <string.h>
5
- #include "murmur3.h"
6
-
7
- int main(int argc, char **argv) {
8
- uint32_t hash[4]; /* Output for the hash */
9
- uint32_t seed = 42; /* Seed value for hash */
10
-
11
- int x;
12
-
13
- for (x = 1; x < argc; x++) {
14
- FILE *fh = fopen(argv[x], "rb");
15
-
16
- if (fh != NULL) {
17
- fseek(fh, 0L, SEEK_END);
18
- long s = ftell(fh);
19
-
20
- char *buffer = malloc(s + 1);
21
- buffer[s] = '\0';
22
-
23
- rewind(fh);
24
-
25
- if (s != 0) {
26
- fread(buffer, s, 1, fh);
27
- fclose(fh);
28
- fh = NULL;
29
- }
30
-
31
- MurmurHash3_x86_32(buffer, strlen(buffer), seed, hash);
32
- printf("%08u\n", hash[0]);
33
-
34
- free(buffer);
35
-
36
- if (fh != NULL)
37
- fclose(fh);
38
- }
39
- }
40
-
41
- return 0;
42
- }
@@ -1 +0,0 @@
1
- puts "Making Murmur3 binary..."
data/ext/change/murmur3.c DELETED
@@ -1,315 +0,0 @@
1
- //-----------------------------------------------------------------------------
2
- // MurmurHash3 was written by Austin Appleby, and is placed in the public
3
- // domain. The author hereby disclaims copyright to this source code.
4
-
5
- // Note - The x86 and x64 versions do _not_ produce the same results, as the
6
- // algorithms are optimized for their respective platforms. You can still
7
- // compile and run any of them on any platform, but your performance with the
8
- // non-native version will be less than optimal.
9
-
10
- #include "murmur3.h"
11
-
12
- //-----------------------------------------------------------------------------
13
- // Platform-specific functions and macros
14
-
15
- #ifdef __GNUC__
16
- #define FORCE_INLINE __attribute__((always_inline))
17
- #else
18
- #define FORCE_INLINE
19
- #endif
20
-
21
- static inline FORCE_INLINE uint32_t rotl32 ( uint32_t x, int8_t r )
22
- {
23
- return (x << r) | (x >> (32 - r));
24
- }
25
-
26
- static inline FORCE_INLINE uint64_t rotl64 ( uint64_t x, int8_t r )
27
- {
28
- return (x << r) | (x >> (64 - r));
29
- }
30
-
31
- #define ROTL32(x,y) rotl32(x,y)
32
- #define ROTL64(x,y) rotl64(x,y)
33
-
34
- #define BIG_CONSTANT(x) (x##LLU)
35
-
36
- //-----------------------------------------------------------------------------
37
- // Block read - if your platform needs to do endian-swapping or can only
38
- // handle aligned reads, do the conversion here
39
-
40
- #define getblock(p, i) (p[i])
41
-
42
- //-----------------------------------------------------------------------------
43
- // Finalization mix - force all bits of a hash block to avalanche
44
-
45
- static inline FORCE_INLINE uint32_t fmix32 ( uint32_t h )
46
- {
47
- h ^= h >> 16;
48
- h *= 0x85ebca6b;
49
- h ^= h >> 13;
50
- h *= 0xc2b2ae35;
51
- h ^= h >> 16;
52
-
53
- return h;
54
- }
55
-
56
- //----------
57
-
58
- static inline FORCE_INLINE uint64_t fmix64 ( uint64_t k )
59
- {
60
- k ^= k >> 33;
61
- k *= BIG_CONSTANT(0xff51afd7ed558ccd);
62
- k ^= k >> 33;
63
- k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
64
- k ^= k >> 33;
65
-
66
- return k;
67
- }
68
-
69
- //-----------------------------------------------------------------------------
70
-
71
- void MurmurHash3_x86_32 ( const void * key, int len,
72
- uint32_t seed, void * out )
73
- {
74
- const uint8_t * data = (const uint8_t*)key;
75
- const int nblocks = len / 4;
76
- int i;
77
-
78
- uint32_t h1 = seed;
79
-
80
- uint32_t c1 = 0xcc9e2d51;
81
- uint32_t c2 = 0x1b873593;
82
-
83
- //----------
84
- // body
85
-
86
- const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
87
-
88
- for(i = -nblocks; i; i++)
89
- {
90
- uint32_t k1 = getblock(blocks,i);
91
-
92
- k1 *= c1;
93
- k1 = ROTL32(k1,15);
94
- k1 *= c2;
95
-
96
- h1 ^= k1;
97
- h1 = ROTL32(h1,13);
98
- h1 = h1*5+0xe6546b64;
99
- }
100
-
101
- //----------
102
- // tail
103
-
104
- const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
105
-
106
- uint32_t k1 = 0;
107
-
108
- switch(len & 3)
109
- {
110
- case 3: k1 ^= tail[2] << 16;
111
- case 2: k1 ^= tail[1] << 8;
112
- case 1: k1 ^= tail[0];
113
- k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
114
- };
115
-
116
- //----------
117
- // finalization
118
-
119
- h1 ^= len;
120
-
121
- h1 = fmix32(h1);
122
-
123
- *(uint32_t*)out = h1;
124
- }
125
-
126
- //-----------------------------------------------------------------------------
127
-
128
- void MurmurHash3_x86_128 ( const void * key, const int len,
129
- uint32_t seed, void * out )
130
- {
131
- const uint8_t * data = (const uint8_t*)key;
132
- const int nblocks = len / 16;
133
- int i;
134
-
135
- uint32_t h1 = seed;
136
- uint32_t h2 = seed;
137
- uint32_t h3 = seed;
138
- uint32_t h4 = seed;
139
-
140
- uint32_t c1 = 0x239b961b;
141
- uint32_t c2 = 0xab0e9789;
142
- uint32_t c3 = 0x38b34ae5;
143
- uint32_t c4 = 0xa1e38b93;
144
-
145
- //----------
146
- // body
147
-
148
- const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
149
-
150
- for(i = -nblocks; i; i++)
151
- {
152
- uint32_t k1 = getblock(blocks,i*4+0);
153
- uint32_t k2 = getblock(blocks,i*4+1);
154
- uint32_t k3 = getblock(blocks,i*4+2);
155
- uint32_t k4 = getblock(blocks,i*4+3);
156
-
157
- k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
158
-
159
- h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;
160
-
161
- k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
162
-
163
- h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;
164
-
165
- k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
166
-
167
- h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;
168
-
169
- k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
170
-
171
- h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
172
- }
173
-
174
- //----------
175
- // tail
176
-
177
- const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
178
-
179
- uint32_t k1 = 0;
180
- uint32_t k2 = 0;
181
- uint32_t k3 = 0;
182
- uint32_t k4 = 0;
183
-
184
- switch(len & 15)
185
- {
186
- case 15: k4 ^= tail[14] << 16;
187
- case 14: k4 ^= tail[13] << 8;
188
- case 13: k4 ^= tail[12] << 0;
189
- k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
190
-
191
- case 12: k3 ^= tail[11] << 24;
192
- case 11: k3 ^= tail[10] << 16;
193
- case 10: k3 ^= tail[ 9] << 8;
194
- case 9: k3 ^= tail[ 8] << 0;
195
- k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
196
-
197
- case 8: k2 ^= tail[ 7] << 24;
198
- case 7: k2 ^= tail[ 6] << 16;
199
- case 6: k2 ^= tail[ 5] << 8;
200
- case 5: k2 ^= tail[ 4] << 0;
201
- k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
202
-
203
- case 4: k1 ^= tail[ 3] << 24;
204
- case 3: k1 ^= tail[ 2] << 16;
205
- case 2: k1 ^= tail[ 1] << 8;
206
- case 1: k1 ^= tail[ 0] << 0;
207
- k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
208
- };
209
-
210
- //----------
211
- // finalization
212
-
213
- h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;
214
-
215
- h1 += h2; h1 += h3; h1 += h4;
216
- h2 += h1; h3 += h1; h4 += h1;
217
-
218
- h1 = fmix32(h1);
219
- h2 = fmix32(h2);
220
- h3 = fmix32(h3);
221
- h4 = fmix32(h4);
222
-
223
- h1 += h2; h1 += h3; h1 += h4;
224
- h2 += h1; h3 += h1; h4 += h1;
225
-
226
- ((uint32_t*)out)[0] = h1;
227
- ((uint32_t*)out)[1] = h2;
228
- ((uint32_t*)out)[2] = h3;
229
- ((uint32_t*)out)[3] = h4;
230
- }
231
-
232
- //-----------------------------------------------------------------------------
233
-
234
- void MurmurHash3_x64_128 ( const void * key, const int len,
235
- const uint32_t seed, void * out )
236
- {
237
- const uint8_t * data = (const uint8_t*)key;
238
- const int nblocks = len / 16;
239
- int i;
240
-
241
- uint64_t h1 = seed;
242
- uint64_t h2 = seed;
243
-
244
- uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
245
- uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
246
-
247
- //----------
248
- // body
249
-
250
- const uint64_t * blocks = (const uint64_t *)(data);
251
-
252
- for(i = 0; i < nblocks; i++)
253
- {
254
- uint64_t k1 = getblock(blocks,i*2+0);
255
- uint64_t k2 = getblock(blocks,i*2+1);
256
-
257
- k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
258
-
259
- h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
260
-
261
- k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
262
-
263
- h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
264
- }
265
-
266
- //----------
267
- // tail
268
-
269
- const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
270
-
271
- uint64_t k1 = 0;
272
- uint64_t k2 = 0;
273
-
274
- switch(len & 15)
275
- {
276
- case 15: k2 ^= (uint64_t)(tail[14]) << 48;
277
- case 14: k2 ^= (uint64_t)(tail[13]) << 40;
278
- case 13: k2 ^= (uint64_t)(tail[12]) << 32;
279
- case 12: k2 ^= (uint64_t)(tail[11]) << 24;
280
- case 11: k2 ^= (uint64_t)(tail[10]) << 16;
281
- case 10: k2 ^= (uint64_t)(tail[ 9]) << 8;
282
- case 9: k2 ^= (uint64_t)(tail[ 8]) << 0;
283
- k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
284
-
285
- case 8: k1 ^= (uint64_t)(tail[ 7]) << 56;
286
- case 7: k1 ^= (uint64_t)(tail[ 6]) << 48;
287
- case 6: k1 ^= (uint64_t)(tail[ 5]) << 40;
288
- case 5: k1 ^= (uint64_t)(tail[ 4]) << 32;
289
- case 4: k1 ^= (uint64_t)(tail[ 3]) << 24;
290
- case 3: k1 ^= (uint64_t)(tail[ 2]) << 16;
291
- case 2: k1 ^= (uint64_t)(tail[ 1]) << 8;
292
- case 1: k1 ^= (uint64_t)(tail[ 0]) << 0;
293
- k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
294
- };
295
-
296
- //----------
297
- // finalization
298
-
299
- h1 ^= len; h2 ^= len;
300
-
301
- h1 += h2;
302
- h2 += h1;
303
-
304
- h1 = fmix64(h1);
305
- h2 = fmix64(h2);
306
-
307
- h1 += h2;
308
- h2 += h1;
309
-
310
- ((uint64_t*)out)[0] = h1;
311
- ((uint64_t*)out)[1] = h2;
312
- }
313
-
314
- //-----------------------------------------------------------------------------
315
-
data/ext/change/murmur3.h DELETED
@@ -1,21 +0,0 @@
1
- //-----------------------------------------------------------------------------
2
- // MurmurHash3 was written by Austin Appleby, and is placed in the
3
- // public domain. The author hereby disclaims copyright to this source
4
- // code.
5
-
6
- #ifndef _MURMURHASH3_H_
7
- #define _MURMURHASH3_H_
8
-
9
- #include <stdint.h>
10
-
11
- //-----------------------------------------------------------------------------
12
-
13
- void MurmurHash3_x86_32 (const void *key, int len, uint32_t seed, void *out);
14
-
15
- void MurmurHash3_x86_128(const void *key, int len, uint32_t seed, void *out);
16
-
17
- void MurmurHash3_x64_128(const void *key, int len, uint32_t seed, void *out);
18
-
19
- //-----------------------------------------------------------------------------
20
-
21
- #endif // _MURMURHASH3_H_