trackman 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem 'rest-client', :git => 'git@github.com:jfabre/rest-client.git'
data/lib/tasks.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  if defined?(Rails) && ::Rails::VERSION::STRING =~ /^[3-9]\.[1-9]/
2
+ Bundler.require
2
3
  class Tasks < Rails::Railtie
3
4
  rake_tasks do
4
5
  Dir[File.join(File.dirname(__FILE__),'../rails_generators/trackman/templates/*.rake')].each { |f| load f }
@@ -83,7 +83,6 @@ module Trackman
83
83
  begin
84
84
  return sync if autosync
85
85
  rescue Exception => ex
86
- #require_relative 'remote_asset.rb'
87
86
  ::Trackman::Assets::RemoteAsset.log_exception ex
88
87
  return false
89
88
  end
@@ -8,25 +8,20 @@ module Trackman
8
8
 
9
9
  def translate url, parent_url
10
10
  root = working_dir.realpath
11
- path = url.dup
12
11
 
13
-
12
+ path = url.dup
14
13
  path.slice! /^(\/assets|assets\/)/
15
14
  path = Pathname.new path
16
15
 
17
16
  path = prepare_for_sprocket(path, parent_url, root) if path.relative?
18
17
  begin
19
18
  path = sprockets.resolve path
20
- rescue Exception
19
+ rescue Exception => e
21
20
  return nil
22
21
  end
23
22
  path.relative_path_from(root).to_s
24
23
  end
25
-
26
- def sprockets
27
- @@sprockets ||= init_env
28
- end
29
-
24
+
30
25
  def prepare_for_sprocket path, parent_url, root
31
26
  folder = (root + Pathname.new(parent_url)).parent.realpath
32
27
  path = (folder + path).to_s
@@ -34,28 +29,10 @@ module Trackman
34
29
  path
35
30
  end
36
31
 
37
- def init_env
38
- env = ::Sprockets::Environment.new
39
-
40
- paths = ['app', 'lib', 'vendor'].inject([]) do |array, f|
41
- array + ["images", "stylesheets", "javascripts"].map{|p| "#{working_dir}/#{f}/assets/#{p}" }
42
- end
43
-
44
- paths << "#{working_dir}/public"
45
- paths.each{|p| env.append_path p }
46
- env
47
- end
48
- def subfolder(file)
49
- if file.include?('.js')
50
- subfolder = "javascripts"
51
- elsif file.include?('.css')
52
- subfolder = "stylesheets"
53
- else
54
- subfolder = "images"
55
- end
56
- subfolder
32
+ def sprockets
33
+ ::Rails.application.assets
57
34
  end
58
35
  end
59
36
  end
60
37
  end
61
- end
38
+ end
@@ -10,7 +10,6 @@ module Trackman
10
10
  @@server_url = ENV['TRACKMAN_URL']
11
11
 
12
12
  @@site = "#{@@server_url}/assets"
13
-
14
13
  attr_reader :id
15
14
 
16
15
  def initialize attributes = {}
@@ -22,7 +21,7 @@ module Trackman
22
21
  end
23
22
 
24
23
  def self.log_exception ex
25
- RestClient.post "#{@@server_url}/exceptions", :exception => { :message => ex.message, :backtrace => ex.backtrace }
24
+ RestClient.post "#{@@server_url}/exceptions", :exception => { :message => ex.message, :backtrace => ex.backtrace }, :ssl_version => 'SSLv3'
26
25
  end
27
26
 
28
27
  def file_hash
@@ -45,13 +44,13 @@ module Trackman
45
44
  end
46
45
 
47
46
  def create!
48
- response = RestClient.post @@site, build_params, :content_type => :json, :accept => :json
47
+ response = RestClient.post @@site, build_params, :content_type => :json, :accept => :json, :ssl_version => 'SSLv3'
49
48
  path = response.headers[:location]
50
49
  @id = path[/\d+$/].to_i
51
50
  end
52
51
 
53
52
  def update!
54
- RestClient.put "#{@@site}/#{id}", build_params, :content_type => :json, :accept => :json
53
+ RestClient.put "#{@@site}/#{id}", build_params, :content_type => :json, :accept => :json, :ssl_version => 'SSLv3'
55
54
  end
56
55
  def delete
57
56
  response = RestClient.delete "#{@@site}/#{id}"
@@ -31,7 +31,7 @@ module Trackman
31
31
 
32
32
 
33
33
  def add_configs
34
- if configs.include?(@@TRACKMAN_ERROR) && configs.include?(@@TRACKMAN_MAINTENANCE)
34
+ if configs.include?(@@TRACKMAN_ERROR) && configs.include?(@@TRACKMAN_MAINTENANCE)
35
35
  trackman_configs = {}
36
36
  [[@@TRACKMAN_ERROR, @@ERROR], [@@TRACKMAN_MAINTENANCE, @@MAINTENANCE]].each do |old_c, new_c|
37
37
  trackman_configs[new_c] = configs[old_c]
@@ -40,7 +40,7 @@ module Trackman
40
40
  add = trackman_configs.map{|k,v| "#{k}=#{v}" }.join(' ')
41
41
  add_config add
42
42
  else
