lib/config.rb in xolti-0.1.1 vs lib/config.rb in xolti-0.2.0

- old
+ new

@@ -8,11 +8,11 @@ # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Xolti is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Xolti. If not, see <http://www.gnu.org/licenses/>. require "yaml" @@ -40,11 +40,11 @@ def initialize(raw_config) @project_info = extract_project_info(raw_config["project_info"]) @comment = DefaultComment::HASH.merge!(raw_config["comment"] || {}) @license = raw_config["license"] - @template = raw_config.include?("template") ? raw_config["template"] : IO.binread(Resources.get_template_path(@license)) + @template = extract_template_if_present(raw_config) @offset = raw_config["offset"] || 0 end def get_comment(ext) @comment[ext.delete('.')] @@ -54,7 +54,14 @@ { author: raw_project_info["author"], project_name: raw_project_info["project_name"], year: raw_project_info["year"] || Date.today().year.to_s } + end + + private def extract_template_if_present(raw_config) + return raw_config["template"] if raw_config.include?("template") + default_template_path = Resources.get_template_path(@license) + return IO.binread(default_template_path) if File.exists?(default_template_path) + nil end end