nofly 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 45c77aaaedc7144df4fc83360f17fb543a4e5352
4
+ data.tar.gz: f8125516b5ae19d4b9c7dee2a142f50998b094eb
5
+ SHA512:
6
+ metadata.gz: 0b6361cdfac00400e129b9ac675323e2251200af86de8acb50917980e6ba3fc3942a9183df7c1bb36d01fd9cfbe683193a00a16047e305ca4393321acdf755ee
7
+ data.tar.gz: 31693f417b7bf8cb04cc27189910243414ec749f7d466f69b6b386e2918b7eda60e1d9880105d2ec24d2c18930f6c044666c86aaf9203703e335dc8a786c2860
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Josh Dean
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = Nofly
2
+
3
+ == What is it?
4
+
5
+ Nofly wraps communications about a particular event on an object in a managable and scalable structure.
6
+
7
+ == Tell me more!
8
+
9
+ When we send communications to users it is usually in response to an event. Users often have their own communications preferences (when/how/what).
10
+
11
+ This logic can easily become complicated and so I developed Nofly to abstract it and let the core application only worry about knowing what event happened to which object/record.
12
+
13
+ == Is using Nofly a good experience?
14
+
15
+ I want it to be! Basically, in your controller (or maybe an observer or wherever you think is best) we do something like <i>Nofly.for( @sandwich ).eat</i> and then we create *notify_for_sandwich.cs* which has a function *eat* in which we do all our notification logic - i.e. check user preferences and send emails, in-app notifications, push notifications, etc.
16
+
17
+ == Installation
18
+
19
+ Add an autoload path for the directory you'll keep your nofly <i> config.autoload_paths += Dir["#{config.root}/app/nofly"] </i> to *application.rb*
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Nofly'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ Bundler::GemHelper.install_tasks
20
+
21
+ require 'rake/testtask'
22
+
23
+ Rake::TestTask.new(:test) do |t|
24
+ t.libs << 'lib'
25
+ t.libs << 'test'
26
+ t.pattern = 'test/**/*_test.rb'
27
+ t.verbose = false
28
+ end
29
+
30
+
31
+ require "bundler/gem_tasks"
32
+ require "rspec/core/rake_task"
33
+
34
+ RSpec::Core::RakeTask.new
35
+
36
+ task :default => :spec
37
+ task :test => :spec
data/lib/nofly.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Nofly
2
+ require 'nofly/event_library'
3
+ def self.for(obj, options = {})
4
+ begin
5
+ Nofly.const_get("#{obj.class.to_s}Nofly").new(obj, options)
6
+ rescue
7
+ raise "Cannot nofly that. Have you forgotten to create a nofly event library for '#{obj.class.to_s}?'"
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,22 @@
1
+ module Nofly
2
+ class EventLibrary
3
+ def initialize(obj, options)
4
+ @obj = obj
5
+ @options = options
6
+ end
7
+
8
+ private
9
+
10
+ def method_missing(method, *args, &block)
11
+ # enables 'foo' to return @obj if it is an instance of the Foo class
12
+ return @obj if @obj.class.to_s.downcase.to_sym == method
13
+
14
+ # access options' keys as if they were local variables
15
+ if @options[method] || @options[method.to_sym]
16
+ return @options[method] || @options[method.to_sym]
17
+ end
18
+
19
+ super
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Nofly
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :nofly do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nofly do
4
+
5
+ it "should raise an exception if the nofly event library for that class cannot be found" do
6
+ expect { Nofly.for(Object.new) }.to raise_error
7
+ end
8
+
9
+ it "should return a nofly event library if that class can be found" do
10
+ expect( Nofly.for(Foo.new) ).to be_a_kind_of Nofly::EventLibrary
11
+ end
12
+ end
data/spec/nofly/foo.rb ADDED
@@ -0,0 +1,3 @@
1
+ class Foo
2
+
3
+ end
@@ -0,0 +1,12 @@
1
+ class FooNofly < Nofly::EventLibrary
2
+
3
+ # example of a nofly class
4
+
5
+ def created
6
+ # here is where we send out our notifications about the creation of a foo
7
+ # mailer
8
+ # in-app notification
9
+ # push notification
10
+ end
11
+
12
+ end
@@ -0,0 +1,2 @@
1
+ Dir["nofly/*.rb"].each {|file| require file }
2
+ require 'nofly'
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nofly
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Dean
8
+ - Chalkle.com
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-05-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: When we send communications to users it is usually in response to an
57
+ event. Users often have their own communications preferences (when/how/what). This
58
+ logic can easily become complicated and so I developed Nofly to abstract it and
59
+ let the core application only worry about knowing what event happened to which object/record.
60
+ email:
61
+ - jdbdean@gmail.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - MIT-LICENSE
67
+ - README.rdoc
68
+ - Rakefile
69
+ - lib/nofly.rb
70
+ - lib/nofly/event_library.rb
71
+ - lib/nofly/version.rb
72
+ - lib/tasks/nofly_tasks.rake
73
+ - spec/lib/nofly_spec.rb
74
+ - spec/nofly/foo.rb
75
+ - spec/nofly/foo_nofly.rb
76
+ - spec/spec_helper.rb
77
+ homepage: https://github.com/Jdbdean/nofly
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.2.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Nofly - don't write notifications on the fly. Nofly wraps communications
101
+ about a particular event on an object so you can write managable code.
102
+ test_files:
103
+ - spec/lib/nofly_spec.rb
104
+ - spec/nofly/foo.rb
105
+ - spec/nofly/foo_nofly.rb
106
+ - spec/spec_helper.rb