Class: Mygithub::MilkodeAccessor
- Inherits:
-
Object
- Object
- Mygithub::MilkodeAccessor
- Defined in:
- lib/mygithub/milkode_accessor.rb
Instance Attribute Summary collapse
-
#dbdir ⇒ Object
readonly
Returns the value of attribute dbdir.
Instance Method Summary collapse
- #add(args) ⇒ Object
-
#cdweb_execute_with_options(stdout, options) ⇒ Object
milkode/cdweb/cli_cdweb.rb:95.
- #create_milkweb_yaml(icon_url) ⇒ Object
- #database_exitst? ⇒ Boolean
- #exist?(name) ⇒ Boolean
- #init ⇒ Object
-
#initialize(dbdir) ⇒ MilkodeAccessor
constructor
A new instance of MilkodeAccessor.
- #update(args) ⇒ Object
- #web(options) ⇒ Object
Constructor Details
#initialize(dbdir) ⇒ MilkodeAccessor
Returns a new instance of MilkodeAccessor.
17 18 19 20 21 |
# File 'lib/mygithub/milkode_accessor.rb', line 17 def initialize(dbdir) @dbdir = dbdir @cdstk = Milkode::Cdstk.new($stdout, @dbdir) @yaml = YamlFileWrapper.load_if(@dbdir) end |
Instance Attribute Details
#dbdir ⇒ Object (readonly)
Returns the value of attribute dbdir.
15 16 17 |
# File 'lib/mygithub/milkode_accessor.rb', line 15 def dbdir @dbdir end |
Instance Method Details
#add(args) ⇒ Object
48 49 50 |
# File 'lib/mygithub/milkode_accessor.rb', line 48 def add(args) @cdstk.add(args, {:same_add => true}) end |
#cdweb_execute_with_options(stdout, options) ⇒ Object
milkode/cdweb/cli_cdweb.rb:95
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/mygithub/milkode_accessor.rb', line 90 def (stdout, ) dbdir = File.([:DbDir]) # 使用するデータベースの位置設定 Milkode::Database.setup(dbdir) # サーバースクリプトのある場所へ移動 FileUtils.cd(File.join File.dirname(__FILE__), 'web') # Rackサーバー起動 Rack::Server.start() end |
#create_milkweb_yaml(icon_url) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mygithub/milkode_accessor.rb', line 31 def create_milkweb_yaml(icon_url) filename = File.join(@dbdir, 'milkweb.yaml') File.open(filename, "w") do |f| f.write <<EOF --- :home_title : "MyGithub" :home_icon : #{icon_url} :header_title: "MyGithub" :header_icon : #{icon_url} :display_about_milkode: false EOF end end |
#database_exitst? ⇒ Boolean
60 61 62 |
# File 'lib/mygithub/milkode_accessor.rb', line 60 def database_exitst? @yaml && @yaml.contents.size > 0 end |
#exist?(name) ⇒ Boolean
56 57 58 |
# File 'lib/mygithub/milkode_accessor.rb', line 56 def exist?(name) !@yaml.find_name(name).nil? end |
#init ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/mygithub/milkode_accessor.rb', line 23 def init unless File.exist? @dbdir FileUtils.mkdir_p @dbdir @cdstk.init({}) @yaml = YamlFileWrapper.load_if(@dbdir) end end |
#update(args) ⇒ Object
52 53 54 |
# File 'lib/mygithub/milkode_accessor.rb', line 52 def update(args) @cdstk.update(args, {}) end |
#web(options) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/mygithub/milkode_accessor.rb', line 64 def web() opts = { :environment => ENV['RACK_ENV'] || "development", :pid => nil, :Port => [:port], :Host => [:host], :AccessLog => [], :config => "config.ru", # ---------------------------- :server => [:server], :LaunchBrowser => ![:no_browser], :LaunchURL => database_exitst? ? nil : '/login', :DbDir => [:db], } # init init # open @cdstk.assert_compatible # Milkode::CLI_Cdweb.execute_with_options($stdout, opts) ($stdout, opts) end |