gretel 4.0.2 → 4.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
2
  SHA256:
3
- metadata.gz: 7c9acb3e1bababfdec129ddf28041956e1d9cedab4168612403bc45e6f6be2ce
4
- data.tar.gz: 5d8a64b3af412616443a6f2fae688b3cff882cd4e39aebeb071c551a573fc2ca
3
+ metadata.gz: d28cb34acf4eef47659c295f4dfd63b442fa7181552de3716015eb4f2d070c8f
4
+ data.tar.gz: e8cb450b18ea1f00dffc6e580655931109ddd1389cafce109b1ab597e832761a
5
5
  SHA512:
6
- metadata.gz: dfd59117fcad2e1459647cbf42bb52fb063fc49b49070ae5a8f7372b58f4f95317036597ca474f7c00fb17dcbd1809f9d503066495cd8d52d510342db6ad95a0
7
- data.tar.gz: 4466f946506b36678860eb17b922243fbcd4bc848f6c8fcd93ebb588dae02df4f9a78c934aa884d9a1dedf586fbc721128591696f887bafa9c88372859eb2877
6
+ metadata.gz: a7b13ae376b35bfc5508472752bfac4cd98022a19d7e00e0c8535ba1aa7c44e07a5f5068d98c2ca364ad6d1f25adc8671090ef9ac7f2879328273c94a8ac4e1b
7
+ data.tar.gz: 0e1451f51c1c2742c339a0b08489b2b503c3c751402eb432d0498b1b9ad2b44a1be2abf568c5f7387fed67aca07d959eb5bf9a41eb90d25f7b50beea3b6e09b4
@@ -5,10 +5,13 @@ rvm:
5
5
  - 2.6
6
6
  - 2.5
7
7
  env:
8
- - RAILS="~> '5.1.0'"
9
- - RAILS="~> '5.2.0'"
10
- - RAILS="~> '6.0.0'"
8
+ - RAILS_VERSION="~> 5.1.0"
9
+ - RAILS_VERSION="~> 5.2.0"
10
+ - RAILS_VERSION="~> 6.0.0"
11
+ - RAILS_VERSION="master"
11
12
  before_script:
12
13
  - "cd spec/dummy; rake db:migrate; rake db:test:prepare; cd ../.."
14
+ after_script:
15
+ - "cat coverage/coverage.txt"
13
16
  notifications:
14
17
  email: false
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 4.1.0
4
+ * Depends only `railties` and `actionview`, not `rails` (via #7)
5
+ * Include `Gretel::ViewHelpers` module in `ActiveSupport.on_load(:action_view)` block
6
+ * Fix ruby 2.7 keywords warning (via #24, thanks @aki77)
7
+ * Fix multithreaded environment issue (via #13)
8
+ * `breadcrumbs.rb` is now evaluated in a instance of `Gretel::Crumbs::Builder`. If you want to call methods from `breadcrumbs.rb` other than `crumb`, `crumbs` and `crumb_defined?`, you need to call it via full reference like `Gretel::Crumbs.xxxx`
9
+
3
10
  ## Version 4.0.2
4
11
  * The return value of `breadcrumbs` is `html_safe` now (via #22)
5
12
  * For the slim template engine users: You don't need to use `==` instead of `=` for `breadcrumbs`
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  rails_version = ENV['RAILS_VERSION'] || '>= 0'
6
- gem 'rails', rails_version
6
+ gem 'rails', rails_version == 'master' ? { github: 'rails/rails' } : rails_version
@@ -15,7 +15,8 @@ Gem::Specification.new do |gem|
15
15
  end
16
16
  gem.require_paths = ["lib"]
17
17
 
18
- gem.add_dependency "rails", ">= 5.1"
18
+ gem.add_dependency "railties", [">= 5.1", "< 7.0"]
19
+ gem.add_dependency "actionview", [">= 5.1", "< 7.0"]
19
20
  gem.add_development_dependency "sqlite3"
20
21
  gem.add_development_dependency "rspec-rails"
21
22
  gem.add_development_dependency "simplecov"
@@ -1,10 +1,6 @@
1
1
  require 'gretel/version'
2
2
  require 'gretel/resettable'
3
- require 'gretel/crumbs'
4
- require 'gretel/crumb'
5
- require 'gretel/link'
6
- require 'gretel/renderer'
7
- require 'gretel/view_helpers'
3
+ require 'gretel/railtie'
8
4
 
9
5
  module Gretel
10
6
  class << self
@@ -57,5 +53,3 @@ module Gretel
57
53
  end
58
54
  end
59
55
  end
60
-
61
- ActionView::Base.send :include, Gretel::ViewHelpers
@@ -1,3 +1,5 @@
1
+ require 'gretel/link'
2
+
1
3
  module Gretel
2
4
  class Crumb
3
5
  # Initializes a new crumb from the given +key+.
@@ -13,7 +15,7 @@ module Gretel
13
15
  raise ArgumentError, "Breadcrumb :#{key} not found." unless block
14
16
  @key = key
15
17
  @context = context
16
- instance_exec *args, &block
18
+ instance_exec(*args, &block)
17
19
  end
18
20
 
19
21
  # Sets link of the breadcrumb.
@@ -29,7 +31,7 @@ module Gretel
29
31
 
30
32
  # Transform objects to real paths.
31
33
  url = url_for(url) if url
32
-
34
+
33
35
  links << Gretel::Link.new(key, text, url, options)
34
36
  end
35
37
 
@@ -64,5 +66,6 @@ module Gretel
64
66
  def method_missing(method, *args, &block)
65
67
  context.send(method, *args, &block)
66
68
  end
69
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
67
70
  end
68
71
  end
@@ -3,11 +3,6 @@ module Gretel
3
3
  class << self
4
4
  include Resettable
5
5
 
6
- # Stores the supplied block for later use.
7
- def crumb(key, &block)
8
- crumbs[key] = block
9
- end
10
-
11
6
  # Returns a hash of all stored crumb blocks.
12
7
  def crumbs
13
8
  @crumbs ||= {}
@@ -20,14 +15,15 @@ module Gretel
20
15
 
21
16
  # Loads the breadcrumb configuration files.
22
17
  def load_breadcrumbs
23
- @crumbs = {}
18
+ builder = Builder.new
24
19
 
25
20
  loaded_file_mtimes.clear
26
21
  breadcrumb_files.each do |file|
27
- instance_eval open(file).read, file
22
+ builder.instance_eval open(file).read, file
28
23
  loaded_file_mtimes << File.mtime(file)
29
24
  end
30
25
 
26
+ @crumbs = builder.crumbs
31
27
  @loaded = true
32
28
  end
33
29
 
@@ -59,6 +55,29 @@ module Gretel
59
55
  def loaded_file_mtimes
60
56
  @loaded_file_mtimes ||= []
61
57
  end
58
+
59
+ class Builder
60
+ attr_reader :crumbs
61
+
62
+ def initialize
63
+ @crumbs = {}
64
+ end
65
+
66
+ # Stores the supplied block for later use.
67
+ def crumb(key, &block)
68
+ crumbs[key] = block
69
+ end
70
+
71
+ # Returns a hash of all stored crumb blocks.
72
+ def crumbs
73
+ @crumbs ||= {}
74
+ end
75
+
76
+ # Returns true if a crumb with the given key has been set.
77
+ def crumb_defined?(key)
78
+ crumbs.has_key?(key)
79
+ end
80
+ end
62
81
  end
63
82
  end
64
83
  end
@@ -0,0 +1,11 @@
1
+ require 'gretel/view_helpers'
2
+
3
+ module Gretel
4
+ class Railtie < ::Rails::Railtie
5
+ initializer 'gretel.view_helpers' do
6
+ ActiveSupport.on_load(:action_view) do
7
+ include ViewHelpers
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,6 @@
1
+ require 'gretel/crumbs'
2
+ require 'gretel/crumb'
3
+
1
4
  module Gretel
2
5
  class Renderer
3
6
  DEFAULT_OPTIONS = {
@@ -1,3 +1,3 @@
1
1
  module Gretel
2
- VERSION = "4.0.2"
2
+ VERSION = "4.1.0"
3
3
  end
@@ -1,3 +1,5 @@
1
+ require 'gretel/renderer'
2
+
1
3
  module Gretel
2
4
  module ViewHelpers
3
5
  # Sets the current breadcrumb to be rendered elsewhere. Put it somewhere in the view, preferably in the top, before you render any breadcrumbs HTML:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gretel
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Bunk
@@ -9,15 +9,18 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-25 00:00:00.000000000 Z
12
+ date: 2020-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
15
+ name: railties
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '5.1'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '7.0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -25,6 +28,29 @@ dependencies:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '5.1'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
34
+ - !ruby/object:Gem::Dependency
35
+ name: actionview
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5.1'
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '7.0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '5.1'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '7.0'
28
54
  - !ruby/object:Gem::Dependency
29
55
  name: sqlite3
30
56
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +131,7 @@ files:
105
131
  - lib/gretel/crumb.rb
106
132
  - lib/gretel/crumbs.rb
107
133
  - lib/gretel/link.rb
134
+ - lib/gretel/railtie.rb
108
135
  - lib/gretel/renderer.rb
109
136
  - lib/gretel/resettable.rb
110
137
  - lib/gretel/version.rb