class Ruggy::Ext

Public Class Methods

new(app=nil, opts={}) click to toggle source
# File lib/mushin_ext_ruggy.rb, line 9
def initialize app=nil, opts={}, params={}
  @app      = app
  @opts     = opts
  @params   = params 
end

Public Instance Methods

call(env) click to toggle source
# File lib/mushin_ext_ruggy.rb, line 19
def call env 
  env ||= Hash.new 

  case @opts[:cqrs]
  when :cqrs_query 
    #inbound code
    @app.call(env)
    #outbound code
  when :cqrs_command
    #inbound code
    env[:repo] = clone_repo(env[@params[:slug][:clone_url]], @params[:local_repo_path])

    @app.call(env)
    #outbound code
  else
    raise "Ruggy requires you to specify if your cqrs call is command or query?"
  end

end
check_params(*keys) click to toggle source
# File lib/mushin_ext_ruggy.rb, line 15
def check_params *keys
  return (keys.all? {|key| (@params.key?(key) && !@params[key].nil?)})
end
clone_repo(clone_url, local_repo_path) click to toggle source
# File lib/mushin_ext_ruggy.rb, line 48
def clone_repo clone_url, local_repo_path
  #      Rugged::Repository.clone_at(@clone_url, @local_repo_path)
  Rugged::Repository.clone_at(@clone_url, @local_repo_path, {
    transfer_progress: lambda { |total_objects, indexed_objects, received_objects, local_objects, total_deltas, indexed_deltas, received_bytes|
      print("\r total_objects: #{total_objects}, indexed_objects: #{indexed_objects}, received_objects: #{received_objects}, local_objects: #{local_objects}, total_deltas: #{total_deltas}, indexed_deltas: #{indexed_deltas}, received_bytes: #{received_bytes}")
    }
  })
  return @repo = Rugged::Repository.new(@local_repo_path)
end
generate_lapses_hash(commits, filepath) click to toggle source

env = [{:lapse_id =>“#{start_blob_sha}_#{finish_blob_sha}”, :start_blob_content => “”, :finish_blob_content => “”, :lapse => “thecontentofthelapse to be viewed in the browser”, :lapse_metadata => “json stuff”}]

# File lib/mushin_ext_ruggy.rb, line 41
def generate_lapses_hash commits, filepath
  commits.each do |commit|
    #find the blob of the filepath
    #
  end
end