platformx 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,12 @@
1
1
  module Platformx
2
+ # Layout helpers
3
+ # @author Tim Mushen
2
4
  module LayoutHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
- ########################################################
9
- #
10
- # Panel
11
- #
12
- ########################################################
5
+
6
+ # Panel top view helper
7
+ # @param title [String] the title of the panel
8
+ # @param panel_class [String] the panel html classes
9
+ # @return [String] rendered panel top html
13
10
  def x_panel_top(title: "", panel_class: "")
14
11
  if title != ""
15
12
  title=<<EOS
@@ -26,6 +23,8 @@ EOS
26
23
  return panel
27
24
  end
28
25
 
26
+ # Panel bttom view helper
27
+ # @return [String] rendered panel bottom html
29
28
  def x_panel_bottom
30
29
  panel =<<EOS
31
30
  </div>
@@ -34,11 +33,13 @@ EOS
34
33
  return panel
35
34
  end
36
35
 
37
- ########################################################
38
- #
39
- # Card
40
- #
41
- ########################################################
36
+ # Card (top) view helper
37
+ # @param title [String] title of the card
38
+ # @param subtitle [String] subtitle of the card
39
+ # @param card_class [String] card html classes
40
+ # @param header_css [String] header css of the card
41
+ # @param buttons [String] card buttons
42
+ # @return [String] rendered card top html
42
43
  def x_card_top(title: "",subtitle: "", card_class: "", header_css: "", buttons: "")
43
44
  if title != ""
44
45
  title=<<EOS
@@ -58,6 +59,8 @@ EOS
58
59
  return panel
59
60
  end
60
61
 
62
+ # Card (bottom) view helper
63
+ # @return [String] rendered card bottom html
61
64
  def x_card_bottom
62
65
  panel =<<EOS
63
66
  </div>
@@ -66,12 +69,9 @@ EOS
66
69
  return panel
67
70
  end
68
71
 
69
- ########################################################
70
- #
71
- # Gravitar
72
- #
73
- ########################################################
74
-
72
+ # Gravitar view helper
73
+ # @param email [String] email of the user to show the garvitar
74
+ # @return [String] gravitar image uri
75
75
  def x_gravitar(email: "")
76
76
  hash = ""
77
77
 
@@ -88,11 +88,10 @@ def x_gravitar(email: "")
88
88
  return image_src
89
89
  end
90
90
 
91
- ########################################################
92
- #
93
91
  # Student Tabs Nav
94
- #
95
- ########################################################
92
+ # @param active [String] tab active
93
+ # @param tabs [Array] array of tabs
94
+ # @return [String] rendered tabs navigation
96
95
  def x_tabs(active: "", tabs: array)
97
96
 
98
97
  tab_builder = ""
@@ -124,11 +123,11 @@ return tab_wrapper
124
123
  end
125
124
 
126
125
 
127
- ########################################################
128
- #
129
126
  # Dashboard Number Widget
130
- #
131
- ########################################################
127
+ # @param label [String] number widget label
128
+ # @param value [String] number widget value
129
+ # @param icon [String] number widget icon
130
+ # @return [String] rendered number widget
132
131
  def x_number_widget(label: "", value: "", icon: "")
133
132
 
134
133
  icon_html = ""
@@ -146,10 +145,5 @@ EOS
146
145
  return widget
147
146
 
148
147
  end
149
- ########################################################
150
- #
151
- # End
152
- #
153
- ########################################################
154
148
  end
155
- end
149
+ end
@@ -1,11 +1,9 @@
1
1
  module Platformx
2
+ # Mail module
3
+ # @author Tim Mushen
2
4
  module Mail
3
5
 
4
- ########################################################
5
- #
6
- # Conig
7
- #
8
- ########################################################
6
+ # Conig mail
9
7
  def self.init
10
8
  #Pony Configs
11
9
  Pony.options = {
@@ -24,11 +22,10 @@ def self.init
24
22
  }
25
23
  end
26
24
 
27
- ########################################################
28
- #
29
- # Mail
30
- #
31
- ########################################################
25
+ # Send mail
26
+ # @param to [String] to addresses
27
+ # @param cc [String] cc addresses
28
+ # @param html_body [String] body of the message (in html)
32
29
  def self.mail(to: "", cc: "", subject: "", html_body: "")
33
30
  init
34
31
  Pony.mail(
@@ -40,4 +37,4 @@ def self.mail(to: "", cc: "", subject: "", html_body: "")
40
37
  end
41
38
 
42
39
  end
43
- end
40
+ end
@@ -1,10 +1,15 @@
1
1
  module Platformx
2
+
3
+ # Notification helpers
4
+ # @author Tim Mushen
2
5
  module NotifyHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
6
+
7
+ # Notify view helper
8
+ # @param flash [Object] flash object
9
+ # @param timer [Integer] the length the notify should show
10
+ # @param align [String] the alignment of the notify (left or right)
11
+ # @param from [String] the location of the notify
12
+ # @return [String] rendered notify message (js script)
8
13
  def x_notify(flash: "", timer: 4000, align: "right", from:"top")
9
14
 
10
15
  color = "success"
@@ -35,11 +40,5 @@ return cb
35
40
  end
36
41
  end
37
42
 
38
-
39
- ########################################################
40
- #
41
- # End
42
- #
43
- ########################################################
44
43
  end
45
- end
44
+ end
@@ -1,4 +1,6 @@
1
1
  module Platformx
2
+ # Omniauth helpers
3
+ # @author Tim Mushen
2
4
  module OmniauthHelpers
3
5
  ########################################################
4
6
  #
@@ -13,4 +15,4 @@ module Platformx
13
15
  #
14
16
  ########################################################
15
17
  end
16
- end
18
+ end
@@ -1,12 +1,13 @@
1
1
  module Platformx
2
+
3
+ # Omniauth routes
4
+ # @author Tim Mushen
2
5
  module OmniauthRoutes
3
6
 
7
+ # Register routes for OmniAuth with Sinatra app
8
+ # @todo add individual route documentation. yard-sinatra plugin is not detecting these
9
+ # routes. Probably because of the app.get format.
4
10
  def self.registered(app)
5
- ########################################################
6
- #
7
- # Start Method
8
- #
9
- ########################################################
10
11
 
11
12
  app.get '/omniauth-test/?' do
12
13
  "Yes!"
@@ -54,11 +55,6 @@ app.get '/logout' do
54
55
  redirect '/'
55
56
  end
56
57
 
57
- ########################################################
58
- #
59
- # End Methods
60
- #
61
- ########################################################
62
58
  end
63
59
  end
64
- end
60
+ end
data/lib/platformx/pdf.rb CHANGED
@@ -1,14 +1,16 @@
1
1
  module Platformx
2
+
3
+ # PDF helpers module
4
+ # @author Tim Mushen
2
5
  module PdfHelpers
3
- ########################################################
4
- #
5
- # PDF's
6
- #
7
- ########################################################
8
6
 
9
-
10
-
11
- ################# Fill PDF #################
7
+ # Fill pdf helper
8
+ # @todo Figure out what this method does and returns
9
+ # @param source_pdf [String] source pdf
10
+ # @param target_file_path [String] target file path
11
+ # @param new_pdf_name [String] new name of the pdf
12
+ # @param pdf_variables [String] pdf variables
13
+ # @param flatten [String] if to flatten or not
12
14
  def x_fill_pdf(source_pdf: "", target_file_path: "", new_pdf_name: "", pdf_variables: {}, flatten: true)
13
15
  # include pdftk
14
16
  pdftk = PdfForms.new(settings.pdftk_path)
@@ -28,15 +30,5 @@ def x_fill_pdf(source_pdf: "", target_file_path: "", new_pdf_name: "", pdf_varia
28
30
  :flatten => flatten
29
31
  end
30
32
 
31
-
32
-
33
-
34
-
35
-
36
- ########################################################
37
- #
38
- # End Class
39
- #
40
- ########################################################
41
33
  end
42
- end
34
+ end
@@ -1,43 +1,57 @@
1
1
  module Platformx
2
+ # Stripe helpers module
3
+ # @author Tim Mushen
2
4
  module StripeHelpers
3
5
  require "active_support/all"
4
- ########################################################
5
- #
6
- # Start Helpers
7
- #
8
- ########################################################
6
+
7
+ # Provide all stripe invoices
8
+ # @param customer_id [String] stripe customer id
9
+ # @return [Array<Stripe::Invoice>] collection of stripe invoices
9
10
  def x_stripe_invoices(customer_id: "")
10
11
  invoices = Stripe::Invoice.all
11
12
  return invoices
12
13
  end
13
14
 
15
+ # Get specific stripe invoice
16
+ # @param invoice [String] stripe invoice id
17
+ # @return [Stripe::Invoice] the stripe invoice identified by id
14
18
  def x_stripe_invoice(invoice: "")
15
19
  invoice = Stripe::Invoice.retrieve(invoice)
16
20
  return invoice
17
21
  end
18
22
 
23
+ # Get stripe customer
24
+ # @param customer_id [String] stripe customer id
25
+ # @return [Stripe::Customer] stripe customer identified by id
19
26
  def x_stripe_customer(customer_id: "")
20
27
  customer = Stripe::Customer.retrieve(customer_id)
21
28
  return customer
22
29
  end
23
30
 
31
+ # Retrieve stripe card for a customer
32
+ # @param customer_id [String] stripe customer id
33
+ # @param card_id [String] stripe card id
34
+ # @return [Stripe::Card] stripe card
24
35
  def x_stripe_customer_card(customer_id: "", card_id: "")
25
36
  customer = Stripe::Customer.retrieve(customer_id)
26
37
  card = customer.sources.retrieve(card_id)
27
38
  return card
28
39
  end
29
40
 
41
+ # Delete a stripe card for a customer
42
+ # @param customer_id [String] stripe customer id
43
+ # @param card_id [String] stripe card id
44
+ # @return [Stripe::Card] stripe card which was deleted
30
45
  def x_stripe_customer_card_delete(customer_id: "", card_id: "")
31
46
  customer = Stripe::Customer.retrieve(customer_id)
32
47
  card = customer.sources.retrieve(card_id).delete()
33
48
  return card
34
49
  end
35
50
 
36
- ########################################################
37
- #
38
- # Common functions for Stripe
39
- #
40
- ########################################################
51
+ # Stripe total including tax
52
+ # @param amount [Numeric] amount
53
+ # @param tax_percentage [Numeric] tax percentage
54
+ # @return [String] stripe total including tax if included
41
55
  def x_stripe_total(amount: "", tax_percentage: "")
42
56
  num = 0
43
57
 
@@ -55,11 +69,5 @@ def x_stripe_total(amount: "", tax_percentage: "")
55
69
 
56
70
  end
57
71
 
58
-
59
- ########################################################
60
- #
61
- # End
62
- #
63
- ########################################################
64
72
  end
65
- end
73
+ end
@@ -1,17 +1,22 @@
1
1
  module Platformx
2
+ # Text helpers module
3
+ # @author Tim Mushen
2
4
  module TextHelpers
3
- ########################################################
4
- #
5
- # Start Helpers
6
- #
7
- ########################################################
8
5
 
9
- # Slug
6
+ # Generates slug from text
7
+ # @param slug [String] text to slug
8
+ # @return [String] slugged text
10
9
  def x_slug(slug: "")
11
10
  return slug.slugify
12
11
  end
13
12
 
14
- #x_boolean_label
13
+ # Generate boolean label
14
+ # @param value [Boolean] boolean value
15
+ # @param type [String] boolean label type
16
+ # @return [String] boolean label (yes or no for boolean value)
17
+ # @example
18
+ # x_boolean_label(true) # -> "Yes"
19
+ # x_boolean_label(false) # -> "No"
15
20
  def x_boolean_label(value: "", type: "text")
16
21
 
17
22
  if !value.nil? && value == true
@@ -23,10 +28,6 @@ def x_boolean_label(value: "", type: "text")
23
28
  return str
24
29
 
25
30
  end
26
- ########################################################
27
- #
28
- # End
29
- #
30
- ########################################################
31
+
31
32
  end
32
- end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Platformx
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/platformx.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # PlatformX - gems
1
2
  require "platformx/version"
2
3
  require "platformx/auth"
3
4
  require "platformx/form"
@@ -11,7 +12,7 @@ require "platformx/pdf"
11
12
  require "platformx/text"
12
13
  require "platformx/aws"
13
14
 
14
- ########################### Require Gems ############################
15
+ # 3rd party gems
15
16
  require "sinatra/base"
16
17
  require "sinatra/contrib/all"
17
18
  require "sinatra/partial"
@@ -42,41 +43,93 @@ require "fog"
42
43
  module Platformx
43
44
 
44
45
  class << self
46
+ # Controls the app configuration
47
+ # @return [Platformx::Configuration] configuration object
45
48
  attr_accessor :configuration
46
49
  end
47
50
 
51
+ # Configure the PlatformX gem
52
+ #
53
+ # @example
54
+ # Platformxe.confgure do |config|
55
+ # config.bugsnag_api_key = "XYZ"
56
+ #
57
+ # config.mail_from = "John Doe"
58
+ # config.mail_address = "johndoe@example.com"
59
+ # config.mail_port = "578"
60
+ # config.mail_domain = "smtp.mailgun.org"
61
+ # config.mail_user_name = ""
62
+ # config.mail_password = ""
63
+ # config.mail_authentication = "plain"
64
+ #
65
+ # config.aws_bucket = ""
66
+ # config.aws_access_key_id = ""
67
+ # config.aws_secret_access_key = ""
68
+ # config.aws_region = ""
69
+ # end
48
70
  def self.configure
49
71
  self.configuration ||= Configuration.new
50
72
  yield(configuration)
51
73
  end
52
74
 
53
- ########################################################
54
- #
55
- # Start Configuration Class
56
- #
57
- ########################################################
75
+ #
76
+ # PlatformX configuration class.
77
+ #
78
+ # @author Tim Mushen
79
+ #
58
80
  class Configuration
59
81
 
60
- # For Bugsnag
82
+ # Controls the bugsnag api key attribute
83
+ # @return [String] Bugsnag api key
61
84
  attr_accessor :bugsnag_api_key
62
85
 
63
- # X_mail
86
+ # Controls the mail from
87
+ # @return [String] the mail from
64
88
  attr_accessor :mail_from
89
+
90
+ # Controls the mail address
91
+ # @return [String] the mail address
65
92
  attr_accessor :mail_address
93
+
94
+ # Controls the mail port number
95
+ # @return [String] the mail port number
66
96
  attr_accessor :mail_port
97
+
98
+ # Controls the mail domain
99
+ # @return [String] the mail domain
67
100
  attr_accessor :mail_domain
101
+
102
+ # Controls the mail user name
103
+ # @return [String] the mail user name
68
104
  attr_accessor :mail_user_name
105
+
106
+ # Controls the mail password
107
+ # @return [String] the mail password
69
108
  attr_accessor :mail_password
109
+
110
+ # Controls mail authentication
111
+ # @return [String] mail authentication
70
112
  attr_accessor :mail_authentication
71
-
72
- # For AWS/Fog
113
+
114
+ # Controls the aws bucket name
115
+ # @return [String] aws bucket name
73
116
  attr_accessor :aws_bucket
117
+
118
+ # Controls the aws access key id
119
+ # @return [String] the aws access key id
74
120
  attr_accessor :aws_access_key_id
121
+
122
+ # Controls the aws secret access key
123
+ # @return [String] the aws secret access key
75
124
  attr_accessor :aws_secret_access_key
125
+
126
+ # Controls the aws region
127
+ # @return [String] aws region
76
128
  attr_accessor :aws_region
77
129
 
130
+ # Initialize Platformx configuration object and set defaults
78
131
  def initialize
79
- # Bugsnag:
132
+ # Bugsnag
80
133
  @bugsnag_api_key = ""
81
134
 
82
135
  # X_mail
@@ -98,54 +151,46 @@ module Platformx
98
151
  end
99
152
 
100
153
 
101
-
102
-
103
- ########################################################
104
- #
105
- # Start Sinatra Module
106
- #
107
- ########################################################
108
-
154
+ # Platformx - Sinatra module
109
155
  module Sinatra
110
156
 
111
- def self.registered(app)
112
- app.helpers Platformx::DateHelpers
113
- app.helpers Platformx::StripeHelpers
114
- app.helpers Platformx::AuthHelpers
115
- app.helpers Platformx::FormHelpers
116
- app.helpers Platformx::LayoutHelpers
117
- app.helpers Platformx::NotifyHelpers
118
- app.helpers Platformx::FakerHelpers
119
- app.helpers Platformx::TextHelpers
120
- app.helpers Platformx::PdfHelpers
121
- app.helpers Platformx::S3Helpers
122
-
157
+ def self.registered(app)
158
+ app.helpers Platformx::DateHelpers
159
+ app.helpers Platformx::StripeHelpers
160
+ app.helpers Platformx::AuthHelpers
161
+ app.helpers Platformx::FormHelpers
162
+ app.helpers Platformx::LayoutHelpers
163
+ app.helpers Platformx::NotifyHelpers
164
+ app.helpers Platformx::FakerHelpers
165
+ app.helpers Platformx::TextHelpers
166
+ app.helpers Platformx::PdfHelpers
167
+ app.helpers Platformx::S3Helpers
168
+
123
169
  # #BugSnag
124
170
  # if Platformx.configuration.bugsnag_api_key != ""
125
- # app.Bugsnag.configure do |config|
126
- # config.api_key = Platformx.configuration.bugsnag_api_key
127
- # end
128
- # app.use Bugsnag::Rack
129
- # app.enable :raise_errors
171
+ # app.Bugsnag.configure do |config|
172
+ # config.api_key = Platformx.configuration.bugsnag_api_key
173
+ # end
174
+ # app.use Bugsnag::Rack
175
+ # app.enable :raise_errors
130
176
  # end
131
177
 
178
+ # Configure Better Errors
179
+ if app.development?
180
+ app.use BetterErrors::Middleware
181
+ BetterErrors.application_root = __dir__
182
+ end
132
183
 
133
- # Configure Better Errors
134
- if app.development?
135
- app.use BetterErrors::Middleware
136
- BetterErrors.application_root = __dir__
137
- end
138
-
139
- # Configure Rack Protection
140
- if app.production?
141
- app.use Rack::Protection
142
- end
143
-
144
- end
184
+ # Configure Rack Protection
185
+ if app.production?
186
+ app.use Rack::Protection
187
+ end
188
+ end
145
189
 
146
190
  end # End Sinatra
147
191
  end
192
+
148
193
  #Register Helpers
149
194
  Sinatra.register Platformx::Sinatra
150
195
  Sinatra.register Sinatra::Numeric
151
- Sinatra.register Sinatra::HtmlHelpers
196
+ Sinatra.register Sinatra::HtmlHelpers
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platformx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - timmushen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-21 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler