aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-11-20 13:19:53 +0100
committerGuido Günther <agx@sigxcpu.org>2016-11-22 08:09:34 +0100
commit1a9a01563f52405df62764bd8850a501f9685fb6 (patch)
tree393db9a64e5e7ec67e9577d780c41a53ca3c59af
parent5657b20b4490f25b200eb6743f289155884b72bd (diff)
Rubocop cleanups
-rw-r--r--.gitignore4
-rw-r--r--.rubocop.yml23
-rw-r--r--Gemfile2
-rw-r--r--Rakefile20
-rw-r--r--foreman_influxdb.gemspec1
-rw-r--r--lib/foreman_influxdb/client.rb26
-rw-r--r--lib/foreman_influxdb/engine.rb6
-rw-r--r--lib/foreman_influxdb/version.rb2
8 files changed, 53 insertions, 31 deletions
diff --git a/.gitignore b/.gitignore
index 26e7265..408a1a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
+.bundle/
+vendor/
Gemfile.lock
-pkg \ No newline at end of file
+pkg
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..c3dcdc2
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,23 @@
+Rails:
+ Enabled: true
+
+# Don't enforce documentation
+Style/Documentation:
+ Enabled: false
+
+# Force before_filter until upgrade to Rails 4
+Rails/ActionFilter:
+ EnforcedStyle: filter
+
+Metrics/MethodLength:
+ Max: 20
+
+Metrics/LineLength:
+ Max: 111 # TODO: discuss and set this
+
+Style/Next:
+ Enabled: false
+
+# Support both ruby19 and hash_rockets
+Style/HashSyntax:
+ Enabled: false
diff --git a/Gemfile b/Gemfile
index c80ee36..fa75df1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,3 @@
-source "http://rubygems.org"
+source 'https://rubygems.org'
gemspec
diff --git a/Rakefile b/Rakefile
index 6591feb..15d2aba 100644
--- a/Rakefile
+++ b/Rakefile
@@ -4,20 +4,14 @@ begin
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
+
begin
- require 'rdoc/task'
-rescue LoadError
- require 'rdoc/rdoc'
- require 'rake/rdoctask'
- RDoc::Task = Rake::RDocTask
+ require 'rubocop/rake_task'
+ RuboCop::RakeTask.new
+rescue => _
+ puts 'Rubocop not loaded.'
end
-RDoc::Task.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'ForemanInfluxdb'
- rdoc.options << '--line-numbers'
- rdoc.rdoc_files.include('README.rdoc')
- rdoc.rdoc_files.include('lib/**/*.rb')
+task :default do
+ Rake::Task['rubocop'].execute
end
-
-Bundler::GemHelper.install_tasks
diff --git a/foreman_influxdb.gemspec b/foreman_influxdb.gemspec
index 6d13dba..c7803c7 100644
--- a/foreman_influxdb.gemspec
+++ b/foreman_influxdb.gemspec
@@ -17,4 +17,5 @@ Gem::Specification.new do |s|
s.add_dependency 'influxdb-rails', '>= 0.1.11'
s.add_development_dependency 'rake'
+ s.add_development_dependency 'rubocop', '~> 0.42'
end
diff --git a/lib/foreman_influxdb/client.rb b/lib/foreman_influxdb/client.rb
index ca297c8..6c4ff98 100644
--- a/lib/foreman_influxdb/client.rb
+++ b/lib/foreman_influxdb/client.rb
@@ -1,22 +1,24 @@
require 'influxdb-rails'
-class ForemanInfluxdb::Client
- attr_reader :influx
- attr_reader :database
+module ForemanInfluxdb
+ class Client
+ attr_reader :influx
+ attr_reader :database
- def initialize(opts = {})
- @database = "theforeman"
- InfluxDB::Rails.configure do |config|
+ def initialize(opts = {})
+ @database = 'theforeman'
+ InfluxDB::Rails.configure do |config|
config.influxdb_database = @database
- config.influxdb_username = opts[:username]
+ config.influxdb_username = opts[:username]
config.influxdb_password = opts[:password]
config.influxdb_hosts = opts[:hosts] || ['localhost']
config.influxdb_port = opts[:port] || '8086'
- config.series_name_for_controller_runtimes = "theforeman.controller"
- config.series_name_for_view_runtimes = "theforeman.view"
- config.series_name_for_db_runtimes = "theforeman.db"
+ config.series_name_for_controller_runtimes = 'theforeman.controller'
+ config.series_name_for_view_runtimes = 'theforeman.view'
+ config.series_name_for_db_runtimes = 'theforeman.db'
+ end
+ @client = InfluxDB::Rails.client
+ @client.create_database if opts[:create_database]
end
- @client = InfluxDB::Rails.client
- @client.create_database if opts[:create_database]
end
end
diff --git a/lib/foreman_influxdb/engine.rb b/lib/foreman_influxdb/engine.rb
index 716f6c2..ca769e1 100644
--- a/lib/foreman_influxdb/engine.rb
+++ b/lib/foreman_influxdb/engine.rb
@@ -2,15 +2,15 @@ module ForemanInfluxdb
class Engine < ::Rails::Engine
engine_name 'foreman_influxdb'
- initializer "foreman_influxdb.register_plugin", :after => :finisher_hook do |app|
+ initializer 'foreman_influxdb.register_plugin', :after => :finisher_hook do
Foreman::Plugin.register :foreman_influxdb do
requires_foreman '> 1.10'
end
end
-
+
initializer 'foreman_influxdb.setup_notifications' do
opts = SETTINGS[:influxdb] || {}
- client = ForemanInfluxdb::Client.new(opts)
+ ForemanInfluxdb::Client.new(opts)
end
end
end
diff --git a/lib/foreman_influxdb/version.rb b/lib/foreman_influxdb/version.rb
index e9845f8..03d4344 100644
--- a/lib/foreman_influxdb/version.rb
+++ b/lib/foreman_influxdb/version.rb
@@ -1,3 +1,3 @@
module ForemanInfluxdb
- VERSION = "0.0.1"
+ VERSION = '0.0.1'.freeze
end