marfa 0.1.5 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a423c48b5405907fa9a6e7e782f8695dad2c3c36
4
- data.tar.gz: 9a4ab9f1754e2bdab22f437a5928ef00f94b8fa3
3
+ metadata.gz: a777d031578dcff7a85bf3264c509d21586551d9
4
+ data.tar.gz: b4690307d3915a21c4db20aa9035927fcd094d6f
5
5
  SHA512:
6
- metadata.gz: 138fe6e3b19da6060c509eaebd92b7c7a13c6a0f39ca8a435958e9cc9faa5c6c714c9be89c28d4815e45b7ccbf0dc1939a5d97691a7f42f9d0ddc0e1c82352ff
7
- data.tar.gz: 400b292c45fdfa2bf8218147282bc1a15dee62f1c9ea1456c229dd9f8e2e5dfcb4c0d8ae7e8ab6961d4be14dff45b10a472356c4996fb386fa878671cbd8411c
6
+ metadata.gz: b0dd578a7013bbd5f3b6b27204b73caa56ffde015c06f76f62fd6065db914c4adc3f7dfbd072f75ab1aabeeb7a877698cfc8486b5eb6fd44d34bd98d18c81138
7
+ data.tar.gz: e82ff2f99c26bfa94dbf1b5c6c4339554b250273e50b46642b1e26059923c559bcbd4bf0a5cf8b94124058bb193dfb292c0d981bd208f6d455503d02b2dc41cd
@@ -18,6 +18,12 @@ module Marfa
18
18
  _configure_ext_modules(Marfa::Controllers::BaseController)
19
19
  end
20
20
 
21
+ # Configure Marfa in block
22
+ def self.configure
23
+ config if @config.nil?
24
+ yield @config
25
+ end
26
+
21
27
  private
22
28
 
23
29
  # Configure controller settings
@@ -3,7 +3,6 @@ require 'rack/csrf'
3
3
  require 'device_detector'
4
4
  require 'marfa/helpers/controller'
5
5
  require 'marfa/helpers/http/vary'
6
- require 'marfa/helpers/javascript'
7
6
 
8
7
  # Extending Marfa
9
8
  module Marfa
@@ -24,7 +23,6 @@ module Marfa
24
23
  # All methods defined below might be used in child controllers
25
24
  helpers Marfa::Helpers::Controller
26
25
  helpers Marfa::Helpers::HTTP::Vary
27
- helpers Marfa::Helpers::Javascript
28
26
  end
29
27
  end
30
28
  end
@@ -14,63 +14,64 @@ module Marfa
14
14
  def marfa_rb(project_path)
15
15
  File.open("#{project_path}/config/marfa.rb", 'w') do |file|
16
16
  file.puts "# Marfa configuration file
17
-
18
- # Specifying API Server is needed
19
- Marfa.config.api_server = ''
20
-
21
- # Views path is needed
22
- Marfa.config.views = File.expand_path('./app/views')
23
-
24
- # Cache config
25
- Marfa.config.cache = {
26
- enabled: false,
27
- host: '',
28
- port: 0,
29
- db: 0,
30
- expiration_time: 3600
31
- }
32
-
33
- # Static files content path
34
- Marfa.config.content_path = '/images/content/'
35
-
36
- Marfa.config.cache_styles = true
37
-
38
- # Public folder
39
- Marfa.config.public_folder = File.expand_path('./static')
40
-
41
- # Static files cache
42
- Marfa.config.static_cache_control = [:public, max_age: 2_592_000]
43
-
44
- # CSRF Protection
45
- Marfa.config.csrf_enabled = false
46
-
47
- # HTML Compression
48
- Marfa.config.html_compression_options = {
49
- enabled: true,
50
- remove_multi_spaces: true,
51
- remove_comments: true,
52
- remove_intertag_spaces: false,
53
- remove_quotes: true,
54
- compress_css: false,
55
- compress_javascript: false,
56
- simple_doctype: false,
57
- remove_script_attributes: true,
58
- remove_style_attributes: true,
59
- remove_link_attributes: true,
60
- remove_form_attributes: false,
61
- remove_input_attributes: true,
62
- remove_javascript_protocol: true,
63
- remove_http_protocol: false,
64
- remove_https_protocol: false,
65
- preserve_line_breaks: false,
66
- simple_boolean_attributes: true
67
- }
68
-
69
- # CSS Minifying
70
- Marfa.config.minify_css = true
71
-
72
- # JS Minifying
73
- Marfa.config.minify_js = true
17
+ Marfa.configure do |cfg|
18
+ # Specifying API Server is needed
19
+ cfg.api_server = ''
20
+
21
+ # Views path is needed
22
+ cfg.views = File.expand_path('./app/views')
23
+
24
+ # Cache config
25
+ cfg.cache = {
26
+ enabled: false,
27
+ host: '',
28
+ port: 0,
29
+ db: 0,
30
+ expiration_time: 3600
31
+ }
32
+
33
+ # Static files content path
34
+ cfg.content_path = '/images/content/'
35
+
36
+ cfg.cache_styles = true
37
+
38
+ # Public folder
39
+ cfg.public_folder = File.expand_path('./static')
40
+
41
+ # Static files cache
42
+ cfg.static_cache_control = [:public, max_age: 2_592_000]
43
+
44
+ # CSRF Protection
45
+ cfg.csrf_enabled = false
46
+
47
+ # HTML Compression
48
+ cfg.html_compression_options = {
49
+ enabled: true,
50
+ remove_multi_spaces: true,
51
+ remove_comments: true,
52
+ remove_intertag_spaces: false,
53
+ remove_quotes: true,
54
+ compress_css: false,
55
+ compress_javascript: false,
56
+ simple_doctype: false,
57
+ remove_script_attributes: true,
58
+ remove_style_attributes: true,
59
+ remove_link_attributes: true,
60
+ remove_form_attributes: false,
61
+ remove_input_attributes: true,
62
+ remove_javascript_protocol: true,
63
+ remove_http_protocol: false,
64
+ remove_https_protocol: false,
65
+ preserve_line_breaks: false,
66
+ simple_boolean_attributes: true
67
+ }
68
+
69
+ # CSS Minifying
70
+ cfg.minify_css = true
71
+
72
+ # JS Minifying
73
+ cfg.minify_js = true
74
+ end
74
75
  "
75
76
  end
76
77
  end
@@ -0,0 +1,32 @@
1
+ require 'pony'
2
+
3
+ # Email adapter for Pony gem
4
+ module Marfa
5
+ # Extending Helpers
6
+ module Helpers
7
+ # Provide helpers for Sinatra controllers
8
+ module Email
9
+ # Send email using mailbox config
10
+ # @param template [String] - path to template file
11
+ # @param to [String] - email address to send
12
+ # @param subject [String] - email subject
13
+ # @param data [Hash] - data to render in template
14
+ # @param mailbox [Symbol] - mailbox config
15
+ # @example:
16
+ # send_email('mail', 'user@example.com', :admin, 'Hello', { title: 'Hello!' })
17
+ def send_email(template, to, mailbox = :default, subject = '', data = {})
18
+ config = Marfa.config.email[mailbox]
19
+ return if config.nil?
20
+
21
+ body = haml :"#{template}", locals: data, layout: false
22
+
23
+ Pony.options = {
24
+ via: :smtp,
25
+ via_options: config
26
+ }
27
+
28
+ Pony.mail(to: to, subject: subject, html_body: body)
29
+ end
30
+ end
31
+ end
32
+ end
data/lib/marfa/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Version constant
2
2
  module Marfa
3
3
  # The version constant for the current version of Marfa
4
- VERSION = '0.1.5' unless defined?(Marfa::VERSION)
4
+ VERSION = '0.1.8' unless defined?(Marfa::VERSION)
5
5
 
6
6
  # The current Marfa version.
7
7
  # @return [String] The version number
data/lib/marfa.rb CHANGED
@@ -6,7 +6,7 @@ require 'marfa/helpers/controller'
6
6
  require 'marfa/helpers/http/vary'
7
7
  require 'marfa/helpers/scss'
8
8
  require 'marfa/helpers/style'
9
- require 'marfa/helpers/javascript'
9
+ require 'marfa/helpers/email'
10
10
  require 'marfa/controllers'
11
11
  require 'marfa/controllers/base_controller'
12
12
  require 'marfa/controllers/css_controller'
data/marfa.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'marfa'
6
- s.version = '0.1.5'
6
+ s.version = '0.1.8'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.date = Time.now.strftime('%Y-%m-%d')
9
9
  s.summary = 'Little Sinatra-based framework'
@@ -32,5 +32,6 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency('csso-rails', '~> 0.5.0')
33
33
  s.add_dependency('yard')
34
34
  s.add_dependency('yard-sinatra')
35
- s.add_dependency('compass')
35
+ s.add_dependency('compass', '~> 1.0.3')
36
+ s.add_dependency('pony', '~> 1.11')
36
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marfa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Krechetov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-02-08 00:00:00.000000000 Z
13
+ date: 2017-02-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: haml
@@ -240,16 +240,30 @@ dependencies:
240
240
  name: compass
241
241
  requirement: !ruby/object:Gem::Requirement
242
242
  requirements:
243
- - - ">="
243
+ - - "~>"
244
244
  - !ruby/object:Gem::Version
245
- version: '0'
245
+ version: 1.0.3
246
246
  type: :runtime
247
247
  prerelease: false
248
248
  version_requirements: !ruby/object:Gem::Requirement
249
249
  requirements:
250
- - - ">="
250
+ - - "~>"
251
251
  - !ruby/object:Gem::Version
252
- version: '0'
252
+ version: 1.0.3
253
+ - !ruby/object:Gem::Dependency
254
+ name: pony
255
+ requirement: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - "~>"
258
+ - !ruby/object:Gem::Version
259
+ version: '1.11'
260
+ type: :runtime
261
+ prerelease: false
262
+ version_requirements: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - "~>"
265
+ - !ruby/object:Gem::Version
266
+ version: '1.11'
253
267
  description: Little Sinatra-based framework
254
268
  email: mvkrechetov@gmail.com
255
269
  executables:
@@ -275,8 +289,8 @@ files:
275
289
  - lib/marfa/file_templates.rb
276
290
  - lib/marfa/helpers/classes/string.rb
277
291
  - lib/marfa/helpers/controller.rb
292
+ - lib/marfa/helpers/email.rb
278
293
  - lib/marfa/helpers/http/vary.rb
279
- - lib/marfa/helpers/javascript.rb
280
294
  - lib/marfa/helpers/sass_functions.rb
281
295
  - lib/marfa/helpers/scss.rb
282
296
  - lib/marfa/helpers/style.rb
@@ -1,46 +0,0 @@
1
- require 'babel/transpiler'
2
- require 'closure-compiler'
3
-
4
- # TODO: Remove in v0.2
5
-
6
- # Javascript
7
- module Marfa
8
- # Helpers for Javascript
9
- module Helpers
10
- # Javascript module
11
- module Javascript
12
- def js_transpile(path, is_plain_text = true)
13
- path = File.read(path) unless is_plain_text
14
- result = Babel::Transpiler.transform(path)
15
- result['code']
16
- end
17
-
18
- # https://developers.google.com/closure/compiler/docs/compilation_levels
19
- def js_import(path)
20
- path = settings.views + path
21
-
22
- closure = Closure::Compiler.new(
23
- compilation_level: 'SIMPLE_OPTIMIZATIONS',
24
- language_out: 'ES5_STRICT'
25
- )
26
-
27
- code = js_transpile(path, false)
28
- code = closure.compile(code) if Marfa.config.minify_js
29
- '<script>' + code + '</script>'
30
- end
31
-
32
- # https://developers.google.com/closure/compiler/docs/compilation_levels
33
- def js_import_from_haml(path, data = {})
34
- closure = Closure::Compiler.new(
35
- compilation_level: 'SIMPLE_OPTIMIZATIONS',
36
- language_out: 'ES5_STRICT'
37
- )
38
-
39
- template = haml :"#{path}", :layout => false, :locals => data
40
- code = js_transpile(template)
41
- code = closure.compile(code)
42
- '<script>' + code + '</script>'
43
- end
44
- end
45
- end
46
- end