nezu 0.7.2 → 0.8.0

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: 3ac75044557f02b4b54a04c3ad4d074b7d86c1cd
4
- data.tar.gz: 7db33c6544789096b0038ae9f03767cd52548641
3
+ metadata.gz: d98336e57c79a4eb2e7be4d6a93745250a518032
4
+ data.tar.gz: 7a0fff0ba1aa12e30e8e985f2a0d0b9b7b75df43
5
5
  SHA512:
6
- metadata.gz: 73bf7bdebfe716378ae42717ded8305efec61dc614131369686225e510dd152c73c1f425c8a3a371fbd6b0950dff05e786363053eb425d3ad23fc7ff4e3db954
7
- data.tar.gz: 77600514d23d02dac3eb6fa2044b69dfca3650f1141d1ca12520e31e903bbb12ac188c2c4720dde315d0b733c1e78190ccafa4737e4a1ea28b0e5223cd2b7384
6
+ metadata.gz: 51585cd03c24893d086c8497cc798ad2a4bb67e159485c39bb1c2e9109c6542e84dc0521560b716fadc660fa06be4d13bec8cf71eaad509ec65ca87c35ea3978
7
+ data.tar.gz: 1f8d1782cd621046137d7b8d2bc4a1d2215f6d24671e2c84872ee230ab2717a5667c5ca9c0433724581d9bdd14579e44e0c1f457a96edb9bc1a339a155cec5a1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nezu (0.7.1)
4
+ nezu (0.7.2)
5
5
  activerecord
6
6
  activesupport
7
7
  amqp
@@ -13,71 +13,65 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activemodel (4.0.0)
17
- activesupport (= 4.0.0)
16
+ activemodel (4.0.2)
17
+ activesupport (= 4.0.2)
18
18
  builder (~> 3.1.0)
19
- activerecord (4.0.0)
20
- activemodel (= 4.0.0)
19
+ activerecord (4.0.2)
20
+ activemodel (= 4.0.2)
21
21
  activerecord-deprecated_finders (~> 1.0.2)
22
- activesupport (= 4.0.0)
22
+ activesupport (= 4.0.2)
23
23
  arel (~> 4.0.0)
24
24
  activerecord-deprecated_finders (1.0.3)
25
- activesupport (4.0.0)
25
+ activesupport (4.0.2)
26
26
  i18n (~> 0.6, >= 0.6.4)
27
27
  minitest (~> 4.2)
28
28
  multi_json (~> 1.3)
29
29
  thread_safe (~> 0.1)
30
30
  tzinfo (~> 0.3.37)
31
- amq-client (1.0.2)
32
- amq-protocol (>= 1.2.0)
31
+ amq-protocol (1.9.2)
32
+ amqp (1.3.0)
33
+ amq-protocol (>= 1.9.2)
33
34
  eventmachine
34
- amq-protocol (1.7.0)
35
- amqp (1.0.2)
36
- amq-client (~> 1.0.2)
37
- amq-protocol (>= 1.3.0)
38
- eventmachine
39
- arel (4.0.0)
40
- atomic (1.1.12)
35
+ arel (4.0.2)
36
+ atomic (1.1.14)
41
37
  builder (3.1.4)
42
- bunny (0.10.2)
43
- amq-protocol (>= 1.6.0)
38
+ bunny (1.1.2)
39
+ amq-protocol (>= 1.9.2)
44
40
  columnize (0.3.6)
45
- configatron (2.13.0)
46
- yamler (>= 0.1.0)
47
- debugger (1.6.1)
41
+ configatron (3.0.1)
42
+ debugger (1.6.5)
48
43
  columnize (>= 0.3.1)
49
44
  debugger-linecache (~> 1.2.0)
50
- debugger-ruby_core_source (~> 1.2.3)
45
+ debugger-ruby_core_source (~> 1.3.1)
51
46
  debugger-linecache (1.2.0)
