Class: Nsume::Cli
- Inherits:
-
Thor
- Object
- Thor
- Nsume::Cli
- Defined in:
- lib/nsume/cli.rb
Instance Method Summary collapse
- #init(path = Dir.pwd) ⇒ Object
- #navbar(site = 'blog') ⇒ Object
- #post(title = 'title', content = '') ⇒ Object
- #switch(theme) ⇒ Object
- #theme ⇒ Object
- #themes ⇒ Object
- #up ⇒ Object
- #version ⇒ Object
Instance Method Details
#init(path = Dir.pwd) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nsume/cli.rb', line 14 def init(path=Dir.pwd) Nsume.config.dest_path = path Nsume::Prepare.generator Nsume::Prepare.jquery Nsume::Prepare.bootstrap_js Nsume::Prepare.bootswatch_css Nsume::Prepare.bootswatch_js Nsume::Prepare.bootswatch_theme ['theme'] Nsume::Logger.info "Successfully initialized." end |
#navbar(site = 'blog') ⇒ Object
65 66 67 |
# File 'lib/nsume/cli.rb', line 65 def (site='blog') Nsume::Prepare. site end |
#post(title = 'title', content = '') ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nsume/cli.rb', line 28 def post(title='title', content='') name = "#{Date.today.strftime("%Y-%m-%d")}-#{title}.md" path = File.(name, Nsume.config.posts_path) unless File.exists?(path) file = ERB.new(Nsume.config.post_template).result(binding) File.write(path, file) Nsume::Logger.info "Created a posts." else Nsume::Logger.info "Existed a posts." end end |
#switch(theme) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nsume/cli.rb', line 41 def switch(theme) path = File.join(Nsume.config.dest_path, '_config.yml') raw = YAML.load_file(path) raw['theme'] = theme file = YAML.dump(raw) File.write(path, file) Nsume::Prepare.bootswatch_theme theme Nsume::Logger.info "Switched theme." end |
#theme ⇒ Object
53 54 55 56 57 |
# File 'lib/nsume/cli.rb', line 53 def theme path = File.join(Nsume.config.dest_path, '_config.yml') raw = YAML.load_file(path) puts raw['theme'] end |
#themes ⇒ Object
60 61 62 |
# File 'lib/nsume/cli.rb', line 60 def themes puts Nsume.config.themes end |