Skip to content

Commit

Permalink
update based on latest foreman_plugin_template
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Oct 16, 2023
1 parent 59d85d7 commit b8345d6
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 54 deletions.
39 changes: 39 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require:
- rubocop-performance
- rubocop-rails
- rubocop-minitest

AllCops:
TargetRubyVersion: 2.5
TargetRailsVersion: 6.0
Exclude:
- 'node_modules/**/*'
- 'vendor/**/*'

Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation
IndentationWidth: 2

Layout/EmptyLineAfterGuardClause:
Enabled: false

Layout/LineLength:
Enabled: 111 # TODO: discuss and set this

Rails:
Enabled: true

Style/Alias:
EnforcedStyle: prefer_alias_method

# Don't enforce documentation
Style/Documentation:
Enabled: false

# Don't enforce frozen string literals
Style/FrozenStringLiteralComment:
Enabled: false

# Support both ruby19 and hash_rockets
Style/HashSyntax:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "http://rubygems.org"
source 'https://rubygems.org'
gem 'sprockets-rails', '~> 2.3.2'
gem 'sass-rails'
gem 'activesupport'
Expand Down
19 changes: 13 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Foremantheme'
rdoc.title = 'ForemanThemeSatellite'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'


APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)

Bundler::GemHelper.install_tasks

Expand All @@ -36,5 +33,15 @@ Rake::TestTask.new(:test) do |t|
t.verbose = false
end

task default: :test

begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new
rescue => _
puts 'Rubocop not loaded.'
end

task :default => :test
task :default do
Rake::Task['rubocop'].execute
end
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['@theforeman/builder/babel'],
module.exports = {
presets: ['@theforeman/builder/babel'],
};
27 changes: 16 additions & 11 deletions foreman_theme_satellite.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
require File.expand_path('lib/foreman_theme_satellite/version', __dir__)
require 'date'
require File.expand_path('../lib/foreman_theme_satellite/version', __FILE__)

Gem::Specification.new do |s|
s.name = "foreman_theme_satellite"
s.name = 'foreman_theme_satellite'
s.version = ForemanThemeSatellite::VERSION
s.date = Date.today.to_s
s.authors = ["Alon Goldboim, Shimon Stein"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/alongoldboim/foreman_theme_satellite"
s.summary = "This is a plugin that enables building a theme for Foreman."
s.metadata = { "is_foreman_plugin" => "true" }
s.license = 'GPL-3.0'
s.authors = ['Alon Goldboim, Shimon Stein']
s.email = ['[email protected]']
s.homepage = 'https://github.com/theforeman/foreman_theme_satellite'
s.summary = 'This is a plugin that enables building a theme for Foreman.'
# also update locale/gemspec.rb
s.description = "Theme changes for Satellite 6."
s.description = 'Theme changes for Satellite 6.'
s.files = Dir['{app,config,db,lib,locale,webpack}/**/*'] +
['LICENSE', 'Rakefile', 'README.md'] +
['package.json']
s.files -= Dir['**/*.orig']
s.test_files = Dir['test/**/*']
s.test_files -= Dir['test/**/*.orig']
s.test_files = Dir['test/**/*'] + Dir['webpack/**/__tests__/*.js']

s.add_dependency "deface"
s.add_dependency "activesupport"
s.add_development_dependency 'rubocop'
s.add_development_dependency 'rubocop-minitest'
s.add_development_dependency 'rubocop-performance'
s.add_development_dependency 'rubocop-rails'
s.add_development_dependency 'rdoc'
end
3 changes: 1 addition & 2 deletions lib/foreman_theme_satellite.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "foreman_theme_satellite/version"
require "foreman_theme_satellite/engine"
require 'foreman_theme_satellite/engine'

module ForemanThemeSatellite
end
17 changes: 8 additions & 9 deletions lib/tasks/foreman_theme_satellite_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'rake/testtask'

# Tasks
namespace :foreman_theme_satellite do
namespace :example do
Expand All @@ -12,10 +14,12 @@ end
namespace :test do
desc 'Test ForemanThemeSatellite'
Rake::TestTask.new(:foreman_theme_satellite) do |t|
test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
t.libs << ['test', test_dir]
test_dir = File.expand_path('../../test', __dir__)
t.libs << 'test'
t.libs << test_dir
t.pattern = "#{test_dir}/**/*_test.rb"
t.verbose = true
t.warning = false
end
end

Expand All @@ -36,14 +40,9 @@ namespace :foreman_theme_satellite do
end
end

Rake::Task[:test].enhance do
Rake::Task['test:foreman_theme_satellite'].invoke
end
Rake::Task[:test].enhance ['test:foreman_theme_satellite']

load 'tasks/jenkins.rake'
if Rake::Task.task_defined?(:'jenkins:unit')
Rake::Task['jenkins:unit'].enhance do
Rake::Task['test:foreman_theme_satellite'].invoke
Rake::Task['foreman_theme_satellite:rubocop'].invoke
end
Rake::Task['jenkins:unit'].enhance ['test:foreman_theme_satellite', 'foreman_theme_satellite:rubocop']
end
47 changes: 25 additions & 22 deletions locale/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
# make tx-update - download and merge translations from Transifex
# make clean - clean everything
#
DOMAIN = foreman_theme_satellite
VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
DOMAIN = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).name')
VERSION = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).version')
POTFILE = $(DOMAIN).pot
MOFILE = $(DOMAIN).mo
POFILES = $(shell find . -name '*.po')
POFILES = $(shell find . -name '$(DOMAIN).po')
MOFILES = $(patsubst %.po,%.mo,$(POFILES))
POXFILES = $(patsubst %.po,%.pox,$(POFILES))
EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
JSFILES = $(shell find ../app/assets/javascripts/*/locale -name '$(DOMAIN).js')

%.mo: %.po
mkdir -p $(shell dirname $@)/LC_MESSAGES
Expand All @@ -29,34 +31,35 @@ all-mo: $(MOFILES)
cat $@
! grep -q msgid $@

check: $(POXFILES)
msgfmt -c ${POTFILE}
%.edit.po:
touch $@

# Merge PO files
update-po:
for f in $(shell find ./ -name "*.po") ; do \
msgmerge -N --backup=none -U $$f ${POTFILE} ; \
done
check: $(POXFILES)

# Unify duplicate translations
uniq-po:
for f in $(shell find ./ -name "*.po") ; do \
msguniq $$f -o $$f ; \
done

tx-pull:
tx pull -f
for f in $(POFILES) ; do \
tx-pull: $(EDITFILES)
cd .. && tx pull -f
for f in $(EDITFILES) ; do \
sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
done
-git commit -a -m "i18n - pulling from tx"

reset-po:
# merging po files is unnecessary when using transifex.com
git checkout -- ../locale/*/*po
tx-update: tx-pull
@echo
@echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation
@echo then run rake plugin:po_to_json[$(DOMAIN)] from the Foreman installation
@echo then run make -C locale mo-files to finish
@echo

build-mo-files: $(MOFILES)

tx-update: tx-pull reset-po $(MOFILES)
# amend mo files
git add ../locale/*/LC_MESSAGES
git commit -a --amend -m "i18n - pulling from tx"
-echo Changes commited!
mo-files: build-mo-files
git add $(POFILES) $(POTFILE) $(JSFILES) ../locale/*/LC_MESSAGES
git commit -m "i18n - pulling from tx"
@echo
@echo Changes commited!
@echo
2 changes: 1 addition & 1 deletion test/test_plugin_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This calls the main test_helper in Foreman-core
require 'test_helper'

# Add plugin to FactoryGirl's paths
# Add plugin to FactoryBot's paths
FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
FactoryBot.reload

Expand Down

0 comments on commit b8345d6

Please sign in to comment.