paid_up 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +320 -1457
- data/lib/generators/paid_up/install/templates/initializer.rb +19 -19
- data/lib/paid_up/configuration.rb +5 -4
- data/lib/paid_up/feature.rb +90 -0
- data/lib/paid_up.rb +4 -3
- data/paid_up.gemspec +7 -11
- data/spec/dummy/config/environments/development.rb +0 -5
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/environments/test.rb +0 -3
- data/spec/dummy/config/initializers/assets.rb +1 -1
- data/spec/dummy/config/initializers/paid_up.rb +19 -19
- data/spec/models/paid_up/feature_spec.rb +5 -0
- metadata +18 -11
- data/app/models/paid_up/feature.rb +0 -75
- data/bin/rails +0 -19
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/rspec +0 -3
- data/spec/dummy/bin/setup +0 -29
@@ -2,24 +2,24 @@ PaidUp.configure do |config|
|
|
2
2
|
config.anonymous_customer_stripe_id = 'anonymous-customer'
|
3
3
|
config.anonymous_plan_stripe_id = 'anonymous-plan'
|
4
4
|
config.free_plan_stripe_id = 'free-plan'
|
5
|
-
end
|
6
5
|
|
7
|
-
PaidUp
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
)
|
13
|
-
PaidUp
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
PaidUp.add_feature(
|
7
|
+
slug: 'ad_free',
|
8
|
+
title: 'Ad Free',
|
9
|
+
description: 'Are ads removed from the site with this plan?',
|
10
|
+
setting_type: 'boolean'
|
11
|
+
)
|
12
|
+
PaidUp.add_feature(
|
13
|
+
slug: 'groups',
|
14
|
+
title: 'Groups',
|
15
|
+
description: 'How many groups are allowed with this plan?',
|
16
|
+
setting_type: 'table_rows' # Enables table row counting that is enabled by a positive value
|
18
17
|
# for the PaidUp::PlanFeatureSetting.setting associated with this PaidUp::Feature
|
19
|
-
)
|
20
|
-
PaidUp
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
18
|
+
)
|
19
|
+
PaidUp.add_feature(
|
20
|
+
slug: 'doodads',
|
21
|
+
title: 'Doodads',
|
22
|
+
description: 'How many doodads included with this plan?',
|
23
|
+
setting_type: 'rolify_rows'
|
24
|
+
)
|
25
|
+
end
|
@@ -5,18 +5,19 @@ module PaidUp
|
|
5
5
|
end
|
6
6
|
@@configuration = configuration
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def self.configuration
|
10
10
|
@@configuration ||= PaidUp::Configuration.new
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
class Configuration
|
14
|
-
attr_accessor :anonymous_customer_stripe_id, :anonymous_plan_stripe_id, :free_plan_stripe_id
|
15
|
-
|
14
|
+
attr_accessor :anonymous_customer_stripe_id, :anonymous_plan_stripe_id, :free_plan_stripe_id, :features
|
15
|
+
|
16
16
|
def initialize
|
17
17
|
self.anonymous_customer_stripe_id = "TODO"
|
18
18
|
self.anonymous_plan_stripe_id = "TODO"
|
19
19
|
self.free_plan_stripe_id = "TODO"
|
20
|
+
self.features = {}
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module PaidUp
|
2
|
+
|
3
|
+
@@feature_object = {}
|
4
|
+
|
5
|
+
def self.add_feature(params)
|
6
|
+
feature = PaidUp::Feature.new(params)
|
7
|
+
@@feature_object[feature.slug.to_sym] = feature
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.features
|
11
|
+
@@feature_object
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
class Feature
|
16
|
+
include ActiveModel::Model
|
17
|
+
include ActiveModel::AttributeMethods
|
18
|
+
|
19
|
+
attr_accessor :slug, :title, :setting_type, :description
|
20
|
+
|
21
|
+
validates_presence_of :slug, :title, :setting_type
|
22
|
+
validates :setting_type, inclusion: { in: %w(boolean table_rows rolify_rows) }
|
23
|
+
validates_with PaidUp::Validators::TableRows, field: 'setting_type', comparison: 'table_rows', found_in: 'slug'
|
24
|
+
validates_with PaidUp::Validators::RolifyRows, field: 'setting_type', comparison: 'rolify_rows', found_in: 'slug'
|
25
|
+
|
26
|
+
def self.raw
|
27
|
+
PaidUp.features
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
slug
|
32
|
+
end
|
33
|
+
|
34
|
+
def feature_model_name
|
35
|
+
acceptable_setting_types = ['table_rows', 'rolify_rows']
|
36
|
+
unless acceptable_setting_types.include? setting_type
|
37
|
+
raise :no_implicit_conversion_of_type_features.l(type: setting_type)
|
38
|
+
end
|
39
|
+
slug.classify
|
40
|
+
end
|
41
|
+
|
42
|
+
def feature_model
|
43
|
+
feature_model_name.constantize
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.find_by_slug(slug)
|
47
|
+
raw[slug.to_sym]
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.all
|
51
|
+
raw.values
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.find_all(**conditions)
|
55
|
+
collection = []
|
56
|
+
for feature in all
|
57
|
+
qualifies = true
|
58
|
+
conditions.each do |key, value|
|
59
|
+
unless feature.send(key) == value
|
60
|
+
qualifies = false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
if qualifies
|
64
|
+
collection << feature
|
65
|
+
end
|
66
|
+
end
|
67
|
+
collection
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.find(**conditions)
|
71
|
+
find_all(conditions).first
|
72
|
+
end
|
73
|
+
|
74
|
+
# Define on self, since it's a class method
|
75
|
+
def self.method_missing(method_sym, *arguments, &block)
|
76
|
+
# the first argument is a Symbol, so you need to_s it if you want to pattern match
|
77
|
+
if method_sym.to_s =~ /^find_by_(.*)$/
|
78
|
+
self.find($1.to_sym => arguments.first)
|
79
|
+
elsif method_sym.to_s =~ /^find_all_by_(.*)$/
|
80
|
+
self.find_all($1.to_sym => arguments.first)
|
81
|
+
else
|
82
|
+
super
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.respond_to_missing?(method_name, include_private = false)
|
87
|
+
method_name.to_s.start_with?('find_') || super
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/paid_up.rb
CHANGED
@@ -14,7 +14,11 @@ module PaidUp
|
|
14
14
|
require 'cancan'
|
15
15
|
require 'rolify'
|
16
16
|
|
17
|
+
require 'paid_up/validators/table_rows'
|
18
|
+
require 'paid_up/validators/rolify_rows'
|
19
|
+
|
17
20
|
require 'paid_up/configuration'
|
21
|
+
require 'paid_up/feature'
|
18
22
|
require 'paid_up/railtie'
|
19
23
|
require 'paid_up/engine'
|
20
24
|
require 'paid_up/localization'
|
@@ -26,9 +30,6 @@ module PaidUp
|
|
26
30
|
require 'paid_up/mixins/subscriber'
|
27
31
|
require 'paid_up/mixins/paid_for'
|
28
32
|
|
29
|
-
require 'paid_up/validators/table_rows'
|
30
|
-
require 'paid_up/validators/rolify_rows'
|
31
|
-
|
32
33
|
require 'haml-rails'
|
33
34
|
require 'bootstrap_leather'
|
34
35
|
|
data/paid_up.gemspec
CHANGED
@@ -2,19 +2,18 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: paid_up 0.
|
5
|
+
# stub: paid_up 0.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "paid_up"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Karen Lundgren"]
|
14
|
-
s.date = "2015-05-
|
14
|
+
s.date = "2015-05-26"
|
15
15
|
s.description = "Allows a model of your choosing (such as users) to subscribe to a plan, which enables features."
|
16
16
|
s.email = "karen.e.lundgren@gmail.com"
|
17
|
-
s.executables = ["rails"]
|
18
17
|
s.extra_rdoc_files = [
|
19
18
|
"LICENSE.txt",
|
20
19
|
"README.md"
|
@@ -36,7 +35,6 @@ Gem::Specification.new do |s|
|
|
36
35
|
"app/helpers/paid_up/plans_helper.rb",
|
37
36
|
"app/helpers/paid_up/subscriptions_helper.rb",
|
38
37
|
"app/models/paid_up/ability.rb",
|
39
|
-
"app/models/paid_up/feature.rb",
|
40
38
|
"app/models/paid_up/plan.rb",
|
41
39
|
"app/models/paid_up/plan_feature_setting.rb",
|
42
40
|
"app/models/paid_up/unlimited.rb",
|
@@ -55,7 +53,6 @@ Gem::Specification.new do |s|
|
|
55
53
|
"app/views/paid_up/plans/index.html.haml",
|
56
54
|
"app/views/paid_up/subscriptions/index.html.haml",
|
57
55
|
"app/views/paid_up/subscriptions/new.html.haml",
|
58
|
-
"bin/rails",
|
59
56
|
"config/initializers/stripe.rb",
|
60
57
|
"config/locales/en.yml",
|
61
58
|
"config/routes.rb",
|
@@ -74,6 +71,7 @@ Gem::Specification.new do |s|
|
|
74
71
|
"lib/paid_up/engine.rb",
|
75
72
|
"lib/paid_up/extensions/integer.rb",
|
76
73
|
"lib/paid_up/extensions/stripe.rb",
|
74
|
+
"lib/paid_up/feature.rb",
|
77
75
|
"lib/paid_up/localization.rb",
|
78
76
|
"lib/paid_up/mixins/paid_for.rb",
|
79
77
|
"lib/paid_up/mixins/subscriber.rb",
|
@@ -95,11 +93,6 @@ Gem::Specification.new do |s|
|
|
95
93
|
"spec/dummy/app/models/user.rb",
|
96
94
|
"spec/dummy/app/views/layouts/application.html.haml",
|
97
95
|
"spec/dummy/app/views/pages/index.html.haml",
|
98
|
-
"spec/dummy/bin/bundle",
|
99
|
-
"spec/dummy/bin/rails",
|
100
|
-
"spec/dummy/bin/rake",
|
101
|
-
"spec/dummy/bin/rspec",
|
102
|
-
"spec/dummy/bin/setup",
|
103
96
|
"spec/dummy/config.ru",
|
104
97
|
"spec/dummy/config/application.rb",
|
105
98
|
"spec/dummy/config/boot.rb",
|
@@ -199,6 +192,7 @@ Gem::Specification.new do |s|
|
|
199
192
|
s.add_development_dependency(%q<bootstrap-sass>, ["~> 3.3"])
|
200
193
|
s.add_development_dependency(%q<sass-rails>, ["~> 5.0"])
|
201
194
|
s.add_development_dependency(%q<high_voltage>, ["~> 2.3"])
|
195
|
+
s.add_development_dependency(%q<rspec-rails>, ["~> 3.2"])
|
202
196
|
else
|
203
197
|
s.add_dependency(%q<rails>, ["~> 4"])
|
204
198
|
s.add_dependency(%q<rails-i18n>, ["~> 4"])
|
@@ -218,6 +212,7 @@ Gem::Specification.new do |s|
|
|
218
212
|
s.add_dependency(%q<bootstrap-sass>, ["~> 3.3"])
|
219
213
|
s.add_dependency(%q<sass-rails>, ["~> 5.0"])
|
220
214
|
s.add_dependency(%q<high_voltage>, ["~> 2.3"])
|
215
|
+
s.add_dependency(%q<rspec-rails>, ["~> 3.2"])
|
221
216
|
end
|
222
217
|
else
|
223
218
|
s.add_dependency(%q<rails>, ["~> 4"])
|
@@ -238,6 +233,7 @@ Gem::Specification.new do |s|
|
|
238
233
|
s.add_dependency(%q<bootstrap-sass>, ["~> 3.3"])
|
239
234
|
s.add_dependency(%q<sass-rails>, ["~> 5.0"])
|
240
235
|
s.add_dependency(%q<high_voltage>, ["~> 2.3"])
|
236
|
+
s.add_dependency(%q<rspec-rails>, ["~> 3.2"])
|
241
237
|
end
|
242
238
|
end
|
243
239
|
|
@@ -15,8 +15,6 @@ Rails.application.configure do
|
|
15
15
|
|
16
16
|
# Don't care if the mailer can't send.
|
17
17
|
config.action_mailer.raise_delivery_errors = false
|
18
|
-
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
19
|
-
|
20
18
|
|
21
19
|
# Print deprecation notices to the Rails logger.
|
22
20
|
config.active_support.deprecation = :log
|
@@ -40,7 +38,4 @@ Rails.application.configure do
|
|
40
38
|
|
41
39
|
# Raises error for missing translations
|
42
40
|
# config.action_view.raise_on_missing_translations = true
|
43
|
-
|
44
|
-
# We need to serve static files since there's no webserver to do it.
|
45
|
-
config.serve_static_files = true
|
46
41
|
end
|
@@ -29,7 +29,7 @@ Rails.application.configure do
|
|
29
29
|
# config.assets.css_compressor = :sass
|
30
30
|
|
31
31
|
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
32
|
-
config.assets.compile =
|
32
|
+
config.assets.compile = false
|
33
33
|
|
34
34
|
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
35
35
|
# yet still be able to expire them through the digest params.
|
@@ -7,5 +7,5 @@ Rails.application.config.assets.version = '1.0'
|
|
7
7
|
# Rails.application.config.assets.paths << Emoji.images_path
|
8
8
|
|
9
9
|
# Precompile additional assets.
|
10
|
-
# application.js, application.css
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
11
|
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -2,24 +2,24 @@ PaidUp.configure do |config|
|
|
2
2
|
config.anonymous_customer_stripe_id = 'anonymous-customer'
|
3
3
|
config.anonymous_plan_stripe_id = 'anonymous-plan'
|
4
4
|
config.free_plan_stripe_id = 'free-plan'
|
5
|
-
end
|
6
5
|
|
7
|
-
PaidUp
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
)
|
13
|
-
PaidUp
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
PaidUp.add_feature(
|
7
|
+
slug: 'ad_free',
|
8
|
+
title: 'Ad Free',
|
9
|
+
description: 'Are ads removed from the site with this plan?',
|
10
|
+
setting_type: 'boolean'
|
11
|
+
)
|
12
|
+
PaidUp.add_feature(
|
13
|
+
slug: 'groups',
|
14
|
+
title: 'Groups',
|
15
|
+
description: 'How many groups are allowed with this plan?',
|
16
|
+
setting_type: 'rolify_rows' # Enables table row counting that is enabled by a positive value
|
18
17
|
# for the PaidUp::PlanFeatureSetting.setting associated with this PaidUp::Feature
|
19
|
-
)
|
20
|
-
PaidUp
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
18
|
+
)
|
19
|
+
PaidUp.add_feature(
|
20
|
+
slug: 'doodads',
|
21
|
+
title: 'Doodads',
|
22
|
+
description: 'How many doodads included with this plan?',
|
23
|
+
setting_type: 'table_rows'
|
24
|
+
)
|
25
|
+
end
|
@@ -17,6 +17,11 @@ describe PaidUp::Feature do
|
|
17
17
|
it { should eq 'Group' }
|
18
18
|
end
|
19
19
|
|
20
|
+
context '.raw' do
|
21
|
+
subject { PaidUp::Feature.raw }
|
22
|
+
it { should eq( { ad_free: ad_free_feature, groups: groups_feature, doodads: doodads_feature } ) }
|
23
|
+
end
|
24
|
+
|
20
25
|
context '.all' do
|
21
26
|
subject { PaidUp::Feature.all }
|
22
27
|
it { should eq [ad_free_feature, groups_feature, doodads_feature] }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paid_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karen Lundgren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -262,11 +262,24 @@ dependencies:
|
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '2.3'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: rspec-rails
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '3.2'
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '3.2'
|
265
279
|
description: Allows a model of your choosing (such as users) to subscribe to a plan,
|
266
280
|
which enables features.
|
267
281
|
email: karen.e.lundgren@gmail.com
|
268
|
-
executables:
|
269
|
-
- rails
|
282
|
+
executables: []
|
270
283
|
extensions: []
|
271
284
|
extra_rdoc_files:
|
272
285
|
- LICENSE.txt
|
@@ -288,7 +301,6 @@ files:
|
|
288
301
|
- app/helpers/paid_up/plans_helper.rb
|
289
302
|
- app/helpers/paid_up/subscriptions_helper.rb
|
290
303
|
- app/models/paid_up/ability.rb
|
291
|
-
- app/models/paid_up/feature.rb
|
292
304
|
- app/models/paid_up/plan.rb
|
293
305
|
- app/models/paid_up/plan_feature_setting.rb
|
294
306
|
- app/models/paid_up/unlimited.rb
|
@@ -307,7 +319,6 @@ files:
|
|
307
319
|
- app/views/paid_up/plans/index.html.haml
|
308
320
|
- app/views/paid_up/subscriptions/index.html.haml
|
309
321
|
- app/views/paid_up/subscriptions/new.html.haml
|
310
|
-
- bin/rails
|
311
322
|
- config/initializers/stripe.rb
|
312
323
|
- config/locales/en.yml
|
313
324
|
- config/routes.rb
|
@@ -326,6 +337,7 @@ files:
|
|
326
337
|
- lib/paid_up/engine.rb
|
327
338
|
- lib/paid_up/extensions/integer.rb
|
328
339
|
- lib/paid_up/extensions/stripe.rb
|
340
|
+
- lib/paid_up/feature.rb
|
329
341
|
- lib/paid_up/localization.rb
|
330
342
|
- lib/paid_up/mixins/paid_for.rb
|
331
343
|
- lib/paid_up/mixins/subscriber.rb
|
@@ -347,11 +359,6 @@ files:
|
|
347
359
|
- spec/dummy/app/models/user.rb
|
348
360
|
- spec/dummy/app/views/layouts/application.html.haml
|
349
361
|
- spec/dummy/app/views/pages/index.html.haml
|
350
|
-
- spec/dummy/bin/bundle
|
351
|
-
- spec/dummy/bin/rails
|
352
|
-
- spec/dummy/bin/rake
|
353
|
-
- spec/dummy/bin/rspec
|
354
|
-
- spec/dummy/bin/setup
|
355
362
|
- spec/dummy/config.ru
|
356
363
|
- spec/dummy/config/application.rb
|
357
364
|
- spec/dummy/config/boot.rb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
class PaidUp::Feature
|
2
|
-
include ActiveModel::Model
|
3
|
-
include ActiveModel::AttributeMethods
|
4
|
-
|
5
|
-
@@instance_collector = []
|
6
|
-
|
7
|
-
attr_accessor :slug, :title, :setting_type, :description
|
8
|
-
|
9
|
-
validates_presence_of :slug, :title, :setting_type
|
10
|
-
validates :setting_type, inclusion: { in: %w(boolean table_rows rolify_rows) }
|
11
|
-
validates_with PaidUp::Validators::TableRows, field: 'setting_type', comparison: 'table_rows', found_in: 'slug'
|
12
|
-
validates_with PaidUp::Validators::RolifyRows, field: 'setting_type', comparison: 'rolify_rows', found_in: 'slug'
|
13
|
-
|
14
|
-
def initialize(attributes = {})
|
15
|
-
super attributes
|
16
|
-
@@instance_collector << self
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_s
|
20
|
-
slug
|
21
|
-
end
|
22
|
-
|
23
|
-
def feature_model_name
|
24
|
-
acceptable_setting_types = ['table_rows', 'rolify_rows']
|
25
|
-
unless acceptable_setting_types.include? setting_type
|
26
|
-
raise :no_implicit_conversion_of_type_features.l(type: setting_type)
|
27
|
-
end
|
28
|
-
slug.classify
|
29
|
-
end
|
30
|
-
|
31
|
-
def feature_model
|
32
|
-
feature_model_name.constantize
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.all
|
36
|
-
@@instance_collector
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.find_all(**conditions)
|
40
|
-
collection = []
|
41
|
-
for feature in all
|
42
|
-
qualifies = true
|
43
|
-
conditions.each do |key, value|
|
44
|
-
unless feature.send(key) == value
|
45
|
-
qualifies = false
|
46
|
-
end
|
47
|
-
end
|
48
|
-
if qualifies
|
49
|
-
collection << feature
|
50
|
-
end
|
51
|
-
end
|
52
|
-
collection
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.find(**conditions)
|
56
|
-
find_all(conditions).first
|
57
|
-
end
|
58
|
-
|
59
|
-
# Define on self, since it's a class method
|
60
|
-
def self.method_missing(method_sym, *arguments, &block)
|
61
|
-
# the first argument is a Symbol, so you need to_s it if you want to pattern match
|
62
|
-
if method_sym.to_s =~ /^find_by_(.*)$/
|
63
|
-
self.find($1.to_sym => arguments.first)
|
64
|
-
elsif method_sym.to_s =~ /^find_all_by_(.*)$/
|
65
|
-
self.find_all($1.to_sym => arguments.first)
|
66
|
-
else
|
67
|
-
super
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.respond_to_missing?(method_name, include_private = false)
|
72
|
-
method_name.to_s.start_with?('find_') || super
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
data/bin/rails
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
-
|
4
|
-
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
-
ENGINE_PATH = File.expand_path('../../lib/paid_up/engine', __FILE__)
|
6
|
-
|
7
|
-
# Set up gems listed in the Gemfile.
|
8
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
-
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
-
|
11
|
-
# require 'rails/all'
|
12
|
-
|
13
|
-
require "active_record/railtie"
|
14
|
-
require "action_controller/railtie"
|
15
|
-
require "action_mailer/railtie"
|
16
|
-
require "action_view/railtie"
|
17
|
-
require "sprockets/railtie"
|
18
|
-
|
19
|
-
require 'rails/engine/commands'
|
data/spec/dummy/bin/bundle
DELETED
data/spec/dummy/bin/rails
DELETED
data/spec/dummy/bin/rake
DELETED
data/spec/dummy/bin/rspec
DELETED
data/spec/dummy/bin/setup
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
-
|
7
|
-
Dir.chdir APP_ROOT do
|
8
|
-
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file:
|
10
|
-
|
11
|
-
puts "== Installing dependencies =="
|
12
|
-
system "gem install bundler --conservative"
|
13
|
-
system "bundle check || bundle install"
|
14
|
-
|
15
|
-
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?("config/database.yml")
|
17
|
-
# system "cp config/database.yml.sample config/database.yml"
|
18
|
-
# end
|
19
|
-
|
20
|
-
puts "\n== Preparing database =="
|
21
|
-
system "bin/rake db:setup"
|
22
|
-
|
23
|
-
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system "rm -f log/*"
|
25
|
-
system "rm -rf tmp/cache"
|
26
|
-
|
27
|
-
puts "\n== Restarting application server =="
|
28
|
-
system "touch tmp/restart.txt"
|
29
|
-
end
|