bullet_train 1.0.25 → 1.0.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f53e93d30c7a323663e913316ef0d2b705a052ab3f8f075e0ea25bcfb233f8ec
4
- data.tar.gz: 8e33b7ca547682b3cc6b045167ecef56c133c15dd3b2e1996dd660af7871929b
3
+ metadata.gz: 736f0b129992c87c1813769d963aa769e8677b8aa34114e1271358ea6cb315f2
4
+ data.tar.gz: ba9c8955e07d738664793dbfc25adcf66c31d57008e9e3a8e93f1a850c307019
5
5
  SHA512:
6
- metadata.gz: 8a676d76f96eedefab979c6c6dd3b871351133fb799e0b0618748b2738831ab444e814ddfe3634cd19bd408ad844e43901eac091c836156039865e78618bb7b2
7
- data.tar.gz: 9f99942b4e68d2a21468fd557edaf14796482f69b385e5b1115af71eabce415d5968d418bb29525da65fd6d88344665cc06d5b4c2e6de0549bba02e76a6b39a5
6
+ metadata.gz: 19c0375970f7a2f3399f18cf5549c57a6d289bd7cf32f4f858b8aba06656ca37c6561ae9dcd2972691de1db0f41bcbfea0b3c419f2568682d4f4199a7703da8d
7
+ data.tar.gz: 50a5943e0e7c03197d5eb7b4e7c7cfd74011706c1ee8363bd5e6e82c4947fa929ebe7a773eae856385fa78ce9b3c5ffa963cfd08e0ee7ae94ceb98e7288688d1
@@ -0,0 +1,6 @@
1
+ module BaseHelper
2
+ # TODO This is for the billing package to override, but I feel like there has got to be a better way to do this.
3
+ def hide_team_resource_menus?
4
+ false
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.0.25"
2
+ VERSION = "1.0.26"
3
3
  end
data/lib/bullet_train.rb CHANGED
@@ -7,6 +7,9 @@ require "bullet_train/super_load_and_authorize_resource"
7
7
  require "bullet_train/has_uuid"
8
8
  require "bullet_train/scope_validator"
9
9
 
10
+ require "colorizer"
11
+ require "string/emoji"
12
+
10
13
  require "devise"
11
14
  # require "devise-two-factor"
12
15
  # require "rqrcode"
@@ -32,3 +35,86 @@ module BulletTrain
32
35
  mattr_accessor :routing_concerns, default: []
33
36
  mattr_accessor :linked_gems, default: ["bullet_train"]
34
37
  end
