haml-rails 1.0.0 → 2.1.0

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
- SHA1:
3
- metadata.gz: fd4e782b975a13cfd5ef38f19650e2c9028dc006
4
- data.tar.gz: f8ba9eb9204a69d693bb6889ff11179f99fd5055
2
+ SHA256:
3
+ metadata.gz: c92791c4d02db70961e18508ae709bd86a9bae7325eb8afd6f7c8286c3d7824f
4
+ data.tar.gz: 0a4ad454a0c72f707159ee95c4a529cdf3c4194a64b13a690b475a1ff72687c1
5
5
  SHA512:
6
- metadata.gz: 89b10fb1366277ed37d3022d109a94827105eecbfcb60e44adfb605b57beacd8620a1f647812deb83ab6d2a0d5e4ee4eebd99ef1fe91869b22593451d02da9a0
7
- data.tar.gz: eeb501849dc14d680c872c5ca98bc4fe4fc0c16071836e37810ae2d06afc2a0454db610c9807a017086078ed0cae16dbf7a074536b2749c8497f0c2f99a06196
6
+ metadata.gz: e3232df46c3893fab9e0cec861ddb8d88bfd9fe3c40bc0e05a4c67915ef58bd4f54ff9e39a4cc040853cd42fe421942629a46f31294b1622098047e42d5a89a2
7
+ data.tar.gz: d25c5e7ff3ef9fb3e0879129ffe8689c9e06d2b945b404d2be3775573142645304189440deb9ca755b1d5684df1775ea707acd046d6c31f77abdb750bcd98677
@@ -0,0 +1,64 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version:
23
+ - 3.1
24
+ - 3.0
25
+ - 2.7
26
+ - jruby
27
+ gemfile:
28
+ - rails_7_0
29
+ - rails_6_1
30
+ - rails_6_0
31
+
32
+ include:
33
+ - ruby-version: 2.7
34
+ gemfile: rails_5_2
35
+ - ruby-version: 2.7
36
+ gemfile: rails_5_1
37
+
38
+ - ruby-version: 2.6
39
+ gemfile: rails_6_1
40
+ - ruby-version: 2.6
41
+ gemfile: rails_6_0
42
+ - ruby-version: 2.6
43
+ gemfile: rails_5_2
44
+ - ruby-version: 2.6
45
+ gemfile: rails_5_1
46
+
47
+ exclude:
48
+ - ruby-version: jruby
49
+ gemfile: rails_7_0
50
+
51
+ env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
52
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
53
+ steps:
54
+ - uses: actions/checkout@v3
55
+ - name: Set up Ruby
56
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
57
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
58
+ uses: ruby/setup-ruby@v1
59
+ # uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
60
+ with:
61
+ ruby-version: ${{ matrix.ruby-version }}
62
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
63
+ - name: Run tests
64
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -4,3 +4,4 @@
4
4
  gemfiles/*.lock
5
5
  tmp/
6
6
  /vendor/bundle
7
+ log
data/Appraisals CHANGED
@@ -1,15 +1,19 @@
1
- appraise "rails_4_0" do
2
- gem "rails", "~> 4.0.1"
1
+ appraise "rails_5_1" do
2
+ gem "rails", "~> 5.1.0"
3
3
  end
4
4
 
5
- appraise "rails_4_1" do
6
- gem "rails", "4.1"
5
+ appraise "rails_5_2" do
6
+ gem "rails", "~> 5.2.0"
7
7
  end
8
8
 
9
- appraise "rails_4_2" do
10
- gem "rails", "4.2"
9
+ appraise "rails_6_0" do
10
+ gem "rails", "~> 6.0.0"
11
11
  end
12
12
 
13
- appraise "rails_5_0" do
14
- gem "rails", "5.0"
13
+ appraise "rails_6_1" do
14
+ gem "rails", "~> 6.1.0"
15
+ end
16
+
17
+ appraise "rails_7_0" do
18
+ gem "rails", "~> 7.0.0"
15
19
  end
data/Gemfile CHANGED
@@ -3,6 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in haml-rails.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rubysl', '~> 2.0', platforms: :rbx
7
- gem 'minitest', platforms: :rbx
8
6
  gem 'html2haml'
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Haml-rails
2
+ [![Build Status](https://travis-ci.org/haml/haml-rails.svg)](https://travis-ci.org/haml/haml-rails)
2
3
 
3
- Haml-rails provides Haml generators for Rails 4. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah.
4
+ Haml-rails provides Haml generators for Rails 5. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah.
4
5
 
5
6
  To use it, add this line to your Gemfile:
6
7
 
7
- gem "haml-rails", "~> 0.9"
8
+ gem "haml-rails", "~> 2.0"
8
9
 
9
10
  This ensures that:
10
11
 
@@ -30,19 +31,29 @@ start using `app/views/layouts/application.html.haml` instead.
30
31
 
31
32
  If you want to convert all of your .erb views into .haml, you can do so using the following command:
32
33
 
33
- $ rake haml:erb2haml
34
+ $ rails haml:erb2haml
34
35
 
35
36
  If you already have .haml files for one or more of the .erb files, the rake task will give you the option of either
36
37
  replacing these .haml files or leaving them in place.
37
38
 
38
39
  Once the task is complete, you will have the option of deleting the original .erb files. Unless you are under
39
- version control, it is recommended that you decline this option.
40
+ version control, it is recommended that you decline this option. If you are running in a script, you can use
41
+ an environment variable to answer this question.
42
+
43
+ $ HAML_RAILS_DELETE_ERB=true rails haml:erb2haml
44
+
45
+ Running the above will not prompt for the question and will delete the original .erb files. Setting this value to
46
+ false will also not prompt, however, will leave the .erb files intact.
40
47
 
41
48
  ### Older versions of Rails
42
49
 
43
- The current version of Haml-rails requires 4.0.1 or later.
50
+ The current version of Haml-rails requires Rails 5.1 or later.
51
+
52
+ Haml-rails version 1.0.0 is the last version to support Rails 4. To use it, add this line to your Gemfile:
44
53
 
45
- Haml-rails version 0.4 is the last version to support Rails 3. To use it, add this line to your Gemfile:
54
+ gem "haml-rails", "~> 1.0.0"
55
+
56
+ For Rails 3, use haml-rails version 0.4 by adding this line to your Gemfile instead:
46
57
 
47
58
  gem "haml-rails", "~> 0.4.0"
48
59
 
@@ -50,10 +61,6 @@ Haml-rails version 0.4 is the last version to support Rails 3. To use it, add th
50
61
 
51
62
  Haml generators originally from [rails3-generators](http://github.com/indirect/rails3-generators), and written by José Valim, André Arko, Paul Barry, Anuj Dutta, Louis T, and Chris Rhoden. Tests originally written by Louis T.
52
63
 
53
- ### Code Status
54
-
55
- [![Build Status](https://travis-ci.org/indirect/haml-rails.svg)](https://travis-ci.org/indirect/haml-rails)
56
-
57
64
  ### License
58
65
 
59
66
  Ruby license or MIT license, take your pick.
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "html2haml"
6
+ gem "rails", "~> 5.1.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "html2haml"
6
+ gem "rails", "~> 5.2.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "html2haml"
6
+ gem "rails", "~> 6.0.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "html2haml"
6
+ gem "rails", "~> 6.1.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "html2haml"
6
+ gem "rails", "~> 7.0.0"
7
+
8
+ gemspec path: "../"
data/haml-rails.gemspec CHANGED
@@ -7,24 +7,24 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["André Arko"]
9
9
  s.email = ["andre@arko.net"]
10
- s.homepage = "http://github.com/indirect/haml-rails"
10
+ s.homepage = "https://github.com/haml/haml-rails"
11
11
  s.summary = "let your Gemfile do the configuring"
12
- s.description = "Haml-rails provides Haml generators for Rails 4. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah."
12
+ s.description = "Haml-rails provides Haml generators for Rails 5. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah."
13
13
  s.licenses = ["MIT"]
14
14
 
15
- s.rubyforge_project = "haml-rails"
16
- s.required_rubygems_version = ">= 1.3.6"
15
+ s.required_rubygems_version = ">= 2.0.0"
16
+ s.required_ruby_version = ">= 2.3.0"
17
17
 
18
- s.add_dependency "haml", [">= 4.0.6", "< 6.0"]
19
- s.add_dependency "activesupport", [">= 4.0.1"]
20
- s.add_dependency "actionpack", [">= 4.0.1"]
21
- s.add_dependency "railties", [">= 4.0.1"]
22
- s.add_dependency "html2haml", [">= 1.0.1"]
23
-
24
- s.add_development_dependency "rails", [">= 4.0.1"]
25
- s.add_development_dependency "bundler", "~> 1.7"
18
+ s.add_dependency "haml", [">= 4.0.6"]
19
+ s.add_dependency "activesupport", [">= 5.1"]
20
+ s.add_dependency "actionpack", [">= 5.1"]
21
+ s.add_dependency "railties", [">= 5.1"]
22
+
23
+ s.add_development_dependency "html2haml", [">= 1.0.1"]
24
+ s.add_development_dependency "rails", [">= 5.1"]
25
+ s.add_development_dependency "bundler"
26
26
  s.add_development_dependency "rake"
27
- s.add_development_dependency 'appraisal', '~> 1.0'
27
+ s.add_development_dependency 'appraisal'
28
28
 
29
29
  s.files = `git ls-files`.split("\n")
30
30
  s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
@@ -5,12 +5,11 @@ module Haml
5
5
  class ControllerGenerator < Erb::Generators::ControllerGenerator
6
6
  source_root File.expand_path("../templates", __FILE__)
7
7
 
8
- protected
8
+ private
9
9
 
10
10
  def handler
11
11
  :haml
12
12
  end
13
-
14
13
  end
15
14
  end
16
15
  end
@@ -1,42 +1,14 @@
1
- require 'generators/haml/controller/controller_generator'
1
+ require 'rails/generators/erb/mailer/mailer_generator'
2
2
 
3
3
  module Haml
4
4
  module Generators
5
- class MailerGenerator < ControllerGenerator
5
+ class MailerGenerator < Erb::Generators::MailerGenerator
6
6
  source_root File.expand_path("../templates", __FILE__)
7
7
 
8
- def copy_view_files
9
- if ::Rails.version.to_s >= "4.2.0"
10
- view_base_path = File.join("app/views", class_path, file_name)
11
- empty_directory view_base_path
8
+ private
12
9
 
13
- if self.behavior == :invoke
14
- formats.each do |format|
15
- layout_path = File.join("app/views/layouts", filename_with_extensions("mailer", format))
16
- template filename_with_extensions(:layout, format), layout_path
17
- end
18
- end
19
-
20
- actions.each do |action|
21
- @action = action
22
-
23
- formats.each do |format|
24
- @path = File.join(view_base_path, filename_with_extensions(action, format))
25
- template filename_with_extensions(:view, format), @path
26
- end
27
- end
28
- else
29
- super
30
- end
31
- end
32
-
33
- protected
34
- def format
35
- :text
36
- end
37
-
38
- def formats
39
- [:text, :html]
10
+ def handler
11
+ :haml
40
12
  end
41
13
  end
42
14
  end
@@ -1,3 +1,8 @@
1
+ !!!
1
2
  %html
3
+ %head
4
+ %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/
5
+ :css
6
+ /* Email styles need to be inline */
2
7
  %body
3
8
  = yield
@@ -21,7 +21,7 @@ module Haml
21
21
  end
22
22
  end
23
23
 
24
- protected
24
+ private
25
25
 
26
26
  def available_views
27
27
  %w(index edit show new)
@@ -30,7 +30,6 @@ module Haml
30
30
  def handler
31
31
  :haml
32
32
  end
33
-
34
33
  end
35
34
  end
36
35
  end
@@ -1,5 +1,5 @@
1
1
  module Haml
2
2
  module Rails
3
- VERSION = "1.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
data/lib/haml-rails.rb CHANGED
@@ -4,8 +4,6 @@ require 'haml/railtie'
4
4
 
5
5
  module Haml
6
6
  module Rails
7
- class Engine < ::Rails::Engine
8
- end
9
7
  class Railtie < ::Rails::Railtie
10
8
  config.app_generators.template_engine :haml
11
9
 
@@ -46,7 +44,13 @@ module Haml
46
44
  # provided directly by railties 3.2..4.1 but was dropped in 4.2.
47
45
  if Gem::Requirement.new(">= 4.2").satisfied_by?(Gem::Version.new(::Rails.version))
48
46
  initializer 'haml_rails.configure_source_annotation' do
49
- SourceAnnotationExtractor::Annotation.register_extensions('haml') do |tag|
47
+ annotation_class = if ::Rails::VERSION::STRING >= '6.0'
48
+ require 'rails/source_annotation_extractor'
49
+ ::Rails::SourceAnnotationExtractor::Annotation
50
+ else
51
+ ::SourceAnnotationExtractor::Annotation
52
+ end
53
+ annotation_class.register_extensions('haml') do |tag|
50
54
  /\s*-#\s*(#{tag}):?\s*(.*)/