43
- raise SetupException, "Can't find trackman configuration, make sure trackman addon is installed."
43
+ raise SetupException, "cannot find trackman configuration, make sure trackman addon is installed"
44
44
  end
45
45
  end
46
46
 
@@ -96,4 +96,4 @@ module Trackman
96
96
 
97
97
  class SetupException < Exception
98
98
  end
99
- end
99
+ end
@@ -1,7 +1,11 @@
1
1
  module Trackman
2
2
  class Railtie < Rails::Railtie
3
- initializer "trackman.insert_middleware" do |app|
4
- app.config.middleware.use "Trackman::RackMiddleware"
3
+ initializer "trackman.hook" do |app|
4
+ #app.config.middleware.use "Trackman::RackMiddleware"
5
+ app.config.after_initialize do
6
+ Trackman::Assets::Asset.autosync
7
+ end
5
8
  end
6
9
  end
7
- end
10
+ end
11
+
@@ -1,3 +1,3 @@
1
1
  module Trackman
2
- VERSION = "0.3.5"
3
- end
2
+ VERSION = "0.4.0"
3
+ end
@@ -5,12 +5,12 @@ namespace :trackman do
5
5
  desc "Syncs your assets with the server, this is what gets executed when you deploy to heroku."
6
6
  task :sync => :environment do
7
7
  RestClient.log = Logger.new(STDOUT) if Debugger.debug_mode?
8
+
8
9
  Trackman::Assets::Asset.sync
9
10
  end
10
11
 
11
12
  desc "Sets up the heroku configs required by Trackman"
12
13
  task :setup, :app do |t, args|
13
-
14
14
  heroku_version = Gem.loaded_specs["heroku"].version.to_s
15
15
  Trackman::ConfigurationHandler.new(heroku_version, app: args[:app]).setup
16
16
  end
@@ -9,5 +9,4 @@
9
9
  <h1>We're undergoing a maintenance(503)</h1>
10
10
  </div>
11
11
  </body>
12
- </html>
13
- r
12
+ </html>
@@ -1,6 +1,6 @@
1
1
  class AppCreator
2
2
  def self.get_config url
3
- response = RestClient.post url, :plan => 'test', :heroku_id => 123
3
+ response = RestClient.post url, :plan => 'test', :heroku_id => 123, :ssl_version => 'SSLv3'
4
4
  json = JSON.parse response
5
5
 
6
6
  trackman_url = json['config']['TRACKMAN_URL'].gsub('https', 'http')
@@ -31,7 +31,9 @@ class FakablePathManTester
31
31
  define_method :translate do |url, parent_url|
32
32
  parent = parent_url.to_s.dup
33
33
  parent.slice!(prepath)
34
- prepath + real_translate(url, parent)
34
+ result = real_translate(url, parent)
35
+ return prepath + result unless result.nil?
36
+ nil
35
37
  end
36
38
  end
37
39
  end
@@ -17,8 +17,7 @@ describe Trackman::Assets::Components::Rails32PathResolver do
17
17
  @test.stub(:prepare_for_sprocket).and_return('some/path')
18
18
  @test.stub(:sprockets).and_return(sprocket)
19
19
 
20
- @test.translate 'some/path', 'path/to/my/parent'
21
-
22
20
  lambda { @test.translate 'some/path', 'path/to/my/parent' }.should_not raise_error
23
21
  end
22
+
24
23
  end
@@ -10,7 +10,6 @@ describe Trackman::Assets::RemoteAsset do
10
10
  json = JSON.parse response
11
11
  @trackman_url = json['config']['TRACKMAN_URL'].gsub('https', 'http')
12
12
 
13
- puts @trackman_url
14
13
  @config = [[:@@server_url, @trackman_url], [:@@site, "#{@trackman_url}/assets"]]
15
14
  @config.each do |s, v|
16
15
  RemoteAsset.send(:class_variable_set, s, v)
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,30 @@ RSpec.configure do |config|
13
13
  end
14
14
 
15
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
35
+ end
36
+ end
37
+ end
38
+
39
+
16
40
  Asset = Trackman::Assets::Asset unless defined?(Asset)
17
41
  CssAsset = Trackman::Assets::CssAsset unless defined?(CssAsset)
18
42
  HtmlAsset = Trackman::Assets::HtmlAsset unless defined?(HtmlAsset)
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.3.5
4
+ version: 0.4.0
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-08-27 00:00:00.000000000 Z
13
+ date: 2012-09-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -428,7 +428,6 @@ files:
428
428
  - spec/helpers/act_like_rails2311.rb
429
429
  - spec/helpers/act_like_rails32.rb
430
430
  - spec/helpers/app_creator.rb
431
- - spec/helpers/config_helper.rb
432
431
  - spec/helpers/fakable_pathman_tester.rb
433
432
  - spec/html_asset_spec.rb
434
433
  - spec/paths/pathman_spec.rb
@@ -740,7 +739,6 @@ test_files:
740
739
  - spec/helpers/act_like_rails2311.rb
741
740
  - spec/helpers/act_like_rails32.rb
742
741
  - spec/helpers/app_creator.rb
743
- - spec/helpers/config_helper.rb
744
742
  - spec/helpers/fakable_pathman_tester.rb
745
743
  - spec/html_asset_spec.rb
746
744
  - spec/paths/pathman_spec.rb
File without changes