プロジェクト

全般

プロフィール

最適化 #615 » plugin_revised.patch

Osamu Koga, 2013-10-20 23:31

差分を表示:

core/miquire_plugin.rb
63 63
    def get_spec(path)
64 64
      type_strict path => String
65 65
      plugin_dir = FileTest.directory?(path) ? path : File.dirname(path)
66
      spec_filename = File.join(plugin_dir, "spec")
66
      spec_filename = File.join(plugin_dir, ".mikutter.yml")
67
      deprecated_spec = false;
68
      unless FileTest.exist? spec_filename
69
        spec_filename = File.join(plugin_dir, "spec")
70
        deprecated_spec = true
71
      end
67 72
      if FileTest.exist? spec_filename
68 73
        spec = YAML.load_file(spec_filename).symbolize
69 74
        spec[:path] = plugin_dir
70 75
        spec[:kind] = get_kind(path)
71
        spec
72 76
      elsif FileTest.exist? path
73
        { slug: File.basename(path, ".rb").to_sym,
77
        spec = { slug: File.basename(path, ".rb").to_sym,
74 78
          kind: get_kind(path),
75
          path: plugin_dir } end end
79
          path: plugin_dir } end 
80
      spec[:deprecated_spec] = deprecated_spec
81
      spec
82
    end
76 83

  
77 84
    def get_spec_by_slug(slug)
78 85
      type_strict slug => Symbol
......
131 138
      ::Plugin.create(spec[:slug].to_sym) do
132 139
        self.spec = spec end
133 140
      Kernel.load File.join(spec[:path], "#{spec[:slug]}.rb")
141
      if spec[:deprecated_spec]
142
        title = "#{spec[:slug]}: specファイルは非推奨になりました。"
143
        Plugin.call(:modify_activity,
144
                    { plugin: spec[:slug],
145
                      kind: "system",
146
                      title: title,
147
                      date: Time.now,
148
                      description: "#{title}\n代わりに.mikutter.ymlを使ってください。"}) end
134 149
      true end
135 150
  end
136 151
end
(2-2/2)