Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

開発加速系Gemの追加 #55

Closed
wants to merge 9 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DATABASE_PORT=3306
DATABASE_USER=root
DATABASE_PASSWORD=
DATABASE_HOST=localhost
DATABASE_SOCKET=/tmp/mysql.sock
17 changes: 12 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ gem "jbuilder", "~> 2.5"
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and
# get a debugger console
gem "byebug", platforms: %i[mri mingw x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem "capybara", "~> 2.13"
gem "onkcop", require: false
gem "selenium-webdriver"

gem "byebug", platforms: %i[mri mingw x64_mingw]
gem "dotenv-rails"
gem "onkcop", require: false
gem "pry-byebug"
gem "pry-doc"
gem "pry-rails"
end

group :development do
Expand All @@ -50,6 +52,11 @@ group :development do
gem "web-console", ">= 3.3.0"
# Spring speeds up development by keeping your application running
# in the background. Read more: https://github.com/rails/spring
gem "annotate"
gem "better_errors"
gem "binding_of_caller"
gem "bullet"
gem "rails-erd"
gem "rubocop"
gem "spring"
gem "spring-watcher-listen", "~> 2.0.0"
Expand Down
49 changes: 49 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,22 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
annotate (2.7.2)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 13.0)
arel (8.0.0)
ast (2.3.0)
better_errors (2.3.0)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
bindex (0.5.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.3)
bullet (5.6.1)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.10.0)
byebug (9.0.6)
capybara (2.14.4)
addressable
Expand All @@ -54,6 +66,8 @@ GEM
xpath (~> 2.0)
childprocess (0.7.1)
ffi (~> 1.0, >= 1.0.11)
choice (0.2.0)
coderay (1.1.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
Expand All @@ -62,6 +76,11 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
debug_inspector (0.0.3)
dotenv (2.2.1)
dotenv-rails (2.2.1)
dotenv (= 2.2.1)
railties (>= 3.2, < 5.2)
erubi (1.6.1)
execjs (2.7.0)
ffi (1.9.18)
Expand Down Expand Up @@ -98,6 +117,18 @@ GEM
parser (2.4.0.0)
ast (~> 2.2)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (3.4.3)
byebug (>= 9.0, < 9.1)
pry (~> 0.10)
pry-doc (0.11.1)
pry (~> 0.9)
yard (~> 0.9)
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (2.0.5)
puma (3.9.1)
rack (2.0.3)
Expand All @@ -118,6 +149,11 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-erd (1.5.2)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.2)
Expand All @@ -142,6 +178,7 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rspec (1.16.0)
rubocop (>= 0.49.0)
ruby-graphviz (1.2.3)
ruby-progressbar (1.8.1)
ruby_dep (1.5.0)
rubyzip (1.2.1)
Expand All @@ -159,6 +196,7 @@ GEM
selenium-webdriver (3.4.4)
childprocess (~> 0.5)
rubyzip (~> 1.0)
slop (3.6.0)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
Expand All @@ -185,6 +223,7 @@ GEM
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.3.0)
uniform_notifier (1.10.0)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
Expand All @@ -195,20 +234,30 @@ GEM
websocket-extensions (0.1.2)
xpath (2.1.0)
nokogiri (~> 1.3)
yard (0.9.9)

PLATFORMS
ruby

DEPENDENCIES
annotate
better_errors
binding_of_caller
bullet
byebug
capybara (~> 2.13)
coffee-rails (~> 4.2)
dotenv-rails
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
mysql2 (>= 0.3.18, < 0.5)
onkcop
pry-byebug
pry-doc
pry-rails
puma (~> 3.7)
rails (~> 5.1.2)
rails-erd
rubocop
sass-rails (~> 5.0)
selenium-webdriver
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ gem install bundler
brew install mysql
```

### graphviz(ER図自動生成用)
```
brew install graphviz
```

### editorconfig plugin
[ここ](http://editorconfig.org/#download)からエディタに合わせたものをインストールすること。

Expand All @@ -66,6 +71,11 @@ cd Aktiva-V2-Server
bundle install --path=vendor/bundle
```

3. envファイルをコピーし自分の設定に合わせて変更する
```sh
cp .env.sample .env
```

