Skip to content
This repository was archived by the owner on Jun 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ end

group :test do
gem 'mocha', require: false
gem 'capybara', '2.3.0'
gem 'launchy'
end

gem 'devise', "~> 3.2.2"
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
addressable (2.3.8)
arel (5.0.1.20140414130214)
bcrypt-ruby (3.1.2)
bluecloth (2.2.0)
builder (3.2.2)
capybara (2.3.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coffee-rails (4.0.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0.beta, < 5.0)
Expand Down Expand Up @@ -77,6 +84,8 @@ GEM
multi_json (>= 1.5)
kgio (2.9.3)
kramdown (1.1.0)
launchy (2.4.3)
addressable (~> 2.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
Expand All @@ -87,13 +96,16 @@ GEM
rails (> 3.2.0)
metaclass (0.0.4)
mime-types (1.25.1)
mini_portile (0.6.2)
minitest (5.3.3)
mocha (1.0.0)
metaclass (~> 0.0.1)
mono_logger (1.1.0)
multi_json (1.10.0)
multi_xml (0.5.4)
multipart-post (1.2.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (0.8.1)
faraday (~> 0.8)
httpauth (~> 0.1)
Expand Down Expand Up @@ -206,13 +218,16 @@ GEM
activesupport (>= 3.0.7)
rails (>= 3.0.7)
will_paginate (3.0.4)
xpath (2.0.0)
nokogiri (~> 1.3)
yard (0.8.7.3)

PLATFORMS
ruby

DEPENDENCIES
bluecloth
capybara (= 2.3.0)
coffee-rails (~> 4.0.0)
dalli
devise (~> 3.2.2)
Expand All @@ -222,6 +237,7 @@ DEPENDENCIES
httparty
jbuilder (~> 1.0.1)
jquery-rails
launchy
mail_view (~> 1.0.2)
maildown
mocha
Expand Down
10 changes: 8 additions & 2 deletions app/controllers/repos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ def new
end

def show
@repo = Repo.where(full_name: params[:full_name]).first
@repo = Repo.where(full_name: params[:full_name]).first

if @repo
@docs = @repo.doc_methods.order("created_at DESC").page(params[:page]).per_page(params[:per_page]||20)
@docs = @repo
.doc_methods

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I like this style. Very smooth...
I haven't hit #send's guts yet but I love the idea of the params being passed to a method named as such. Nice

.send(params[:doc_status] || :scoper)
.order("created_at DESC")
.page(params[:page])
.per_page(params[:per_page]||20)

@repo_sub = current_user.repo_subscriptions.where(repo_id: @repo.id).first if current_user
@subscribers = @repo.
subscribers.
Expand Down
4 changes: 4 additions & 0 deletions app/models/doc_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def self.with_docs
where("doc_comments_count > 0")
end

def self.scoper
where(nil)
end

def raw_file
read_attribute(:file)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def self.find_for_github_oauth(auth, signed_in_resource=nil)
user.update_attributes(params)
else
email = auth.info.email
email = GitHubBub::Request.fetch("/user/emails", token: token).json_body.first if email.blank?
email = GitHubBub.get("/user/emails", token: token).json_body.first if email.blank?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schneems You would know, because you wrote GitHubBub, but I got a NoMethodError on fetch, so I checked the gem's source, and it looked like it's been replaced by get? Was this referencing an older version of the code?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HA!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's an older API

params = params.merge(:password => Devise.friendly_token[0,20],
:name => auth.extra.raw_info.name,
:email => email)
Expand Down
9 changes: 9 additions & 0 deletions app/views/repos/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
<hr />
<%= will_paginate @docs, :container => false %>

<ul class='nav nav-tabs'>
<li class=<%= 'active' if params[:doc_status] == 'with_docs' %>>
<%= link_to 'Documented Methods', repo_path(@repo, doc_status: 'with_docs') %>
</li>
<li class=<%= 'active' if params[:doc_status] == 'missing_docs' %>>
<%= link_to 'Undocumented Methods', repo_path(@repo, doc_status: 'missing_docs') %>
</li>
</ul>

<ul>
<% @docs.each do |doc| %>
<li>
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/doc_comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
comment:
id: 1
doc_class_id: 1
doc_method_id: 2
comment: 'this is a comment'
created_at: 2012-11-10 21:50:48.351554000 Z
updated_at: 2012-11-10 21:50:48.351554000 Z
21 changes: 21 additions & 0 deletions test/fixtures/doc_methods.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
migrate:
id: 1
repo_id: 3
name: undocumented_method
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's important to you to have real file and method names, but it makes the tests clearer to write it this way.

line: 43
created_at: 2012-11-10 21:50:48.351554000 Z
updated_at: 2012-11-10 21:50:48.351554000 Z
doc_comments_count: 0
path: 'lib/sinatra'
file: 'base.rb'

other:
id: 2
repo_id: 3
name: documented_method
line: 43
created_at: 2012-11-10 21:50:48.351554000 Z
updated_at: 2012-11-10 21:50:48.351554000 Z
doc_comments_count: 100
path: 'lib/sinatra'
file: 'base.rb'
18 changes: 18 additions & 0 deletions test/integration/sorting_methods_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "test_helper"

class SortingMethodsTest < ActionDispatch::IntegrationTest
include Capybara::DSL
fixtures :repos
fixtures :doc_methods
fixtures :doc_comments

test 'sorting methods by documentation status' do
visit '/'
click_link 'rails'
click_link 'Documented Methods'
assert_not page.has_content?('ActiveRecord#undocumented')
click_link 'Undocumented Methods'
assert_not page.has_content?('ActiveRecord#documented')
end

end
2 changes: 2 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ def fixture_path(name = "")

require 'parsers/yard_test'
require 'mocha/setup'
require 'capybara/rails'

Q.queue_config.inline = true