flashee 0.3.3 → 0.3.4

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
  SHA256:
3
- metadata.gz: 24d913d85e05b65cba97c90c078b602586ffc7041065afb5343afa20eb9a48dc
4
- data.tar.gz: 19158e733d9a0c95a19640bf0441768fdb48c660772f121a6d23e462ebed53e4
3
+ metadata.gz: 446cda8e1d0cecd2902f3f9805dc6753007571c23875fa54d7a020b87a309477
4
+ data.tar.gz: 341cc0620380d36ee3d67615f8285f2b3ca09785b10a5df46d2d4f66b611da01
5
5
  SHA512:
6
- metadata.gz: 7b606779158af5b140ecc890d3393584755af4a9bf6889f5deaf81e1aacfb33c72a99dc0ab8f10c613d494937193fb30be7d4bcc0eb6acd7f3bb9ec24006e2c8
7
- data.tar.gz: f837abfd7c06f168f6be930838c0f1cad43c4a24d6c195aa6f3eb9c39398885e8ecc8674affbe84b313c05bcd147aca68eb63e06f6cbe09e18a789b4f068b96e
6
+ metadata.gz: f4ffd55bc15af4ba41bb917e94e177ba90089aef08317395c4058cc5a2038af0420c967c05a71ec5eba1b499ab895746952d72d38badb00a8f9ab8c9890efaa8
7
+ data.tar.gz: 0e24d3bd8d6f49783eee53d2d7a637be9f8ea7d0221f73db2fd065dee58e69e689b75256ac8f4e13fe9990ca10c26529564cdc2a53fe9e619dab72877f66dcf0
data/Rakefile CHANGED
@@ -4,14 +4,18 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
+ require 'sdoc'
7
8
  require 'rdoc/task'
8
9
 
9
10
  RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.rdoc_dir = 'docs'
11
12
  rdoc.title = 'Flashee'
12
13
  rdoc.options << '--line-numbers'
14
+ rdoc.options << '--format=sdoc'
15
+ rdoc.template = 'rails'
13
16
  rdoc.rdoc_files.include('README.md')
14
17
  rdoc.rdoc_files.include('lib/**/*.rb')
18
+ rdoc.main = 'README.md'
15
19
  end
16
20
 
17
21
  require 'bundler/gem_tasks'
@@ -1,5 +1,6 @@
1
1
  require "flashee/railtie"
2
+ require "flashee/builders"
2
3
 
3
4
  module Flashee
4
- # Your code goes here...
5
+ require 'erb'
5
6
  end
@@ -0,0 +1,63 @@
1
+ module Flashee
2
+ class Builders
3
+ # Called by install generators to build the appropriate helper file
4
+ #
5
+ # == Parameters:
6
+ #
7
+ # * flashee_helper_mode::
8
+ # A string to define what mode to render the templates in
9
+ #
10
+ # == Returns:
11
+ # A string of the template contents
12
+ #
13
+ def self.helper_builder flashee_helper_mode
14
+ @mode = flashee_helper_mode
15
+ @template = File.read(File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "flashee_helper.rb.erb"))
16
+ return ERB.new(@template).result(binding)
17
+ end
18
+
19
+ # Called by install generators to build the appropriate view partial
20
+ #
21
+ # == Parameters:
22
+ #
23
+ # * flashee_helper_mode::
24
+ # if flashee_helper_mode is set to "foundation" it will copy the foundation template.
25
+ # Otherwise it will copy the standard template that fits everything else.
26
+ #
27
+ # == Returns:
28
+ # A string of the template contents
29
+ #
30
+ def self.view_builder flashee_helper_mode
31
+ @mode = flashee_helper_mode
32
+ if @mode == "foundation"
33
+ view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages_foundation.html.erb")
34
+ view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb")
35
+ FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials")
36
+ FileUtils.cp_r view_partial_source, view_partial_target
37
+ else
38
+ view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages.html.erb")
39
+ view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb")
40
+ FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials")
41
+ FileUtils.cp_r view_partial_source, view_partial_target
42
+ end
43
+ end
44
+
45
+ # Called by install generators to create a file inside of the apps file structure
46
+ #
47
+ # == Parameters:
48
+ # * file_path::
49
+ # Path to file including filename and extension
50
+ #
51
+ # * file_contents::
52
+ # Contents to print into the file_path
53
+ #
54
+ # == Returns:
55
+ # A file inside file_path containing file_contents
56
+ #
57
+ def self.file_builder file_path, file_contents
58
+ @out_file = File.new(file_path, 'w')
59
+ @out_file.puts(file_contents)
60
+ @out_file.close
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,4 @@
1
1
  module Flashee
2
- VERSION = '0.3.3'
2
+ # Defines the current Gem version
3
+ VERSION = '0.3.4'
3
4
  end
@@ -4,23 +4,18 @@ module Flashee
4
4
  # Houses the logic to install flashee into the target rails app using the bootstrap CSS framework.
5
5
  # BootstrapGenerator translates to the `flashee:install:bootstrap
6
6
  class BootstrapGenerator < Rails::Generators::Base
7
-
8
- # Copies `lib/templates/flashee_bootstrap_helper.rb` into `app/helpers/flashee_helper.rb`.
9
- def copy_helper
10
- helper_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "flashee_bootstrap_helper.rb")
11
- helper_target = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
12
7
 
13
- FileUtils.cp_r helper_source, helper_target
14
- end
8
+ # Creates bootstrap mode helper.
9
+ def create_helper
10
+ @helper_file = Builders.helper_builder "bootstrap"
11
+ helper_target_path = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
15
12
 
16
- # Copies `lib/templates/_flash_messages.html.erb` to `app/views/partials/_flash_messages.html.erb`,
17
- # will also create `app/partials` if it doesn't exist already.
18
- def copy_partial
19
- view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages.html.erb")
20
- view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb")
13
+ Builders.file_builder helper_target_path, @helper_file
14
+ end
21
15
 
22
- FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials")
23
- FileUtils.cp_r view_partial_source, view_partial_target
16
+ # Creates bootstrap mode view partial
17
+ def create_partial
18
+ Builders.view_builder "bootstrap"
24
19
  end
25
20
 
26
21
  # After installation completes, print the ERB snippet to the command line.
@@ -5,22 +5,17 @@ module Flashee
5
5
  # BulmaGenerator translates to the `flashee:install:bulma` command.
6
6
  class BulmaGenerator < Rails::Generators::Base
7
7
 
8
- # Copies `lib/templates/flashee_bulma_helper.rb` into `app/helpers/flashee_helper.rb`.
9
- def copy_helper
10
- helper_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "flashee_bulma_helper.rb")
11
- helper_target = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
8
+ # Creates bulma mode helper.
9
+ def create_helper
10
+ @helper_file = Builders.helper_builder "bulma"
11
+ helper_target_path = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
12
12
 
13
- FileUtils.cp_r helper_source, helper_target
13
+ Builders.file_builder helper_target_path, @helper_file
14
14
  end
15
15
 
16
- # Copies `lib/templates/_flash_messages.html.erb` to `app/views/partials/_flash_messages.html.erb`,
17
- # will also create `app/partials` if it doesn't exist already.
18
- def copy_partial
19
- view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages.html.erb")
20
- view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb")
21
-
22
- FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials")
23
- FileUtils.cp_r view_partial_source, view_partial_target
16
+ # Creates bulma mode view partial
17
+ def create_partial
18
+ Builders.view_builder "bulma"
24
19
  end
25
20
 
26
21
  # After installation completes, print the ERB snippet to the command line.
@@ -4,23 +4,18 @@ module Flashee
4
4
  # Houses the logic to install flashee into the target rails app using the foundation CSS framework.
5
5
  # FoundationGenerator translates to the `flashee:install:foundation` command.
6
6
  class FoundationGenerator < Rails::Generators::Base
7
-
8
- # Copies `lib/templates/flashee_foundation_helper.rb` into `app/helpers/flashee_helper.rb`.
9
- def copy_helper
10
- helper_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "flashee_foundation_helper.rb")
11
- helper_target = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
12
7
 
13
- FileUtils.cp_r helper_source, helper_target
14
- end
8
+ # Creates foundation mode helper.
9
+ def create_helper
10
+ @helper_file = Builders.helper_builder "foundation"
11
+ helper_target_path = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
15
12
 
16
- # Copies `lib/templates/_flash_messages_foundation.html.erb` to `app/views/partials/_flash_messages.html.erb`,
17
- # will also create `app/partials` if it doesn't exist already.
18
- def copy_partial
19
- view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages_foundation.html.erb")
20
- view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb")
13
+ Builders.file_builder helper_target_path, @helper_file
14
+ end
21
15
 
22
- FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials")
23
- FileUtils.cp_r view_partial_source, view_partial_target
16
+ # Creates foundation mode view partial
17
+ def create_partial
18
+ Builders.view_builder "foundation"
24
19
  end
25
20
 
26
21
  # After installation completes, print the ERB snippet to the command line.
@@ -1,13 +1,18 @@
1
1
  module Flashee
2
2
  module Generators
3
3
  # Parent class that houses all of the sub generators, fund below a list of current generators and their corresponding commands.
4
- #
4
+ #
5
+ # * InstallGenerator
6
+ # $ rails generate flashee:install
7
+ #
5
8
  # * Install::BootstrapGenerator
6
- # flashee:install:bootstrap
9
+ # $ rails generate flashee:install:bootstrap
10
+ #
7
11
  # * Install::BulmaGenerator
8
- # flashee:install:bulma
12
+ # $ rails generate flashee:install:bulma
13
+ #
9
14
  # * Install::FoundationGenerator
10
- # flashee:install:foundation
15
+ # $ rails generate flashee:install:foundation
11
16
  #
12
17
  module Install
13
18
  end
@@ -4,22 +4,16 @@ module Flashee
4
4
  # InstallGenerator translates to the `flashee:install` command.
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
 
7
- # Copies `lib/templates/flashee_helper.rb` into `app/helpers/flashee_helper.rb`.
8
- def copy_helper
9
- helper_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "flashee_helper.rb")
10
- helper_target = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
11
-
12
- FileUtils.cp_r helper_source, helper_target
7
+ # Creates basic mode helper.
8
+ def create_helper
9
+ @helper_file = Builders.helper_builder "basic"
10
+ helper_target_path = File.join(Rails.root, "app", "helpers", "flashee_helper.rb")
11
+ Builders.file_builder helper_target_path, @helper_file
13
12
  end
14
13
 
15
- # Copies `lib/templates/_flash_messages.html.erb` to `app/views/partials/_flash_messages.html.erb`,
16
- # will also create `app/partials` if it doesn't exist already.
17
- def copy_partial
18
- view_partial_source = File.join(Gem.loaded_specs["flashee"].full_gem_path, "lib", "templates", "_flash_messages.html.erb")
19
- view_partial_target = File.join(Rails.root, "app", "views", "partials", "_flash_messages.html.erb")
20
-
21
- FileUtils::mkdir_p File.join(Rails.root, "app", "views", "partials")
22
- FileUtils.cp_r view_partial_source, view_partial_target
14
+ # Creates basic mode view partial
15
+ def create_partial
16
+ Builders.view_builder "basic"
23
17
  end
24
18
 
25
19
  # After installation completes, print the ERB snippet to the command line.
@@ -2,4 +2,4 @@
2
2
  <div class="<%= flashee_for(type) %>">
3
3
  <%= message %>
4
4
  </div>
5
- <% end %>
5
+ <% end %>
@@ -2,4 +2,4 @@
2
2
  <div data-alert class="<%= flashee_for(type) %>">
3
3
  <%= message %>
4
4
  </div>
5
- <% end %>
5
+ <% end %>
@@ -10,15 +10,5 @@ module FlasheeHelper
10
10
  # A string for the css class
11
11
  #
12
12
  def flashee_for flash_type
13
- case flash_type.to_s
14
- when "success"
15
- "success"
16
- when "error"
17
- "error"
18
- when "alert"
19
- "alert"
20
- else
21
- flash_type.to_s
22
- end
23
13
  end
24
14
  end
@@ -0,0 +1,67 @@
1
+ <% if @mode == "basic" %>
2
+ module FlasheeHelper
3
+ def flashee_for flash_type
4
+ case flash_type.to_s
5
+ when "success"
6
+ "success"
7
+ when "error"
8
+ "error"
9
+ when "alert"
10
+ "alert"
11
+ else
12
+ flash_type.to_s
13
+ end
14
+ end
15
+ end
16
+ <% elsif @mode == "bootstrap" %>
17
+ module FlasheeHelper
18
+ def flashee_for flash_type
19
+ case flash_type.to_s
20
+ when "success"
21
+ "alert alert-success"
22
+ when "error"
23
+ "alert alert-danger"
24
+ when "alert"
25
+ "alert alert-warning"
26
+ when "info"
27
+ "alert alert-primary"
28
+ else
29
+ flash_type.to_s
30
+ end
31
+ end
32
+ end
33
+ <% elsif @mode == "foundation" %>
34
+ module FlasheeHelper
35
+ def flashee_for flash_type
36
+ case flash_type.to_s
37
+ when "success"
38
+ "alert-box success"
39
+ when "error"
40
+ "alert-box alert"
41
+ when "alert"
42
+ "alert-box warning"
43
+ when "info"
44
+ "alert-box info"
45
+ else
46
+ flash_type.to_s
47
+ end
48
+ end
49
+ end
50
+ <% elsif @mode == "bulma" %>
51
+ module FlasheeHelper
52
+ def flashee_for flash_type
53
+ case flash_type.to_s
54
+ when "success"
55
+ "notification is-success"
56
+ when "error"
57
+ "notification is-danger"
58
+ when "alert"
59
+ "notification is-warning"
60
+ when "info"
61
+ "notification is-primary"
62
+ else
63
+ flash_type.to_s
64
+ end
65
+ end
66
+ end
67
+ <% end %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flashee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Burns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-01 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Rails helper to style flash messages
42
56
  email:
43
57
  - jb@jbernsie.me
@@ -48,6 +62,7 @@ files:
48
62
  - README.md
49
63
  - Rakefile
50
64
  - lib/flashee.rb
65
+ - lib/flashee/builders.rb
51
66
  - lib/flashee/railtie.rb
52
67
  - lib/flashee/version.rb
53
68
  - lib/generators/flashee/install/bootstrap_generator.rb
@@ -57,10 +72,8 @@ files:
57
72
  - lib/generators/flashee/install_generator.rb
58
73
  - lib/templates/_flash_messages.html.erb
59
74
  - lib/templates/_flash_messages_foundation.html.erb
60
- - lib/templates/flashee_bootstrap_helper.rb
61
- - lib/templates/flashee_bulma_helper.rb
62
- - lib/templates/flashee_foundation_helper.rb
63
75
  - lib/templates/flashee_helper.rb
76
+ - lib/templates/flashee_helper.rb.erb
64
77
  homepage: https://github.com/jbernsie/flashee
65
78
  licenses:
66
79
  - MIT
@@ -1,16 +0,0 @@
1
- module FlasheeHelper
2
- def flashee_for flash_type
3
- case flash_type.to_s
4
- when "success"
5
- "alert alert-success"
6
- when "error"
7
- "alert alert-danger"
8
- when "alert"
9
- "alert alert-warning"
10
- when "info"
11
- "alert alert-primary"
12
- else
13
- flash_type.to_s
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module FlasheeHelper
2
- def flashee_for flash_type
3
- case flash_type.to_s
4
- when "success"
5
- "notification is-success"
6
- when "error"
7
- "notification is-danger"
8
- when "alert"
9
- "notification is-warning"
10
- when "info"
11
- "notification is-primary"
12
- else
13
- flash_type.to_s
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module FlasheeHelper
2
- def flashee_for flash_type
3
- case flash_type.to_s
4
- when "success"
5
- "alert-box success"
6
- when "error"
7
- "alert-box alert"
8
- when "alert"
9
- "alert-box warning"
10
- when "info"
11
- "alert-box info"
12
- else
13
- flash_type.to_s
14
- end
15
- end
16
- end