Class: Flux::CLI::Review::Github::PullRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/flux/cli/review.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PullRequest

Returns a new instance of PullRequest.



162
163
164
# File 'lib/flux/cli/review.rb', line 162

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



178
179
180
181
182
183
184
# File 'lib/flux/cli/review.rb', line 178

def method_missing(name, *args)
  if @data.has_key?(name.to_sym)
    @data[name.to_sym]
  else
    super
  end
end

Class Method Details

.all(opts = {}) ⇒ Object



114
115
116
117
# File 'lib/flux/cli/review.rb', line 114

def all(opts = {})
  pull_requests(opts.merge(:state => 'open')) +
    pull_requests(opts.merge(:state => 'closed'))
end

.create(data) ⇒ Object



119
120
121
122
123
# File 'lib/flux/cli/review.rb', line 119

def create(data)
  pr.create_request Github.config['repo_user'],
                    Github.config['repo_name'],
                    PullRequest.new(data).to_hash
end

.open(opts = {}) ⇒ Object



125
126
127
# File 'lib/flux/cli/review.rb', line 125

def open(opts = {})
  pull_requests({:state => 'open'}.merge(opts))
end

.prObject



129
130
131
# File 'lib/flux/cli/review.rb', line 129

def pr
  Github.gh.pull_requests
end

.update(id, data) ⇒ Object



133
134
135
136
137
138
# File 'lib/flux/cli/review.rb', line 133

def update(id, data)
  pr.update_request Github.config['repo_user'],
                    Github.config['repo_name'],
                    id,
                    data.dup
end

Instance Method Details

#closeObject



166
167
168
169
170
# File 'lib/flux/cli/review.rb', line 166

def close
  @data[:state] = 'closed'

  self.class.update number, {:state => @data[:state]}
end

#diffObject



172
173
174
175
176
# File 'lib/flux/cli/review.rb', line 172

def diff
  auth = [Github.config['username'], Github.config['password']]

  open(@data[:diff_url], :http_basic_authentication => auth).read
end

#open?Boolean

Returns:

  • (Boolean)


186
187
188
# File 'lib/flux/cli/review.rb', line 186

def open?
  state == 'open'
end

#to_hashObject



190
191
192
# File 'lib/flux/cli/review.rb', line 190

def to_hash
  @data.merge(:body => ReviewBody.to_markdown(@data[:body]))
end