pigeons 0.0.1pre2 → 0.0.1pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Pigeons
2
- VERSION = "0.0.1pre2"
2
+ VERSION = "0.0.1pre3"
3
3
  end
data/tasks/pigeons.rake CHANGED
@@ -18,8 +18,13 @@ namespace :pigeons do
18
18
  p [ 'Pigeons::', 'Rake::Pigeons::Check', 'Completed' ]
19
19
  end
20
20
 
21
+ # Arguments
22
+ # days:: Number of days to run simulation (default: 15)
23
+ # debug:: Should we print extensive debug information?
24
+ # true_send:: If 'yes' will truly deliver letters, otherwise don't send letters. Alt: set send = <action_name> and only that letter will be sent
25
+ # force:: Force simulation to run in production environment
21
26
  desc "Run a simulation by day of Pigeon letters to be sent."
22
- task :flight_test, [ :days, :debug, :force ] => :environment do |t, args|
27
+ task :flight_test, [ :days, :debug, :true_send, :force ] => :environment do |t, args|
23
28
  unless Rails.env.staging? || Rails.env.development? || Rails.env.test? # Note, due to mocks, etc. this is not considered safe to run on any environment besides develpoment and staging
24
29
  unless args[:force].blank?
25
30
  puts "\n\e[0;31m ######################################################################"
@@ -33,13 +38,14 @@ namespace :pigeons do
33
38
  proceed = STDIN.gets[0..0] rescue nil
34
39
  exit unless proceed == 'y' || proceed == 'Y'
35
40
  else
36
- raise "Refusing to run Flight Test on anything but Development and Staging (try rake pigeons:flight_test[days,debug,*force])"
41
+ raise "Refusing to run Flight Test on anything but Development and Staging (try rake pigeons:flight_test[days,debug,*force,send])"
37
42
  end
38
43
  end
39
44
 
40
45
  p [ 'Pigeons::', 'Rake::Pigeons::FlightTest', 'Initiating', args ]
41
46
  days = args[:days] ? args[:days].to_i : 15 # Default to 15 days?
42
47
  debug = args[:debug] || false
48
+ true_send = args[:true_send]
43
49
 
44
50
  # Stub both Time.now and Time.current
45
51
  reality = Time.now
@@ -51,7 +57,12 @@ namespace :pigeons do
51
57
  # TODO: I'd like to be able to do this without degrading the environment with stubs, but that's probably not going to happen
52
58
  time_class = class << ::Time; self; end
53
59
  pigeon_class = class << ::PigeonMailer; self; end
54
- PigeonMailer.action_methods.each { |mailer_action| pigeon_class.send(:define_method, mailer_action) { |*args| return true } }
60
+
61
+ # Allow sending of letters during simulation
62
+
63
+ unless %w(true t yes y 1).include?(true_send)
64
+ PigeonMailer.action_methods.each { |mailer_action| pigeon_class.send(:define_method, mailer_action) { |*args| return true } unless mailer_action == true_send || ActionMailer::Base.action_methods.include?(mailer_action) || mailer_action =~ /.*[_]callbacks[=?]?$/ } # action_methods shouldn't return mailer internals, but it does, so let's skip what's defined in ActionMailer::Base
65
+ end
55
66
 
56
67
  PigeonLetter.transaction do
57
68
  begin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pigeons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1pre2
4
+ version: 0.0.1pre3
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
12
+ date: 2013-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport