Sha256: 871eb5c3d16f17a0e052515d67b540bf83184c63f5c364f3444a101e5b9dd58b

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

module Rlaunchpadlib
    class Project

        attr_accessor :project
        attr_accessor :overview_data

        attr_accessor :bug_data
        attr_accessor :branch_data
        attr_accessor :merge_proposal_data
        attr_accessor :subscription_data
        attr_accessor :timeline_data

        def initialize(project)
            @project = project
            @client = Rlaunchpadlib::Client.new
        end

        def overview
            if @overview_data.nil?
                @client.get(@project)
            else
                @overview_data
            end
        end


        def bugs
            if @bug_data.nil?
                @bug_data = @client.get(@project, 'searchTasks')
            end
            @bug_data
        end


        def branches
            if @branch_data.nil?
                @branch_data = @client.get(@project, 'getBranches')
            end
            @branch_data
        end


        def merge_proposals
            if @merge_proposal_data.nil?
                @merge_proposal_data = @client.get(@project, 'getMergeProposals')
            end
            @merge_proposal_data
        end

        def subscriptions
            if @subscription_data.nil?
                @subscription_data = @client.get(@project, 'getSubscriptions')
            end
            @subscription_data
        end

        def timeline
            if @timeline_data.nil?
                @timeline_data = @client.get(@project, 'get_timeline')
            end
            @timeline_data
        end


        def clear_cache
            @overview_data = nil
            @subscription_data = nil
            @branch_data = nil
            @merge_proposal_data = nil
            @bug_data = nil
            @timeline_data = nil
        end



        # I'm nuts so lets patch method missing.
        def method_missing(name, *args, &block)
          overview.has_key?(name.to_s) ? overview[name.to_s] : super
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rlaunchpadlib-0.1.0 lib/rlaunchpadlib/project.rb
rlaunchpadlib-0.0.1 lib/rlaunchpadlib/project.rb