picocss-gem 0.2.1 → 0.2.2

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: 13514ec9b56c58860022d60ed268eaf16d235c247a8f789f7c72a4b28d407ab5
4
- data.tar.gz: 4629a1276f5ea200cbc496e3b9806a4eeb7a2784cc281ab44a375bdf8e2544bb
3
+ metadata.gz: dda0b7c4ff7a811d4f5dad392a493780f42181289dd7b234993af410e03a7936
4
+ data.tar.gz: e21d75b68d5588f28f2afc2900899b881069de3bff154c9e305b8f029940e090
5
5
  SHA512:
6
- metadata.gz: a16073ee2c4ff017559475a24bb9371c03efdadcb642a3c3f4a72c5b1870645e7fe0cfc1d7db211eaa1e8dc4ca564cd1c158d513a511b9bb07d2183a8fc543f6
7
- data.tar.gz: 0c318642b13fb9d4168b096732578e1f7a2590aa9f7838834479a17c08475fe5fb0f003d50a25de8843ecacf7493a6df8e54953734c2ed03e1192f2e261acc81
6
+ metadata.gz: 482bfc643e251360c2caaeb90f568b2b54a338f74a847105631fb97f28fe5af0a0f43fd333b854baff09cdf63e2df00621d6922ccf46a4591d107ad4d450b360
7
+ data.tar.gz: 4b67844061b8b25b58845e302ef26f180a5cc0e27562b9628e5ee1bc9ced9969ed01d6da6bc379c885919dc2919bb0e57a6ecefe9cd305f6c350dbb38da1583d
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "fileutils"
2
4
 
3
5
  module Picocss
@@ -7,21 +9,27 @@ module Picocss
7
9
  red pink fuchsia purple violet indigo blue
8
10
  cyan jade green lime yellow amber pumpkin
9
11
  orange sand grey zinc slate min
10
- ]
12
+ ].freeze
13
+
14
+ TEMPLATES_DIR = File.expand_path("../templates", __dir__)
11
15
 
12
16
  def self.generate(theme = "min")
13
17
  theme = "min" unless THEMES.include?(theme)
14
- puts "📦 Instalando tema PicoCSS '#{theme}' no projeto Bridgetown..."
15
18
 
16
- gem_path = Gem.loaded_specs["picocss-gem"].full_gem_path
17
- css_file = File.join(gem_path, "lib", "generators", "picocss", "templates", "pico.#{theme}.min.css")
19
+ css_file =
20
+ if theme == "min"
21
+ File.join(TEMPLATES_DIR, "pico.min.css")
22
+ else
23
+ File.join(TEMPLATES_DIR, "pico.#{theme}.min.css")
24
+ end
18
25
 
19
26
  dest_dir = "src/assets/stylesheets"
20
27
  FileUtils.mkdir_p(dest_dir)
21
28
  FileUtils.cp(css_file, File.join(dest_dir, "pico.css"))
22
29
 
23
- puts "✅ Tema '#{theme}' copiado para #{dest_dir}/pico.css"
30
+ puts "Tema '#{theme}' copiado para #{dest_dir}/pico.css"
24
31
  puts "Adicione no layout: <link rel='stylesheet' href='/assets/css/pico.css' />"
32
+ puts ""
25
33
  end
26
34
  end
27
35
  end
@@ -3,10 +3,10 @@ require "fileutils"
3
3
  module Picocss
4
4
  module Generators
5
5
  class TemplateLoginGenerator
6
- def self.generate
7
- gem_path = Gem.loaded_specs["picocss-gem"].full_gem_path
8
- template_file = File.join(gem_path, "lib", "generators", "picocss", "templates", "login.html.erb")
6
+ TEMPLATES_DIR ||= File.expand_path("../templates", __dir__)
9
7
 
8
+ def self.generate
9
+ template_file = File.join(TEMPLATES_DIR, "login.html.erb")
10
10
  dest_dir = "src/_includes"
11
11
  FileUtils.mkdir_p(dest_dir)
12
12
  FileUtils.cp(template_file, File.join(dest_dir, "login.html"))
@@ -1,12 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
1
4
  require "rails/generators"
2
5
 
3
6
  module Picocss
4
7
  module Generators
5
8
  class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path("templates", __dir__)
9
+ TEMPLATES_DIR = File.expand_path("../templates", __dir__)
10
+ source_root TEMPLATES_DIR
7
11
 