51
55
  end
52
56
  end
@@ -4,7 +4,6 @@ require 'shellwords'
4
4
  module Haml
5
5
  module Generators
6
6
  class ApplicationLayoutGenerator < ::Rails::Generators::Base
7
-
8
7
  HTML_LAYOUT_PATH = 'app/views/layouts/application.html.erb'
9
8
  HAML_LAYOUT_PATH = 'app/views/layouts/application.html.haml'
10
9
 
@@ -27,9 +26,7 @@ module Haml
27
26
  else
28
27
  puts "Error! There is no file named app/views/layouts/application.html.erb."
29
28
  end
30
-
31
29
  end
32
-
33
30
  end
34
31
  end
35
32
  end
@@ -10,6 +10,8 @@ namespace :haml do
10
10
  exit
11
11
  end
12
12
 
13
+ erb_files_to_convert = erb_files.dup
14
+
13
15
  haml_files_w_out_ext = haml_files.map { |f| f.gsub(/\.haml\z/, '') }
14
16
 
15
17
  # Get a list of all those erb files that already seem to have .haml equivalents
@@ -22,21 +24,24 @@ namespace :haml do
22
24
  puts "Some of your .html.erb files seem to already have .haml equivalents:"
23
25
  already_existing.map { |f| puts "\t#{f}" }
