devise_subscriber 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/TODO +1 -0
- data/devise_subscriber.gemspec +23 -0
- data/lib/devise_subscriber.rb +13 -0
- data/lib/devise_subscriber/model.rb +54 -0
- data/lib/devise_subscriber/rails.rb +6 -0
- data/lib/devise_subscriber/version.rb +3 -0
- data/lib/generators/devise_subscriber/USAGE +8 -0
- data/lib/generators/devise_subscriber/devise_subscriber_generator.rb +82 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebb9cdeb48bb21af82fc9e8155e995f5068b3a36
|
4
|
+
data.tar.gz: 138e3b5d4b1c805509806bbb3fb13bf2e880c97b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bcb702890d1ea588280b6376fc574c3ed4968c39454238f5353e09184699af33cad559d14bcb74e187d827cfbf94b8b6382ac25ba1b468e659a12034cee6f58c
|
7
|
+
data.tar.gz: 67fcf5e8d6b08c2c6f3b8f40e36e79406c5d8d52736ad6292f3d5595bfeb3104761caf137c7f041df08313b8bbf65309f0626156db11b77cb4a48bbf4184b70c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Rahul P. Chaudhari
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# DeviseSubscriber
|
2
|
+
|
3
|
+
Devise hook for adding users into subscriber list of newsletter.
|
4
|
+
|
5
|
+
## NOTE
|
6
|
+
|
7
|
+
This gem is in WIP and big TODO list
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'devise_subscriber'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install devise_subscriber
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Work in progress
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'devise_subscriber/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "devise_subscriber"
|
8
|
+
spec.version = DeviseSubscriber::VERSION
|
9
|
+
spec.authors = ["Rahul P. Chaudhari"]
|
10
|
+
spec.email = ["rahul100885@gmail.com"]
|
11
|
+
spec.description = %q{Devise extension for newsletter subscribers}
|
12
|
+
spec.summary = %q{Simple devise extension for newsletter subscription}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Devise
|
2
|
+
module Models
|
3
|
+
module Subscriber
|
4
|
+
# Method will come here
|
5
|
+
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
#after_create :add_into_subscriber
|
10
|
+
after_save :process_subscription
|
11
|
+
|
12
|
+
has_one :subscriber, as: :subscrible
|
13
|
+
|
14
|
+
attr_accessor :subscribe_value
|
15
|
+
end
|
16
|
+
|
17
|
+
def subscribe
|
18
|
+
if self.subscribe_value.nil?
|
19
|
+
self.subscriber.subscribe if self.subscriber
|
20
|
+
else
|
21
|
+
self.subscribe_value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def subscribe=(value)
|
26
|
+
self.subscribe_value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_subscription
|
30
|
+
if self.subscribe_value
|
31
|
+
self.subscribe!
|
32
|
+
else
|
33
|
+
self.unsubscribe!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def subscribe!
|
38
|
+
self.set_subscription(true)
|
39
|
+
end
|
40
|
+
|
41
|
+
def unsubscribe!
|
42
|
+
self.set_subscription(false)
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_subscription value
|
46
|
+
if self.subscriber
|
47
|
+
self.subscriber.update_attributes({subscribe: value, email: self.email})
|
48
|
+
else
|
49
|
+
self.create_subscriber({subscribe: value, email: self.email })
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
class DeviseSubscriberGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
|
6
|
+
desc "Generate subscriber model with devise"
|
7
|
+
|
8
|
+
def create_model_file
|
9
|
+
if model_exists?
|
10
|
+
say "Model already exists"
|
11
|
+
else
|
12
|
+
generate "model", "subscriber subscrible:references{polymorphic} email:string subscribe:boolean"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# def run_other_generators
|
17
|
+
# if model_exists?
|
18
|
+
# say "Model already exists"
|
19
|
+
# else
|
20
|
+
# invoke "model", "subscriber subscrible:references{polymorphic} email:string subscribe:boolean"
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
protected
|
25
|
+
def model_exists?
|
26
|
+
File.exists?(File.join(destination_root, model_path))
|
27
|
+
end
|
28
|
+
|
29
|
+
def model_path
|
30
|
+
@model_path ||= File.join("app", "models", "subscriber.rb")
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# def self.source_root
|
35
|
+
# @_devise_source_root ||= File.expand_path("../templates", __FILE__)
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# def self.orm_has_migration?
|
39
|
+
# Rails::Generators.options[:rails][:orm] == :active_record
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# def self.next_migration_number(dirname)
|
43
|
+
# if ActiveRecord::Base.timestamped_migrations
|
44
|
+
# Time.now.utc.strftime("%Y%m%d%H%M%S")
|
45
|
+
# else
|
46
|
+
# "%.3d" % (current_migration_number(dirname) + 1)
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# class_option :orm
|
51
|
+
# class_option :migration, :type => :boolean, :default => orm_has_migration?
|
52
|
+
#
|
53
|
+
# def invoke_orm_model
|
54
|
+
# if model_exists?
|
55
|
+
# say "* Model already exists."
|
56
|
+
# elsif options[:orm].present?
|
57
|
+
# invoke "model", ["Subscriber"], :migration => false, :orm => options[:orm]
|
58
|
+
#
|
59
|
+
# unless model_exists?
|
60
|
+
# abort "Tried to invoke the model generator for '#{options[:orm]}' but could not find it.\n" <<
|
61
|
+
# "Please create your model by hand before calling `rails g devise_subscriber`."
|
62
|
+
# end
|
63
|
+
# else
|
64
|
+
# abort "Cannot create a devise model because config.generators.orm is blank.\n" <<
|
65
|
+
# "Please create your model by hand or configure your generators orm before calling `rails g devise_subscriber`."
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# def create_migration_file
|
70
|
+
# migration_template 'migration.rb', "db/migrate/create_devise_subscriber.rb"
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# protected
|
74
|
+
#
|
75
|
+
# def model_exists?
|
76
|
+
# File.exists?(File.join(destination_root, model_path))
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
# def model_path
|
80
|
+
# @model_path ||= File.join("app", "models", "#{file_path}.rb")
|
81
|
+
# end
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_subscriber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rahul P. Chaudhari
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Devise extension for newsletter subscribers
|
42
|
+
email:
|
43
|
+
- rahul100885@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- TODO
|
54
|
+
- devise_subscriber.gemspec
|
55
|
+
- lib/devise_subscriber.rb
|
56
|
+
- lib/devise_subscriber/model.rb
|
57
|
+
- lib/devise_subscriber/rails.rb
|
58
|
+
- lib/devise_subscriber/version.rb
|
59
|
+
- lib/generators/devise_subscriber/USAGE
|
60
|
+
- lib/generators/devise_subscriber/devise_subscriber_generator.rb
|
61
|
+
homepage: ''
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>'
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.3.1
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.3
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Simple devise extension for newsletter subscription
|
85
|
+
test_files: []
|