Class: Ruggy::Ext
- Inherits:
-
Object
- Object
- Ruggy::Ext
- Defined in:
- lib/mushin_ext_ruggy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #check_params(*keys) ⇒ Object
- #clone_repo(clone_url, local_repo_path) ⇒ Object
-
#generate_lapses_hash(commits, filepath) ⇒ Object
env = [=>“#{start_blob_sha_#finish_blob_sha”, :start_blob_content => “”, :finish_blob_content => “”, :lapse => “thecontentofthelapse to be viewed in the browser”, :lapse_metadata => “json stuff”}].
-
#initialize(app = nil, opts = {}, params = {}) ⇒ Ext
constructor
A new instance of Ext.
Constructor Details
#initialize(app = nil, opts = {}, params = {}) ⇒ Ext
Returns a new instance of Ext.
9 10 11 12 13 |
# File 'lib/mushin_ext_ruggy.rb', line 9 def initialize app=nil, opts={}, params={} @app = app @opts = opts @params = params end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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) ⇒ Object
15 16 17 |
# 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) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# 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) ⇒ Object
env = [=>“#{start_blob_sha_#finish_blob_sha”, :start_blob_content => “”, :finish_blob_content => “”, :lapse => “thecontentofthelapse to be viewed in the browser”, :lapse_metadata => “json stuff”}]
41 42 43 44 45 46 |
# 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 |