trackman 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/lib/trackman.rb +14 -7
  2. data/lib/trackman/assets.rb +4 -14
  3. data/lib/trackman/assets/asset.rb +3 -3
  4. data/lib/trackman/assets/asset_factory.rb +46 -0
  5. data/lib/trackman/assets/bundled_asset.rb +26 -0
  6. data/lib/trackman/assets/composite_asset.rb +40 -0
  7. data/lib/trackman/assets/css_asset.rb +1 -1
  8. data/lib/trackman/assets/html_asset.rb +1 -1
  9. data/lib/trackman/assets/persistence.rb +9 -0
  10. data/lib/trackman/assets/persistence/remote.rb +54 -0
  11. data/lib/trackman/assets/remote_asset.rb +4 -45
  12. data/lib/trackman/assets/remote_asset_factory.rb +11 -0
  13. data/lib/trackman/components.rb +9 -0
  14. data/lib/trackman/components/conventions.rb +21 -0
  15. data/lib/trackman/components/diffable.rb +28 -0
  16. data/lib/trackman/components/hashable.rb +27 -0
  17. data/lib/trackman/components/shippable.rb +29 -0
  18. data/lib/trackman/errors.rb +9 -0
  19. data/lib/trackman/errors/asset_not_found_error.rb +6 -0
  20. data/lib/trackman/errors/config_not_found_error.rb +6 -0
  21. data/lib/trackman/errors/config_setup_error.rb +7 -0
  22. data/lib/trackman/path.rb +9 -0
  23. data/lib/trackman/path/rails32_resolver.rb +35 -0
  24. data/lib/trackman/path/rails_resolver.rb +29 -0
  25. data/lib/trackman/path/resolver.rb +32 -0
  26. data/lib/trackman/scaffold.rb +2 -14
  27. data/lib/trackman/utility.rb +9 -0
  28. data/lib/trackman/utility/configuration.rb +98 -0
  29. data/lib/trackman/{core_extensions.rb → utility/core_extensions.rb} +0 -0
  30. data/lib/trackman/utility/debugger.rb +24 -0
  31. data/lib/{trackman_railtie.rb → trackman/utility/railtie.rb} +2 -1
  32. data/lib/trackman/version.rb +1 -1
  33. data/rails_generators/trackman_tasks/templates/trackman.rake +1 -1
  34. data/spec/asset_factory_spec.rb +3 -3
  35. data/spec/asset_spec.rb +1 -1
  36. data/spec/composite_asset_spec.rb +2 -2
  37. data/spec/{configuration_handler_spec.rb → configuration_spec.rb} +6 -6
  38. data/spec/diffable_spec.rb +2 -2
  39. data/spec/helpers/act_like_rails2311.rb +2 -2
  40. data/spec/helpers/act_like_rails32.rb +2 -2
  41. data/spec/helpers/app_creator.rb +12 -5
  42. data/spec/helpers/fakable_pathman_tester.rb +5 -5
  43. data/spec/paths/pathman_spec.rb +2 -2
  44. data/spec/paths/rails32_pathman_spec.rb +2 -2
  45. data/spec/{rails32_path_resolver_spec.rb → rails32_resolver_spec.rb} +3 -3
  46. data/spec/remote_asset_spec.rb +13 -17
  47. data/spec/{scaffolding_spec.rb → scaffold_spec.rb} +0 -0
  48. data/spec/shippable_spec.rb +2 -2
  49. data/spec/spec_helper.rb +6 -6
  50. data/spec/sync_spec.rb +1 -1
  51. metadata +32 -27
  52. data/lib/trackman/assets/components.rb +0 -13
  53. data/lib/trackman/assets/components/asset_factory.rb +0 -48
  54. data/lib/trackman/assets/components/bundled_asset.rb +0 -29
  55. data/lib/trackman/assets/components/composite_asset.rb +0 -42
  56. data/lib/trackman/assets/components/conventions.rb +0 -23
  57. data/lib/trackman/assets/components/diffable.rb +0 -30
  58. data/lib/trackman/assets/components/hashable.rb +0 -29
  59. data/lib/trackman/assets/components/path_resolver.rb +0 -34
  60. data/lib/trackman/assets/components/rails32_path_resolver.rb +0 -39
  61. data/lib/trackman/assets/components/rails_path_resolver.rb +0 -31
  62. data/lib/trackman/assets/components/remote_asset_factory.rb +0 -13
  63. data/lib/trackman/assets/components/shippable.rb +0 -31
  64. data/lib/trackman/assets/errors.rb +0 -10
  65. data/lib/trackman/assets/errors/asset_not_found_error.rb +0 -8
  66. data/lib/trackman/assets/errors/config_not_found_error.rb +0 -8
  67. data/lib/trackman/configuration_handler.rb +0 -99
  68. data/lib/trackman/debugger.rb +0 -9
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Trackman::Assets::Components::Diffable do
3
+ describe Trackman::Components::Diffable do
4
4
  class TestDiff
