Podspec correct search paths organization - cocoapods

I have a project that I want to be a part of cocoapods or just have an easy installation via cocoapods.
Ok, let's see in it.
It has directories in root:
Tools/ #directory where all items of project stored
ExternalLibraries/ # directory where all external libraries stored (.a libraries of third party guys with their .h header files)
Submodules/ # directory where all external projects stored that have open source code and can be placed as submodule
Example/ # directory with example
Ok, which options I should specify in Podspec file for correct behaviour?
I ended up with this spec.
Pod::Spec.new do |s|
s.name = "WowProjectTools"
s.source = {
:git => "https://github.com/wow/WowProjectTools.git",
:submodules => true
}
s.source_files = "Tools/**/*.{h,m}" # include all tools files
s.exclude_files = "Example" # exclude all examples
s.frameworks = "Foundation", "SystemConfiguration", "CoreData" # add all frameworks (system frameworks)
s.libraries = "icucore", "z" # ok, I need these libraries like libz.dylib and libicucore.dylib
s.vendored_libraries = 'ExternalLibraries/**' # hmm, these libraries are third party, no?
s.requires_arc = true #
s.xcconfig = { "HEADER_SEARCH_PATHS" => ["./Submodules/**/*.h","./ExternalLibraries/**/*.h"] } # add header search paths
end

Related

Add custom entries to acknowledgments.plist generated by Cocoapods

Cocoapods generates a plist which can be copied "post_install" to the settings bundle.
I'd love to add some custom entries in for items which need attribution but aren't Cocoapods.
I've looked through the source for https://github.com/CocoaPods/cocoapods-acknowledgements but I am not familiar with Ruby and I can't figure out where to start.
post_install do | installer |
require'fileutils'
FileUtils.cp_r('Pods/Target Support Files/Pods-xxx/Pods-xxx-acknowledgements.plist', 'xxx/Settings.bundle/Acknowledgements.plist', :remove_destination => true)
end
I don't need someone to write a whole solution for me, just point me in the right direction.
As my not complete answer got deleted, here now the full working version:
Based on this python script: https://gist.github.com/wagyu298/cb11f5d6eabd9acc7425cc106fc03fd2
We came up with a solution in our project:
def add_license_manually
require 'cfpropertylist'
additional_license = {
"FooterText" => "Copyright (c) 2020, Example Dev All rights reserved.
Redistribution......",
"License" => "MIT",
"Title" => "Library",
"Type" => "PSGroupSpecifier"
}
ack_plist_name = 'Pods/Target Support Files/Pods-xxx/Pods-xxx-acknowledgements.plist'
# read plist
plist = CFPropertyList::List.new(:file => ack_plist_name)
# convert to native data
data = CFPropertyList.native_types(plist.value)
# append the license
data["PreferenceSpecifiers"].insert(-1, additional_license)
# convert back
plist.value = CFPropertyList.guess(data)
# write plist to file
plist.save(ack_plist_name, CFPropertyList::List::FORMAT_XML)
end
And in your post_install, you add add_license_manually() before the
FileUtis.cp_r(...)
line

How does readthedocs generate Sphinx HTML from RST without a conf.py?

