Class: Senju::Projects
- Inherits:
-
Object
- Object
- Senju::Projects
- Defined in:
- lib/senju/projects.rb
Constant Summary collapse
- PATH =
Dir.home + '/.senju/projects'
Class Method Summary collapse
- .[](name) ⇒ Object
- .[]=(name, table) ⇒ Object
- .add_interactive(name) ⇒ Object
- .data ⇒ Object
- .load ⇒ Object
- .write ⇒ Object
Class Method Details
.[](name) ⇒ Object
21 22 23 |
# File 'lib/senju/projects.rb', line 21 def self.[](name) data[name] || raise("Unknown project \"#{name}\".") end |
.[]=(name, table) ⇒ Object
25 26 27 |
# File 'lib/senju/projects.rb', line 25 def self.[]=(name, table) data[name] = table end |
.add_interactive(name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/senju/projects.rb', line 29 def self.add_interactive(name) print "Repository type [github, gitlab, trello]: " type = STDIN.gets.chomp case type when "github", "gitlab" print "Repository path (team/repository): " repo = STDIN.gets.chomp when "trello" print "board id (like aBcDeF1234): " repo = STDIN.gets.chomp end self[name] = { "repo" => repo, "type" => type } write print "Senju project add successfly.\n".colorize(:green) end |
.data ⇒ Object
17 18 19 |
# File 'lib/senju/projects.rb', line 17 def self.data self.load end |
.load ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/senju/projects.rb', line 5 def self.load if File.exist? PATH @data = YAML.load_file(PATH) else @data = {} end end |
.write ⇒ Object
13 14 15 |
# File 'lib/senju/projects.rb', line 13 def self.write YAML.dump(@data, File.open(PATH, 'w')) end |