lib/asset_hat/vcs.rb in asset_hat-0.1.2 vs lib/asset_hat/vcs.rb in asset_hat-0.1.3

- old
+ new

@@ -1,6 +1,10 @@ module AssetHat + class << self + attr_accessor :last_commit_ids, :last_bundle_commit_ids + end + def self.last_commit_id(*args) # Usage: # # AssetHat.last_commit_id('public/stylesheets/application.css') # AssetHat.last_commit_id('public/stylesheets/ie.css', @@ -18,17 +22,17 @@ # Validate options if options[:vcs] != :git raise 'Git is currently the only supported VCS.' and return end - @@last_commit_ids ||= {} - if @@last_commit_ids[filepaths].blank? + @last_commit_ids ||= {} + if @last_commit_ids[filepaths].blank? h = `git log -1 --pretty=format:%h #{filepaths} 2>/dev/null` # `h` has either the abbreviated Git commit hash or an empty string - @@last_commit_ids[filepaths] = h if h.present? + @last_commit_ids[filepaths] = h if h.present? end - @@last_commit_ids[filepaths] + @last_commit_ids[filepaths] end def self.last_bundle_commit_id(bundle, type) # Usage: # @@ -44,22 +48,22 @@ raise "Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}." return end # Default to `{:css => {}, :js => {}}` - @@last_bundle_commit_ids ||= + @last_bundle_commit_ids ||= TYPES.inject({}) { |hsh, t| hsh.merge(t => {}) } - if @@last_bundle_commit_ids[type][bundle].blank? + if @last_bundle_commit_ids[type][bundle].blank? dir = self.assets_dir(type) filepaths = self.bundle_filepaths(bundle, type) if filepaths.present? - @@last_bundle_commit_ids[type][bundle] = self.last_commit_id(*filepaths) + @last_bundle_commit_ids[type][bundle] = self.last_commit_id(*filepaths) end end - @@last_bundle_commit_ids[type][bundle] + @last_bundle_commit_ids[type][bundle] end - def self.last_commit_ids ; @@last_commit_ids ; end + def self.last_commit_ids ; @last_commit_ids ; end end