fluent-format 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c146d76922041322724ecc30226d50f82a10233
4
- data.tar.gz: b9f8974f98d0c56705ae57a0d936d6f470a49f28
3
+ metadata.gz: 45e9edeceed0b41a528b44e55f62acc590c10511
4
+ data.tar.gz: f1f8d83c06393f8e1711f09d518df075cda1d9b8
5
5
  SHA512:
6
- metadata.gz: b969c2059241258ce3c03a5c043805d3696726c0c1a2ff2b0cfa6409dda770649f65760bc07ae468943831609060c57f97fed9cae2d25c10550832df5b0c6fba
7
- data.tar.gz: 1f09c86414d97aac4186616cf677c4d05b68652eca921ea2da12ea99e735040ea02b51c5459fd3d568ddfc150a543de134d5f3fe2f42d0c9cab13da21903bf96
6
+ metadata.gz: 0214b3c0202711b8524ba1aa1224adc9423660fb480582967f5c274f99a50eacd7f8765cfb20fa659e85470681b309424fa24150de7733a26aacf637ddf9eca5
7
+ data.tar.gz: 4c4d3e307d2f1c45708da99e444c36d3a09f5c29aced24c84a06bb35315845eefa610f3bc7f28cc119b2d7c31eb329257f98781a61c0d21cab55cef52b299c20
@@ -1,3 +1,9 @@
1
+ ## 0.2.4 (2014/04/14)
2
+
3
+ Enhancements:
4
+
5
+ * Add `gemfile` option and `inline_config` option for fluent-format check
6
+
1
7
  ## 0.2.3 (2014/04/10)
2
8
 
3
9
  Enhancement:
@@ -13,11 +13,10 @@ module Fluent
13
13
  # Check config file
14
14
  #
15
15
  # @param [IO|String] config_dev
16
- # @param [String] plugin_dir the plugin directory
17
- # @param [Array] libs load libraries (to require)
16
+ # @param [Hash] opts
18
17
  # @return [Boolean]
19
- def self.check(config_dev, plugin_dir = nil, libs = nil)
20
- Fluent::Format::Check.new(config_dev, plugin_dir, libs).run
18
+ def self.check(config_dev, opts = {})
19
+ Fluent::Format::Check.new(config_dev, opts).run
21
20
  end
22
21
  end
23
22
  end
@@ -6,9 +6,7 @@ module Fluent
6
6
  # Initialize
7
7
  #
8
8
  # @param [IO|String] config_dev
9
- # @param [String] plugin_dir the plugin directory
10
- # @param [Array] libs load libraries (to require)
11
- def initialize(config_dev, plugin_dir = nil, libs = nil)
9
+ def initialize(config_dev, opts = {})
12
10
  @opts = {
13
11
  :config_path => config_dev, # Fluent::DEFAULT_CONFIG_PATH,
14
12
  :plugin_dirs => [Fluent::DEFAULT_PLUGIN_DIR],
@@ -22,8 +20,11 @@ module Fluent
22
20
  :suppress_interval => 0,
23
21
  :suppress_repeated_stacktrace => false,
24
22
  }
25
- @opts[:plugin_dirs] << plugin_dir if plugin_dir
26
- @opts[:libs] += libs if libs and !libs.empty?
23
+ @opts[:plugin_dirs] += opts[:plugin_dirs] if opts[:plugin_dirs] and !opts[:plugin_dirs].empty?
24
+ @opts[:libs] += opts[:libs] if opts[:libs] and !opts[:libs].empty?
25
+ @opts[:inline_config] = opts[:inline_config]
26
+ @opts[:gemfile] = opts[:gemfile]
27
+ @opts[:gem_install_path] = opts[:gem_install_path]
27
28
  end
28
29
 
29
30
  # Check config file
@@ -32,12 +33,58 @@ module Fluent
32
33
  # @raise Fluent::ConfigError if plugin raises config error
33
34
  # @return true if success
34
35
  def run
36
+ Fluent::Format::BundlerInjection.new(@opts).run
35
37
  Fluent::Supervisor.new(@opts).extended_dry_run
36
38
  end
37
39
  end
38
40
  end
39
41
  end
40
42
 
43
+ module Fluent
44
+ class Format
45
+ class BundlerInjection
46
+ def initialize(opts = {})
47
+ @opts = {
48
+ :gemfile => opts[:gemfile],
49
+ :gem_install_path => opts[:gem_install_path],
50
+ }
51
+ end
52
+
53
+ def run
54
+ # copy from lib/fluent/command/fluentd.rb
55
+ if ENV['FLUENTD_DISABLE_BUNDLER_INJECTION'] != '1' && gemfile = @opts[:gemfile]
56
+ ENV['BUNDLE_GEMFILE'] = gemfile
57
+ if path = @opts[:gem_install_path]
58
+ ENV['BUNDLE_PATH'] = path
59
+ else
60
+ ENV['BUNDLE_PATH'] = File.expand_path(File.join(File.dirname(gemfile), 'vendor/bundle'))
61
+ end
62
+ ENV['FLUENTD_DISABLE_BUNDLER_INJECTION'] = '1'
63
+ bundler_injection
64
+ end
65
+ end
66
+
67
+ def bundler_injection
68
+ # basically copy from lib/fluent/command/bundler_injection.rb
69
+ system("bundle install")
70
+ unless $?.success?
71
+ exit $?.exitstatus
72
+ end
73
+
74
+ cmdline = [
75
+ 'bundle',
76
+ 'exec',
77
+ RbConfig.ruby,
78
+ File.expand_path(File.join(File.dirname(__FILE__), '../../../bin/fluent-format')),
79
+ ] + ARGV
80
+
81
+ exec *cmdline
82
+ exit! 127
83
+ end
84
+ end
85
+ end
86
+ end
87
+
41
88
  # lib/fluent/supervisor.rb
42
89
  # Open the existing class and define new methods
43
90
  module Fluent
@@ -17,15 +17,14 @@ module Fluent
17
17
 
18
18
  desc "check", "Check fluent.conf"
19
19
  option :config, :aliases => ["-c"], :type => :string, :default => 'fluent.conf', :desc => 'Fluentd configuration file'
20
- option :plugin, :aliases => ["-p"], :type => :string, :desc => 'Additional Fluentd plugin directory'
21
- option :require, :aliases => ["-r"], :type => :array, :desc => 'Additional Fluentd lib path'
20
+ option :plugin_dirs, :aliases => ["-p"], :type => :array, :desc => 'add plugin directory'
21
+ option :libs, :aliases => ["-r"], :type => :array, :desc => 'load library'
22
+ option :inline_config, :aliases => ["-i"], :type => :string, :desc => 'inline config which is appended to the config file on-fly'
23
+ option :gemfile, :aliases => ["-g"], :type => :string, :desc => 'Gemfile path'
24
+ option :gem_install_path, :aliases => ["-G"], :type => :string, :desc => 'Gem install path (default: $(dirname $gemfile)/vendor/bundle)'
22
25
  def check
23
26
  config = @options[:config]
24
- plugin = @options[:plugin]
25
- require 'pry'
26
- binding.pry
27
- libs = @options[:require]
28
- Fluent::Format.check(config, plugin, libs)
27
+ Fluent::Format.check(config, @options)
29
28
  rescue => e
30
29
  $stderr.puts "#{e.class} #{e.message} #{e.backtrace.first}"
31
30
  exit 1
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  class Format
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
@@ -1,9 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Fluent::Format::Check do
4
- let(:plugin_dir) { File.expand_path('../../../example', File.dirname(__FILE__)) }
5
- let(:libs) { [File.expand_path('../../../example/out_example', File.dirname(__FILE__))] }
6
- let(:subject) { Fluent::Format.check(config, plugin_dir, libs) }
4
+ let(:opts) {{
5
+ :plugin_dirs => [File.expand_path('../../../example', File.dirname(__FILE__))],
6
+ :libs => [File.expand_path('../../../example/out_example', File.dirname(__FILE__))]
7
+ }}
8
+ let(:subject) { Fluent::Format.check(config, opts) }
7
9
 
8
10
  context "valid" do
9
11
  let(:config) { StringIO.new(%[<match>\ntype stdout\n</match>]) }
@@ -40,14 +40,15 @@ describe Fluent::Format::CLI do
40
40
  it { expect { subject }.not_to raise_error }
41
41
  end
42
42
 
43
- context "plugin option" do
44
- let(:opts) { {config: "fluent.conf", plugin: "example"} }
43
+ context "-p option" do
44
+ let(:opts) { {config: "fluent.conf", plugin_dirs: ["example"]} }
45
45
  it { capture_stderr { subject }.should == "" }
46
46
  it { expect { subject }.not_to raise_error }
47
47
  end
48
48
 
49
- context "require option" do
50
- let(:opts) { {config: "fluent.conf", require: ["example/out_example"]} }
49
+ context "-r option" do
50
+ let(:libs) { [File.expand_path('../../../example/out_example', File.dirname(__FILE__))] }
51
+ let(:opts) { {config: "fluent.conf", libs: libs } }
51
52
  it { capture_stderr { subject }.should == "" }
52
53
  it { expect { subject }.not_to raise_error }
53
54
  end
@@ -65,7 +66,7 @@ describe Fluent::Format::CLI do
65
66
  end
66
67
 
67
68
  context "param error" do
68
- let(:opts) { {config: "example/param_error.conf", plugin: "example"} }
69
+ let(:opts) { {config: "example/param_error.conf", plugin_dirs: ["example"]} }
69
70
  it { capture_stderr { subject }.should include("out_example.rb") }
70
71
  it { expect { subject }.to raise_error(SystemExit) }
71
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor