trackman 0.0.6 → 0.0.8
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/lib/trackman/assets/asset.rb +5 -3
- data/lib/trackman/assets/remote_asset.rb +4 -1
- data/lib/trackman/version.rb +1 -1
- data/spec/asset_all_spec.rb +2 -2
- data/spec/asset_spec.rb +17 -3
- data/spec/helpers/fakable_pathman_tester.rb +24 -2
- data/spec/rails2311/first_push_spec.rb +6 -6
- data/spec/rails32/first_push_spec.rb +6 -5
- data/spec/remote_asset_spec.rb +2 -2
- metadata +2 -2
@@ -21,8 +21,8 @@ module Trackman
|
|
21
21
|
|
22
22
|
def ==(other)
|
23
23
|
return false if other.nil?
|
24
|
-
other_path = other.path.is_a?(Pathname) ? other.path : Pathname.new(other.path)
|
25
|
-
other_path.to_s == path.to_s || path.
|
24
|
+
other_path = other.path.is_a?(Pathname) ? other.path : Pathname.new(other.path)
|
25
|
+
other_path.to_s == path.to_s || path.cleanpath == other_path.cleanpath
|
26
26
|
end
|
27
27
|
|
28
28
|
def <=>(another)
|
@@ -37,13 +37,15 @@ module Trackman
|
|
37
37
|
result += -1
|
38
38
|
elsif another.is_child_of(self)
|
39
39
|
result += 1
|
40
|
+
else
|
41
|
+
result = self.path.to_s <=> another.path.to_s
|
40
42
|
end
|
41
43
|
|
42
44
|
result
|
43
45
|
end
|
44
46
|
|
45
47
|
def is_child_of(parent)
|
46
|
-
parent.
|
48
|
+
parent.assets.include? self
|
47
49
|
end
|
48
50
|
|
49
51
|
def self.all
|
@@ -33,7 +33,7 @@ module Trackman
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.all
|
36
|
-
|
36
|
+
get_attributes.map{ |r| RemoteAsset.new(r) }.sort
|
37
37
|
end
|
38
38
|
|
39
39
|
def create!
|
@@ -65,6 +65,9 @@ module Trackman
|
|
65
65
|
def ensure_config
|
66
66
|
raise Errors::ConfigNotFoundError, "The config TRACKMAN_URL is missing." if @@server_url.nil?
|
67
67
|
end
|
68
|
+
def self.get_attributes
|
69
|
+
JSON.parse(RestClient.get @@site).map{|r| Hash[r.map{ |k, v| [k.to_sym, v] }] }
|
70
|
+
end
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
data/lib/trackman/version.rb
CHANGED
data/spec/asset_all_spec.rb
CHANGED
@@ -45,9 +45,9 @@ describe Trackman::Assets::Asset do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
expected = [
|
48
|
-
TestAsset.create(:path => 'spec/test_data/all/3.js'),
|
49
|
-
TestAsset.create(:path => 'spec/test_data/all/2.gif'),
|
50
48
|
TestAsset.create(:path => 'spec/test_data/all/1.css'),
|
49
|
+
TestAsset.create(:path => 'spec/test_data/all/2.gif'),
|
50
|
+
TestAsset.create(:path => 'spec/test_data/all/3.js'),
|
51
51
|
TestAsset.maintenance_page,
|
52
52
|
TestAsset.error_page
|
53
53
|
]
|
data/spec/asset_spec.rb
CHANGED
@@ -57,10 +57,8 @@ describe Trackman::Assets::Asset do
|
|
57
57
|
it "returns a remote asset equal to the previous one" do
|
58
58
|
local = TestAsset.maintenance_page
|
59
59
|
|
60
|
-
AppCreator.create
|
61
60
|
remote = local.to_remote
|
62
|
-
|
63
|
-
|
61
|
+
|
64
62
|
local.should eq(remote)
|
65
63
|
remote.is_a?(RemoteAsset).should be_true
|
66
64
|
end
|
@@ -96,4 +94,20 @@ describe Trackman::Assets::Asset do
|
|
96
94
|
(dependent <=> dependency).should == 1
|
97
95
|
(dependency <=> dependent).should == -1
|
98
96
|
end
|
97
|
+
|
98
|
+
it "fixes the bug with realpath" do
|
99
|
+
class MyAsset < Asset
|
100
|
+
def validate_path?
|
101
|
+
false
|
102
|
+
end
|
103
|
+
def file_hash
|
104
|
+
123
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
local = MyAsset.new(:path => 'public/test.html')
|
109
|
+
remote = MyAsset.new(:path => 'public/./test.html')
|
110
|
+
|
111
|
+
local.should == remote
|
112
|
+
end
|
99
113
|
end
|
@@ -21,7 +21,21 @@ class FakablePathManTester
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
|
+
RemoteAsset.class_eval do
|
26
|
+
singleton_class = class << self; self; end
|
27
|
+
singleton_class.instance_eval do
|
28
|
+
alias_method :old_get_attributes, :get_attributes
|
29
|
+
define_method :get_attributes do
|
30
|
+
old_get_attributes.map do |h|
|
31
|
+
my_hash = h.dup
|
32
|
+
my_hash[:path] = prepath + h[:path] unless h[:path].start_with? prepath
|
33
|
+
my_hash
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
25
39
|
Conventions.module_eval do
|
26
40
|
alias :real_maintenance_path :maintenance_path
|
27
41
|
alias :real_error_path :error_path
|
@@ -55,7 +69,15 @@ class FakablePathManTester
|
|
55
69
|
|
56
70
|
remove_method :real_maintenance_path
|
57
71
|
remove_method :real_error_path
|
58
|
-
end
|
72
|
+
end
|
73
|
+
|
74
|
+
RemoteAsset.class_eval do
|
75
|
+
singleton_class = class << self; self; end
|
76
|
+
singleton_class.instance_eval do
|
77
|
+
alias_method :get_attributes, :old_get_attributes
|
78
|
+
remove_method :old_get_attributes
|
79
|
+
end
|
80
|
+
end
|
59
81
|
end
|
60
82
|
end
|
61
83
|
|
@@ -18,12 +18,12 @@ describe 'full path' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "replaces all images" do
|
21
|
-
|
22
|
-
|
23
|
-
Asset.sync
|
24
|
-
actual = RemoteAsset.all
|
21
|
+
local = Asset.all
|
25
22
|
|
26
|
-
|
27
|
-
|
23
|
+
Asset.sync
|
24
|
+
remote = RemoteAsset.all
|
25
|
+
|
26
|
+
remote.count.should == 8
|
27
|
+
local.each{|l| remote.should include(l) }
|
28
28
|
end
|
29
29
|
end
|
@@ -65,12 +65,13 @@ describe 'full path' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it "replaces all images" do
|
68
|
-
|
68
|
+
local = Asset.all
|
69
69
|
|
70
70
|
Asset.sync
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
remote = RemoteAsset.all
|
72
|
+
|
73
|
+
remote.count.should == 7
|
74
|
+
|
75
|
+
local.each{|l| remote.should include(l) }
|
75
76
|
end
|
76
77
|
end
|
data/spec/remote_asset_spec.rb
CHANGED
@@ -43,9 +43,9 @@ describe Trackman::Assets::RemoteAsset do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns all assets on the server" do
|
46
|
-
expected = ['spec/test_data/
|
46
|
+
expected = ['spec/test_data/a.js', 'spec/test_data/y.css', 'public/503-error.html', 'public/503.html', 'spec/test_data/sample.html']
|
47
47
|
|
48
|
-
assets = ['spec/test_data/
|
48
|
+
assets = ['spec/test_data/a.js', 'spec/test_data/y.css', 'spec/test_data/sample.html'].map { |f| RemoteAsset.new(:path => f) }
|
49
49
|
|
50
50
|
assets.each{|f| f.create! }
|
51
51
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|