24
26
 
25
- # Ask the user whether he/she would like to overwrite them.
26
- begin
27
- puts "Would you like to overwrite these .haml files? (y/n)"
28
- should_overwrite = STDIN.gets.chomp.downcase[0]
29
- end until ['y', 'n'].include?(should_overwrite)
27
+ if ENV.has_key?("HAML_RAILS_OVERWRITE_HAML") && (ENV["HAML_RAILS_OVERWRITE_HAML"] == "false")
28
+ should_overwrite = 'n'
29
+ else
30
+ # Ask the user whether he/she would like to overwrite them.
31
+ begin
32
+ puts "Would you like to overwrite these .haml files? (y/n)"
33
+ should_overwrite = STDIN.gets.chomp.downcase[0]
34
+ end until ['y', 'n'].include?(should_overwrite)
35
+ end
30
36
  puts '-'*80
31
37
 
32
38
  # If we are not overwriting, remove each already_existing from our erb_files list
33
39
  if should_overwrite == 'n'
34
- erb_files = erb_files - already_existing
40
+ erb_files_to_convert = erb_files - already_existing
35
41
 
36
- if erb_files.empty?
42
+ if erb_files_to_convert.empty?
37
43
  # It is possible no .erb files remain, after we remove already_existing
38
- puts "No .erb files remain. Task will now exit."
39
- return
44
+ puts "No .erb files to convert"
40
45
  end
41
46
  else
42
47
  # Delete the current .haml
@@ -44,7 +49,7 @@ namespace :haml do
44
49
  end
45
50
  end
46
51
 
47
- erb_files.each do |file|
52
+ erb_files_to_convert.each do |file|
48
53
  puts "Generating HAML for #{file}..."
49
54
  `html2haml #{file} #{file.gsub(/\.erb\z/, '.haml')}`
50
55
  end
@@ -52,16 +57,19 @@ namespace :haml do
52
57
  puts '-'*80
53
58
 
54
59
  puts "HAML generated for the following files:"
55
- erb_files.each do |file|
60
+ erb_files_to_convert.each do |file|
56
61
  puts "\t#{file}"
57
62
  end
58
63
 
59
64
  puts '-'*80
60
- begin
61
- puts 'Would you like to delete the original .erb files? (This is not recommended unless you are under version control.) (y/n)'
62
- should_delete = STDIN.gets.chomp.downcase[0]
63
- end until ['y', 'n'].include?(should_delete)
64
-
65
+ if ENV.has_key?("HAML_RAILS_DELETE_ERB") && (ENV["HAML_RAILS_DELETE_ERB"] == "true")
66
+ should_delete = 'y'
67
+ else
68
+ begin
69
+ puts 'Would you like to delete the original .erb files? (This is not recommended unless you are under version control.) (y/n)'
70
+ should_delete = STDIN.gets.chomp.downcase[0]
71
+ end until ['y', 'n'].include?(should_delete)
72
+ end
65
73
  if should_delete == 'y'
66
74
  puts "Deleting original .erb files."
67
75
  File.delete(*erb_files)
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
- require 'lib/generators/haml/testing_helper'
2
+ require 'rails/generators/rails/controller/controller_generator'
3
+ require 'generators/haml/controller/controller_generator'
3
4
 
4
5
  class Haml::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
5
6
  destination Rails.root
@@ -11,8 +12,8 @@ class Haml::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
11
12
  arguments %w(Account foo bar --template-engine haml)
12
13
 
13
14
  test "should invoke haml engine" do
14
- run_generator
15
+ run_generator
15
16
  assert_file "app/views/account/foo.html.haml"
16
17
  assert_file "app/views/account/bar.html.haml"
17
- end
18
+ end
18
19
  end
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
- require 'lib/generators/haml/testing_helper'
2
+ require 'rails/generators/mailer/mailer_generator'
3
+ require 'generators/haml/mailer/mailer_generator'
3
4
 
4
5
  class Haml::Generators::MailerGeneratorTest < Rails::Generators::TestCase
5
6
  destination File.join(Rails.root)
@@ -13,34 +14,74 @@ class Haml::Generators::MailerGeneratorTest < Rails::Generators::TestCase
13
14
  run_generator
14
15
 
15
16
  if ::Rails.version.to_s >= '4.2'
16
-
17
17
  assert_file "app/views/layouts/mailer.text.haml" do |view|
18
- assert_match /\= yield/, view
18
+ assert_match(/\= yield/, view)
19
19
  end
20
20
 
21
21
  assert_file "app/views/layouts/mailer.html.haml" do |view|
22
- assert_match /\= yield/, view
22
+ assert_match(/\= yield/, view)
23
23
  end
24
24
 
25
- assert_file "app/views/notifier/foo.html.haml" do |view|
26
- assert_match %r(app/views/notifier/foo\.html\.haml), view
27
- assert_match /\= @greeting/, view
25
+ assert_file "app/views/notifier_mailer/foo.html.haml" do |view|
26
+ assert_match %r(app/views/notifier_mailer/foo\.html\.haml), view
27
+ assert_match(/\= @greeting/, view)
28
28
  end
29
29
 
30
- assert_file "app/views/notifier/bar.html.haml" do |view|
31
- assert_match %r(app/views/notifier/bar\.html\.haml), view
32
- assert_match /\= @greeting/, view
30
+ assert_file "app/views/notifier_mailer/bar.html.haml" do |view|
31
+ assert_match %r(app/views/notifier_mailer/bar\.html\.haml), view
32
+ assert_match(/\= @greeting/, view)
33
+ end
34
+
35
+ assert_file "app/views/notifier_mailer/foo.text.haml" do |view|
36
+ assert_match %r(app/views/notifier_mailer/foo\.text\.haml), view
37
+ assert_match(/\= @greeting/, view)
38
+ end
39
+
40
+ assert_file "app/views/notifier_mailer/bar.text.haml" do |view|
41
+ assert_match %r(app/views/notifier_mailer/bar\.text\.haml), view
42
+ assert_match(/\= @greeting/, view)
43
+ end
44
+ else
45
+ if ::Rails.version.to_s >= '4.1'
46
+ assert_file "app/views/notifier/foo.html.haml" do |view|
47
+ assert_match %r(app/views/notifier/foo\.html\.haml), view
48
+ assert_match(/\= @greeting/, view)
49
+ end
50
+
51
+ assert_file "app/views/notifier/bar.html.haml" do |view|
52
+ assert_match %r(app/views/notifier/bar\.html\.haml), view
53
+ assert_match(/\= @greeting/, view)
54
+ end
33
55
  end
34
- end
35
56
 
36
- assert_file "app/views/notifier/foo.text.haml" do |view|
37
- assert_match %r(app/views/notifier/foo\.text\.haml), view
38
- assert_match /\= @greeting/, view
57
+ assert_file "app/views/notifier/foo.text.haml" do |view|
58
+ assert_match %r(app/views/notifier/foo\.text\.haml), view
59
+ assert_match(/\= @greeting/, view)
60
+ end
61
+
62
+ assert_file "app/views/notifier/bar.text.haml" do |view|
63
+ assert_match %r(app/views/notifier/bar\.text\.haml), view
64
+ assert_match(/\= @greeting/, view)
65
+ end
39
66
  end
67
+ end
68
+
69
+ test 'suffix is not duplicated' do
70
+ if ::Rails.version.to_s >= '4.2'
71
+ run_generator ['notifier_mailer', 'foo', 'bar', '--template-engine', 'haml']
72
+
73
+ assert_no_file 'app/views/notifier_mailer_mailer/'
74
+ assert_file 'app/views/notifier_mailer/'
75
+
76
+ assert_no_file 'app/views/notifier_mailer_mailer/foo.text.haml'
77
+ assert_file 'app/views/notifier_mailer/foo.text.haml'
78
+ assert_no_file 'app/views/notifier_mailer_mailer/foo.html.haml'
79
+ assert_file 'app/views/notifier_mailer/foo.html.haml'
40
80
 
41
- assert_file "app/views/notifier/bar.text.haml" do |view|
42
- assert_match %r(app/views/notifier/bar\.text\.haml), view
43
- assert_match /\= @greeting/, view
81
+ assert_no_file 'app/views/notifier_mailer_mailer/bar.text.haml'
82
+ assert_file 'app/views/notifier_mailer/bar.text.haml'
83
+ assert_no_file 'app/views/notifier_mailer_mailer/bar.html.haml'
84
+ assert_file 'app/views/notifier_mailer/bar.html.haml'
44
85
  end
45
86
  end
46
87
  end
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
- require 'lib/generators/haml/testing_helper'
2
+ require 'rails/generators/rails/scaffold/scaffold_generator'
3
+ require 'generators/haml/scaffold/scaffold_generator'
3
4
 
4
5
  class Haml::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
5
6
  destination File.join(Rails.root)
data/test/test_helper.rb CHANGED
@@ -1,79 +1,47 @@
1
1
  require 'rubygems'
2
2
  require 'minitest/autorun'
3
- require 'rails/all'
3
+ require 'action_pack'
4
+ require 'action_controller'
5
+ require 'action_view'
6
+ require 'rails'
4
7
  require 'rails/generators'
5
8
  require 'rails/generators/test_case'
9
+ Bundler.require(:default)
6
10
 
7
11
  class TestApp < Rails::Application
8
12
  config.root = File.dirname(__FILE__)
13
+ config.eager_load = false
9
14
  end
10
15
 
11
16
  module Rails
12
17
  def self.root
13
- @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'rails'))
18
+ @root ||= Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'rails')))
14
19
  end
15
20
  end
16
21
 
17
- # Call configure to load the settings from
18
- # Rails.application.config.generators to Rails::Generators
19
- Rails.application.load_generators
22
+ TestApp.initialize!
20
23
 
21
24
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
22
25
 
23
- def copy_routes
24
- routes = File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb')
25
- destination = File.join(Rails.root, "config")
26
- FileUtils.mkdir_p(destination)
27
- FileUtils.cp File.expand_path(routes), File.expand_path(destination)
28
- end
29
-
30
- # Asserts the given class exists in the given content. When a block is given,
31
- # it yields the content of the class.
32
- #
33
- # assert_file "test/functional/accounts_controller_test.rb" do |controller_test|
34
- # assert_class "AccountsControllerTest", controller_test do |klass|
35
- # assert_match /context "index action"/, klass
36
- # end
37
- # end
38
- #
39
- def assert_class(klass, content)
40
- assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/m, "Expected to have class #{klass}"
41
- yield $2.strip if block_given?
42
- end
43
-
44
- def generator_list
45
- {
46
- :rails => ['scaffold', 'controller', 'mailer'],
47
- :haml => ['scaffold', 'controller', 'mailer']
48
- }
49
- end
50
-
51
- def path_prefix(name)
52
- case name
53
- when :rails
54
- 'rails/generators'
55
- else
56
- 'generators'
57
- end
58
- end
26
+ module Haml
27
+ module Rails
28
+ module GeneratorTestHelpers
29
+ private
59
30
 
60
- def require_generators(generator_list)
61
- generator_list.each do |name, generators|
62
- generators.each do |generator_name|
63
- if name.to_s == 'rails' && generator_name.to_s == 'mailer'
64
- require File.join(path_prefix(name), generator_name.to_s, "#{generator_name}_generator")
65
- else
66
- require File.join(path_prefix(name), name.to_s, generator_name.to_s, "#{generator_name}_generator")
31
+ def copy_routes
32
+ routes = File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb')
33
+ destination = File.join(::Rails.root, "config")
34
+ FileUtils.mkdir_p(destination)
35
+ FileUtils.cp File.expand_path(routes), File.expand_path(destination)
67
36
  end
68
37
  end
69
38
  end
70
39
  end
71
- alias :require_generator :require_generators
72
40
 
73
- require_generators generator_list
41
+ ::Rails::Generators::TestCase.include Haml::Rails::GeneratorTestHelpers
74
42
 
75
43
  # Remove tmp directory when test suite is completed
76
- MiniTest::Unit.after_tests do
44
+ MiniTest.after_run do
77
45
  tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp'))
78
46
  FileUtils.rm_r(tmp_dir)
79
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2022-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.0.6
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,51 +24,48 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 4.0.6
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: activesupport
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: 4.0.1
33
+ version: '5.1'
40
34
  type: :runtime
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - ">="
45
39
  - !ruby/object:Gem::Version
46
- version: 4.0.1
40
+ version: '5.1'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: actionpack
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: 4.0.1
47
+ version: '5.1'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - ">="
59
53
  - !ruby/object:Gem::Version
60
- version: 4.0.1
54
+ version: '5.1'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: railties
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - ">="
66
60
  - !ruby/object:Gem::Version
67
- version: 4.0.1
61
+ version: '5.1'
68
62
  type: :runtime
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - ">="
73
67
  - !ruby/object:Gem::Version
74
- version: 4.0.1
68
+ version: '5.1'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: html2haml
77
71
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +73,7 @@ dependencies:
79
73
  - - ">="
80
74
  - !ruby/object:Gem::Version
81
75
  version: 1.0.1
82
- type: :runtime
76
+ type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
@@ -92,28 +86,28 @@ dependencies:
92
86
  requirements:
93
87
  - - ">="
94
88
  - !ruby/object:Gem::Version
95
- version: 4.0.1
89
+ version: '5.1'
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - ">="
101
95
  - !ruby/object:Gem::Version
102
- version: 4.0.1
96
+ version: '5.1'
103
97
  - !ruby/object:Gem::Dependency
104
98
  name: bundler
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
- - - "~>"
101
+ - - ">="
108
102
  - !ruby/object:Gem::Version
109
- version: '1.7'
103
+ version: '0'
110
104
  type: :development
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
- - - "~>"
108
+ - - ">="
115
109
  - !ruby/object:Gem::Version
116
- version: '1.7'
110
+ version: '0'
117
111
  - !ruby/object:Gem::Dependency
118
112
  name: rake
119
113
  requirement: !ruby/object:Gem::Requirement
@@ -132,17 +126,17 @@ dependencies:
132
126
  name: appraisal
133
127
  requirement: !ruby/object:Gem::Requirement
134
128
  requirements:
135
- - - "~>"
129
+ - - ">="
136
130
  - !ruby/object:Gem::Version
137
- version: '1.0'
131
+ version: '0'
138
132
  type: :development
139
133
  prerelease: false
140
134
  version_requirements: !ruby/object:Gem::Requirement
141
135
  requirements:
142
- - - "~>"
136
+ - - ">="
143
137
  - !ruby/object:Gem::Version
144
- version: '1.0'
145
- description: Haml-rails provides Haml generators for Rails 4. It also enables Haml
138
+ version: '0'
139
+ description: Haml-rails provides Haml generators for Rails 5. It also enables Haml
146
140
  as the templating engine for you, so you don't have to screw around in your own
147
141
  application.rb when your Gemfile already clearly indicated what templating engine
148
142
  you have installed. Hurrah.
@@ -152,17 +146,18 @@ executables: []
152
146
  extensions: []
153
147
  extra_rdoc_files: []
154
148
  files:
149
+ - ".github/workflows/ruby.yml"
155
150
  - ".gitignore"
156
- - ".travis.yml"
157
151
  - Appraisals
158
152
  - Gemfile
159
153
  - LICENSE
160
154
  - README.md
161
155
  - Rakefile
162
- - gemfiles/rails_4_0.gemfile
163
- - gemfiles/rails_4_1.gemfile
164
- - gemfiles/rails_4_2.gemfile
165
- - gemfiles/rails_5_0.gemfile
156
+ - gemfiles/rails_5_1.gemfile
157
+ - gemfiles/rails_5_2.gemfile
158
+ - gemfiles/rails_6_0.gemfile
159
+ - gemfiles/rails_6_1.gemfile
160
+ - gemfiles/rails_7_0.gemfile
166
161
  - haml-rails.gemspec
167
162
  - lib/generators/haml/controller/controller_generator.rb
168
163
  - lib/generators/haml/controller/templates/view.html.haml
@@ -185,13 +180,12 @@ files:
185
180
  - test/lib/generators/haml/controller_generator_test.rb
186
181
  - test/lib/generators/haml/mailer_generator_test.rb
187
182
  - test/lib/generators/haml/scaffold_generator_test.rb
188
- - test/lib/generators/haml/testing_helper.rb
189
183
  - test/test_helper.rb
190
- homepage: http://github.com/indirect/haml-rails
184
+ homepage: https://github.com/haml/haml-rails
191
185
  licenses:
192
186
  - MIT
193
187
  metadata: {}
194
- post_install_message:
188
+ post_install_message:
195
189
  rdoc_options: []
196
190
  require_paths:
197
191
  - lib
@@ -199,16 +193,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
193
  requirements:
200
194
  - - ">="
201
195
  - !ruby/object:Gem::Version
202
- version: '0'
196
+ version: 2.3.0
203
197
  required_rubygems_version: !ruby/object:Gem::Requirement
204
198
  requirements:
205
199
  - - ">="
206
200
  - !ruby/object:Gem::Version
207
- version: 1.3.6
201
+ version: 2.0.0
208
202
  requirements: []
209
- rubyforge_project: haml-rails
210
- rubygems_version: 2.6.11
211
- signing_key:
203
+ rubygems_version: 3.4.0.dev
204
+ signing_key:
212
205
  specification_version: 4
213
206
  summary: let your Gemfile do the configuring
214
207
  test_files: []
data/.travis.yml DELETED
@@ -1,30 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- before_install: "gem install bundler"
5
- rvm:
6
- - 2.4.1
7
- - 2.3.1
8
- - 2.2.5
9
- - 2.1
10
- - 2.0
11
- - 1.9.3
12
- - jruby-19mode
13
- gemfile:
14
- - gemfiles/rails_5_0.gemfile
15
- - gemfiles/rails_4_2.gemfile
16
- - gemfiles/rails_4_1.gemfile
17
- - gemfiles/rails_4_0.gemfile
18
- matrix:
19
- exclude:
20
- - rvm: 2.1
21
- gemfile: gemfiles/rails_5_0.gemfile
22
- - rvm: 2.0
23
- gemfile: gemfiles/rails_5_0.gemfile
24
- - rvm: 1.9.3
25
- gemfile: gemfiles/rails_5_0.gemfile
26
- - rvm: jruby-19mode
27
- gemfile: gemfiles/rails_5_0.gemfile
28
- - rvm: 1.9.3
29
- gemfile: gemfiles/rails_4_1.gemfile
30
- script: "bundle exec rake test"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rubysl", "~> 2.0", :platforms => :rbx
6
- gem "minitest", :platforms => :rbx
7
- gem "html2haml"
8
- gem "rails", "~> 4.0.1"
9
-
10
- gemspec :path => "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rubysl", "~> 2.0", :platforms => :rbx
6
- gem "minitest", :platforms => :rbx
7
- gem "html2haml"
8
- gem "rails", "4.1"
9
-
10
- gemspec :path => "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rubysl", "~> 2.0", :platforms => :rbx
6
- gem "minitest", :platforms => :rbx
7
- gem "html2haml"
8
- gem "rails", "4.2"
9
-
10
- gemspec :path => "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rubysl", "~> 2.0", :platforms => :rbx
6
- gem "minitest", :platforms => :rbx
7
- gem "html2haml"
8
- gem "rails", "5.0"
9
-
10
- gemspec :path => "../"
@@ -1 +0,0 @@
1
- require_generators :haml => ['scaffold', 'controller', 'mailer']