trackman 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- trackman (0.4.2)
12
+ trackman (0.4.3)
13
13
  heroku (>= 2.26.2)
14
14
  json
15
15
  nokogiri
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Fabre Jeremy and Petre Emanuel
1
+ Copyright (c) 2012 SynApps, Inc. All Rights Reserved
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
4
  software and associated documentation files (the "Software"), to deal in the Software
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Trackman
2
2
  Trackman is a Heroku add-on that hosts your maintenance pages and their assets outside your app.
3
- Version them as a part of your project.
3
+ You keep them within your project, trackman syncs them to s3 when you deploy.
4
4
 
5
- works out of the box for Ruby(1.8.7 and 1.9.3) on
6
- * Rails 2
7
- * Rails 3
5
+ Works out of the box for Ruby(1.8.7 and 1.9.3) on
6
+ * Rails 2.3
7
+ * Rails 3.x
8
8
 
9
9
  ##Quick peek
10
10
  ###The first time
@@ -38,9 +38,9 @@ This will add trackman.rake to lib/tasks/
38
38
  rake trackman:setup
39
39
  ```
40
40
  This sets your initial heroku configurations and ensures that when your app is down or in maintenance your pages will be requested by heroku.
41
- If you have maintenance or error pages setup for heroku, we will back them up in a configuration before we override them.
41
+ If you have maintenance or error pages setup for heroku, trackman will back them up in a configuration before we overwrite them.
42
42
 
43
- On your next push Trackman will look for changes to your maintenance pages and sync them!
43
+ On your next push Trackman will look for changes to your pages, linked assets and sync them.
44
44
 
45
45
  ### Optional - If for any reason you wish to troubleshoot the sync operation:
46
46
 
@@ -84,7 +84,7 @@ https://github.com/SynApps/trackman/issues
84
84
 
85
85
  ###Copyright
86
86
 
87
- Copyright © 2012 Emanuel Petre, Jeremy Fabre
87
+ Copyright © 2012 SynApps
88
88
 
89
89
  ## License
90
90
 
@@ -1,11 +1,8 @@
1
1
  module Trackman
2
2
  module Assets
3
3
  class Asset
4
- extend Components::AssetFactory
5
- extend Components::Conventions
6
- extend Components::Diffable
7
- extend Components::Shippable
8
- include Components::Hashable
4
+ extend Components::AssetFactory, Components::Conventions
5
+ extend Components::Diffable, Components::Shippable
9
6
  include Comparable
10
7
 
11
8
  def initialize attributes = {}
@@ -19,7 +16,7 @@ module Trackman
19
16
  attr_reader :path, :assets
20
17
 
21
18
  def to_remote
22
- RemoteAsset.new(:path => @path, :virtual_path => self.virtual_path)
19
+ RemoteAsset.create(:path => @path, :virtual_path => self.virtual_path)
23
20
  end
24
21
 
25
22
  def ==(other)
@@ -50,7 +47,11 @@ module Trackman
50
47
  def is_child_of(parent)
51
48
  parent.assets.include? self
52
49
  end
53
-
50
+
51
+ def to_s
52
+ "<#{self.class}:\npath=#{path}\nfile_hash=#{file_hash}>"
53
+ end
54
+
54
55
  def self.all
55
56
  return [] unless maintenance_path.exist?
56
57
 
@@ -63,6 +64,7 @@ module Trackman
63
64
  def self.sync
64
65
  local = Asset.all
65
66
  remote = RemoteAsset.all
67
+
66
68
  diff_result = diff(local, remote)
67
69
 
68
70
  Debugger.trace diff_result.inspect
@@ -4,26 +4,33 @@ module Trackman
4
4
  module AssetFactory
5
5
  def create attributes = {}
6
6
  path = attributes[:path]
7
+ instance = retrieve_parent(path).new attributes
8
+ add_content_behavior instance
9
+ end
7
10
 
11
+ def retrieve_parent path
8
12
  if File.extname(path) == '.html'
9
13
  parent = HtmlAsset
10
14
  elsif File.extname(path) == '.css'
11
15
  parent = CssAsset
12
16
  else
13
17
  parent = Asset
14
- end
15
-
16
- instance = parent.new attributes
18
+ end
19
+ parent
20
+ end
17
21
 
22
+ def add_content_behavior instance
18
23
  if asset_pipeline_enabled?
19
- instance.extend Rails32PathResolver
24
+ instance.extend Rails32PathResolver, BundledAsset
25
+ return instance
20
26
  elsif rails_defined? #fallback to rails without asset pipeline
21
27
  instance.extend RailsPathResolver
22
28
  end
29
+ instance.extend Hashable
23
30
 
24
31
  instance
25
32
  end
26
-
33
+
27
34
  def rails_defined?
28
35
  Object.const_defined?(:Rails)
29
36
  end
@@ -31,11 +38,10 @@ module Trackman
31
38
  def asset_pipeline_enabled?
32
39
  rails_defined? &&
33
40
  Rails.respond_to?(:application) &&
34
- Rails.application.respond_to?(:config) &&
35
- Rails.application.config.respond_to?(:assets) &&
41
+ Rails.application.respond_to?(:assets) &&
36
42
  Rails.application.config.assets.enabled
37
43
  end
38
44
  end
39
45
  end
40
46
  end
41
- end
47
+ end
@@ -0,0 +1,29 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module BundledAsset
5
+ include Hashable
6
+
7
+ def env
8
+ @@env ||= ::Rails.application.assets.index
9
+ end
10
+
11
+ def data
12
+ result = (@bundled ||= init_data)
13
+
14
+ return super if result.nil? || result.length == 0
15
+ result
16
+ end
17
+
18
+ def init_data
19
+ begin
20
+ return env[env.attributes_for(path.realpath).pathname].to_s
21
+ rescue
22
+ return nil
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -14,15 +14,14 @@ module Trackman
14
14
 
15
15
  def assets
16
16
  internals = children_paths.select{|p| p.internal_path? }.map{|p| {old: p, new_path: translate(p, path)} }
17
- internals.select{|p| !p[:new_path].nil? }.map{|p| asset_from(p[:old], p[:new_path])}.inject([]) do |sum, a|
18
- sum << a
19
- sum.concat(a.assets.select{|child| !sum.include?(child) })
20
- sum
17
+ internals = internals.select{|p| !p[:new_path].nil? }.map{|p| asset_from(p[:old], p[:new_path])}
18
+ internals.inject([]) do |sum, a|
19
+ (sum << a) + a.assets.select{|child| !sum.include?(child) }
21
20
  end
22
21
  end
23
22
 
24
23
  def asset_from(virtual, physical)
25
- Asset.create(:virtual_path => virtual.dup, :path => physical)
24
+ Asset.create(:virtual_path => virtual, :path => physical)
26
25
  end
27
26
 
28
27
  def inner_css_paths
@@ -4,6 +4,7 @@ module Trackman
4
4
  module Diffable
5
5
  def diff local, remote
6
6
  to_create = local.select{|a| remote.all? { |s| a.path != s.path } }.map{|a| a.to_remote }
7
+
7
8
  {
8
9
  :create => to_create,
9
10
  :update => remote.select{|a| local.any?{ |s| a.path == s.path && a.file_hash != s.file_hash }},
@@ -4,24 +4,23 @@ module Trackman
4
4
  module Assets
5
5
  module Components
6
6
  module Hashable
7
-
8
7
  def data
9
- @data ||= read_file
8
+ @data ||= read_file(path)
10
9
  end
11
10
 
12
11
  def file_hash
13
- Digest::MD5.hexdigest(data)
12
+ @file_hash ||= (data.nil? ? "" : Digest::MD5.hexdigest(data))
14
13
  end
15
14
 
16
15
  protected
17
- def read_file
16
+ def read_file(file_path)
18
17
  begin
19
- file = File.open(path)
18
+ file = File.open(file_path)
20
19
  return file.read
21
20
  rescue
22
21
  return nil
23
22
  ensure
24
- file.close
23
+ file.close unless file.nil?
25
24
  end
26
25
  end
27
26
  end
@@ -16,7 +16,7 @@ module Trackman
16
16
  path = prepare_for_sprocket(path, parent_url, root) if path.relative?
17
17
  begin
18
18
  path = sprockets.resolve path
19
- rescue Exception => e
19
+ rescue Sprockets::FileNotFound => e
20
20
  Debugger.trace "Could not find path: #{path}\n#{e.message}"
21
21
  return nil
22
22
  end
@@ -0,0 +1,13 @@
1
+ module Trackman
2
+ module Assets
3
+ module Components
4
+ module RemoteAssetFactory
5
+ include AssetFactory
6
+
7
+ def retrieve_parent(path)
8
+ RemoteAsset
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -15,9 +15,9 @@ module Trackman
15
15
  def build_proc symbol, instance
16
16
  case symbol
17
17
  when :update
18
- proc = Proc.new { instance.update! }
18
+ proc = Proc.new { instance.update }
19
19
  when :create
20
- proc = Proc.new { instance.create! }
20
+ proc = Proc.new { instance.insert }
21
21
  when :delete
22
22
  proc = Proc.new { instance.delete }
23
23
  else
@@ -1,7 +1,9 @@
1
1
  module Trackman
2
2
  module Assets
3
3
  module Components
4
- @@modules = [:Conventions, :Diffable, :Hashable, :Shippable, :CompositeAsset, :AssetFactory, :PathResolver, :Rails32PathResolver, :RailsPathResolver]
4
+ @@modules = [:Conventions, :Diffable, :Hashable,
5
+ :Shippable, :CompositeAsset, :AssetFactory, :PathResolver,
6
+ :Rails32PathResolver, :RailsPathResolver, :BundledAsset, :RemoteAssetFactory]
5
7
 
6
8
  ::Trackman::Assets.autoloads 'trackman/assets/components', @@modules do |s,p|
7
9
  autoload s, p
@@ -7,6 +7,8 @@ RestClient.log = Logger.new(STDOUT) if Debugger.debug_mode?
7
7
  module Trackman
8
8
  module Assets
9
9
  class RemoteAsset < Asset
10
+ extend Components::RemoteAssetFactory
11
+
10
12
  @@server_url = ENV['TRACKMAN_URL']
11
13
 
12
14
  @@site = "#{@@server_url}/assets"
@@ -24,10 +26,6 @@ module Trackman
24
26
  RestClient.post "#{@@server_url}/exceptions", :exception => { :message => ex.message, :backtrace => ex.backtrace }, :ssl_version => 'SSLv3'
25
27
  end
26
28
 
27
- def file_hash
28
- @file_hash || super
29
- end
30
-
31
29
  def validate_path?
32
30
  false
33
31
  end
@@ -36,22 +34,25 @@ module Trackman
36
34
  response = RestClient.get "#{@@site}/#{id}"
37
35
 
38
36
  body = Hash[JSON.parse(response).map{ |k, v| [k.to_sym, v] }]
39
- RemoteAsset.new(body)
37
+
38
+ RemoteAsset.create(body)
40
39
  end
41
40
 
42
41
  def self.all
43
- get_attributes.map{ |r| RemoteAsset.new(r) }.sort
42
+ get_attributes.map{ |r| RemoteAsset.create(r) }.sort
44
43
  end
45
44
 
46
- def create!
45
+
46
+ def insert
47
47
  response = RestClient.post @@site, build_params, :content_type => :json, :accept => :json, :ssl_version => 'SSLv3'
48
48
  path = response.headers[:location]
49
49
  @id = path[/\d+$/].to_i
50
50
  end
51
51
 
52
- def update!
52
+ def update
53
53
  RestClient.put "#{@@site}/#{id}", build_params, :content_type => :json, :accept => :json, :ssl_version => 'SSLv3'
54
54
  end
55
+
55
56
  def delete
56
57
  response = RestClient.delete "#{@@site}/#{id}"
57
58
  true
@@ -70,7 +71,7 @@ module Trackman
70
71
 
71
72
  private
72
73
  def build_params
73
- { :asset => { :virtual_path => virtual_path.to_s, :path => path.to_s, :file => File.open(path) } }
74
+ { :asset => { :virtual_path => virtual_path.to_s, :path => path.to_s, :file => AssetIO.new(path.to_s, data) }, :multipart => true }
74
75
  end
75
76
  def ensure_config
76
77
  raise Errors::ConfigNotFoundError, "The config TRACKMAN_URL is missing." if @@server_url.nil?
@@ -78,6 +79,25 @@ module Trackman
78
79
  def self.get_attributes
79
80
  JSON.parse(RestClient.get @@site).map{|r| Hash[r.map{ |k, v| [k.to_sym, v] }] }
80
81
  end
82
+
83
+ class AssetIO < StringIO
84
+ attr_accessor :filepath
85
+
86
+ def initialize(*args)
87
+ super(*args[1..-1])
88
+ @filepath = args[0]
89
+ end
90
+
91
+ def original_filename
92
+ File.basename(filepath)
93
+ end
94
+ def content_type
95
+ MIME::Types.type_for(path).to_s
96
+ end
97
+ def path
98
+ @filepath
99
+ end
100
+ end
81
101
  end
82
102
  end
83
103
  end
@@ -1,7 +1,6 @@
1
1
  module Trackman
2
2
  class Railtie < Rails::Railtie
3
3
  initializer "trackman.hook" do |app|
4
- #app.config.middleware.use "Trackman::RackMiddleware"
5
4
  app.config.after_initialize do
6
5
  Trackman::Assets::Asset.autosync
7
6
  end
@@ -1,3 +1,3 @@
1
1
  module Trackman
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -40,6 +40,9 @@ describe Trackman::Assets::Components::AssetFactory do
40
40
  end
41
41
 
42
42
  class App
43
+ def assets
44
+ Rails::Assets.new
45
+ end
43
46
  def config
44
47
  Rails::Config.new
45
48
  end
data/spec/asset_spec.rb CHANGED
@@ -30,7 +30,7 @@ describe Trackman::Assets::Asset do
30
30
  describe "#data" do
31
31
  it "returns content of the file specified by path" do
32
32
  path = "./spec/spec_helper.rb"
33
- asset = Asset.new(:path => path)
33
+ asset = Asset.create(:path => path)
34
34
 
35
35
  asset.data.should eq(File.open(path).read)
36
36
  end
@@ -39,7 +39,7 @@ describe Trackman::Assets::Asset do
39
39
  describe "#hash" do
40
40
  it "returns the fingerprint of data" do
41
41
  path = "./spec/spec_helper.rb"
42
- asset = Asset.new(:path => path)
42
+ asset = Asset.create(:path => path)
43
43
 
44
44
  file = File.open path
45
45
  asset.file_hash.should eq(Digest::MD5.hexdigest(file.read))
@@ -23,8 +23,8 @@ describe Trackman::Assets::Components::CompositeAsset do
23
23
  @composite = TestComposite.new
24
24
  end
25
25
  it "has children" do
26
- asset = CssAsset.new(:path => 'spec/test_data/css/with-asset.css')
27
- asset.assets.should == [CssAsset.new(:path => 'spec/test_data/css/imported.css')]
26
+ asset = Asset.create(:path => 'spec/test_data/css/with-asset.css')
27
+ asset.assets.should == [Asset.create(:path => 'spec/test_data/css/imported.css')]
28
28
  end
29
29
 
30
30
  it "removes the translated assets that are nil" do
@@ -2,24 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe CssAsset do
4
4
  it "returns its assets when it has import in it" do
5
- asset = CssAsset.new(:path => 'spec/test_data/css/with-asset.css')
5
+ asset = Asset.create(:path => 'spec/test_data/css/with-asset.css')
6
6
 
7
- asset.assets.should == [CssAsset.new(:path => 'spec/test_data/css/imported.css')]
7
+ asset.assets.should == [Asset.create(:path => 'spec/test_data/css/imported.css')]
8
8
  end
9
9
 
10
10
  it "returns multiple assets when it has multiple imports" do
11
- actual = CssAsset.new(:path => 'spec/test_data/css/with-multiple-assets.css')
11
+ actual = Asset.create(:path => 'spec/test_data/css/with-multiple-assets.css')
12
12
  expected = [
13
- CssAsset.new(:path => 'spec/test_data/css/imported.css'),
14
- CssAsset.new(:path => 'spec/test_data/css/imported2.css')
13
+ Asset.create(:path => 'spec/test_data/css/imported.css'),
14
+ Asset.create(:path => 'spec/test_data/css/imported2.css')
15
15
  ]
16
16
 
17
17
  actual.assets.should == expected
18
18
  end
19
19
 
20
20
  it "returns an image if it is within the css" do
21
- actual = CssAsset.new(:path => 'spec/test_data/css/image/with-image.css')
22
- expected = [ Asset.new(:path => 'spec/test_data/css/image/riding-you.jpg')]
21
+ actual = Asset.create(:path => 'spec/test_data/css/image/with-image.css')
22
+ expected = [ Asset.create(:path => 'spec/test_data/css/image/riding-you.jpg')]
23
23
 
24
24
  actual.assets.should == expected
25
25
  end
@@ -27,9 +27,9 @@ describe CssAsset do
27
27
  it "returns all recursive css imports and images under the css file" do
28
28
  expected =
29
29
  [
30
- CssAsset.new(:path => 'spec/test_data/css/recursive/imported-lvl2.css'),
31
- CssAsset.new(:path => 'spec/test_data/css/recursive/imported-lvl3.css'),
32
- Asset.new(:path => 'spec/test_data/css/recursive/riding-you.jpg')
30
+ Asset.create(:path => 'spec/test_data/css/recursive/imported-lvl2.css'),
31
+ Asset.create(:path => 'spec/test_data/css/recursive/imported-lvl3.css'),
32
+ Asset.create(:path => 'spec/test_data/css/recursive/riding-you.jpg')
33
33
  ]
34
34
  asset = Asset.create(:path => 'spec/test_data/css/recursive/imported-recursive.css')
35
35
  actual = asset.assets
@@ -13,8 +13,8 @@ describe Trackman::Assets::Components::Diffable do
13
13
  }
14
14
 
15
15
  remote = [
16
- RemoteAsset.new(:path => 'spec/test_data/sample.html', :file_hash => 'abcd123'),
17
- RemoteAsset.new(:path => 'spec/test_data/test1.jpeg', :file_hash => '12345')
16
+ RemoteAsset.create(:path => 'spec/test_data/sample.html', :file_hash => 'abcd123'),
17
+ RemoteAsset.create(:path => 'spec/test_data/test1.jpeg', :file_hash => '12345')
18
18
  ]
19
19
 
20
20
  local = [Asset.create(:path => 'spec/test_data/sample.html')]
@@ -18,12 +18,12 @@ class AppCreator
18
18
  @@config.each do |s, v|
19
19
  RemoteAsset.send(:class_variable_set, s, v)
20
20
  end
21
+
22
+ @@config
21
23
  end
22
24
 
23
25
  def self.reset
24
- RemoteAsset.all.each do |a|
25
- a.delete
26
- end
26
+ RemoteAsset.all.each { |a| a.delete }
27
27
 
28
28
  @@config.each do |k,v|
29
29
  RemoteAsset.send(:class_variable_set, k, v)
@@ -49,6 +49,7 @@ describe 'happy path' do
49
49
  actual = RemoteAsset.all
50
50
 
51
51
  actual.should == expected
52
+ actual.each{|a| a.data.should_not be_nil }
52
53
  end
53
54
  end
54
55
 
@@ -10,9 +10,9 @@ describe Trackman::Assets::Components::Rails32PathResolver do
10
10
  @test = Rails32ResolverTest.new
11
11
  end
12
12
 
13
- it "does not throw when sprockets throws" do
13
+ it "does not throw when sprockets throws a FileNotFound" do
14
14
  sprocket = double "SprocketEnvironment"
15
- sprocket.stub(:resolve).and_raise(Exception)
15
+ sprocket.stub(:resolve).and_raise(Sprockets::FileNotFound)
16
16
 
17
17
  @test.stub(:prepare_for_sprocket).and_return('some/path')
18
18
  @test.stub(:sprockets).and_return(sprocket)
@@ -1,32 +1,33 @@
1
1
  require 'spec_helper'
2
+ require 'helpers/app_creator'
2
3
 
3
4
  describe Trackman::Assets::RemoteAsset do
4
- before :all do
5
- user = ENV['HEROKU_USERNAME']
6
- pass = ENV['HEROKU_PASSWORD']
7
- server = ENV['TRACKMAN_SERVER_URL']
5
+ before :each do
6
+ # user = ENV['HEROKU_USERNAME']
7
+ # pass = ENV['HEROKU_PASSWORD']
8
+ # server = ENV['TRACKMAN_SERVER_URL']
9
+ @old_file = nil
10
+ @config = AppCreator.create
8
11
 
9
- response = RestClient.post "http://#{user}:#{pass}@#{server}/heroku/resources", :plan => 'test', :heroku_id => 123
10
- json = JSON.parse response
11
- @trackman_url = json['config']['TRACKMAN_URL'].gsub('https', 'http')
12
+ # response = RestClient.post "http://#{user}:#{pass}@#{server}/heroku/resources", :plan => 'test', :heroku_id => 123
13
+ # json = JSON.parse response
14
+ # @trackman_url = json['config']['TRACKMAN_URL'].gsub('https', 'http')
12
15
 
13
- @config = [[:@@server_url, @trackman_url], [:@@site, "#{@trackman_url}/assets"]]
14
- @config.each do |s, v|
15
- RemoteAsset.send(:class_variable_set, s, v)
16
- end
16
+ # @config = [[:@@server_url, @trackman_url], [:@@site, "#{@trackman_url}/assets"]]
17
+ # @config.each do |s, v|
18
+ # RemoteAsset.send(:class_variable_set, s, v)
19
+ # end
17
20
  end
18
21
 
19
22
  after :each do
20
- RemoteAsset.all.each do |a|
21
- a.delete
22
- end
23
-
23
+ AppCreator.reset
24
+ @config = nil
24
25
  File.open('spec/test_data/y.css', 'w') {|f| f.write @old_file } unless @old_file.nil?
25
26
  end
26
27
 
27
28
  it "creates assets on the server" do
28
- expected = RemoteAsset.new(:path => 'spec/test_data/test2.png')
29
- expected.create!
29
+ expected = RemoteAsset.create(:path => 'spec/test_data/test2.png')
30
+ expected.insert
30
31
 
31
32
  actual = RemoteAsset.find expected.id
32
33
 
@@ -34,8 +35,8 @@ describe Trackman::Assets::RemoteAsset do
34
35
  end
35
36
 
36
37
  it "deletes assets on the server" do
37
- expected = RemoteAsset.new(:path => 'spec/test_data/y.css')
38
- expected.create!
38
+ expected = RemoteAsset.create(:path => 'spec/test_data/y.css')
39
+ expected.insert
39
40
 
40
41
  expected.delete
41
42
 
@@ -43,34 +44,40 @@ describe Trackman::Assets::RemoteAsset do
43
44
  end
44
45
 
45
46
  it "returns all assets on the server" do
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
+ expected = [
48
+ 'spec/test_data/a.js', 'spec/test_data/y.css',
49
+ 'public/503-error.html', 'public/503.html',
50
+ 'spec/test_data/sample.html'
51
+ ]
47
52
 
48
- assets = ['spec/test_data/a.js', 'spec/test_data/y.css', 'spec/test_data/sample.html'].map { |f| RemoteAsset.new(:path => f) }
53
+ assets = ['spec/test_data/a.js', 'spec/test_data/y.css', 'spec/test_data/sample.html'].map do |f|
54
+ RemoteAsset.create(:path => f)
55
+ end
49
56
 
50
- assets.each{|f| f.create! }
57
+ assets.each{|f| f.insert }
51
58
 
52
59
  RemoteAsset.all.map{|a| a.path.to_s }.should eq(expected)
53
60
  end
54
61
 
55
62
  it "updates assets on the server" do
56
- expected = RemoteAsset.new(:path => 'spec/test_data/y.css')
63
+ expected = RemoteAsset.create(:path => 'spec/test_data/y.css')
57
64
 
58
- expected.create!
65
+ expected.insert
59
66
 
60
67
  @old_file = File.open(expected.path) { |f| f.read }
61
68
  File.open(expected.path, 'w') { |f| f.write "wassup cutie pie?" }
62
69
 
63
- expected.update!
70
+ expected.update
64
71
  actual = RemoteAsset.find(expected.id)
65
72
 
66
73
  actual.should eq(expected)
67
74
  end
68
75
 
69
76
  it "throws if a config is missing" do
70
- begin
77
+ begin
71
78
  @config.each {|k,v| RemoteAsset.send(:class_variable_set, k, nil) }
72
79
  @config.each do |k,v|
73
- lambda { RemoteAsset.new(:path => 'spec/test_data/a.js') }.should raise_error(Trackman::Assets::Errors::ConfigNotFoundError)
80
+ lambda { RemoteAsset.create(:path => 'spec/test_data/a.js') }.should raise_error(Trackman::Assets::Errors::ConfigNotFoundError)
74
81
  end
75
82
  ensure
76
83
  @config.each {|k,v| RemoteAsset.send(:class_variable_set, k, v) }
data/spec/spec_helper.rb CHANGED
@@ -5,34 +5,34 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
  require 'trackman'
8
-
8
+ require 'sprockets'
9
9
  RSpec.configure do |config|
10
10
  config.treat_symbols_as_metadata_keys_with_true_values = true
11
11
  config.run_all_when_everything_filtered = true
12
12
  config.filter_run :focus
13
13
  end
14
14
 
15
-
16
- module Trackman
17
- module Assets
18
- module Components
19
- module Rails32PathResolver
20
- def sprockets
21
- @@sprockets ||= init_env
22
- end
23
-
24
- def init_env
25
- env = ::Sprockets::Environment.new
26
- paths = ['app', 'lib', 'vendor'].inject([]) do |array, f|
27
- array + ["images", "stylesheets", "javascripts"].map{|p| "#{working_dir}/#{f}/assets/#{p}" }
28
- end
29
- paths << "#{working_dir}/public"
30
- paths.each{|p| env.append_path p }
31
-
32
- env
33
- end
34
- end
15
+ module Trackman::Assets::Components::BundledAsset
16
+ def env
17
+ working_dir = Pathname.new(Dir.pwd)
18
+ env = ::Sprockets::Environment.new
19
+ paths = ['app', 'lib', 'vendor'].inject([]) do |array, f|
20
+ array + ["images", "stylesheets", "javascripts"].map{|p| "#{working_dir}/#{f}/assets/#{p}" }
21
+ end
22
+ paths << "#{working_dir}/public"
23
+ paths.each{|p| env.append_path p }
24
+ env
25
+ end
26
+ end
27
+ module Trackman::Assets::Components::Rails32PathResolver
28
+ def sprockets
29
+ env = ::Sprockets::Environment.new
30
+ paths = ['app', 'lib', 'vendor'].inject([]) do |array, f|
31
+ array + ["images", "stylesheets", "javascripts"].map{|p| "#{working_dir}/#{f}/assets/#{p}" }
35
32
  end
33
+ paths << "#{working_dir}/public"
34
+ paths.each{|p| env.append_path p }
35
+ env
36
36
  end
37
37
  end
38
38
 
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.4.2
4
+ version: 0.4.3
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-09-02 00:00:00.000000000 Z
13
+ date: 2012-09-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -163,6 +163,7 @@ files:
163
163
  - lib/trackman/assets/asset.rb
164
164
  - lib/trackman/assets/components.rb
165
165
  - lib/trackman/assets/components/asset_factory.rb
166
+ - lib/trackman/assets/components/bundled_asset.rb
166
167
  - lib/trackman/assets/components/composite_asset.rb
167
168
  - lib/trackman/assets/components/conventions.rb
168
169
  - lib/trackman/assets/components/diffable.rb
@@ -170,6 +171,7 @@ files:
170
171
  - lib/trackman/assets/components/path_resolver.rb
171
172
  - lib/trackman/assets/components/rails32_path_resolver.rb
172
173
  - lib/trackman/assets/components/rails_path_resolver.rb
174
+ - lib/trackman/assets/components/remote_asset_factory.rb
173
175
  - lib/trackman/assets/components/shippable.rb
174
176
  - lib/trackman/assets/css_asset.rb
175
177
  - lib/trackman/assets/errors.rb