def build(self):
        """
        Runs a jekyll build within a defined bundler environment
        Involves the following:
            - Try to run a jekyll build within a defined bundler environment
                - Once again, either use the one provided with the repository or the gh-pages one
        :param draft: Include drafts?
        :return: 
        """
        bundler = Bundle()
        try:
            if current_config.DEBUG:
                logger.debug("Starting Jekyll build.")
            with open(os.path.join(self._repo.deploy_path, 'status.txt'),
                      'w') as log_file:
                log_file.write(
                    dumps({
                        "status": 0,
                        "msg": 'Starting build ...'
                    }))
            jekyll = Jekyll(source=self._repo.build_path,
                            dest=self._repo.deploy_path,
                            config=[
                                os.path.join(self._repo.build_path,
                                             '_config.yml'),
                                os.path.join(current_config.TEMPLATEDIR,
                                             'keep_files.yml')
                            ],
                            draft=self._repo.draft)

            bundler.exec(executable=jekyll,
                         gemfile=self._gemfile).call(pwd=self._repo.build_path)
            with open(os.path.join(self._repo.deploy_path, 'status.txt'),
                      'w') as log_file:
                log_file.write(dumps({"status": 0, "msg": 'Deployed page!'}))
        except BundleError:
            raise
        except OSError:
            raise
示例#2
0
 def test_exec(self):
     j = Jekyll()
     b = Bundle()
     self.assertListEqual(b.exec(j).cmd, ["bundle", "exec", "jekyll", "build"])
示例#3
0
    def test_executable_error(self):
        e = Jekyll(source="test")
        with self.assertRaises(JekyllError) as context:
            e.call()

        self.assertTrue(context.exception.return_code == -1)
示例#4
0
    def test_add_parameter_executable(self):
        j = Jekyll()
        e = Executable("test", "executable", "with", "parameters")

        j.add_parameter(e)
        self.assertListEqual(j.cmd, ["jekyll", "build"] + e.cmd)
示例#5
0
    def test_add_parameter_key_value(self):
        j = Jekyll()

        j.add_parameter("--source", "./")
        self.assertListEqual(j.cmd, ["jekyll", "build", "--source", "./"])
示例#6
0
    def test_add_parameter_string(self):
        j = Jekyll()

        j.add_parameter("test")
        self.assertListEqual(j.cmd, ["jekyll", "build", "test"])
示例#7
0
 def test_simple(self):
     j = Jekyll()
     self.assertListEqual(j.cmd, ["jekyll", "build"])