bullet_train-themes-light 1.3.23 → 1.3.24

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: 437f822c3d8ab03b2b316020e1597f0a25626e24051f503a7225046af0cda90a
4
- data.tar.gz: 4fe3b37b205202c6680f325f88dc71b48a0ec36ba33212da35ccb909d345ff72
3
+ metadata.gz: 5928cebefcf72bf371bd19fd488587dcd20cbe6ca21f5f207f3530ab96a142c2
4
+ data.tar.gz: de69366834b591529df60bc6499c2c3b3fd730684d32df30cdc27748da649688
5
5
  SHA512:
6
- metadata.gz: 9e8cf89ea54197232dd36f34b417b7fd787532728bee6ce7f68a2a7e3a08f303b82aa56a0ad3e5b38c91d20411056018799fe3bc9395991ee9b1038046d5260d
7
- data.tar.gz: 6f5d15ed50126e67e76db0c2adefb5b41c8bd15178d01c76fd97a35ea812f0a86b35110f647a885d888f672f22f61da2f5431297e03c3bcbb0d80d2141bbbc40
6
+ metadata.gz: 4189c039fc15e7f694d4154330164c631217a17df44a6d07b31651119481677d9517bebeaaf1bbfd9aa661068fa53cd006b5e781297e8547803ce1dd7b3bfe11
7
+ data.tar.gz: 1a07949f68f306ff7a992bbd4de05d619e2df95de63cf2bacbedc4dc8be0e7ea8feeff778b5d715acf8d84d8499f19f5211e84ef394a911be2edbdc0dde4143f
@@ -1,7 +1,7 @@
1
1
  module BulletTrain
2
2
  module Themes
3
3
  module Light
4
- VERSION = "1.3.23"
4
+ VERSION = "1.3.24"
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,5 @@
1
+ require "masamune"
2
+
1
3
  module BulletTrain
2
4
  module Themes
3
5
  module Application
@@ -148,33 +150,16 @@ module BulletTrain
148
150
  end
149
151
 
150
152
  def self.install_theme(theme_name)
151
- # Grabs the current theme from
152
- # def current_theme
153
- # :theme_name
154
- # end
155
- current_theme_regexp = /(^ :)(.*)/
156
- current_theme = nil
157
-
158
- new_lines = []
159
- [
160
- "./app/helpers/application_helper.rb",
161
- "./Procfile.dev",
162
- "./package.json"
163
- ].each do |file|
164
- File.open(file, "r") do |f|
165
- new_lines = f.readlines
166
- new_lines = new_lines.map do |line|
167
- # Make sure we get the current theme before trying to replace it in any of the files.
168
- # We grab it from the first file in the array above.
169
- current_theme = line.scan(current_theme_regexp).flatten.last if line.match?(current_theme_regexp)
170
-
171
- line.gsub!(/#{current_theme}/, theme_name) unless current_theme.nil?
172
- line
173
- end
174
- end
175
-
176
- File.open(file, "w") do |f|
177
- f.puts new_lines.join
153
+ helper = Pathname.new("./app/helpers/application_helper.rb")
154
+ msmn = Masamune::AbstractSyntaxTree.new(helper.readlines.join)
155
+ current_theme_def = msmn.method_definitions(name: "current_theme").pop
156
+ current_theme = msmn.symbols.find { |node| node[:line_number] > current_theme_def[:line_number] }[:token]
157
+ helper.write msmn.replace(type: :symbol, old_token: current_theme, new_token: theme_name)
158
+
159
+ [Pathname.new("./Procfile.dev"), Pathname.new("./package.json")].each do |file|
160
+ changed = file.read.gsub! current_theme, theme_name
161
+ if changed
162
+ file.write changed
178
163
  end
179
164
  end
180
165
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-themes-light
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.23
4
+ version: 1.3.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-05 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard