42 |
43 |
44 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | APP_PATH = File.expand_path('../../config/application', __FILE__)
7 | require_relative '../config/boot'
8 | require 'rails/commands'
9 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | require_relative '../config/boot'
7 | require 'rake'
8 | Rake.application.run
9 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 |
4 | # path to your application root.
5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6 |
7 | Dir.chdir APP_ROOT do
8 | # This script is a starting point to setup your application.
9 | # Add necessary setup steps to this file:
10 |
11 | puts "== Installing dependencies =="
12 | system "gem install bundler --conservative"
13 | system "bundle check || bundle install"
14 |
15 | # puts "\n== Copying sample files =="
16 | # unless File.exist?("config/database.yml")
17 | # system "cp config/database.yml.sample config/database.yml"
18 | # end
19 |
20 | puts "\n== Preparing database =="
21 | system "bin/rake db:setup"
22 |
23 | puts "\n== Removing old logs and tempfiles =="
24 | system "rm -f log/*"
25 | system "rm -rf tmp/cache"
26 |
27 | puts "\n== Restarting application server =="
28 | system "touch tmp/restart.txt"
29 | end
30 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast
4 | # It gets overwritten when you run the `spring binstub` command
5 |
6 | unless defined?(Spring)
7 | require "rubygems"
8 | require "bundler"
9 |
10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12 | ENV["GEM_HOME"] = ""
13 | Gem.paths = ENV
14 |
15 | gem "spring", match[1]
16 | require "spring/binstub"
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/chef/moved_to_commit-infra_repo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minamijoyo/commit-m/1e96590e29495cf24d3e60d07577bb975e3dbe1a/chef/moved_to_commit-infra_repo
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module CommitM
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 |
15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17 | # config.time_zone = 'Central Time (US & Canada)'
18 |
19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21 | # config.i18n.default_locale = :de
22 |
23 | # Do not swallow errors in after_commit/after_rollback callbacks.
24 | config.active_record.raise_in_transactional_callbacks = true
25 |
26 | # for bootstrap-sass
27 | config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
28 |
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | default: &default
2 | adapter: mysql2
3 | charset: utf8mb4
4 | encoding: utf8mb4
5 | collation: utf8mb4_general_ci
6 | reconnect: false
7 | pool: 5
8 |
9 | development:
10 | <<: *default
11 | socket: /var/lib/mysql/mysql.sock
12 | database: db_development
13 | username: user_development
14 | password: pass_development
15 |
16 | test:
17 | <<: *default
18 | socket: /var/lib/mysql/mysql.sock
19 | database: db_test
20 | username: user_test
21 | password: pass_test
22 |
23 | production:
24 | <<: *default
25 | host: <%= ENV['DB_HOST'] %>
26 | port: <%= ENV['DB_PORT'] %>
27 | database: <%= ENV['DB_DATABASE'] %>
28 | username: <%= ENV['DB_USERNAME'] %>
29 | password: <%= ENV['DB_PASSWORD'] %>
30 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports and disable caching.
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send.
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger.
20 | config.active_support.deprecation = :log
21 |
22 | # Raise an error on page load if there are pending migrations.
23 | config.active_record.migration_error = :page_load
24 |
25 | # Debug mode disables concatenation and preprocessing of assets.
26 | # This option may cause significant delays in view rendering with a large
27 | # number of complex assets.
28 | config.assets.debug = true
29 |
30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31 | # yet still be able to expire them through the digest params.
32 | config.assets.digest = true
33 |
34 | # Adds additional error checking when serving assets at runtime.
35 | # Checks for improperly declared sprockets dependencies.
36 | # Raises helpful error messages.
37 | config.assets.raise_runtime_errors = true
38 |
39 | # Raises error for missing translations
40 | # config.action_view.raise_on_missing_translations = true
41 | end
42 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application
18 | # Add `rack-cache` to your Gemfile before enabling this.
19 | # For large-scale production use, consider using a caching reverse proxy like
20 | # NGINX, varnish or squid.
21 | # config.action_dispatch.rack_cache = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26 |
27 | # Compress JavaScripts and CSS.
28 | config.assets.js_compressor = :uglifier
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35 | # yet still be able to expire them through the digest params.
36 | config.assets.digest = true
37 |
38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39 |
40 | # Specifies the header that your server uses for sending files.
41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43 |
44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45 | # config.force_ssl = true
46 |
47 | # Use the lowest log level to ensure availability of diagnostic information
48 | # when problems arise.
49 | config.log_level = :debug
50 |
51 | # Prepend all log lines with the following tags.
52 | # config.log_tags = [ :subdomain, :uuid ]
53 |
54 | # Use a different logger for distributed setups.
55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56 |
57 | # Use a different cache store in production.
58 | # config.cache_store = :mem_cache_store
59 |
60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61 | # config.action_controller.asset_host = 'http://assets.example.com'
62 |
63 | # Ignore bad email addresses and do not raise email delivery errors.
64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65 | # config.action_mailer.raise_delivery_errors = false
66 |
67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68 | # the I18n.default_locale when a translation cannot be found).
69 | config.i18n.fallbacks = true
70 |
71 | # Send deprecation notices to registered listeners.
72 | config.active_support.deprecation = :notify
73 |
74 | # Use default logging formatter so that PID and timestamp are not suppressed.
75 | config.log_formatter = ::Logger::Formatter.new
76 |
77 | # Do not dump schema after migrations.
78 | config.active_record.dump_schema_after_migration = false
79 | end
80 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure static file server for tests with Cache-Control for performance.
16 | config.serve_static_files = true
17 | config.static_cache_control = 'public, max-age=3600'
18 |
19 | # Show full error reports and disable caching.
20 | config.consider_all_requests_local = true
21 | config.action_controller.perform_caching = false
22 |
23 | # Raise exceptions instead of rendering exception templates.
24 | config.action_dispatch.show_exceptions = false
25 |
26 | # Disable request forgery protection in test environment.
27 | config.action_controller.allow_forgery_protection = false
28 |
29 | # Tell Action Mailer not to deliver emails to the real world.
30 | # The :test delivery method accumulates sent emails in the
31 | # ActionMailer::Base.deliveries array.
32 | config.action_mailer.delivery_method = :test
33 |
34 | # Randomize the order test cases are executed.
35 | config.active_support.test_order = :random
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.action_dispatch.cookies_serializer = :json
4 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/mysqlpls.rb:
--------------------------------------------------------------------------------
1 | require 'active_record/connection_adapters/abstract_mysql_adapter'
2 |
3 | module ActiveRecord
4 | module ConnectionAdapters
5 | class AbstractMysqlAdapter
6 | NATIVE_DATABASE_TYPES[:string] = { :name => "varchar", :limit => 191 }
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_commit_m_session'
4 |
--------------------------------------------------------------------------------
/config/initializers/utf8_enforcer_tag.rb:
--------------------------------------------------------------------------------
1 | module ActionView
2 | module Helpers
3 | module FormTagHelper
4 | def utf8_enforcer_tag
5 | "".html_safe
6 | end
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | # The priority is based upon order of creation: first created -> highest priority.
3 | # See how all your routes lay out with "rake routes".
4 |
5 | # You can have the root of your site routed with "root"
6 | root 'commits#index'
7 | match 'commits/search', to: 'commits#search', via: ['post', 'get']
8 |
9 | # Example of regular route:
10 | # get 'products/:id' => 'catalog#view'
11 |
12 | # Example of named route that can be invoked with purchase_url(id: product.id)
13 | # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
14 |
15 | # Example resource route (maps HTTP verbs to controller actions automatically):
16 | # resources :products
17 |
18 | # Example resource route with options:
19 | # resources :products do
20 | # member do
21 | # get 'short'
22 | # post 'toggle'
23 | # end
24 | #
25 | # collection do
26 | # get 'sold'
27 | # end
28 | # end
29 |
30 | # Example resource route with sub-resources:
31 | # resources :products do
32 | # resources :comments, :sales
33 | # resource :seller
34 | # end
35 |
36 | # Example resource route with more complex sub-resources:
37 | # resources :products do
38 | # resources :comments
39 | # resources :sales do
40 | # get 'recent', on: :collection
41 | # end
42 | # end
43 |
44 | # Example resource route with concerns:
45 | # concern :toggleable do
46 | # post 'toggle'
47 | # end
48 | # resources :posts, concerns: :toggleable
49 | # resources :photos, concerns: :toggleable
50 |
51 | # Example resource route within a namespace:
52 | # namespace :admin do
53 | # # Directs /admin/products/* to Admin::ProductsController
54 | # # (app/controllers/admin/products_controller.rb)
55 | # resources :products
56 | # end
57 | end
58 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rake secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: a5e8fba249fa55bf43311a8d6a45384b1152b1b73f310c40b043f51e9d20eb7f854b29818b1f738310c261ba37f2493b5bfecbc997564e859e2861f4010df1b4
15 |
16 | test:
17 | secret_key_base: 7a3aefbdb63be85be18e59a7f6b408aed0a711cc5ff712a40bdd046c1cedd841bf2ffbdcacbb2f0db31a8e78ecbc2545be2d11c302ec36f27ce7351239f1171b
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/db/migrate/20150201100358_create_commits.rb:
--------------------------------------------------------------------------------
1 | class CreateCommits < ActiveRecord::Migration
2 | def change
3 | create_table :commits do |t|
4 | t.string :repo_full_name
5 | t.string :sha
6 | t.text :message
7 |
8 | t.timestamps null: false
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20150206073821_add_fulltext_index_to_commit.rb:
--------------------------------------------------------------------------------
1 | class AddFulltextIndexToCommit < ActiveRecord::Migration
2 | def change
3 | add_index :commits, :message, type: :fulltext
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20150815015250_remove_fulltext_index_from_commit.rb:
--------------------------------------------------------------------------------
1 | class RemoveFulltextIndexFromCommit < ActiveRecord::Migration
2 | def change
3 | remove_index :commits, :message
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # encoding: UTF-8
2 | # This file is auto-generated from the current state of the database. Instead
3 | # of editing this file, please use the migrations feature of Active Record to
4 | # incrementally modify your database, and then regenerate this schema definition.
5 | #
6 | # Note that this schema.rb definition is the authoritative source for your
7 | # database schema. If you need to create the application database on another
8 | # system, you should be using db:schema:load, not running all the migrations
9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 | # you'll amass, the slower it'll run and the greater likelihood for issues).
11 | #
12 | # It's strongly recommended that you check this file into your version control system.
13 |
14 | ActiveRecord::Schema.define(version: 20150815015250) do
15 |
16 | create_table "commits", force: :cascade do |t|
17 | t.string "repo_full_name", limit: 191
18 | t.string "sha", limit: 191
19 | t.text "message", limit: 65535
20 | t.datetime "created_at", null: false
21 | t.datetime "updated_at", null: false
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 | # Mayor.create(name: 'Emanuel', city: cities.first)
8 |
9 |
10 | #CSV.foreach('db/commits.txt') do |row|
11 | # Commit.create(:repo_full_name => row[0], :sha => row[1], :message => row[2])
12 | #end
13 |
14 | # commit message can contain character ,
15 | # so read line and split by myself.
16 | open('db/commits.txt') do |file|
17 | file.each do |line|
18 | repo_full_name, sha, message = line.split(', ', 3)
19 | Commit.create(:repo_full_name => repo_full_name,
20 | :sha => sha,
21 | :message => message[0,1024])
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minamijoyo/commit-m/1e96590e29495cf24d3e60d07577bb975e3dbe1a/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minamijoyo/commit-m/1e96590e29495cf24d3e60d07577bb975e3dbe1a/lib/tasks/.keep
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minamijoyo/commit-m/1e96590e29495cf24d3e60d07577bb975e3dbe1a/log/.keep
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/minamijoyo/commit-m/1e96590e29495cf24d3e60d07577bb975e3dbe1a/public/favicon.ico
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Allow: /$
3 | Disallow: /*
4 |
--------------------------------------------------------------------------------
/public/sorry.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | sorry
9 |
10 |
11 | Sorry. Site is currently under maintenance. Please try again later. If you have an inquiry, please send your messeage to @minamijoyo .
12 |
13 |
14 |
--------------------------------------------------------------------------------
/spec/factories.rb:
--------------------------------------------------------------------------------
1 | FactoryGirl.define do
2 | factory :commit do
3 | sequence(:repo_full_name) { |n| "Repo#{n}" }
4 | sequence(:sha) { |n| "#{n}"}
5 | sequence(:message) { |n| "Message #{n}"}
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/models/commit_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Commit, type: :model do
4 | before { @commit = Commit.new(
5 | repo_full_name: 'minamijoyo/commit-m',
6 | sha: 'ad029c9d6d79ad6e1b2ca4ff33e998c23c471675',
7 | message: 'Initial commit') }
8 |
9 | subject { @commit }
10 |
11 | it { should respond_to(:repo_full_name) }
12 | it { should respond_to(:sha) }
13 | it { should respond_to(:message) }
14 |
15 | it { should be_valid }
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'spork'
3 | #uncomment the following line to use spork with the debugger
4 | #require 'spork/ext/ruby-debug'
5 |
6 | Spork.prefork do
7 | # Loading more in this block will cause your tests to run faster. However,
8 | # if you change any configuration or code from libraries loaded here, you'll
9 | # need to restart spork for it take effect.
10 |
11 | # This file is copied to spec/ when you run 'rails generate rspec:install'
12 | ENV['RAILS_ENV'] ||= 'test'
13 | require 'spec_helper'
14 | require File.expand_path('../../config/environment', __FILE__)
15 | require 'rspec/rails'
16 | require 'database_cleaner'
17 | require 'elasticsearch/extensions/test/cluster'
18 | # Add additional requires below this line. Rails is not loaded until this point!
19 |
20 | # Requires supporting ruby files with custom matchers and macros, etc, in
21 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
22 | # run as spec files by default. This means that files in spec/support that end
23 | # in _spec.rb will both be required and run as specs, causing the specs to be
24 | # run twice. It is recommended that you do not name files matching this glob to
25 | # end with _spec.rb. You can configure this pattern with the --pattern
26 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
27 | #
28 | # The following line is provided for convenience purposes. It has the downside
29 | # of increasing the boot-up time by auto-requiring all files in the support
30 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
31 | # require only the support files necessary.
32 | #
33 | # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
34 |
35 | # Checks for pending migrations before tests are run.
36 | # If you are not using ActiveRecord, you can remove this line.
37 | ActiveRecord::Migration.maintain_test_schema!
38 |
39 | RSpec.configure do |config|
40 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
41 | # config.fixture_path = "#{::Rails.root}/spec/fixtures"
42 |
43 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
44 | # examples within a transaction, remove the following line or assign false
45 | # instead of true.
46 | # config.use_transactional_fixtures = true
47 |
48 | # RSpec Rails can automatically mix in different behaviours to your tests
49 | # based on their file location, for example enabling you to call `get` and
50 | # `post` in specs under `spec/controllers`.
51 | #
52 | # You can disable this behaviour by removing the line below, and instead
53 | # explicitly tag your specs with their type, e.g.:
54 | #
55 | # RSpec.describe UsersController, :type => :controller do
56 | # # ...
57 | # end
58 | #
59 | # The different available types are documented in the features, such as in
60 | # https://relishapp.com/rspec/rspec-rails/docs
61 | config.infer_spec_type_from_file_location!
62 |
63 | # for test
64 | config.include Capybara::DSL
65 |
66 | config.before(:suite) do
67 | DatabaseCleaner.strategy = :truncation
68 | end
69 |
70 | config.before(:each) do
71 | DatabaseCleaner.start
72 | end
73 |
74 | config.after(:each) do
75 | DatabaseCleaner.clean
76 | end
77 |
78 | # Elasticsearch test setting
79 | config.before(:all, :elasticsearch) do
80 | Elasticsearch::Extensions::Test::Cluster.start(nodes: 1) unless Elasticsearch::Extensions::Test::Cluster.running?
81 | end
82 |
83 | config.after(:all, :elasticsearch) do
84 | Elasticsearch::Extensions::Test::Cluster.stop if Elasticsearch::Extensions::Test::Cluster.running?
85 | end
86 | end
87 |
88 | def elasticsearch_create_index_and_import
89 | Commit.__elasticsearch__.create_index! force: true
90 | Commit.import
91 | sleep 1
92 | end
93 |
94 | def elasticsearch_delete_index
95 | Commit.__elasticsearch__.client.indices.delete index: Commit.index_name
96 | end
97 | end
98 |
99 | Spork.each_run do
100 | # This code will be run each time you run your specs.
101 |
102 | end
103 |
--------------------------------------------------------------------------------
/spec/requests/commits_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe "Commits", type: :request do
4 | subject { page }
5 |
6 | describe "Root Page" do
7 | before { visit root_path }
8 |
9 | describe "Site name" do
10 | it { should have_content('commit-m') }
11 | it { should have_title('commit-m') }
12 | end
13 |
14 | describe "Twitter link" do
15 | it { should have_link("@minamijoyo", href: "https://twitter.com/minamijoyo")}
16 | end
17 |
18 | describe "Search form", :elasticsearch do
19 | before do
20 | 3.times { FactoryGirl.create(:commit) }
21 | elasticsearch_create_index_and_import
22 | end
23 |
24 | after do
25 | elasticsearch_delete_index
26 | Commit.delete_all
27 | end
28 |
29 | describe 'Click Search button' do
30 | before do
31 | fill_in "keyword", with:"Message"
32 | click_button "Search"
33 | end
34 | it { should have_content('3 results.') }
35 | end
36 |
37 | end
38 | end
39 |
40 | describe "Search Page", :elasticsearch do
41 | before do
42 | 31.times { FactoryGirl.create(:commit) }
43 | elasticsearch_create_index_and_import
44 | end
45 |
46 | after do
47 | elasticsearch_delete_index
48 | Commit.delete_all
49 | end
50 |
51 | describe "Search" do
52 | before do
53 | visit commits_search_path
54 | fill_in "keyword", with:"Message"
55 | click_button "Search"
56 | end
57 | it { should have_content('31 results.') }
58 | it { should have_selector('table') }
59 | it { should have_content('Message') }
60 | it { should have_selector('div.pagination') }
61 |
62 | describe "Pagination" do
63 | before { all('.pagination')[1].click_link('2') }
64 | it { should have_content('Message') }
65 | end
66 | end
67 | end
68 |
69 | end
70 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3 | # The generated `.rspec` file contains `--require spec_helper` which will cause
4 | # this file to always be loaded, without a need to explicitly require it in any
5 | # files.
6 | #
7 | # Given that it is always loaded, you are encouraged to keep this file as
8 | # light-weight as possible. Requiring heavyweight dependencies from this file
9 | # will add to the boot time of your test suite on EVERY test run, even for an
10 | # individual file that may not need all of that loaded. Instead, consider making
11 | # a separate helper file that requires the additional dependencies and performs
12 | # the additional setup, and require it from the spec files that actually need
13 | # it.
14 | #
15 | # The `.rspec` file also contains a few flags that are not defaults but that
16 | # users commonly want.
17 | #
18 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19 | RSpec.configure do |config|
20 | # rspec-expectations config goes here. You can use an alternate
21 | # assertion/expectation library such as wrong or the stdlib/minitest
22 | # assertions if you prefer.
23 | config.expect_with :rspec do |expectations|
24 | # This option will default to `true` in RSpec 4. It makes the `description`
25 | # and `failure_message` of custom matchers include text for helper methods
26 | # defined using `chain`, e.g.:
27 | # be_bigger_than(2).and_smaller_than(4).description
28 | # # => "be bigger than 2 and smaller than 4"
29 | # ...rather than:
30 | # # => "be bigger than 2"
31 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32 | end
33 |
34 | # rspec-mocks config goes here. You can use an alternate test double
35 | # library (such as bogus or mocha) by changing the `mock_with` option here.
36 | config.mock_with :rspec do |mocks|
37 | # Prevents you from mocking or stubbing a method that does not exist on
38 | # a real object. This is generally recommended, and will default to
39 | # `true` in RSpec 4.
40 | mocks.verify_partial_doubles = true
41 | end
42 |
43 | # The settings below are suggested to provide a good initial experience
44 | # with RSpec, but feel free to customize to your heart's content.
45 | =begin
46 | # These two settings work together to allow you to limit a spec run
47 | # to individual examples or groups you care about by tagging them with
48 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49 | # get run.
50 | config.filter_run :focus
51 | config.run_all_when_everything_filtered = true
52 |
53 | # Limits the available syntax to the non-monkey patched syntax that is
54 | # recommended. For more details, see:
55 | # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56 | # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57 | # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58 | config.disable_monkey_patching!
59 |
60 | # Many RSpec users commonly either run the entire suite or an individual
61 | # file, and it's useful to allow more verbose output when running an
62 | # individual spec file.
63 | if config.files_to_run.one?
64 | # Use the documentation formatter for detailed output,
65 | # unless a formatter has already been configured
66 | # (e.g. via a command-line flag).
67 | config.default_formatter = 'doc'
68 | end
69 |
70 | # Print the 10 slowest examples and example groups at the
71 | # end of the spec run, to help surface which specs are running
72 | # particularly slow.
73 | config.profile_examples = 10
74 |
75 | # Run specs in random order to surface order dependencies. If you find an
76 | # order dependency and want to debug it, you can fix the order by providing
77 | # the seed, which is printed after each run.
78 | # --seed 1234
79 | config.order = :random
80 |
81 | # Seed global randomization in this process using the `--seed` CLI option.
82 | # Setting this allows you to use `--seed` to deterministically reproduce
83 | # test failures related to randomization by passing the same `--seed` value
84 | # as the one that triggered the failure.
85 | Kernel.srand config.seed
86 | =end
87 | end
88 |
--------------------------------------------------------------------------------