Class: Renamespace::Paths
- Inherits:
-
Struct
- Object
- Struct
- Renamespace::Paths
- Defined in:
- lib/renamespace/paths.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#source ⇒ Object
Returns the value of attribute source.
Class Method Summary collapse
- .all_ruby_file_paths ⇒ Object
- .custom_camelcasings ⇒ Object
- .namespace_element_from_path_element(path_element) ⇒ Object
- .namespace_elements_for_path(path) ⇒ Object
- .namespace_for_path(path) ⇒ Object
- .path_elements_for_require(path) ⇒ Object
- .require_for_path(path) ⇒ Object
Instance Method Summary collapse
- #destination_namespace ⇒ Object
- #destination_namespace_elements ⇒ Object
- #destination_require_path ⇒ Object
- #same? ⇒ Boolean
- #source_namespace ⇒ Object
- #source_namespace_elements ⇒ Object
- #source_require_path ⇒ Object
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination
4 5 6 |
# File 'lib/renamespace/paths.rb', line 4 def destination @destination end |
#source ⇒ Object
Returns the value of attribute source
4 5 6 |
# File 'lib/renamespace/paths.rb', line 4 def source @source end |
Class Method Details
.all_ruby_file_paths ⇒ Object
33 34 35 |
# File 'lib/renamespace/paths.rb', line 33 def self.all_ruby_file_paths (Dir.glob('**/*.rb') - %w[invert_namespaces.rb renamespace.rb]) end |
.custom_camelcasings ⇒ Object
26 27 28 29 30 31 |
# File 'lib/renamespace/paths.rb', line 26 def self.custom_camelcasings { 'greensync' => 'GreenSync', 'goodwe' => 'GoodWe', } end |
.namespace_element_from_path_element(path_element) ⇒ Object
22 23 24 |
# File 'lib/renamespace/paths.rb', line 22 def self.namespace_element_from_path_element(path_element) custom_camelcasings.fetch(path_element) { path_element.upper_camelcase } end |
.namespace_elements_for_path(path) ⇒ Object
13 14 15 16 |
# File 'lib/renamespace/paths.rb', line 13 def self.namespace_elements_for_path(path) path_elements_for_require(path) .map(&method(:namespace_element_from_path_element)) end |
.namespace_for_path(path) ⇒ Object
5 6 7 |
# File 'lib/renamespace/paths.rb', line 5 def self.namespace_for_path(path) namespace_elements_for_path(path).join('::') end |
.path_elements_for_require(path) ⇒ Object
18 19 20 |
# File 'lib/renamespace/paths.rb', line 18 def self.path_elements_for_require(path) path.sub(%r{^lib/}, '').chomp('.rb').split('/') end |
.require_for_path(path) ⇒ Object
9 10 11 |
# File 'lib/renamespace/paths.rb', line 9 def self.require_for_path(path) path_elements_for_require(path).join('/') end |
Instance Method Details
#destination_namespace ⇒ Object
41 42 43 |
# File 'lib/renamespace/paths.rb', line 41 def destination_namespace self.class.namespace_for_path(destination) end |
#destination_namespace_elements ⇒ Object
49 50 51 |
# File 'lib/renamespace/paths.rb', line 49 def destination_namespace_elements self.class.namespace_elements_for_path(destination) end |
#destination_require_path ⇒ Object
57 58 59 |
# File 'lib/renamespace/paths.rb', line 57 def destination_require_path self.class.require_for_path(destination) end |
#same? ⇒ Boolean
61 62 63 |
# File 'lib/renamespace/paths.rb', line 61 def same? source == destination end |
#source_namespace ⇒ Object
37 38 39 |
# File 'lib/renamespace/paths.rb', line 37 def source_namespace self.class.namespace_for_path(source) end |
#source_namespace_elements ⇒ Object
45 46 47 |
# File 'lib/renamespace/paths.rb', line 45 def source_namespace_elements self.class.namespace_elements_for_path(source) end |
#source_require_path ⇒ Object
53 54 55 |
# File 'lib/renamespace/paths.rb', line 53 def source_require_path self.class.require_for_path(source) end |