I am looking at making changes to an existing project hosted on github and readthedocs. However the generated HTML looks to be built by Sphinx without a conf.py.
$ ls
appendixA.rst chapter11.rst chapter17.rst chapter4.rst html
appendixB.rst chapter12.rst chapter18.rst chapter5.rst images
appendixC.rst chapter13.rst chapter19.rst chapter6.rst index.rst
attribution.rst chapter14.rst chapter2.rst chapter7.rst sandbox
chapter1.rst chapter15.rst chapter20.rst chapter8.rst src
chapter10.rst chapter16.rst chapter3.rst chapter9.rst toc.txt
Note particularly that index.rst exists but conf.py does not. find also shows it is not hiding somewhere else in the project. The generated site on readthedocs works and is consistent with the latest, including some problems seen in the github project, eg Chapter 1 is not indexed properly due to being listed under another name in index.rst.
I am new to Sphinx and readthedocs. In my new local build environment, sphinx doesn't like it at all:
> sphinx-build -b html . html/
Application error:
config directory doesn't contain a conf.py file (.)
That's consistent with the documentation, but not the readthedocs website behaviour. I'm guessing that readthedocs has some fallback behaviour for these cases, probably by generating a simple conf.py from other configuration it holds. However, it makes it hard to reproduce when making changes locally, especially for a project I don't own. If this is the case, I can't find any documentation on this feature. If I am not missing something simple (entirely possible), is there any?
My next step will be to write a new conf.py, and get it to conform to the existing behaviour on a local site. This would be easier if I understood the existing behaviour.
The actual project in question is the Jython book:
https://jython.readthedocs.io/en/latest/
https://github.com/jython/book
Had no luck finding related issues or questions on google, stackoverflow, readthedocs doco or issues. The readthedocs code at https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/projects/models.py seems to have a check for conf.py, too.
Huh, that's interesting that you don't have a conf.py but the docs still built successfully on Date: 2017-10-24T19:18:40.379930Z. I'm just as dumbfounded as you.
Anyway, you can find the conf.py that RTD ends up using under the project's build's raw log file. That might save you some grief. Note that the versions are about 1.5 years old, so you would need to pin versions to try to reproduce it exactly.
cat conf.py
# -*- coding: utf-8 -*-
from recommonmark.parser import CommonMarkParser
extensions = []
templates_path = ['/home/docs/checkouts/readthedocs.org/readthedocs/templates/sphinx', 'templates', '_templates', '.templates']
source_suffix = ['.rst', '.md']
source_parsers = {
'.md': CommonMarkParser,
}
master_doc = 'index'
project = u'jython'
copyright = u'2016'
version = 'latest'
release = 'latest'
exclude_patterns = ['_build']
pygments_style = 'sphinx'
htmlhelp_basename = 'jython'
html_theme = 'sphinx_rtd_theme'
file_insertion_enabled = False
latex_documents = [
('index', 'jython.tex', u'jython Documentation',
u'', 'manual'),
]
###########################################################################
# auto-created readthedocs.org specific configuration #
###########################################################################
#
# The following code was added during an automated build on readthedocs.org
# It is auto created and injected for every build. The result is based on the
# conf.py.tmpl file found in the readthedocs.org codebase:
# https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
#
import sys
import os.path
from six import string_types
from sphinx import version_info
# Get suffix for proper linking to GitHub
# This is deprecated in Sphinx 1.3+,
# as each page can have its own suffix
if globals().get('source_suffix', False):
if isinstance(source_suffix, string_types):
SUFFIX = source_suffix
else:
SUFFIX = source_suffix[0]
else:
SUFFIX = '.rst'
# Add RTD Static Path. Add to the end because it overwrites previous files.
if not 'html_static_path' in globals():
html_static_path = []
if os.path.exists('_static'):
html_static_path.append('_static')
html_static_path.append('/home/docs/checkouts/readthedocs.org/readthedocs/templates/sphinx/_static')
# Add RTD Theme only if they aren't overriding it already
using_rtd_theme = False
if 'html_theme' in globals():
if html_theme in ['default']:
# Allow people to bail with a hack of having an html_style
if not 'html_style' in globals():
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_style = None
html_theme_options = {}
if 'html_theme_path' in globals():
html_theme_path.append(sphinx_rtd_theme.get_html_theme_path())
else:
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
using_rtd_theme = True
else:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_style = None
html_theme_options = {}
if 'html_theme_path' in globals():
html_theme_path.append(sphinx_rtd_theme.get_html_theme_path())
else:
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
using_rtd_theme = True
if globals().get('websupport2_base_url', False):
websupport2_base_url = 'https://readthedocs.org/websupport'
if 'http' not in settings.MEDIA_URL:
websupport2_static_url = 'https://media.readthedocs.org/static/'
else:
websupport2_static_url = 'https://media.readthedocs.org//static'
#Add project information to the template context.
context = {
'using_theme': using_rtd_theme,
'html_theme': html_theme,
'current_version': "latest",
'MEDIA_URL': "https://media.readthedocs.org/",
'PRODUCTION_DOMAIN': "readthedocs.org",
'versions': [
("latest", "/en/latest/"),
],
'downloads': [
("pdf", "//readthedocs.org/projects/jython/downloads/pdf/latest/"),
("htmlzip", "//readthedocs.org/projects/jython/downloads/htmlzip/latest/"),
("epub", "//readthedocs.org/projects/jython/downloads/epub/latest/"),
],
'subprojects': [
],
'slug': 'jython',
'name': u'jython',
'rtd_language': u'en',
'canonical_url': 'http://jython.readthedocs.io/en/latest/',
'analytics_code': 'None',
'single_version': False,
'conf_py_path': '/./',
'api_host': 'https://readthedocs.org',
'github_user': 'jython',
'github_repo': 'book',
'github_version': 'master',
'display_github': True,
'bitbucket_user': 'None',
'bitbucket_repo': 'None',
'bitbucket_version': 'master',
'display_bitbucket': False,
'READTHEDOCS': True,
'using_theme': (html_theme == "default"),
'new_theme': (html_theme == "sphinx_rtd_theme"),
'source_suffix': SUFFIX,
'user_analytics_code': '',
'global_analytics_code': 'UA-17997319-1',
'commit': 'cf5cf6de',
}
if 'html_context' in globals():
html_context.update(context)
else:
html_context = context
# Add custom RTD extension
if 'extensions' in globals():
extensions.append("readthedocs_ext.readthedocs")
else:
extensions = ["readthedocs_ext.readthedocs"]

