Skip to content

Commit

Permalink
Deprecate using Sinatra::ApexCharts extension
Browse files Browse the repository at this point in the history
  • Loading branch information
styd committed Oct 25, 2024
1 parent 8e7ff26 commit c572f8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this project will be documented in this file.
- Chart options set globally not showing as default options
- Chart height options not overriden by default options

### Deprecated
- Using Sinatra helper name `Sinatra::ApexCharts`. No need to call
anything after requiring 'apexcharts' now.

## [0.2.0] - 2022-02-28
### Added
- Option to render chart with a script whose type is module
Expand Down
7 changes: 1 addition & 6 deletions docs/web-support/sinatra.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
### Sinatra

Require it after you `require 'sinatra/base'` and add helper `Sinatra::ApexCharts` in the
class that inherits from `Sinatra::Base`.
Require it after you `require 'sinatra/base'`.

```ruby
require 'sinatra/base'
require 'apexcharts'

class SimpleApp < Sinatra::Base
helpers Sinatra::ApexCharts
end
```

To add the asset (ApexCharts.JS), include a script tag in your template
Expand Down
20 changes: 17 additions & 3 deletions lib/apex_charts/support/sinatra.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# frozen_string_literal: true

module Sinatra
module ApexCharts
include ::ApexCharts::Helper
def self.const_missing(const_name)
if const_name == :ApexCharts
warn "[DEPRECATION] specifying `Sinatra::#{const_name}` as " \
'helper is deprecated and will raise an error in next ' \
'release. Requiring ApexCharts (`require "apexcharts"`) ' \
'is enough to use its chart helper methods.'
::ApexCharts::SinatraHelper
else
super
end
end
end

helpers ApexCharts
module ApexCharts
module SinatraHelper
include ::ApexCharts::Helper
end
end

Sinatra::Base.helpers ApexCharts::SinatraHelper

0 comments on commit c572f8f

Please sign in to comment.