8
12
  def copy_stylesheet
9
- copy_file "pico.min.css", "app/assets/stylesheets/pico.min.css"
13
+ dest_dir = "app/assets/stylesheets"
14
+ FileUtils.mkdir_p(dest_dir)
15
+ FileUtils.cp(File.join(TEMPLATES_DIR, "pico.min.css"), File.join(dest_dir, "pico.css"))
16
+
17
+ say "✅ Tema padrão 'min' copiado para #{dest_dir}/pico.css", :green
18
+ say "Adicione no layout: <%= stylesheet_link_tag 'pico.css' %>", :yellow
10
19
  end
11
20
  end
12
21
  end
@@ -1,25 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "rails/generators"
5
+
1
6
  module Picocss
2
7
  module Generators
3
- themes = %w[
4
- red pink fuchsia purple violet indigo blue
5
- cyan jade green lime yellow amber pumpkin
6
- orange sand grey zinc slate
7
- ]
8
-
9
- themes.each do |color|
10
- klass_name = "Install#{color.capitalize}Generator"
11
-
12
- const_set(klass_name, Class.new(Rails::Generators::Base) do
13
- source_root File.expand_path("templates", __dir__)
14
-
15
- define_method(:copy_theme_file) do
16
- theme_file = "pico.#{color}.min.css"
17
- target_path = "app/assets/stylesheets/#{theme_file}"
18
- copy_file theme_file, target_path
19
- say "✅ Tema '#{color}' instalado com sucesso!", :green
20
- say "Adicione no layout: <%= stylesheet_link_tag '#{theme_file}' %>", :yellow
8
+ module Rails
9
+ class InstallThemeGenerator < ::Rails::Generators::Base
10
+ argument :theme, type: :string, default: "min", banner: "Theme name"
11
+ class_option :destination_root, type: :string, default: "app/assets/stylesheets"
12
+
13
+ THEMES = %w[
14
+ red pink fuchsia purple violet indigo blue
15
+ cyan jade green lime yellow amber pumpkin
16
+ orange sand grey zinc slate min
17
+ ].freeze
18
+
19
+ TEMPLATES_DIR = File.expand_path("../templates", __dir__)
20
+ source_root TEMPLATES_DIR
21
+
22
+ def copy_theme_file
23
+ theme_to_use = THEMES.include?(theme) ? theme : "min"
24
+
25
+ css_file =
26
+ if theme_to_use == "min"
27
+ File.join(TEMPLATES_DIR, "pico.min.css")
28
+ else
29
+ File.join(TEMPLATES_DIR, "pico.#{theme_to_use}.min.css")
30
+ end
31
+
32
+ dest_dir = options[:destination_root]
33
+ FileUtils.mkdir_p(dest_dir)
34
+ FileUtils.cp(css_file, File.join(dest_dir, "pico.css"))
35
+
36
+ puts "Tema '#{theme_to_use}' copiado para #{dest_dir}/pico.css"
37
+ puts "Adicione no layout: <%= stylesheet_link_tag 'pico.css' %>"
38
+ puts ""
21
39
  end
22
- end)
40
+ end
23
41
  end
24
42
  end
25
43
  end
@@ -1,7 +1,21 @@
1
- class Picocss::TemplateLoginGenerator < Rails::Generators::Base
2
- source_root File.expand_path("templates", __dir__)
1
+ # frozen_string_literal: true
3
2
 
4
- def copy_login_template
5
- copy_file "login.html.erb", "app/views/sessions/new.html.erb"
3
+ require "fileutils"
4
+ require "rails/generators"
5
+
6
+ module Picocss
7
+ module Generators
8
+ class TemplateLoginGenerator < Rails::Generators::Base
9
+ TEMPLATES_DIR = File.expand_path("../templates", __dir__)
10
+ source_root TEMPLATES_DIR
11
+
12
+ def copy_login_template
13
+ dest_dir = "app/views/sessions"
14
+ FileUtils.mkdir_p(dest_dir)
15
+ FileUtils.cp(File.join(TEMPLATES_DIR, "login.html.erb"), File.join(dest_dir, "new.html.erb"))
16
+
17
+ say "✅ Template de login copiado para #{dest_dir}/new.html.erb", :green
18
+ end
19
+ end
6
20
  end
7
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Picocss
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picocss-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - douglas-vitoriano