38
+
39
+ def default_url_options_from_base_url
40
+ unless ENV["BASE_URL"].present?
41
+ if Rails.env.development?
42
+ ENV["BASE_URL"] ||= "http://localhost:3000"
43
+ else
44
+ raise "you need to define the value of ENV['BASE_URL'] in your environment. if you're on heroku, you can do this with `heroku config:add BASE_URL=https://your-app-name.herokuapp.com` (or whatever your configured domain is)."
45
+ end
46
+ end
47
+
48
+ parsed_base_url = URI.parse(ENV["BASE_URL"])
49
+ default_url_options = [:user, :password, :host, :port].map { |key| [key, parsed_base_url.send(key)] }.to_h
50
+
51
+ # the name of this property doesn't match up.
52
+ default_url_options[:protocol] = parsed_base_url.scheme
53
+
54
+ default_url_options.compact
55
+ end
56
+
57
+ def inbound_email_enabled?
58
+ ENV["INBOUND_EMAIL_DOMAIN"].present?
59
+ end
60
+
61
+ def subscriptions_enabled?
62
+ false
63
+ end
64
+
65
+ def free_trial?
66
+ ENV["STRIPE_FREE_TRIAL_LENGTH"].present?
67
+ end
68
+
69
+ def stripe_enabled?
70
+ ENV["STRIPE_CLIENT_ID"].present?
71
+ end
72
+
73
+ # 🚅 super scaffolding will insert new oauth providers above this line.
74
+
75
+ def webhooks_enabled?
76
+ true
77
+ end
78
+
79
+ def scaffolding_things_disabled?
80
+ ENV["HIDE_THINGS"].present? || ENV["HIDE_EXAMPLES"].present?
81
+ end
82
+
83
+ def sample_role_disabled?
84
+ ENV["HIDE_EXAMPLES"].present?
85
+ end
86
+
87
+ def demo?
88
+ ENV["DEMO"].present?
89
+ end
90
+
91
+ def cloudinary_enabled?
92
+ ENV["CLOUDINARY_URL"].present?
93
+ end
94
+
95
+ def two_factor_authentication_enabled?
96
+ ENV["TWO_FACTOR_ENCRYPTION_KEY"].present?
97
+ end
98
+
99
+ def any_oauth_enabled?
100
+ [
101
+ stripe_enabled?,
102
+ # 🚅 super scaffolding will insert new oauth provider checks above this line.
103
+ ].select(&:present?).any?
104
+ end
105
+
106
+ def invitation_only?
107
+ ENV["INVITATION_KEYS"].present?
108
+ end
109
+
110
+ def invitation_keys
111
+ ENV["INVITATION_KEYS"].split(",").map(&:strip)
112
+ end
113
+
114
+ def font_awesome?
115
+ ENV["FONTAWESOME_NPM_AUTH_TOKEN"].present?
116
+ end
117
+
118
+ def multiple_locales?
119
+ @multiple_locales ||= I18n.available_locales.many?
120
+ end
data/lib/colorizer.rb ADDED
@@ -0,0 +1,67 @@
1
+ # https://makandracards.com/makandra/24449-hash-any-ruby-object-into-an-rgb-color
2
+ module Colorizer
3
+ extend self
4
+
5
+ def colorize(object)
6
+ # Inspired by Jeremy Ruten (http://stackoverflow.com/questions/1698318/ruby-generate-a-random-hex-color)
7
+ hash = object.hash # hash an object, returns a Fixnum
8
+ trimmed_hash = hash & 0xffffff # trim the hash to the size of 6 hex digits (& is bit-wise AND)
9
+ hex_code = "%06x" % trimmed_hash # format as at least 6 hex digits, pad with zeros
10
+ "##{hex_code}"
11
+ end
12
+
13
+ def colorize_similarly(object, saturation, lightness)
14
+ rnd = ((object.hash * 7) % 100) * 0.01
15
+ hsl_to_rgb(rnd, saturation, lightness)
16
+ end
17
+
18
+ private
19
+
20
+ def hsl_to_rgb(h, sl, l)
21
+ r = l
22
+ g = l
23
+ b = l
24
+ v = l <= 0.5 ? (l * (1.0 + sl)) : (l + sl - l * sl)
25
+ if v > 0
26
+ m = l + l - v
27
+ sv = (v - m) / v
28
+ h *= 6.0
29
+ sextant = h.floor
30
+ fract = h - sextant
31
+ vsf = v * sv * fract
32
+ mid1 = m + vsf
33
+ mid2 = v - vsf
34
+ case sextant
35
+ when 0
36
+ r = v
37
+ g = mid1
38
+ b = m
39
+ when 1
40
+ r = mid2
41
+ g = v
42
+ b = m
43
+ when 2
44
+ r = m
45
+ g = v
46
+ b = mid1
47
+ when 3
48
+ r = m
49
+ g = mid2
50
+ b = v
51
+ when 4
52
+ r = mid1
53
+ g = m
54
+ b = v
55
+ when 5
56
+ r = v
57
+ g = m
58
+ b = mid2
59
+ end
60
+ end
61
+ "##{hex_color_component(r)}#{hex_color_component(g)}#{hex_color_component(b)}"
62
+ end
63
+
64
+ def hex_color_component(i)
65
+ (i * 255).floor.to_s(16).rjust(2, "0")
66
+ end
67
+ end
@@ -0,0 +1,10 @@
1
+ class String
2
+ def strip_emojis
3
+ gsub(Unicode::Emoji::REGEX, "")
4
+ end
5
+
6
+ def only_emoji?
7
+ return false if strip.empty?
8
+ strip_emojis.strip.empty?
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.25
4
+ version: 1.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
@@ -391,6 +391,7 @@ files:
391
391
  - app/helpers/account/teams_helper.rb
392
392
  - app/helpers/account/users_helper.rb
393
393
  - app/helpers/attributes_helper.rb
394
+ - app/helpers/base_helper.rb
394
395
  - app/helpers/email_helper.rb
395
396
  - app/helpers/images_helper.rb
396
397
  - app/helpers/invitation_only_helper.rb
@@ -511,6 +512,8 @@ files:
511
512
  - lib/bullet_train.rb
512
513
  - lib/bullet_train/engine.rb
513
514
  - lib/bullet_train/version.rb
515
+ - lib/colorizer.rb
516
+ - lib/string/emoji.rb
514
517
  - lib/tasks/bullet_train_tasks.rake
515
518
  homepage: https://github.com/bullet-train-co/bullet_train
516
519
  licenses: