arsenicum 0.1.3 → 0.2

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: 9d49ec4dfbcc45d77e58afdf36d28bee1d06eb68
4
- data.tar.gz: 291a2344942b30df1fcc03d274cbb49e76a48560
3
+ metadata.gz: 0db275857e4df7d382e9118bf5939c1d0f414eac
4
+ data.tar.gz: e96f9f008045765ec16630f2f0820d2219144de1
5
5
  SHA512:
6
- metadata.gz: 7f29b77fae0f8c344c64916a44d27d0e02f94a818723d09efda39a8069894344389a9b27b71dd21ff38fc36c093999c6a8fb9b89bee9f82f1d5b25b72e2e5726
7
- data.tar.gz: 3193c124fb5c4c090252a233ea8f7428731155d682f1baa7828ce57ae813c92dbf1bf865dec4aca1e23921134df1dbe07c817242e61ba577a41ed07ff3b7fbdc
6
+ metadata.gz: 8139cf79ce9249b4096db334bd7363c54218339bff1f0a31b6cbc8ce22476462257b45b820a7bb98ff045070d52696a2b1b7f5c5bfa85d9361985c9b51f0a344
7
+ data.tar.gz: babcd0a21ffd39a7cb3543d63fdb1c4a8bb44f3eb98b323f0ab7be563853e5a59606266ec427946e4294521929078b5ffa0ee0dc88ec09bcdd344b42f31bdd47
data/bin/arsenicum CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'arsenicum'
4
- require 'optparse'
5
- require 'yaml'
6
4
 
7
5
  Arsenicum::CLI.new(ARGV).boot
data/bin/arsenicum_rails CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'arsenicum'
4
4
 
5
- Arsenicum::CLI::Rails.new(ARGV).boot
5
+ Arsenicum::CLI::RailsCLI.new(ARGV).boot
@@ -0,0 +1,20 @@
1
+ require 'optparse'
2
+
3
+ class Arsenicum::CLI::RailsCLI < Arsenicum::CLI
4
+ private
5
+ def create_configuration
6
+ ::Arsenicum::Configuration::RailsConfiguration.new
7
+ end
8
+
9
+ def create_main
10
+ ::Arsenicum::Main::RailsMain.new
11
+ end
12
+
13
+ def handle_options(opt)
14
+ super
15
+
16
+ opt.on('-e', '--environment=ENVIRONMENT') do |env|
17
+ configuration.environment env
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,50 @@
1
+ class Arsenicum::CLI
2
+ autoload :RailsCLI, 'arsenicum/cli/rails_cli'
3
+
4
+ attr_reader :arguments, :configuration
5
+ private :arguments, :configuration
6
+
7
+ def initialize(arguments)
8
+ @arguments = arguments
9
+ @configuration = create_configuration
10
+ parse_options arguments
11
+ end
12
+
13
+ def boot
14
+ create_main.run configuration
15
+ end
16
+
17
+ private
18
+ def create_configuration
19
+ Arsenicum::Configuration.new
20
+ end
21
+
22
+ def create_main
23
+ Arsenicum::Main.new
24
+ end
25
+
26
+ def parse_options(arguments)
27
+ OptionParser.new(&method(:handle_options)).parse!(arguments)
28
+ end
29
+
30
+ def handle_options(opt)
31
+ opt.on '-c', '--config-file=CONFIG_FILE', 'Specifies configuration file. all other options will be ignored.' do |config_path|
32
+ config_file = File.expand_path config_path
33
+ script = File.read config_file
34
+ configuration.instance_eval script, config_file, 1
35
+ end
36
+
37
+ opt.on '-d', '--daemonize' do
38
+ configuration.daemonize
39
+ end
40
+
41
+ opt.on '--stdout=PATH' do |v|
42
+ configuration.stdout v
43
+ end
44
+
45
+ opt.on '--stderr=PATH' do |v|
46
+ configuration.stderr v
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,12 @@
1
+ class Arsenicum::Configuration::RailsConfiguration < Arsenicum::Configuration
2
+ attr_reader :rails_env
3
+
4
+ def initialize(*)
5
+ super
6
+ @rails_env = 'development'
7
+ end
8
+
9
+ def environment(env_name)
10
+ @rails_env = env_name
11
+ end
12
+ end
@@ -4,11 +4,12 @@ module Arsenicum
4
4
  class MisconfigurationError < StandardError;end
5
5
 
6
6
  class Configuration
7
- attr_reader :pidfile_path, :daemon, :stdout_path, :stderr_path, :logger_config
7
+ attr_reader :pidfile_path, :daemon, :stdout_path, :stderr_path, :logger_config, :working_directory
8
8
 
9
9
  def initialize
10
10
  @pidfile_path = 'arsenicum.pid'
11
11
  @logger_config = LoggerConfiguration.new
12
+ @working_directory = '.'
12
13
  end
13
14
 
14
15
  def queue_configurations
@@ -41,6 +42,10 @@ module Arsenicum
41
42
  @pidfile_path = path
42
43
  end
43
44
 
45
+ def directory(path)
46
+ @working_directory = path
47
+ end
48
+
44
49
  class InstanceConfiguration
45
50
  include Arsenicum::Util
46
51
 
@@ -197,5 +202,7 @@ module Arsenicum
197
202
  end
198
203
  end
199
204
  end
205
+
206
+ autoload :RailsConfiguration, 'arsenicum/configuration/rails_configuration'
200
207
  end
201
208
  end
@@ -0,0 +1,8 @@
1
+ class Arsenicum::Main::RailsMain < Arsenicum::Main
2
+ def before_boot(config)
3
+ env = config.rails_env || 'development'
4
+ ENV['RAILS_ENV'] = env
5
+
6
+ require './config/environment'
7
+ end
8
+ end
@@ -1,14 +1,8 @@
1
1
  module Arsenicum
2
- module Main
3
- def run(config_file)
2
+ class Main
3
+ def run(config)
4
4
  $0 = 'arsenicum[main]'
5
5
 
6
- config = Arsenicum::Configuration.new
7
- config_file = File.expand_path config_file
8
-
9
- script = File.read config_file
10
- config.instance_eval script, config_file, 1
11
-
12
6
  if config.daemon
13
7
  Process.daemon true, true
14
8
 
@@ -17,9 +11,13 @@ module Arsenicum
17
11
  end
18
12
  end
19
13
 
14
+ Dir.chdir config.working_directory
15
+
20
16
  configure_io config
21
17
  configure_log config
22
18
 
19
+ before_boot(config)
20
+
23
21
  threads = config.queue_configurations.map{|qc|qc.build.start_async}
24
22
  begin
25
23
  threads.each(&:join)
@@ -40,10 +38,12 @@ module Arsenicum
40
38
  end
41
39
  end
42
40
 
41
+ def before_boot(config);end
42
+
43
43
  def configure_log(config)
44
44
  Arsenicum::Logger.configure config.logger_config
45
45
  end
46
46
 
47
- module_function :run, :configure_io, :configure_log
47
+ autoload :RailsMain, 'arsenicum/main/rails_main'
48
48
  end
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module Arsenicum
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2'
3
3
  end
data/lib/arsenicum.rb CHANGED
@@ -12,16 +12,5 @@ module Arsenicum
12
12
  autoload :Task, 'arsenicum/task'
13
13
  autoload :Routing, 'arsenicum/routing'
14
14
  autoload :Logger, 'arsenicum/logger'
15
-
16
- class << self
17
- def configure(arg = nil, &block)
18
- Arsenicum::Configuration.configure arg, &block
19
- end
20
-
21
- def configuration
22
- Configuration.instance
23
- end
24
-
25
- alias_method :config, :configuration
26
- end
15
+ autoload :CLI, 'arsenicum/cli'
27
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arsenicum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - condor
@@ -141,7 +141,10 @@ files:
141
141
  - bin/arsenicum_rails
142
142
  - lib/arsenicum-rails.rb
143
143
  - lib/arsenicum.rb
144
+ - lib/arsenicum/cli.rb
145
+ - lib/arsenicum/cli/rails_cli.rb
144
146
  - lib/arsenicum/configuration.rb
147
+ - lib/arsenicum/configuration/rails_configuration.rb
145
148
  - lib/arsenicum/core.rb
146
149
  - lib/arsenicum/core/broker.rb
147
150
  - lib/arsenicum/core/commands.rb
@@ -151,6 +154,7 @@ files:
151
154
  - lib/arsenicum/io.rb
152
155
  - lib/arsenicum/logger.rb
153
156
  - lib/arsenicum/main.rb
157
+ - lib/arsenicum/main/rails_main.rb
154
158
  - lib/arsenicum/queue.rb
155
159
  - lib/arsenicum/queue/sqs.rb
156
160
  - lib/arsenicum/routing.rb