Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
45a71898
Commit
45a71898
authored
9 years ago
by
Jack Nagel
Browse files
Options
Downloads
Patches
Plain Diff
Isolate formula class namespaces
Closes Homebrew/homebrew#40151. Closes Homebrew/homebrew#40203.
parent
bd5083f9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/formula_versions.rb
+0
-4
0 additions, 4 deletions
Library/Homebrew/formula_versions.rb
Library/Homebrew/formulary.rb
+20
-48
20 additions, 48 deletions
Library/Homebrew/formulary.rb
with
20 additions
and
52 deletions
Library/Homebrew/formula_versions.rb
+
0
−
4
View file @
45a71898
...
...
@@ -32,8 +32,6 @@ class FormulaVersions
path
=
Pathname
.
pwd
.
join
(
"
#{
name
}
.rb"
)
path
.
write
file_contents_at_revision
(
rev
)
old_const
=
Formulary
.
unload_formula
(
name
)
begin
nostdout
{
yield
Formulary
.
factory
(
path
.
to_s
)
}
rescue
*
IGNORED_EXCEPTIONS
=>
e
...
...
@@ -42,8 +40,6 @@ class FormulaVersions
ohai
"
#{
e
}
in
#{
name
}
at revision
#{
rev
}
"
,
e
.
backtrace
if
ARGV
.
debug?
rescue
FormulaUnavailableError
# Suppress this error
ensure
Formulary
.
restore_formula
(
name
,
old_const
)
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/formulary.rb
+
20
−
48
View file @
45a71898
...
...
@@ -2,45 +2,28 @@
# It is not meant to be used directy from formulae.
class
Formulary
module
Formulae
class
<<
self
if
instance_method
(
:const_defined?
).
arity
==
-
1
def
formula_const_defined?
(
name
)
const_defined?
(
name
,
false
)
end
def
formula_const_get
(
name
)
const_get
(
name
,
false
)
end
else
def
formula_const_defined?
(
name
)
const_defined?
(
name
)
end
def
formula_const_get
(
name
)
const_get
(
name
)
end
end
def
remove_formula_const
(
name
)
remove_const
(
name
)
end
FORMULAE
=
{}
def
formula_const_set
(
name
,
value
)
const_set
(
name
,
value
)
end
end
def
self
.
formula_class_defined?
(
path
)
FORMULAE
.
key?
(
path
)
end
def
self
.
unload_formula
formula_name
F
ormulae
.
remove_formula_const
(
class_s
(
formula_name
)
)
def
self
.
formula_class_get
(
path
)
F
ORMULAE
.
fetch
(
path
)
end
def
self
.
restore_formula
formula_name
,
value
old_verbose
,
$VERBOSE
=
$VERBOSE
,
nil
Formulae
.
formula_const_set
(
class_s
(
formula_name
),
value
)
ensure
$VERBOSE
=
old_verbose
def
self
.
load_formula
(
name
,
path
)
mod
=
Module
.
new
mod
.
module_eval
(
path
.
read
,
path
)
class_name
=
class_s
(
name
)
begin
klass
=
mod
.
const_get
(
class_name
)
rescue
NameError
=>
e
raise
FormulaUnavailableError
,
name
,
e
.
backtrace
else
FORMULAE
[
path
]
=
klass
end
end
def
self
.
class_s
name
...
...
@@ -57,13 +40,10 @@ class Formulary
attr_reader
:name
# The formula's ruby file's path or filename
attr_reader
:path
# The ruby constant name of the formula's class
attr_reader
:class_name
def
initialize
(
name
,
path
)
@name
=
name
@path
=
path
.
resolved_path
@class_name
=
Formulary
.
class_s
(
name
)
end
# Gets the formula instance.
...
...
@@ -72,16 +52,8 @@ class Formulary
end
def
klass
begin
have_klass
=
Formulae
.
formula_const_defined?
(
class_name
)
rescue
NameError
=>
e
raise
unless
e
.
name
.
to_s
==
class_name
raise
FormulaUnavailableError
,
name
,
e
.
backtrace
end
load_file
unless
have_klass
Formulae
.
formula_const_get
(
class_name
)
load_file
unless
Formulary
.
formula_class_defined?
(
path
)
Formulary
.
formula_class_get
(
path
)
end
private
...
...
@@ -89,7 +61,7 @@ class Formulary
def
load_file
STDERR
.
puts
"
#{
$0
}
(
#{
self
.
class
.
name
}
): loading
#{
path
}
"
if
ARGV
.
debug?
raise
FormulaUnavailableError
.
new
(
name
)
unless
path
.
file?
Formula
e
.
module_eval
(
path
.
read
,
path
)
Formula
ry
.
load_formula
(
name
,
path
)
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment