github_revisions 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00b7698b62f263d3c05ef22b2b163dc9b9ebf4ff
4
+ data.tar.gz: d89bf9bdf76d93b660fd4a718a1987864dbf6626
5
+ SHA512:
6
+ metadata.gz: 53a245f2461c72c44aa2383820320d0c090fb4bb74385c91cbe744478323e241efb95bb68faf96e5a6199c91426db6ca3c68622e3ce37f759f2b67237c1669ef
7
+ data.tar.gz: ec5e816807704bb5d21017b08d89d62b35b2461cc4dcf5cff0a837a21cbd7e258d9923f509e753e1a590c9ece8fd84d8877eb5b9ba96e4544fcf4c2bfdb49eaa
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .bundle/
2
+ *.log
3
+ test/dummy
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'tzinfo-data'
6
+ gem 'tzinfo'
data/Gemfile.lock ADDED
@@ -0,0 +1,120 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ github_revisions (0.0.1)
5
+ github_api
6
+ rails (~> 4.1.6)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.1.6)
12
+ actionpack (= 4.1.6)
13
+ actionview (= 4.1.6)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ actionpack (4.1.6)
16
+ actionview (= 4.1.6)
17
+ activesupport (= 4.1.6)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ actionview (4.1.6)
21
+ activesupport (= 4.1.6)
22
+ builder (~> 3.1)
23
+ erubis (~> 2.7.0)
24
+ activemodel (4.1.6)
25
+ activesupport (= 4.1.6)
26
+ builder (~> 3.1)
27
+ activerecord (4.1.6)
28
+ activemodel (= 4.1.6)
29
+ activesupport (= 4.1.6)
30
+ arel (~> 5.0.0)
31
+ activesupport (4.1.6)
32
+ i18n (~> 0.6, >= 0.6.9)
33
+ json (~> 1.7, >= 1.7.7)
34
+ minitest (~> 5.1)
35
+ thread_safe (~> 0.1)
36
+ tzinfo (~> 1.1)
37
+ addressable (2.3.6)
38
+ arel (5.0.1.20140414130214)
39
+ builder (3.2.2)
40
+ descendants_tracker (0.0.4)
41
+ thread_safe (~> 0.3, >= 0.3.1)
42
+ erubis (2.7.0)
43
+ faraday (0.9.0)
44
+ multipart-post (>= 1.2, < 3)
45
+ github_api (0.12.1)
46
+ addressable (~> 2.3)
47
+ descendants_tracker (~> 0.0.4)
48
+ faraday (~> 0.8, < 0.10)
49
+ hashie (>= 3.2)
50
+ multi_json (>= 1.7.5, < 2.0)
51
+ nokogiri (~> 1.6.3)
52
+ oauth2
53
+ hashie (3.3.1)
54
+ hike (1.2.3)
55
+ i18n (0.6.11)
56
+ json (1.8.1)
57
+ jwt (1.0.0)
58
+ kaminari (0.16.1)
59
+ actionpack (>= 3.0.0)
60
+ activesupport (>= 3.0.0)
61
+ mail (2.6.1)
62
+ mime-types (>= 1.16, < 3)
63
+ mime-types (2.4.3)
64
+ mini_portile (0.6.0)
65
+ minitest (5.4.2)
66
+ multi_json (1.10.1)
67
+ multi_xml (0.5.5)
68
+ multipart-post (2.0.0)
69
+ nokogiri (1.6.3.1-x64-mingw32)
70
+ mini_portile (= 0.6.0)
71
+ oauth2 (1.0.0)
72
+ faraday (>= 0.8, < 0.10)
73
+ jwt (~> 1.0)
74
+ multi_json (~> 1.3)
75
+ multi_xml (~> 0.5)
76
+ rack (~> 1.2)
77
+ rack (1.5.2)
78
+ rack-test (0.6.2)
79
+ rack (>= 1.0)
80
+ rails (4.1.6)
81
+ actionmailer (= 4.1.6)
82
+ actionpack (= 4.1.6)
83
+ actionview (= 4.1.6)
84
+ activemodel (= 4.1.6)
85
+ activerecord (= 4.1.6)
86
+ activesupport (= 4.1.6)
87
+ bundler (>= 1.3.0, < 2.0)
88
+ railties (= 4.1.6)
89
+ sprockets-rails (~> 2.0)
90
+ railties (4.1.6)
91
+ actionpack (= 4.1.6)
92
+ activesupport (= 4.1.6)
93
+ rake (>= 0.8.7)
94
+ thor (>= 0.18.1, < 2.0)
95
+ rake (10.3.2)
96
+ sprockets (2.12.2)
97
+ hike (~> 1.2)
98
+ multi_json (~> 1.0)
99
+ rack (~> 1.0)
100
+ tilt (~> 1.1, != 1.3.0)
101
+ sprockets-rails (2.2.0)
102
+ actionpack (>= 3.0)
103
+ activesupport (>= 3.0)
104
+ sprockets (>= 2.8, < 4.0)
105
+ thor (0.19.1)
106
+ thread_safe (0.3.4)
107
+ tilt (1.4.1)
108
+ tzinfo (1.2.2)
109
+ thread_safe (~> 0.1)
110
+ tzinfo-data (1.2014.8)
111
+ tzinfo (>= 1.0.0)
112
+
113
+ PLATFORMS
114
+ x64-mingw32
115
+
116
+ DEPENDENCIES
117
+ github_revisions!
118
+ kaminari
119
+ tzinfo
120
+ tzinfo-data
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Jake0oo0
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Github Revisions
2
+
3
+ Provides revision information for various projects from the Github API.
4
+
5
+ ## Installation
6
+
7
+ * gem install 'github_revisions'
8
+ * rails generate github_revisions:install
9
+
10
+ ## Usage
11
+
12
+ * Add your repositories to the repositories array in config/initializers/revisions_config.rb.
13
+ * Repositories should include the following information: Github User/Organization, Repository Name, and a friendly name that will be used to display the repository.
14
+
15
+
16
+ Example repository:
17
+
18
+ ```
19
+ {:name => "github_revisions", :friendly => "Github Revisions", :user => "Jake0oo0"}
20
+ ```
21
+
22
+
23
+ ## Customization
24
+
25
+ Copy the views so that you can customize them to your liking.
26
+
27
+ * rails generate github_revisions:views
28
+
29
+
30
+ ## Credits
31
+
32
+ Full credit to [Jake0oo0](https://github.com/Jake0oo0) for the creation of this gem.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'GithubRevisions'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ Bundler::GemHelper.install_tasks
22
+
23
+ require 'rake/testtask'
24
+
25
+ Rake::TestTask.new(:test) do |t|
26
+ t.libs << 'lib'
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
File without changes
@@ -0,0 +1,50 @@
1
+ class RevisionsController < ApplicationController
2
+ def show
3
+ config_repositories = GithubRevisions.repositories
4
+ current_repo = config_repositories.find {|repo| repo[:name] == params[:id]}
5
+ if not current_repo
6
+ return redirect_first
7
+ end
8
+ revisions = get_revisions(current_repo)
9
+ github_api = GithubRevisions.github
10
+ repositories = Array.new
11
+ config_repositories.each do |repo|
12
+ git_repo = github_api.repos.get(repo[:user], repo[:name])
13
+ oss = git_repo.private
14
+ url = git_repo.html_url
15
+ repositories << {:name => repo[:name], :friendly => repo[:friendly], :url => url, :private => oss, :user => repo[:user]}
16
+ end
17
+ current_repo = repositories.find { |repo| repo[:name] == params[:id] }
18
+ render 'show', :locals => { :current_repo => current_repo, :revisions => revisions, :repositories => repositories}
19
+ end
20
+
21
+ def index
22
+ redirect_first(false)
23
+ end
24
+
25
+ private
26
+
27
+ def redirect_first(alert=true)
28
+ if alert
29
+ return redirect_to revision_path(GithubRevisions.repositories[0][:name]), :alert => "Invalid Github repository."
30
+ else
31
+ return redirect_to revision_path(GithubRevisions.repositories[0][:name])
32
+ end
33
+ end
34
+
35
+ def get_revisions(repository)
36
+ # https://developer.github.com/v3/repos/commits/
37
+ commits = Array.new
38
+ github_api = GithubRevisions.github
39
+ github_commits = github_api.repos.commits.all(repository[:user], repository[:name])
40
+ github_commits.each do |response|
41
+ author = response.commit.author.name
42
+ sha = response.sha
43
+ url = response.html_url
44
+ message = response.commit.message
45
+ date = response.commit.author.date
46
+ commits << {:author => author, :sha => sha, :message => message, :date => date, :url => url}
47
+ end
48
+ return Kaminari.paginate_array(commits).page(params[:page]).per(10)
49
+ end
50
+ end
data/app/views/.keep ADDED
File without changes
@@ -0,0 +1,57 @@
1
+ <style>
2
+ table, th, td {
3
+ border: 1px solid black;
4
+ border-collapse: collapse;
5
+ }
6
+ table {
7
+ width: 100%;
8
+ }
9
+ th, td {
10
+ padding: 5px;
11
+ text-align: left;
12
+ }
13
+ </style>
14
+
15
+ <ul>
16
+ <% repositories.each do |repo| %>
17
+ <li>
18
+ <a href="<%= revision_path(repo[:name]) %>">
19
+ <%= repo[:friendly] %>
20
+ </a>
21
+ </li>
22
+ <% end %>
23
+ </ul>
24
+ <% if not current_repo[:private] %>
25
+ <div class="alert">
26
+ This repository is open source. You can contribute on
27
+ <a href="<%= current_repo[:url] %>">Github.</a>
28
+ </div>
29
+ <% end %>
30
+ <table>
31
+ <tr>
32
+ <th width="5%">SHA</th>
33
+ <th width="8%">Author</th>
34
+ <th width="20%">Commit Message</th>
35
+ <th width="10%">Time</th>
36
+ </tr>
37
+ <% revisions.each do |revision| %>
38
+ <tr>
39
+ <td>
40
+ <a href="<%= revision[:url] %>" target="_blank">
41
+ <%= revision[:sha][0..6] %>
42
+ </a>
43
+ </td>
44
+ <td>
45
+ <%= revision[:author] %>
46
+ </td>
47
+ <td>
48
+ <%= revision[:message] %>
49
+ </td>
50
+ <td>
51
+ <%= time_ago_in_words(revision[:date]) %>
52
+ ago
53
+ </td>
54
+ </tr>
55
+ <% end %>
56
+ </table>
57
+ <%= paginate revisions %>
data/bin/rails ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby.exe
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/github_revisions/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ resources :revisions
3
+ end
@@ -0,0 +1,26 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'github_revisions/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = 'github_revisions'
9
+ s.version = GithubRevisions::VERSION
10
+ s.authors = ['Jake0oo0']
11
+ s.email = ['jake0oo0dev@gmail.com']
12
+ s.homepage = 'http://revisions.jake0oo0.me'
13
+ s.summary = 'Access a list of revisions for various Github repositories.'
14
+ s.description = 'Access a list of revisions for various Github repositories.'
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.require_paths = ['lib']
20
+
21
+
22
+ s.add_development_dependency 'kaminari'
23
+
24
+ s.add_dependency 'rails', '~> 4.1.6'
25
+ s.add_dependency 'github_api'
26
+ end
@@ -0,0 +1,11 @@
1
+ module GithubRevisions
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
5
+
6
+ def copy_config_file
7
+ template 'revisions_config.rb', 'config/initializers/revisions_config.rb'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ GithubRevisions.repositories = [{:name => "github_revisions", :friendly => "Github Revisions", :user => "Jake0oo0"}]
2
+ # GithubRevisions.oauth = ''
@@ -0,0 +1,14 @@
1
+ module GithubRevisions
2
+ module Generators
3
+ class ViewsGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../../../../app/views/revisions', __FILE__)
5
+
6
+ def copy_views
7
+ filename_pattern = File.join self.class.source_root, "*.html.erb"
8
+ Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|
9
+ copy_file f, "app/views/revisions/#{f}"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ require "github_revisions/engine"
2
+ require 'github_api'
3
+
4
+ module GithubRevisions
5
+ mattr_accessor :repositories
6
+ mattr_accessor :oauth
7
+
8
+
9
+ class << self
10
+ def github
11
+ if @@oauth
12
+ return Github.new(:oauth_token => @@oauth)
13
+ else
14
+ return Github.new
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ module GithubRevisions
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module GithubRevisions
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class RevisionsControllerTest < ActionController::TestCase
4
+ test "should get show" do
5
+ get :show
6
+ assert_response :success
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index
11
+ assert_response :success
12
+ end
13
+
14
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class GithubRevisionsTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, GithubRevisions
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class RevisionsHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
15
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_revisions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jake0oo0
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kaminari
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 4.1.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 4.1.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: github_api
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Access a list of revisions for various Github repositories.
56
+ email:
57
+ - jake0oo0dev@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - app/controllers/.keep
69
+ - app/controllers/revisions_controller.rb
70
+ - app/views/.keep
71
+ - app/views/revisions/show.html.erb
72
+ - bin/rails
73
+ - config/routes.rb
74
+ - github_revisions.gemspec
75
+ - lib/generators/github_revisions/install_generator.rb
76
+ - lib/generators/github_revisions/templates/revisions_config.rb
77
+ - lib/generators/github_revisions/views_generator.rb
78
+ - lib/github_revisions.rb
79
+ - lib/github_revisions/engine.rb
80
+ - lib/github_revisions/version.rb
81
+ - test/controllers/revisions_controller_test.rb
82
+ - test/github_revisions_test.rb
83
+ - test/helpers/revisions_helper_test.rb
84
+ - test/integration/navigation_test.rb
85
+ - test/test_helper.rb
86
+ homepage: http://revisions.jake0oo0.me
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.4.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Access a list of revisions for various Github repositories.
110
+ test_files: []