-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in feature/integrate_responder (pull request #4)
KBP-121 integrate responder Approved-by: Tayfun Öziş ERİKAN <[email protected]>
- Loading branch information
Showing
17 changed files
with
351 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Description: | ||
Cybele is a Rails template with Lab2023 standard | ||
defaults. | ||
|
||
For full details check our GitHub project: | ||
https://github.com/kebab-project/cybele | ||
|
||
Example: | ||
cybele ~/Workplace/blog | ||
|
||
This generates a Rails installation in ~/Workplace/blog configured | ||
with our preferred defaults. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require 'pathname' | ||
|
||
require File.expand_path(File.join('..', 'lib', 'cybele', 'generators', 'app_generator'), File.dirname(__FILE__)) | ||
require File.expand_path(File.join('..', 'lib', 'cybele', 'app_builder'), File.dirname(__FILE__)) | ||
require File.expand_path(File.join('..', 'lib', 'cybele', 'version'), File.dirname(__FILE__)) | ||
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path | ||
$LOAD_PATH << source_path | ||
|
||
require 'cybele' | ||
|
||
if ARGV.empty? | ||
puts 'Please provide a path for the new application' | ||
puts | ||
puts 'See --help for more info' | ||
exit 0 | ||
elsif ['-v', '--version'].include? ARGV[0] | ||
elsif %w[-v --version].include? ARGV[0] | ||
puts Cybele::VERSION | ||
exit 0 | ||
end | ||
|
||
templates_root = File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__)) | ||
Cybele::AppGenerator.source_root templates_root | ||
Cybele::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root | ||
Cybele::AppGenerator.start | ||
root = File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__)) | ||
Cybele::AppGenerator.source_root root | ||
Cybele::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << root | ||
Cybele::AppGenerator.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Cybele | ||
module Helpers | ||
private | ||
|
||
def replace_in_file(relative_path, find, replace) | ||
path = File.join(destination_root, relative_path) | ||
contents = IO.read(path) | ||
unless contents.gsub!(find, replace) | ||
raise "#{find.inspect} not found in #{relative_path}" | ||
end | ||
File.open(path, 'w') { |file| file.write(contents) } | ||
end | ||
|
||
def template_content(file) | ||
File.read(File.expand_path(find_in_source_paths(file))) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Cybele | ||
module Helpers | ||
module Responders | ||
def configure_responders | ||
# Add gems | ||
append_file('Gemfile', template_content('responders_Gemfile.erb')) | ||
run_bundle | ||
|
||
# Add initializers | ||
bundle_command 'exec rails generate responders:install' | ||
|
||
# Add js and json to respond :html | ||
replace_in_file 'app/controllers/application_controller.rb', | ||
'respond_to :html', | ||
'respond_to :html, :js, :json' | ||
replace_in_file 'app/controllers/application_controller.rb', | ||
'require "application_responder"', | ||
"require 'application_responder'" | ||
|
||
# Remove comments in locale/responders.yml | ||
uncomment_lines 'config/locales/responders.en.yml', /alert:/ | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
module Cybele | ||
module Helpers | ||
module Sidekiq | ||
def configure_sidekiq | ||
# Add gems | ||
append_file('Gemfile', template_content('sidekiq_Gemfile.erb')) | ||
|
||
create_sidekiq_files | ||
|
||
# Add sidekiq routes to routes | ||
prepend_file 'config/routes.rb', | ||
template_content('sidekiq_routes_require.erb') | ||
inject_into_file 'config/routes.rb', | ||
template_content('sidekiq_routes_mount.erb'), | ||
after: 'Rails.application.routes.draw do' | ||
end | ||
|
||
private | ||
|
||
def create_sidekiq_files | ||
# Initialize files | ||
template 'sidekiq.rb.erb', | ||
'config/initializers/sidekiq.rb', | ||
force: true | ||
# Add tasks | ||
template 'sidekiq.rake.erb', | ||
'lib/tasks/sidekiq.rake', | ||
force: true | ||
|
||
# Add sidekiq.yml | ||
template 'sidekiq.yml.erb', | ||
'config/sidekiq.yml', | ||
force: true | ||
|
||
# Add sidekiq_schedule.yml | ||
template 'sidekiq_schedule.yml.erb', | ||
'config/sidekiq_schedule.yml', | ||
force: true | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.