Class: Checklister::Github::Project
- Inherits:
-
Object
- Object
- Checklister::Github::Project
- Defined in:
- lib/checklister/github/project.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
Default options that we want to pass when querying the github project index
{ sort: "full_name", direction: "asc" }
Instance Method Summary collapse
-
#all(options = {}) ⇒ Array
Get all github's projects.
-
#filtered_by_name(name, _options = {}) ⇒ Array
Get github's projects based on a search string (LIKE on project#name).
-
#get(project_id) ⇒ Hash
Query a particular project based on it's id.
-
#initialize(client) ⇒ Project
constructor
Initialize a github project instance.
Constructor Details
#initialize(client) ⇒ Project
Initialize a github project instance
38 39 40 |
# File 'lib/checklister/github/project.rb', line 38 def initialize(client) @client = client end |
Instance Method Details
#all(options = {}) ⇒ Array
Get all github's projects
52 53 54 55 56 |
# File 'lib/checklister/github/project.rb', line 52 def all( = {}) = DEFAULT_OPTIONS.merge repositories = @client.repositories() repositories.map { |p| ProjectDecorator.new(p).to_hash } end |
#filtered_by_name(name, _options = {}) ⇒ Array
Get github's projects based on a search string (LIKE on project#name)
61 62 63 |
# File 'lib/checklister/github/project.rb', line 61 def filtered_by_name(name, = {}) all.select { |p| p[:name].downcase.include? name.downcase } end |
#get(project_id) ⇒ Hash
Query a particular project based on it's id
45 46 47 |
# File 'lib/checklister/github/project.rb', line 45 def get(project_id) ProjectDecorator.new(@client.repository(project_id)).to_hash end |