compressor 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/compressor.rb +33 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b9e88b6987f1b08a32f163c2d5b434e7049b07a
|
4
|
+
data.tar.gz: 249211f3d66c4196f2a2f391f35bcb03b2a5d51a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61305bad63b1aad29a7548fce3791aac215042efa39df8d830da3b1fe6fdc0dbf081d92f3e6239d35c2d4346a52beb8f692597d48251b8e4965e9774c6010f9
|
7
|
+
data.tar.gz: a05c68c1efc3e2a66689b6fbed37d549015dcbf7adfaea264d1066a74ae28e153690add25921b2e823d135f6bb63e9fa894547aac9ad43bf6df013f3bcfc570a
|
data/lib/compressor.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
unless defined?(Motion::Project::Config)
|
4
5
|
raise "This file must be required within a RubyMotion project Rakefile."
|
@@ -7,19 +8,18 @@ end
|
|
7
8
|
module Motion::Project
|
8
9
|
class Config
|
9
10
|
def concat_files(opts={})
|
10
|
-
|
11
|
-
concatenate_files!(files_to_concatenate, opts[:parallel] || 4)
|
11
|
+
concatenate_files!(extract_concatenated_files(Array(opts[:exclude])), opts[:parallel] || 4)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def extract_concatenated_files(excluded=[])
|
17
17
|
@files.flatten!
|
18
|
-
|
18
|
+
concatenated_files = @files.select { |f| excluded.none? { |excluded_match| !!f.match(excluded_match) } }
|
19
19
|
old_dependencies = @dependencies
|
20
|
+
@files = @files - concatenated_files
|
20
21
|
@dependencies = Dependency.new(@files - @exclude_from_detect_dependencies, @dependencies).run
|
21
|
-
|
22
|
-
@concatenated_files = order_concatenated_files(@concatenated_files)
|
22
|
+
order_concatenated_files(concatenated_files)
|
23
23
|
end
|
24
24
|
|
25
25
|
def order_concatenated_files(concatenated_files)
|
@@ -28,14 +28,18 @@ module Motion::Project
|
|
28
28
|
|
29
29
|
def concatenate_files!(concat_files, parallel=4)
|
30
30
|
group_number = 1
|
31
|
-
|
31
|
+
previous_concat_path = nil
|
32
|
+
|
32
33
|
concat_files.in_groups(parallel, false) do |group|
|
33
34
|
concat_path = File.join(File.expand_path(@project_dir), "build", "app-concatenated-#{group_number}.rb")
|
34
|
-
File.
|
35
|
-
Dir.mkdir(File.dirname(concat_path)) unless File.exist?(File.dirname(concat_path))
|
35
|
+
temp_concat_path = File.join(File.expand_path(@project_dir), "build", "app-concatenated-#{group_number}-temp.rb")
|
36
36
|
Motion::Project::App.info "Concat", concat_path
|
37
37
|
|
38
|
-
|
38
|
+
# Prep the concat path for writing
|
39
|
+
Dir.mkdir(File.dirname(concat_path)) unless File.exist?(File.dirname(concat_path))
|
40
|
+
|
41
|
+
# Concatenate this group of files
|
42
|
+
File.open(temp_concat_path, 'a') do |concat|
|
39
43
|
concat << "# File generated by 'Compressor' by Jamon Holmgren\n\n"
|
40
44
|
concat << "# "
|
41
45
|
group.each do |filename|
|
@@ -46,11 +50,28 @@ module Motion::Project
|
|
46
50
|
concat << "\n"
|
47
51
|
end
|
48
52
|
end
|
49
|
-
|
53
|
+
|
54
|
+
if File.exist?(concat_path) && !FileUtils.cmp(temp_concat_path, concat_path)
|
55
|
+
# Changed file, replace the original
|
56
|
+
File.delete(concat_path)
|
57
|
+
FileUtils.mv(temp_concat_path, concat_path)
|
58
|
+
else
|
59
|
+
# No change, throw it away
|
60
|
+
File.delete(temp_concat_path)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Add this concatenated file to the build files
|
64
|
+
@files.unshift concat_path
|
65
|
+
|
66
|
+
# Ensure that each file gets loaded in the right order
|
67
|
+
if previous_concat_path
|
68
|
+
files_dependencies concat_path => previous_concat_path
|
69
|
+
end
|
70
|
+
previous_concat_path = concat_path
|
71
|
+
|
72
|
+
# Next group
|
50
73
|
group_number += 1
|
51
74
|
end
|
52
|
-
@files.unshift(concatenated)
|
53
|
-
@files.flatten!
|
54
75
|
end
|
55
76
|
end
|
56
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compressor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamon Holmgren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|