5
- extend Trackman::Assets::Components::Diffable
5
+ extend Trackman::Components::Diffable
6
6
  end
7
7
 
8
8
  it "specify the html to update and the image to delete" do
@@ -1,7 +1,7 @@
1
1
 
2
2
  class ActLikeRails2311
3
3
  def self.switch_on
4
- Trackman::Assets::Components::AssetFactory.module_eval do
4
+ Trackman::Assets::AssetFactory.module_eval do
5
5
  alias :old_rails_defined? :rails_defined?
6
6
  alias :old_asset_pipeline_enabled? :asset_pipeline_enabled?
7
7
 
@@ -16,7 +16,7 @@ class ActLikeRails2311
16
16
  end
17
17
 
18
18
  def self.switch_off
19
- Trackman::Assets::Components::AssetFactory.module_eval do
19
+ Trackman::Assets::AssetFactory.module_eval do
20
20
  alias :rails_defined? :old_rails_defined?
21
21
  alias :asset_pipeline_enabled? :old_asset_pipeline_enabled?
22
22
 
@@ -1,6 +1,6 @@
1
1
  class ActLikeRails32
2
2
  def self.switch_on
3
- Trackman::Assets::Components::AssetFactory.module_eval do
3
+ Trackman::Assets::AssetFactory.module_eval do
4
4
  alias :old_asset_pipeline_enabled? :asset_pipeline_enabled?
5
5
 
6
6
  define_method :asset_pipeline_enabled? do
@@ -10,7 +10,7 @@ class ActLikeRails32
10
10
  end
11
11
 
12
12
  def self.switch_off
13
- Trackman::Assets::Components::AssetFactory.module_eval do
13
+ Trackman::Assets::AssetFactory.module_eval do
14
14
  alias :asset_pipeline_enabled? :old_asset_pipeline_enabled?
15
15
  remove_method :old_asset_pipeline_enabled?
16
16
  end
@@ -5,7 +5,7 @@ class AppCreator
5
5
 
6
6
  trackman_url = json['config']['TRACKMAN_URL'].gsub('https', 'http')
7
7
 
8
- [[:@@server_url, trackman_url], [:@@site, "#{trackman_url}/assets"]]
8
+ [[:server_url, trackman_url], [:site, "#{trackman_url}/assets"]]
9
9
  end
10
10
 
11
11
  def self.create
@@ -15,8 +15,12 @@ class AppCreator
15
15
 
16
16
  @@config = get_config "http://#{user}:#{pass}@#{server}/heroku/resources"
17
17
 
18
- @@config.each do |s, v|
19
- RemoteAsset.send(:class_variable_set, s, v)
18
+ Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
19
+ #singleton = class << self; self; end
20
+ @@config.each do |k, v|
21
+ alias_method "old_#{k}", k
22
+ define_method(k, lambda { v })
23
+ end
20
24
  end
21
25
 
