web_rake 0.1.2 → 0.1.3
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 +4 -4
- data/app/controllers/web_rake/tasks_controller.rb +23 -62
- data/lib/web_rake/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 335f7075a11c5508278517e04acd1a77ad37c7baa704475b3082c128b4bde1b5
|
|
4
|
+
data.tar.gz: 4107f317a0ed93c1eb4c5ae9b6cc9f58c790c5956185e82df04c75dd70625f37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 56d5c6ca2d62e2dcff067c8b28512499a085f353ca29d4b0c5d2c23d17855d2767c84fa4cf62f24a767b84287a0aba0c83900be67d83f77b9c5d66d54bb7e612
|
|
7
|
+
data.tar.gz: ac6f472a51bf31a767e84d17c1575dcc5cc83127b981c2d72b1d1c5b67cee6557902206c0b9fc5b0e3579daecffb5675664766a3ef6f7148376fa0dac0c03b9c
|
|
@@ -18,9 +18,8 @@ module WebRake
|
|
|
18
18
|
def execute
|
|
19
19
|
task_name = params[:id].gsub('__', ':')
|
|
20
20
|
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
unless allowed_tasks.include?(task_name)
|
|
21
|
+
# Use find_task to validate the task is allowed
|
|
22
|
+
unless find_task
|
|
24
23
|
redirect_to root_path, alert: "Task not found"
|
|
25
24
|
return
|
|
26
25
|
end
|
|
@@ -80,81 +79,43 @@ module WebRake
|
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
def custom_tasks
|
|
83
|
-
# First, get the names of tasks defined in lib/tasks files
|
|
84
|
-
custom_task_names = extract_task_names_from_files
|
|
85
|
-
|
|
86
|
-
# Always include db:seed task
|
|
87
|
-
custom_task_names << 'db:seed'
|
|
88
|
-
|
|
89
82
|
# Ensure all tasks are loaded
|
|
90
83
|
Rails.application.load_tasks
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
custom_task_names.filter_map do |name|
|
|
94
|
-
Rake::Task[name] rescue nil
|
|
95
|
-
end.select(&:actions)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def extract_task_names_from_files
|
|
99
|
-
task_names = []
|
|
100
|
-
|
|
101
|
-
# Parse each rake file to extract task names
|
|
102
|
-
Dir.glob(Rails.root.join('lib/tasks/**/*.rake')).each do |file|
|
|
103
|
-
content = File.read(file)
|
|
104
|
-
|
|
105
|
-
# Match various task definition patterns
|
|
85
|
+
tasks = []
|
|
106
86
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
# Pattern for: task({ sample_data: :environment }) - Ruby 1.9+ syntax with parens and braces
|
|
113
|
-
content.scan(/task\s*\(\s*\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*:/).each do |match|
|
|
114
|
-
task_names << match[0]
|
|
115
|
-
end
|
|
87
|
+
# Find tasks defined in lib/tasks or db:seed
|
|
88
|
+
Rake.application.tasks.each do |task|
|
|
89
|
+
next if task.actions.blank?
|
|
116
90
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
task_names << match[0]
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
# Pattern for: task "sample_data" => :environment
|
|
123
|
-
content.scan(/task\s+["']([a-zA-Z_][a-zA-Z0-9_]*)["']\s*=>/).each do |match|
|
|
124
|
-
task_names << match[0]
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
# Pattern for: task sample_data: :environment (Ruby 1.9+ syntax)
|
|
128
|
-
content.scan(/task\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*:/).each do |match|
|
|
129
|
-
task_names << match[0]
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Pattern for: task(:sample_data)
|
|
133
|
-
content.scan(/task\s*\(\s*:([a-zA-Z_][a-zA-Z0-9_]*)\s*\)/).each do |match|
|
|
134
|
-
task_names << match[0]
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Pattern for: desc "..." \n task :name
|
|
138
|
-
content.scan(/desc\s+.*?\n\s*task\s+:([a-zA-Z_][a-zA-Z0-9_]*)/).each do |match|
|
|
139
|
-
task_names << match[0]
|
|
91
|
+
if task_from_lib_tasks?(task) || task.name == "db:seed"
|
|
92
|
+
tasks << task
|
|
140
93
|
end
|
|
141
94
|
end
|
|
142
95
|
|
|
143
|
-
|
|
96
|
+
tasks
|
|
144
97
|
end
|
|
145
98
|
|
|
146
99
|
def find_task
|
|
147
100
|
task_name = params[:id].gsub('__', ':')
|
|
148
101
|
|
|
149
|
-
# Check if this is one of our allowed tasks (custom tasks + db:seed)
|
|
150
|
-
allowed_tasks = extract_task_names_from_files + ['db:seed']
|
|
151
|
-
return nil unless allowed_tasks.include?(task_name)
|
|
152
|
-
|
|
153
102
|
# Ensure tasks are loaded
|
|
154
103
|
Rails.application.load_tasks
|
|
155
104
|
|
|
156
105
|
# Find the task
|
|
157
|
-
Rake::Task[task_name] rescue nil
|
|
106
|
+
task = Rake::Task[task_name] rescue nil
|
|
107
|
+
|
|
108
|
+
# Check if it's db:seed or defined in lib/tasks
|
|
109
|
+
return task if task_from_lib_tasks?(task) || task_name == "db:seed"
|
|
110
|
+
|
|
111
|
+
nil
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def task_from_lib_tasks?(task)
|
|
115
|
+
return false if task.actions.blank?
|
|
116
|
+
|
|
117
|
+
source_path = task.actions.first.source_location&.first
|
|
118
|
+
source_path.present? && source_path.include?(Rails.root.join("lib/tasks").to_s)
|
|
158
119
|
end
|
|
159
120
|
end
|
|
160
|
-
end
|
|
121
|
+
end
|
data/lib/web_rake/version.rb
CHANGED