Rendering discrepancy between ReadTheDocs and localhost

I have just uploaded my documentation from Github to ReadTheDocs and I have found that it renders completely different on ReadTheDocs and my local machine. I am using the latest sphinx_rtd_theme on my local machine.
Here is the display on my local machine:
and here is the rendering on ReadTheDocs:
I have tried on Chrome, Firefox and Microsoft Edge with the same results so it does not appear to be a browser problem.
Here is a copy of my conf.py:
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
# -- Project information -----------------------------------------------------
project = 'OrderedTree'
project_title = 'Ordered Tree'
copyright = '2018, Jonathan Gossage'
author = 'Jonathan Gossage'
# The short X.Y version
version = '0.0'
# The full version, including alpha/beta/rc tags
release = '0.0.1'
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# Elements to be included at yhe start of each document file
rst_prolog = """
.. |br| raw:: html
<br />
.. |pn| replace:: {}
.. |pt| replace:: {}
""".format(project, project_title)
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#html_theme = 'sphinx_rtd_theme'
on_rtd = os.environ.get('READTHEDOCS') == 'True'
if on_rtd:
html_theme = 'default'
else:
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
if on_rtd:
html_static_path = []
else:
html_static_path = ['_static']
html_context = { # Specify the css file to use
'css_files': ['_static/theme_overrides.css',]
}
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = '{}doc'.format(project)
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, '{}.tex'.format(project), '{} Documentation'.format(project_title),
'{}'.format(author), 'manual'),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, '{}'.format(project), '{} Documentation'.format(project_title),
[author], 1)
]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, '{}'.format(project), '{} Documentation'.format(project_title),
author, '{}'.format(project), 'One line description of project.',
'Miscellaneous'),
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project_title
epub_author = author
epub_publisher = author
epub_copyright = copyright
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
I have determined what is causing the problem but I have no idea why it is happening or how to fix it. I am using a boiler-plate fragment of HTML from Creative Commons which identifies the license governing use of the documentation. I took the base sphinx_rtd_theme Footer.html and added this fragment to it and used the modified Footer.html to override the base copy. The fragment follows:
<br /> <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a>
<br />
<p>
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>
</p>
The fragment actually works as this HTML is correctly rendered on ReadTheDocs but the rest of the formatting disappears.
What do I need to do to get the local display on ReadTheDocs?
Sounds like static assets are not getting copied over on RTD. Let's look at the build log, under python /home/docs/checkouts/readthedocs.org/user_builds/orderedtree/envs/latest/bin/sphinx-build -T -E -b readthedocs -d _build/doctrees-readthedocs -D language=en . _build/html:
copying static files... WARNING: html_static_path entry '/home/docs/checkouts/readthedocs.org/readthedocs/templates/sphinx/_static' does not exist
You know what? That error sounds strangely familiar for some reason....
Let's see the setting in your conf.py:
html_static_path = ['_static']
Try changing that to:
html_static_path = []
Seems to work for about a dozen other users.

Sphinx pdfbuilder format not resolved, probably missing URL

I am trying to generate a pdf using rst2pdf, but keep getting the error "format not resolved, probably missing URL or undefined destination for target".
I use sphinx to generate the .rst files and am able to generate the HTML output just fine.
To generate the pdf I followed the instructions at: https://gist.github.com/alfredodeza/7fb5c667addb1c6963b9
Directory Structure:
- sphinxtext
* docs
** source
** build
* test.py
Conf.py:
# -*- coding: utf-8 -*-
#
# Test documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 30 12:08:40 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..\..'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.coverage','rst2pdf.pdfbuilder']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Test'
copyright = u'2017, m.a.'
author = u'm.a.'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'1.0.0'
# The full version, including alpha/beta/rc tags.
release = u'1.0.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'Testdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Test.tex', u'Test Documentation',
u'm.a.', 'manual'),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'test', u'Test Documentation',
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Test', u'Test Documentation',
author, 'Test', 'One line description of project.',
'Miscellaneous'),
]
# -- Options for pdf output -------------------------------------------
pdf_documents = [('index', u'rst2pdf', u'Sample rst2pdf doc', u'Your Name'),]
# index - master document
# rst2pdf - name of the generated pdf
# Sample rst2pdf doc - title of the pdf
# Your Name - author name in the pdf
test.py
class Test(object):
'''
Test class
'''
def __init__(self,**kwargs):
"""
Constructor
"""
def some_func(self,a,b,c,d,e,f,g):
"""
Function that does something TEST
:param a: Identifier
:param b: b
:param c: c
:param d: d
:param e: e
:param f: f
:param g: g
:type a: int
:type b: float
:type c: float
:type d: float
:type e: float
:type f: float
:type h: float
:returns: Test obj
:Example:
>>> test=Test()
>>> test.some_func(10, 42164., 0.0, 0., -132.0, 0.0, 0.0)
"""
self.a=a
self.b = b
self.c = c
self.d = d
self.e = e
self.f = f
self.g = g
return self
When building as html I see the following warning: checking consistency... C:\PATH\docs\source\modules.rst: WARNING: document isn't included in any toctree
My index.rst file:
.. Test documentation master file, created by
sphinx-quickstart on Fri Jun 30 12:08:40 2017.
You can adapt this file completely to your liking, but it should at least
contain the root toctree directive.
Welcome to Test's documentation!
================================
.. toctree::
:maxdepth: 2
:caption: Contents:
test
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
My test.rst:
Test Module!
================================
.. automodule:: test
:members:
This has now been resolved in rst2pdf via PR 619.
You can install the version of rst2pdf that has this fix by doing this:
$ cd {some directory where you keep 3rd-party projects, e.g. ~/projects}
$ git clone https://github.com/rst2pdf/rst2pdf.git
$ cd rst2pdf
$ python setup.py install
If you are still getting this message in 2021, it likely means rst2pdf can't figure out where one or more of your links is pointed. For example, I had in-page nav links in my .rst code like this that were ok when building HTML but causing the error referred to by the OP during PDF generation:
`Back to top ↑ <#top>`_
The most reliable solution seems to be to remove these in-page links.
Alternatively, you could just convert these implicit links to raw html blocks like below, which could be a solution if you can get rst2pdf to render raw html using xhtml2pdf (this isn't working for me, but perhaps someone else can get it).
.. |top| raw:: html
Back to top ↑
|top|
Note that in this alternative solution, the in-page links probably will not work in most PDF viewers, so this is really only a solution to get .rst files to compile to both PDF and HTML (as the OP asked), rather than one that will allow identical behavior.

how can I improve my Rakefile (deployment)

I'm writing my first Rakefile. The first things that I see in the doc is "there is no special format for a Rakefile" and "there is no special syntax in a Rakefile".
Ok, so I had to come up with something on my own, but I can see at least two problems with my creature:
1) I need to create a number of folders, five of them. The sequence of 6 directory tasks looks a bit weird. The list of 5 dependencies in deploy task looks even more weird. Can I shrink it down to one line somehow?
2) I need to repeat my directory name literals two times - when I define their deployment paths and when I copy the contents. Can I avoid that without introducing 5 more variables?
In Java Ant I would create a properties file with all name literals - can I do that with Rake?
This is what I've got:
WEBAPPSDIR = '/var/webapps/'
WEBAPPNAME = 'foo.local'
WEBAPPDIR = File.join(WEBAPPSDIR, WEBAPPNAME)
VIEWSDIR = File.join(WEBAPPDIR, 'views')
PUBLICDIR = File.join(WEBAPPDIR, 'public')
CSSDIR = File.join(PUBLICDIR, 'css')
IMAGESDIR = File.join(PUBLICDIR, 'images')
TMPDIR = File.join(WEBAPPDIR, 'tmp')
HTMLDIR = File.join(PUBLICDIR, 'html')
directory VIEWSDIR
directory CSSDIR
directory HTMLDIR
directory IMAGESDIR
directory TMPDIR
desc 'Deploy to webapps dir'
task :deploy => [VIEWSDIR, CSSDIR, IMAGESDIR, TMPDIR, HTMLDIR] do
cp 'config.ru', WEBAPPDIR
Dir.glob('*.rb') {|f| cp f, WEBAPPDIR}
Dir.glob('views/*.{mab,str}') {|f| cp f, VIEWSDIR}
Dir.glob('css/*.css') {|f| cp f, CSSDIR}
Dir.glob('images/*.{png,jpg,gif}') {|f| cp f, IMAGESDIR}
Dir.glob('html/*.html') {|f| cp f, VIEWSDIR}
end
desc 'Cleans webapp dir'
task :clean do
rm_r WEBAPPDIR, {force: true}
end
Other thoughts/links/examples are welcome too.
This does not really answer your question - but why don't you use capistrano ? If you don't know it already, it's a ruby tool frequently used to handle deployments smoothly

Resources