22
26
  @@config
@@ -25,8 +29,11 @@ class AppCreator
25
29
  def self.reset
26
30
  RemoteAsset.all.each { |a| a.delete }
27
31
 
28
- @@config.each do |k,v|
29
- RemoteAsset.send(:class_variable_set, k, v)
32
+ Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
33
+ #singleton = class << self; self; end
34
+ @@config.each do |k,v|
35
+ alias_method k, "old_#{k}"
36
+ end
30
37
  end
31
38
  end
32
39
  end
@@ -1,6 +1,6 @@
1
1
  class FakablePathManTester
2
- @@modules = [PathResolver, Rails32PathResolver, RailsPathResolver]
3
- Conventions = Trackman::Assets::Components::Conventions
2
+ @@modules = [Resolver, Rails32Resolver, RailsResolver]
3
+ Conventions = Trackman::Components::Conventions
4
4
 
5
5
  def self.switch_on prepath
6
6
  override_remote_assets prepath
@@ -16,7 +16,7 @@ class FakablePathManTester
16
16
 
17
17
  def self.override_resolvers prepath
18
18
 
19
- PathResolver.module_eval do
19
+ Resolver.module_eval do
20
20
  alias real_working_dir working_dir
21
21
 
22
22
  define_method :working_dir do
@@ -81,7 +81,7 @@ class FakablePathManTester
81
81
  end
82
82
 
83
83
  def self.reset_resolvers
84
- PathResolver.module_eval do
84
+ Resolver.module_eval do
85
85
  alias :working_dir :real_working_dir
86
86
  remove_method :real_working_dir
87
87
  end
@@ -92,7 +92,7 @@ class FakablePathManTester
92
92
  remove_method :real_translate
93
93
  end
94
94
  end
95
- Rails32PathResolver.send(:class_variable_set, :@@sprockets, nil)
95
+ Rails32Resolver.send(:class_variable_set, :@@sprockets, nil)
96
96
  end
97
97
 
98
98
  def self.reset_conventions
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class PathTester
4
- extend PathResolver
4
+ extend Resolver
5
5
  end
6
6
 
7
- describe PathResolver do
7
+ describe Resolver do
8
8
  it 'gives a path at the same level as the parent if the url is relative and there is no parent specified' do
9
9
  parent_url = 'allo/home.html'
10
10
  url = 'bob.jpg'
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'sprockets'
3
3
 
4
4
  class Rails32Tester
5
- extend Rails32PathResolver
5
+ extend Rails32Resolver
6
6
 
7
7
  def self.working_dir
8
8
  Pathname.new('spec/fixtures/sprockets')
@@ -10,7 +10,7 @@ class Rails32Tester
10
10
  end
11
11
 
12
12
 
13
- describe Rails32PathResolver do
13
+ describe Rails32Resolver do
14
14
  it "serves an image linked by an html" do
15
15
  parent_url = 'public/503.html'
16
16
  url = '/assets/bombero.jpeg'
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class Rails32ResolverTest
4
- include Trackman::Assets::Components::Rails32PathResolver
4
+ include Rails32Resolver
5
5
  end
6
6
 
7
- describe Trackman::Assets::Components::Rails32PathResolver do
8
- Rails32PathResolver = Trackman::Assets::Components::Rails32PathResolver
7
+ describe Trackman::Path::Rails32Resolver do
8
+
9
9
  before :all do
10
10
  @test = Rails32ResolverTest.new
11
11
  end
@@ -3,20 +3,8 @@ require 'helpers/app_creator'
3
3
 
4
4
  describe Trackman::Assets::RemoteAsset do
5
5
  before :each do
6
- # user = ENV['HEROKU_USERNAME']
7
- # pass = ENV['HEROKU_PASSWORD']
8
- # server = ENV['TRACKMAN_SERVER_URL']
9
6
  @old_file = nil
10
7
  @config = AppCreator.create
11
-
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')
15
-
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
20
8
  end
21
9
 
22
10
  after :each do
@@ -74,13 +62,21 @@ describe Trackman::Assets::RemoteAsset do
74
62
  end
75
63
 
76
64
  it "throws if a config is missing" do
77
- begin
78
- @config.each {|k,v| RemoteAsset.send(:class_variable_set, k, nil) }
79
- @config.each do |k,v|
80
- lambda { RemoteAsset.create(:path => 'spec/test_data/a.js') }.should raise_error(Trackman::Assets::Errors::ConfigNotFoundError)
65
+ config = @config
66
+ begin
67
+ Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
68
+ config.each do |k,v|
69
+ alias_method "temp_#{k}", k
70
+ define_method(k, lambda{ nil })
71
+ end
81
72
  end
73
+ lambda { RemoteAsset.create(:path => 'spec/test_data/a.js') }.should raise_error(Trackman::Errors::ConfigNotFoundError)
82
74
  ensure
83
- @config.each {|k,v| RemoteAsset.send(:class_variable_set, k, v) }
75
+ Trackman::Assets::Persistence::Remote::ClassMethods.module_eval do
76
+ config.each do |k,v|
77
+ alias_method k, "temp_#{k}"
78
+ end
79
+ end
84
80
  end
85
81
  end
86
82
  end
File without changes
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Trackman::Assets::Components::Shippable do
3
+ describe Trackman::Components::Shippable do
4
4
  class Test
5
- extend Trackman::Assets::Components::Shippable
5
+ extend Trackman::Components::Shippable
6
6
 
7
7
  @@events = []
8
8
  def self.events
data/spec/spec_helper.rb CHANGED
@@ -12,7 +12,7 @@ RSpec.configure do |config|
12
12
  config.filter_run :focus
13
13
  end
14
14
 
15
- module Trackman::Assets::Components::BundledAsset
15
+ module Trackman::Components::BundledAsset
16
16
  def env
17
17
  working_dir = Pathname.new(Dir.pwd)
18
18
  env = ::Sprockets::Environment.new
@@ -24,7 +24,7 @@ module Trackman::Assets::Components::BundledAsset
24
24
  env
25
25
  end
26
26
  end
27
- module Trackman::Assets::Components::Rails32PathResolver
27
+ module Trackman::Path::Rails32Resolver
28
28
  def sprockets
29
29
  env = ::Sprockets::Environment.new
30
30
  paths = ['app', 'lib', 'vendor'].inject([]) do |array, f|
@@ -42,7 +42,7 @@ CssAsset = Trackman::Assets::CssAsset unless defined?(CssAsset)
42
42
  HtmlAsset = Trackman::Assets::HtmlAsset unless defined?(HtmlAsset)
43
43
  RemoteAsset = Trackman::Assets::RemoteAsset unless defined?(RemoteAsset)
44
44
 
45
- PathResolver = Trackman::Assets::Components::PathResolver unless defined?(PathResolver)
46
- Rails32PathResolver = Trackman::Assets::Components::Rails32PathResolver unless defined?(Rails32PathResolver)
47
- RailsPathResolver = Trackman::Assets::Components::RailsPathResolver unless defined?(RailsPathResolver)
48
- ConfigurationHandler = Trackman::ConfigurationHandler unless defined?(ConfigurationHandler)
45
+ Resolver = Trackman::Path::Resolver unless defined?(Resolver)
46
+ Rails32Resolver = Trackman::Path::Rails32Resolver unless defined?(Rails32Resolver)
47
+ RailsResolver = Trackman::Path::RailsResolver unless defined?(RailsResolver)
48
+ Configuration = Trackman::Utility::Configuration unless defined?(Configuration)
data/spec/sync_spec.rb CHANGED
@@ -74,7 +74,7 @@ describe Trackman::Assets::Asset do
74
74
  it "logs the error when sync is broken" do
75
75
  MyTestAsset.stub!(:sync).and_raise("something is wrong")
76
76
 
77
- RemoteAsset.should_receive(:log_exception).once
77
+ Trackman::Utility::Debugger.should_receive(:log_exception).once
78
78
 
79
79
  lambda { result = MyTestAsset.autosync }.should_not raise_error
80
80
  end
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.5.4
4
+ version: 0.5.5
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-27 00:00:00.000000000 Z
13
+ date: 2012-09-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -164,32 +164,37 @@ files:
164
164
  - lib/trackman.rb
165
165
  - lib/trackman/assets.rb
166
166
  - lib/trackman/assets/asset.rb
167
- - lib/trackman/assets/components.rb
168
- - lib/trackman/assets/components/asset_factory.rb
169
- - lib/trackman/assets/components/bundled_asset.rb
170
- - lib/trackman/assets/components/composite_asset.rb
171
- - lib/trackman/assets/components/conventions.rb
172
- - lib/trackman/assets/components/diffable.rb
173
- - lib/trackman/assets/components/hashable.rb
174
- - lib/trackman/assets/components/path_resolver.rb
175
- - lib/trackman/assets/components/rails32_path_resolver.rb
176
- - lib/trackman/assets/components/rails_path_resolver.rb
177
- - lib/trackman/assets/components/remote_asset_factory.rb
178
- - lib/trackman/assets/components/shippable.rb
167
+ - lib/trackman/assets/asset_factory.rb
168
+ - lib/trackman/assets/bundled_asset.rb
169
+ - lib/trackman/assets/composite_asset.rb
179
170
  - lib/trackman/assets/css_asset.rb
180
- - lib/trackman/assets/errors.rb
181
- - lib/trackman/assets/errors/asset_not_found_error.rb
182
- - lib/trackman/assets/errors/config_not_found_error.rb
183
171
  - lib/trackman/assets/html_asset.rb
172
+ - lib/trackman/assets/persistence.rb
173
+ - lib/trackman/assets/persistence/remote.rb
184
174
  - lib/trackman/assets/remote_asset.rb
185
- - lib/trackman/configuration_handler.rb
186
- - lib/trackman/core_extensions.rb
187
- - lib/trackman/debugger.rb
175
+ - lib/trackman/assets/remote_asset_factory.rb
176
+ - lib/trackman/components.rb
177
+ - lib/trackman/components/conventions.rb
178
+ - lib/trackman/components/diffable.rb
179
+ - lib/trackman/components/hashable.rb
180
+ - lib/trackman/components/shippable.rb
181
+ - lib/trackman/errors.rb
182
+ - lib/trackman/errors/asset_not_found_error.rb
183
+ - lib/trackman/errors/config_not_found_error.rb
184
+ - lib/trackman/errors/config_setup_error.rb
185
+ - lib/trackman/path.rb
186
+ - lib/trackman/path/rails32_resolver.rb
187
+ - lib/trackman/path/rails_resolver.rb
188
+ - lib/trackman/path/resolver.rb
188
189
  - lib/trackman/scaffold.rb
189
190
  - lib/trackman/scaffold/content_saver.rb
190
191
  - lib/trackman/scaffold/pretty-print.xslt
192
+ - lib/trackman/utility.rb
193
+ - lib/trackman/utility/configuration.rb
194
+ - lib/trackman/utility/core_extensions.rb
195
+ - lib/trackman/utility/debugger.rb
196
+ - lib/trackman/utility/railtie.rb
191
197
  - lib/trackman/version.rb
192
- - lib/trackman_railtie.rb
193
198
  - rails_generators/trackman_controller/USAGE
194
199
  - rails_generators/trackman_controller/templates/controller_layout.rb.erb
195
200
  - rails_generators/trackman_controller/templates/view_layout.html.erb
@@ -201,7 +206,7 @@ files:
201
206
  - spec/asset_factory_spec.rb
202
207
  - spec/asset_spec.rb
203
208
  - spec/composite_asset_spec.rb
204
- - spec/configuration_handler_spec.rb
209
+ - spec/configuration_spec.rb
205
210
  - spec/css_asset_spec.rb
206
211
  - spec/diffable_spec.rb
207
212
  - spec/fixtures/composite_assets/query_string_in_path.html
@@ -447,9 +452,9 @@ files:
447
452
  - spec/paths/rails32_pathman_spec.rb
448
453
  - spec/rails2311/first_push_spec.rb
449
454
  - spec/rails32/first_push_spec.rb
450
- - spec/rails32_path_resolver_spec.rb
455
+ - spec/rails32_resolver_spec.rb
451
456
  - spec/remote_asset_spec.rb
452
- - spec/scaffolding_spec.rb
457
+ - spec/scaffold_spec.rb
453
458
  - spec/shippable_spec.rb
454
459
  - spec/spec_helper.rb
455
460
  - spec/sync_spec.rb
@@ -513,7 +518,7 @@ test_files:
513
518
  - spec/asset_factory_spec.rb
514
519
  - spec/asset_spec.rb
515
520
  - spec/composite_asset_spec.rb
516
- - spec/configuration_handler_spec.rb
521
+ - spec/configuration_spec.rb
517
522
  - spec/css_asset_spec.rb
518
523
  - spec/diffable_spec.rb
519
524
  - spec/fixtures/composite_assets/query_string_in_path.html
@@ -759,9 +764,9 @@ test_files:
759
764
  - spec/paths/rails32_pathman_spec.rb
760
765
  - spec/rails2311/first_push_spec.rb
761
766
  - spec/rails32/first_push_spec.rb
762
- - spec/rails32_path_resolver_spec.rb
767
+ - spec/rails32_resolver_spec.rb
763
768
  - spec/remote_asset_spec.rb
764
- - spec/scaffolding_spec.rb
769
+ - spec/scaffold_spec.rb
765
770
  - spec/shippable_spec.rb
766
771
  - spec/spec_helper.rb
767
772
  - spec/sync_spec.rb
@@ -1,13 +0,0 @@
1
- module Trackman
2
- module Assets
3
- module Components
4
- @@modules = [:Conventions, :Diffable, :Hashable,
5
- :Shippable, :CompositeAsset, :AssetFactory, :PathResolver,
6
- :Rails32PathResolver, :RailsPathResolver, :BundledAsset, :RemoteAssetFactory]
7
-
8
- ::Trackman::Assets.autoloads 'trackman/assets/components', @@modules do |s,p|
9
- autoload s, p
10
- end
11
- end
12
- end
13
- end
@@ -1,48 +0,0 @@
1
- module Trackman
2
- module Assets
3
- module Components
4
- module AssetFactory
5
- def create attributes = {}
6
- path = attributes[:path]
7
- instance = retrieve_parent(path).new attributes
8
- add_content_behavior instance
9
- end
10
-
11
- def retrieve_parent path
12
- if File.extname(path) == '.html'
13
- parent = HtmlAsset
14
- elsif File.extname(path) == '.css'
15
- parent = CssAsset
16
- else
17
- parent = Asset
18
- end
19
- parent
20
- end
21
-
22
- def add_content_behavior instance
23
- if asset_pipeline_enabled?
24
- instance.extend Rails32PathResolver, BundledAsset
25
- return instance
26
- elsif rails_defined? #fallback to rails without asset pipeline
27
- instance.extend RailsPathResolver
28
- end
29
- instance.extend Hashable
30
-
31
- instance
32
- end
33
-
34
- def rails_defined?
35
- Object.const_defined?(:Rails)
36
- end
37
-
38
- def asset_pipeline_enabled?
39
- rails_defined? &&
40
- Rails.respond_to?(:application) &&
41
- Rails.application.config.assets.enabled &&
42
- Rails.application.respond_to?(:assets) &&
43
- Rails.application.assets
44
- end
45
- end
46
- end
47
- end
48
- end