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
36 37 38 |
# File 'lib/checklister/github/project.rb', line 36 def initialize(client) @client = client end |
Instance Method Details
#all(options = {}) ⇒ Array
Get all github's projects
50 51 52 53 |
# File 'lib/checklister/github/project.rb', line 50 def all( = {}) = DEFAULT_OPTIONS.merge @client.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)
58 59 60 |
# File 'lib/checklister/github/project.rb', line 58 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
43 44 45 |
# File 'lib/checklister/github/project.rb', line 43 def get(project_id) ProjectDecorator.new(@client.repository(project_id)).to_hash end |