Class: Jets::Commands::Import::Cheatsheet
- Inherits:
-
Object
- Object
- Jets::Commands::Import::Cheatsheet
- Defined in:
- lib/jets/commands/import/cheatsheet.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cheatsheet_vars ⇒ Object
- #create ⇒ Object
-
#initialize(rack_repo_url) ⇒ Cheatsheet
constructor
A new instance of Cheatsheet.
- #jets_project_repo_url ⇒ Object
Constructor Details
#initialize(rack_repo_url) ⇒ Cheatsheet
Returns a new instance of Cheatsheet.
7 8 9 |
# File 'lib/jets/commands/import/cheatsheet.rb', line 7 def initialize(rack_repo_url) @rack_repo_url = rack_repo_url end |
Class Method Details
.create(rack_repo_url) ⇒ Object
3 4 5 |
# File 'lib/jets/commands/import/cheatsheet.rb', line 3 def self.create(rack_repo_url) new(rack_repo_url).create end |
Instance Method Details
#cheatsheet_vars ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/jets/commands/import/cheatsheet.rb', line 21 def cheatsheet_vars import_command = ARGV[0] { import_command: import_command, rack_repo_url: @rack_repo_url, jets_project_repo_url: jets_project_repo_url, } end |
#create ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/jets/commands/import/cheatsheet.rb', line 11 def create path = File.("./templates/", File.dirname(__FILE__)) + "/submodules-cheatsheet.md" basename = File.basename(path) dest = "#{Jets.root}/#{basename}" cheatsheet = Jets::Erb.result(path, cheatsheet_vars) FileUtils.mkdir_p(File.dirname(dest)) IO.write(dest, cheatsheet) puts "Created #{basename} to help with using submodules." end |
#jets_project_repo_url ⇒ Object
30 31 32 33 |
# File 'lib/jets/commands/import/cheatsheet.rb', line 30 def jets_project_repo_url # Thanks: https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr/4089452 `git config --get remote.origin.url`.strip rescue 'https://github.com/user/repo' end |