52
- debugger-ruby_core_source (1.2.3)
53
- diff-lcs (1.2.4)
47
+ debugger-ruby_core_source (1.3.1)
48
+ diff-lcs (1.2.5)
54
49
  eventmachine (1.0.3)
55
- i18n (0.6.4)
56
- json (1.8.0)
50
+ i18n (0.6.9)
51
+ json (1.8.1)
57
52
  minitest (4.7.5)
58
- multi_json (1.7.9)
59
- mysql2 (0.3.13)
60
- rake (10.1.0)
61
- rdoc (3.12.2)
53
+ multi_json (1.8.4)
54
+ mysql2 (0.3.15)
55
+ rake (10.1.1)
56
+ rdoc (4.1.1)
62
57
  json (~> 1.4)
63
58
  rspec (2.14.1)
64
59
  rspec-core (~> 2.14.0)
65
60
  rspec-expectations (~> 2.14.0)
66
61
  rspec-mocks (~> 2.14.0)
67
- rspec-core (2.14.4)
68
- rspec-expectations (2.14.1)
62
+ rspec-core (2.14.7)
63
+ rspec-expectations (2.14.5)
69
64
  diff-lcs (>= 1.1.3, < 2.0)
70
- rspec-mocks (2.14.3)
71
- sdoc (0.3.20)
72
- json (>= 1.1.3)
73
- rdoc (~> 3.10)
74
- term-ansicolor (1.2.2)
75
- tins (~> 0.8)
76
- thread_safe (0.1.2)
65
+ rspec-mocks (2.14.5)
66
+ sdoc (0.4.0)
67
+ json (~> 1.8)
68
+ rdoc (~> 4.0, < 5.0)
69
+ term-ansicolor (1.3.0)
70
+ tins (~> 1.0)
71
+ thread_safe (0.1.3)
77
72
  atomic
78
- tins (0.8.3)
79
- tzinfo (0.3.37)
80
- yamler (0.1.0)
73
+ tins (1.0.0)
74
+ tzinfo (0.3.38)
81
75
 
82
76
  PLATFORMS
83
77
  ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.8.0
@@ -5,22 +5,22 @@ module Nezu
5
5
  include Nezu::Generators
6
6
 
7
7
  def initialize(destination_root)
8
- configatron.destination_root = destination_root
9
- configatron.app_name = File.basename(destination_root)
10
- name_space = configatron.app_name.split(/_/).map(&:capitalize).join('').to_sym
11
- configatron.name_space = Object.const_set(name_space, Module.new) unless Object.const_defined?(name_space)
8
+ Nezu::Config.destination_root = destination_root
9
+ Nezu::Config.app_name = File.basename(destination_root)
10
+ name_space = Nezu::Config.app_name.split(/_/).map(&:capitalize).join('').to_sym
11
+ Nezu::Config.name_space = Object.const_set(name_space, Module.new) unless Object.const_defined?(name_space)
12
12
  end
13
13
 
14
14
  def generate!
15
- raise Nezu::Generators::Application::AppGeneratorError, "\"#{configatron.destination_root}\" already exists" if Dir.exist?(configatron.destination_root)
16
- FileUtils.mkdir_p(configatron.destination_root)
15
+ raise Nezu::Generators::Application::AppGeneratorError, "\"#{Nezu::Config.destination_root}\" already exists" if Dir.exist?(Nezu::Config.destination_root)
16
+ FileUtils.mkdir_p(Nezu::Config.destination_root)
17
17
  generate_files_from_manifest!
18
18
  rename_app_name_template
19
19
  end
20
20
 
21
21
  def rename_app_name_template
22
- File.rename(File.join(configatron.destination_root,'app/consumers/$app_name.rb'),
23
- File.join(configatron.destination_root,"app/consumers/#{configatron.app_name}.rb"))
22
+ File.rename(File.join(Nezu::Config.destination_root,'app/consumers/$app_name.rb'),
23
+ File.join(Nezu::Config.destination_root,"app/consumers/#{Nezu::Config.app_name}.rb"))
24
24
  end
25
25
 
26
26
  def generate_files_from_manifest! # TODO rewrite so a MANIFEST isn´t needed
@@ -5,19 +5,19 @@ require 'nezu/generators/application/app_generator'
5
5
  module Nezu
6
6
  module Generators
7
7
 
8
- configatron.template_paths = [Nezu.gem_path.join('lib/nezu/generators/application/templates')] + ENV['NEZU_TEMPLATES'].to_s.split(':')
9
- configatron.file_suffixes = %w(tt)
8
+ Nezu::Config.template_paths = [Nezu.gem_path.join('lib/nezu/generators/application/templates')] + ENV['NEZU_TEMPLATES'].to_s.split(':')
9
+ Nezu::Config.file_suffixes = %w(tt)
10
10
 
11
11
  def template_to(filename) # e.g. "config/amqp.yml"
12
- dirname = File.join(configatron.destination_root, File.dirname(filename))
12
+ dirname = File.join(Nezu::Config.destination_root, File.dirname(filename))
13
13
  source_file = find_template(filename)
14
14
  if source_file
15
15
  FileUtils.mkdir_p(dirname)
16
16
 
17
- if configatron.file_suffixes.include?(source_file.split('.')[-1])
17
+ if Nezu::Config.file_suffixes.include?(source_file.split('.')[-1])
18
18
  e = ERB.new(File.read(source_file))
19
- File.open(File.join(configatron.destination_root, filename.sub(/\.tt$/,'')), File::CREAT|File::TRUNC|File::WRONLY) do |f|
20
- f.write(e.result(configatron.binding))
19
+ File.open(File.join(Nezu::Config.destination_root, filename.sub(/\.tt$/,'')), File::CREAT|File::TRUNC|File::WRONLY) do |f|
20
+ f.write(e.result(Nezu::Config.binding))
21
21
  end
22
22
  else
23
23
  FileUtils.cp(source_file, dirname)
@@ -28,9 +28,9 @@ module Nezu
28
28
  private
29
29
 
30
30
  def find_template(filename)
31
- candidates = configatron.template_paths.map do |path|
31
+ candidates = Nezu::Config.template_paths.map do |path|
32
32
  [File.join(path, filename)] +
33
- configatron.file_suffixes.map do |suffix|
33
+ Nezu::Config.file_suffixes.map do |suffix|
34
34
  File.join(path, filename) + '.' + suffix
35
35
  end
36
36
  end.flatten
data/lib/nezu/runner.rb CHANGED
@@ -10,8 +10,8 @@ module Nezu
10
10
  # this is the starting point for every application running with "$> nezu run"
11
11
  # it get called from cli.rb
12
12
  def self.start
13
- AMQP.start(configatron.amqp.send(Nezu.env.to_sym).url) do |connection, open_ok|
14
- Nezu.logger.debug("[Nezu Runner] AMQP connection #{configatron.amqp.send(Nezu.env.to_sym).url}")
13
+ AMQP.start(Nezu::Config.amqp.send(Nezu.env.to_sym).url) do |connection, open_ok|
14
+ Nezu.logger.debug("[Nezu Runner] AMQP connection #{Nezu::Config.amqp.send(Nezu.env.to_sym).url}")
15
15
  channel = AMQP::Channel.new(connection, :auto_recovery => true)
16
16
  Nezu.logger.debug("[Nezu Runner] AMQP channel #{channel}")
17
17
  Nezu::Runtime::Consumer.descendants.each do |consumer|
@@ -9,6 +9,7 @@ module Nezu
9
9
  action = params.delete('__action')
10
10
 
11
11
  result = self.send(action.to_sym, params)
12
+ #debugger
12
13
  reply_to = result[:end] == 'true' ? nil : params['__reply_to']
13
14
 
14
15
  if reply_to
@@ -4,7 +4,7 @@ module Nezu
4
4
  extend Nezu::Runtime::Common
5
5
 
6
6
  def self.push!(params = {})
7
- connection = Bunny.new(configatron.amqp.send(Nezu.env.to_sym).url, :threaded => false)
7
+ connection = Bunny.new(Nezu::Config.amqp[Nezu.env.to_sym].url, :threaded => false)
8
8
  connection.start
9
9
  channel = connection.create_channel
10
10
  queue ||= channel.queue(queue_name)
@@ -8,7 +8,7 @@ module Nezu
8
8
 
9
9
  class RecipientError < RuntimeError
10
10
  def self.does_not_exist(q)
11
- klass = q.sub(/^#{configatron.amqp.development.queue_prefix}./, '').sub(/.#{configatron.amqp.development.queue_postfix}$/,'').classify
11
+ klass = q.sub(/^#{Nezu::Config.amqp.development.queue_prefix}./, '').sub(/.#{Nezu::Config.amqp.development.queue_postfix}$/,'').classify
12
12
  message = %Q(
13
13
  The class "#{klass}" doesn`t exist or is not a child of "Nezu::Runtime::Producer".
14
14
  Please create one in \"app/producers/#{klass.underscore}.rb\" with the content of at least:
data/lib/nezu/runtime.rb CHANGED
@@ -11,12 +11,12 @@ module Nezu
11
11
  begin
12
12
  configure_from_yaml('amqp.yml')
13
13
  rescue
14
- Nezu.logger.fatal("[Nezu Runner] no amqp config please create one in config/amqp.yml") unless configatron.amqp.present?
14
+ Nezu.logger.fatal("[Nezu Runner] no amqp config please create one in config/amqp.yml") unless Nezu::Config.amqp.present?
15
15
  raise
16
16
  end
17
- if configatron.database.send(Nezu.env).database.present? && !Class.const_defined?(:Rails)
18
- require configatron.database.send(Nezu.env).adapter
19
- ActiveRecord::Base.establish_connection(configatron.database.send(Nezu.env.to_sym).to_hash)
17
+ if Nezu::Config.database.send(Nezu.env).database.present? && !Class.const_defined?(:Rails)
18
+ require Nezu::Config.database.send(Nezu.env).adapter
19
+ ActiveRecord::Base.establish_connection(Nezu::Config.database.send(Nezu.env.to_sym).to_hash)
20
20
  ActiveRecord::Base.logger = Logger.new(Nezu.root.join('log/', 'database.log'))
21
21
  end
22
22
 
@@ -38,7 +38,7 @@ module Nezu
38
38
  end
39
39
 
40
40
  Nezu.logger.debug("[Nezu Runner] config loaded")
41
- Nezu.logger.debug(configatron.amqp)
41
+ Nezu.logger.debug(Nezu::Config.amqp)
42
42
  end
43
43
 
44
44
  module Common
@@ -59,10 +59,11 @@ module Nezu
59
59
  #
60
60
  def inherited(subclass)
61
61
  subclass.class_eval {cattr_accessor :queue_name} #:exchange_name?
62
+ #debugger
62
63
  subclass.queue_name = ''
63
- subclass.queue_name << "#{configatron.amqp.send(Nezu.env.to_sym).queue_prefix}." unless configatron.amqp.send(Nezu.env.to_sym).queue_prefix.nil?
64
+ subclass.queue_name << "#{Nezu::Config.amqp[Nezu.env.to_sym].queue_prefix}." unless Nezu::Config.amqp[Nezu.env.to_sym].queue_prefix.nil?
64
65
  subclass.queue_name << subclass.to_s.gsub(/^(Producers|Consumers)::/, '').gsub(/::/, '.').underscore
65
- subclass.queue_name << ".#{configatron.amqp.send(Nezu.env.to_sym).queue_postfix}" unless configatron.amqp.send(Nezu.env.to_sym).queue_postfix.nil?
66
+ subclass.queue_name << ".#{Nezu::Config.amqp[Nezu.env.to_sym].queue_postfix}" unless Nezu::Config.amqp[Nezu.env.to_sym].queue_postfix.nil?
66
67
  subclass.queue_name
67
68
  end
68
69
 
@@ -77,7 +78,7 @@ module Nezu
77
78
  config_file = Nezu.root.join('config', yaml_file)
78
79
  if File.exist?(config_file)
79
80
  yaml = YAML.load_file(config_file)
80
- configatron.configure_from_hash(File.basename(yaml_file.sub(/.yml/, '')) => yaml)
81
+ Nezu::Config.configure_from_hash(File.basename(yaml_file.sub(/.yml/, '')) => yaml)
81
82
  else
82
83
  Nezu.logger.info("#{config_file} doesn`t exist. I`m skipping it")
83
84
  end
data/lib/nezu.rb CHANGED
@@ -8,8 +8,14 @@ require 'configatron'
8
8
  require 'term/ansicolor'
9
9
  require 'nezu/runtime'
10
10
 
11
+ # Just an empty Module to give consumers a home
12
+ module Consumers;end
13
+ # Just an empty Module to give producers a home
14
+ module Producers;end
15
+
11
16
  module Nezu
12
17
  mattr_accessor :logger, :app, :env, :root, :gem_path
18
+ Config = configatron
13
19
 
14
20
  #used by Nezu.env and Nezu.env.developent? etc.
15
21
  class Env < String
@@ -47,7 +53,7 @@ module Nezu
47
53
  self.env = Env.new(ENV['NEZU_ENV']||'development')
48
54
 
49
55
  # Returns the app as a class
50
- self.app = configatron.app_name.classify
56
+ self.app = Nezu::Config.app_name.classify
51
57
 
52
58
  # Returns a String like object with the applications absolute root
53
59
  self.root = Root::APP_PATH
@@ -9,15 +9,15 @@ describe Nezu::Generators::Application::AppGenerator do
9
9
  end
10
10
 
11
11
  it 'should have a destination_root' do
12
- configatron.destination_root.should == '/blah/foo'
12
+ Nezu::Config.destination_root.should == '/blah/foo'
13
13
  end
14
14
 
15
15
  it 'should have an app_name' do
16
- configatron.app_name.should == 'foo'
16
+ Nezu::Config.app_name.should == 'foo'
17
17
  end
18
18
 
19
19
  it 'should have a scope' do
20
- configatron.name_space.should == Foo
20
+ Nezu::Config.name_space.should == Foo
21
21
  Foo.class.should be_a(Module)
22
22
  end
23
23
  end
@@ -6,16 +6,16 @@ describe Nezu::Generators do
6
6
  describe '#template_to' do
7
7
  it 'should create a (parsed) copy in the app dir' do
8
8
  template_to('test_file')
9
- File.exists?(File.join(configatron.destination_root, '/test_file')).should be_true
9
+ File.exists?(File.join(Nezu::Config.destination_root, '/test_file')).should be_true
10
10
  end
11
11
 
12
12
  it 'should parse .tt files using erb' do
13
13
  template_to('test_file')
14
- File.read(File.join(configatron.destination_root, '/test_file')).match(/Hi there/).should_not be_nil
14
+ File.read(File.join(Nezu::Config.destination_root, '/test_file')).match(/Hi there/).should_not be_nil
15
15
  end
16
16
 
17
17
  after do
18
- %x(rm -rf #{configatron.destination_root})
18
+ %x(rm -rf #{Nezu::Config.destination_root})
19
19
  end
20
20
  end
21
21
 
@@ -2,6 +2,12 @@ require 'spec_helper'
2
2
  require 'nezu/runtime/consumer'
3
3
  describe Nezu::Runtime::Consumer do
4
4
  describe '::descendants' do
5
+ before do
6
+ #Nezu::Config.amqp.test
7
+ #Nezu::Config.amqp.test.queue_prefix=:test
8
+ #Nezu::Config.amqp.test.queue_postfix='test'
9
+ end
10
+
5
11
  it 'should return a list of heirs' do
6
12
  class Consumer1 < Nezu::Runtime::Consumer;end
7
13
  class Consumer2 < Nezu::Runtime::Consumer;end
@@ -12,7 +18,10 @@ describe Nezu::Runtime::Consumer do
12
18
  describe '#handle_message' do
13
19
  before do
14
20
  class Consumer1 < Nezu::Runtime::Consumer;end
15
- Consumer1.any_instance.should_receive(:send).any_number_of_times.and_return({a: 'hash', with: 'no real_value'})
21
+ Consumer1.any_instance.stub(:send) do |action, params|
22
+ params ||= {}
23
+ params.merge({__action: action})
24
+ end
16
25
  @consumer = Consumer1.new
17
26
  end
18
27
 
@@ -30,17 +39,17 @@ describe Nezu::Runtime::Consumer do
30
39
  end
31
40
 
32
41
  it 'should use the queue_prefix if its set' do
33
- configatron.amqp.send(Nezu.env.to_sym).queue_prefix = 'the_prefix'
42
+ Nezu::Config.amqp[Nezu.env.to_sym].queue_prefix = 'the_prefix'
34
43
  module JustAModule;class ConsumerWithPrefix<Nezu::Runtime::Consumer;end;end
35
44
  JustAModule::ConsumerWithPrefix.queue_name.should == 'the_prefix.just_a_module.consumer_with_prefix'
36
- configatron.amqp.send(Nezu.env.to_sym).queue_prefix = nil
45
+ Nezu::Config.amqp[Nezu.env.to_sym].queue_prefix = nil
37
46
  end
38
47
 
39
48
  it 'should use the queue_postfix if its set' do
40
- configatron.amqp.send(Nezu.env.to_sym).queue_postfix = 'the_postfix'
49
+ Nezu::Config.amqp[Nezu.env.to_sym].queue_postfix = 'the_postfix'
41
50
  module JustAModule;class ConsumerWithPostfix<Nezu::Runtime::Consumer;end;end
42
51
  JustAModule::ConsumerWithPostfix.queue_name.should == 'just_a_module.consumer_with_postfix.the_postfix'
43
- configatron.amqp.send(Nezu.env.to_sym).queue_postfix = nil
52
+ Nezu::Config.amqp[Nezu.env.to_sym].queue_postfix = nil
44
53
  end
45
54
  end
46
55
 
@@ -2,19 +2,19 @@ require 'spec_helper'
2
2
  require 'nezu/runtime/producer'
3
3
  describe Nezu::Runtime::Producer do
4
4
  before do
5
- #Bunny.stub!(:new).and_return(AlwaysHappy.new)
5
+ #Bunny.stub!(:new) { AlwaysHappy.new }
6
6
  end
7
7
 
8
8
  describe '::push!' do
9
9
  it 'should create a new message on the server' do
10
- configatron.amqp.send(Nezu.env.to_sym).url = 'amqp://127.0.0.1'
11
- Bunny.should_receive(:new).with(configatron.amqp.send(Nezu.env.to_sym).url, :threaded=>false).and_return(AlwaysHappy.new)
10
+ Nezu::Config.amqp[Nezu.env.to_sym].url = 'amqp://127.0.0.1'
11
+ Bunny.should_receive(:new).with(Nezu::Config.amqp[Nezu.env.to_sym].url, :threaded=>false).and_return(AlwaysHappy.new)
12
12
  module ExampleProducers;class MyQueue<Nezu::Runtime::Producer;end;end
13
13
  ExampleProducers::MyQueue.push!(:foo => 'bar')
14
14
  end
15
15
 
16
16
  it 'should close its connection' do
17
- configatron.amqp.send(Nezu.env.to_sym).url = 'amqp://127.0.0.1'
17
+ Nezu::Config.amqp[Nezu.env.to_sym].url = 'amqp://127.0.0.1'
18
18
  Bunny::Session.any_instance.should_receive(:close)
19
19
  module ExampleProducers;class MyQueue<Nezu::Runtime::Producer;end;end
20
20
  ExampleProducers::MyQueue.push!(:foo => 'bar')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nezu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sascha Teske
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-21 00:00:00.000000000 Z
12
+ date: 2014-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amqp