3. MySqlを起動する
```sh
mysql.server start
Expand Down
16 changes: 16 additions & 0 deletions app/models/lyric.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# == Schema Information
#
# Table name: lyrics
#
# id :integer not null, primary key
# song_id :integer not null, indexed
# time :time not null
# text :string(255) not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Foreign Keys
#
# fk_rails_... (song_id => songs.song_id)
#

# 歌詞情報
class Lyric < ApplicationRecord
belongs_to :song
Expand Down
10 changes: 10 additions & 0 deletions app/models/person.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# == Schema Information
#
# Table name: people
#
# id :integer not null, primary key
# name :string(255) not null
# created_at :datetime not null
# updated_at :datetime not null
#

# アーティスト、作詞者、作曲者、振り付け師情報
class Person < ApplicationRecord
has_many :artists, class_name: "Song", foreign_key: "artist_id"
Expand Down
15 changes: 15 additions & 0 deletions app/models/play_log.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# == Schema Information
#
# Table name: play_logs
#
# id :integer not null, primary key
# song_id :integer not null, indexed
# time :datetime not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Foreign Keys
#
# fk_rails_... (song_id => songs.song_id)
#

# 再生ログ
class PlayLog < ApplicationRecord
belongs_to :song
Expand Down
24 changes: 24 additions & 0 deletions app/models/song.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# == Schema Information
#
# Table name: songs
#
# song_id :integer not null, primary key
# title :string(255) not null
# artist_id :integer not null, indexed
# lyricist_id :integer indexed
# composer_id :integer indexed
# choreographer_id :integer indexed
# beginners_badge :boolean default(FALSE)
# person_badge :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not null
# video :string(255) not null
#
# Foreign Keys
#
# fk_rails_... (artist_id => people.id)
# fk_rails_... (choreographer_id => people.id)
# fk_rails_... (composer_id => people.id)
# fk_rails_... (lyricist_id => people.id)
#

# 曲情報
class Song < ApplicationRecord
belongs_to :artist,
Expand Down
8 changes: 5 additions & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
host: localhost
port: <%= ENV['DATABASE_PORT'] || '3306' %>
username: <%= ENV['DATABASE_USER'] || 'root' %>
password: <%= ENV['DATABASE_PASSWORD'] %>
host: <%= ENV['DATABASE_HOST'] || 'localhost' %>
socket: <%= ENV['DATABASE_SOCKET'] || '/tmp/mysql.sock' %>

development:
<<: *default
Expand Down
8 changes: 8 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.console = true
Bullet.rails_logger = true
end
end
Binary file added erd.pdf
Binary file not shown.
53 changes: 53 additions & 0 deletions lib/tasks/auto_annotate_models.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
require "annotate"
task :set_annotation_options do
# You can override any of these by setting an environment variable of the
# same name.
Annotate.set_defaults(
"routes" => "false",
"position_in_routes" => "before",
"position_in_class" => "before",
"position_in_test" => "before",
"position_in_fixture" => "before",
"position_in_factory" => "before",
"position_in_serializer" => "before",
"show_foreign_keys" => "true",
"show_complete_foreign_keys" => "false",
"show_indexes" => "false",
"simple_indexes" => "true",
"model_dir" => "app/models",
"root_dir" => "",
"include_version" => "false",
"require" => "",
"exclude_tests" => "true",
"exclude_fixtures" => "true",
"exclude_factories" => "true",
"exclude_serializers" => "true",
"exclude_scaffolds" => "true",
"exclude_controllers" => "true",
"exclude_helpers" => "true",
"exclude_sti_subclasses" => "false",
"ignore_model_sub_dir" => "false",
"ignore_columns" => nil,
"ignore_routes" => nil,
"ignore_unknown_models" => "false",
"hide_limit_column_types" => "integer,boolean",
"hide_default_column_types" => "json,jsonb,hstore",
"skip_on_db_migrate" => "false",
"format_bare" => "true",
"format_rdoc" => "false",
"format_markdown" => "false",
"sort" => "false",
"force" => "false",
"trace" => "false",
"wrapper_open" => nil,
"wrapper_close" => nil,
"with_comment" => true,
)
end

Annotate.load_tasks
end
4 changes: 4 additions & 0 deletions lib/tasks/auto_generate_diagram.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
RailsERD.load_tasks if Rails.env.development?