diff --git a/app/models/fluentd.rb b/app/models/fluentd.rb index ae027fc..9e0a080 100644 --- a/app/models/fluentd.rb +++ b/app/models/fluentd.rb @@ -11,7 +11,7 @@ class Fluentd before_validation :expand_paths COLUMNS = [:id, :variant, :log_file, :pid_file, :config_file, :api_endpoint] - JSON_PATH = Rails.root + "db/fluentd.json" + JSON_PATH = Rails.root + "db/#{Rails.env}-fluentd.json" DEFAULT_CONF = <<-CONF.strip_heredoc type forward @@ -38,12 +38,13 @@ class Fluentd attr_accessor(*COLUMNS) def self.variants - %w(fluentd td-agent) + %w(fluentd_gem td-agent) end def fluentd? - variant == "fluentd" + variant == "fluentd_gem" end + alias :fluentd_gem? :fluentd? def td_agent? variant == "td-agent" diff --git a/app/models/fluentd/agent.rb b/app/models/fluentd/agent.rb index e4ac19d..7c1995b 100644 --- a/app/models/fluentd/agent.rb +++ b/app/models/fluentd/agent.rb @@ -3,7 +3,7 @@ require 'fluent/env' require 'fluent/version' require 'fluent/supervisor' require "fluentd/agent/common" -require "fluentd/agent/fluentd" +require "fluentd/agent/fluentd_gem" require "fluentd/agent/td_agent" require "fluentd/agent/remote" diff --git a/app/models/fluentd/agent/fluentd.rb b/app/models/fluentd/agent/fluentd_gem.rb similarity index 99% rename from app/models/fluentd/agent/fluentd.rb rename to app/models/fluentd/agent/fluentd_gem.rb index a8951fa..09cbe74 100644 --- a/app/models/fluentd/agent/fluentd.rb +++ b/app/models/fluentd/agent/fluentd_gem.rb @@ -1,6 +1,6 @@ class Fluentd class Agent - class Fluentd + class FluentdGem include Common def self.default_options diff --git a/app/views/fluentd/show.html.haml b/app/views/fluentd/show.html.haml index 37921f6..a865c32 100644 --- a/app/views/fluentd/show.html.haml +++ b/app/views/fluentd/show.html.haml @@ -4,7 +4,7 @@ %div.row %div.col-lg-6 %div.well - %span= link_to icon("fa-cog") << t(".setup", target: "fluentd"), new_fluentd_path(variant: "fluentd"), class: "btn btn-primary btn-lg" + %span= link_to icon("fa-cog") << t(".setup", target: "fluentd"), new_fluentd_path(variant: "fluentd_gem"), class: "btn btn-primary btn-lg" %div.col-lg-6 %div.well %span diff --git a/config/application.rb b/config/application.rb index dece7a5..7b60592 100644 --- a/config/application.rb +++ b/config/application.rb @@ -33,10 +33,5 @@ module FluentdUi # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = 'en' config.autoload_paths += %W(#{config.root}/app/workers #{config.root}/lib) - config.after_initialize do - # http://qiita.com/tanaka51/items/c8873319689217bb81a9 - require File.join(Rails.root, "app", "models", "fluentd") - require File.join(Rails.root, "app", "models", "fluentd", "agent", "fluentd") - end end end diff --git a/spec/factories/fluentd.rb b/spec/factories/fluentd.rb index 5ec7b8f..a077e63 100644 --- a/spec/factories/fluentd.rb +++ b/spec/factories/fluentd.rb @@ -1,6 +1,6 @@ FactoryGirl.define do factory :fluentd do - variant "fluentd" + variant "fluentd_gem" log_file (Rails.root + "tmp/fluentd-test/fluentd.log").to_s pid_file (Rails.root + "tmp/fluentd-test/fluentd.pid").to_s config_file (Rails.root + "tmp/fluentd-test/fluentd.conf").to_s diff --git a/spec/models/fluentd/agent_spec.rb b/spec/models/fluentd/agent_spec.rb index 01bcd32..d599060 100644 --- a/spec/models/fluentd/agent_spec.rb +++ b/spec/models/fluentd/agent_spec.rb @@ -74,8 +74,8 @@ describe Fluentd::Agent do let(:instance) { described_class.new(options) } let(:options) { {} } - describe "Fluentd" do - let(:described_class) { Fluentd::Agent::Fluentd } # override nested described_class behavior as https://github.com/rspec/rspec-core/issues/1114 + describe "FluentdGem" do + let(:described_class) { Fluentd::Agent::FluentdGem } # override nested described_class behavior as https://github.com/rspec/rspec-core/issues/1114 it_should_behave_like "Agent has common behavior" diff --git a/spec/models/fluentd_spec.rb b/spec/models/fluentd_spec.rb index 3bf44e4..2dce9c1 100644 --- a/spec/models/fluentd_spec.rb +++ b/spec/models/fluentd_spec.rb @@ -71,7 +71,7 @@ describe Fluentd do before { fluentd.variant = variant } context "fluentd" do - let(:variant) { "fluentd" } + let(:variant) { "fluentd_gem" } it { should be_valid } end @@ -97,9 +97,9 @@ describe Fluentd do describe "variant" do before { fluentd.variant = variant } - context "= fluentd" do - let(:variant) { "fluentd" } - it { fluentd.should be_fluentd } + context "= fluentd_gem" do + let(:variant) { "fluentd_gem" } + it { fluentd.should be_fluentd_gem } it { fluentd.should_not be_td_agent } describe "#load_settings_from_agent_default" do @@ -113,7 +113,7 @@ describe Fluentd do context "= td-agent" do let(:variant) { "td-agent" } - it { fluentd.should_not be_fluentd } + it { fluentd.should_not be_fluentd_gem } it { fluentd.should be_td_agent } describe "#load_settings_from_agent_default" do @@ -130,9 +130,9 @@ describe Fluentd do before { fluentd.variant = variant } subject { fluentd.agent } - context "fluentd" do - let(:variant) { "fluentd" } - it { should be_instance_of(Fluentd::Agent::Fluentd) } + context "fluentd_gem" do + let(:variant) { "fluentd_gem" } + it { should be_instance_of(Fluentd::Agent::FluentdGem) } end context "td-agent" do