Permalink
Browse files

build config refactoring; ready for initial release 0.9.0

  • Loading branch information...
1 parent 087fb74 commit aa52ff4f9343ccfb5bb557ace5972da59cbd0f4b @ches committed Sep 27, 2010
Showing with 104 additions and 42 deletions.
  1. +2 −0 .gitignore
  2. +13 −6 README.rst
  3. +45 −35 Rakefile
  4. +43 −0 bundle/Contents/config.yml
  5. +1 −1 templates/Contents/Info.plist
View
@@ -2,7 +2,9 @@
*.pyc
build
+dist
Framework
+bundle/Contents/env
# files generated from templates/
bundle/Contents/Info.plist
View
@@ -2,16 +2,17 @@
Plex-Vimcasts
=============
-A simple `Plex`_ plugin for `vimcasts.org`_, allowing you to view the
+A simple Plex_ plugin for vimcasts.org_, allowing you to view the
screencasts from the comfort of your media center.
Building From Source
====================
-The `Plex-Vimcasts`_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need:
+The Plex-Vimcasts_ plugin bundle is built from files in the ``bundle/`` and ``templates/`` directories. To build the bundle you'll need:
-* Git_
-* Ruby_ & Rake_ (Both are bundled with OS X)
+- Git_
+- Ruby_ & Rake_ (Both are bundled with OS X)
+- The rb-appscript_ RubyGem (``gem install rb-appscript``)
With those tools installed, get a copy of the source and install the plugin::
@@ -25,6 +26,11 @@ If you'd like to remove the plugin later, use::
Or, ``rake uninstall:hard`` to uninstall the plugin *and* it's preferences and data.
+To Do
+=====
+
+- Proper plugin artwork, instead of stealing Railscasts'
+
License
=======
@@ -37,14 +43,15 @@ This, my first Plex plugin, is essentially a bunch of copy and paste!
- Basically a clone of David Leatherman's `Railscasts plugin`_.
- Rake build script cribbed from Rick Fletcher's `MLB plugin`_. Probably
- overkill for this simple plugin, but especially as a Rubyist it may prove a
- useful model for future plugins :-)
+ overkill for this simple plugin, but it's a nice generalized example for other
+ plugins to follow :-)
.. _Plex: http://plexapp.com/
.. _vimcasts.org: http://vimcasts.org/
.. _Git: http://code.google.com/p/git-osx-installer/downloads/list?can=3
.. _Ruby: http://www.ruby-lang.org/
.. _Rake: http://rake.rubyforge.org/
+.. _rb-appscript: http://appscript.sourceforge.net/rb-appscript/index.html
.. _Railscasts plugin: http://github.com/leathekd/plex_railscasts_plugin
.. _MLB plugin: http://github.com/rfletcher/plex-mlb
View
@@ -1,5 +1,6 @@
-# Lifted from Rick Fletcher's MLB plugin, hat tip is due:
+# Lifted and adapted from Rick Fletcher's MLB plugin, hat tip is due:
# http://github.com/rfletcher/plex-mlb
+# Overkill for this plugin really, but it's a nice general example build setup.
require 'pathname'
require 'rake'
@@ -12,20 +13,35 @@ require 'rubygems'
require 'appscript'
# Base Paths
-PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__))
+PLUGIN_ROOT = Pathname.new(File.dirname(__FILE__)).expand_path
PLUGIN_BUNDLE_DIR = PLUGIN_ROOT + 'bundle'
PLUGIN_BUILD_DIR = PLUGIN_ROOT + 'build'
+PLUGIN_DIST_DIR = PLUGIN_ROOT + 'dist'
PLUGIN_TEMPLATE_DIR = PLUGIN_ROOT + 'templates'
# Plex and Plex Media Server paths
-APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support")
+APP_SUPPORT_DIR = Pathname.new("#{ENV['HOME']}/Library/Application Support").expand_path
PLEX_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex'
PMS_SUPPORT_DIR = APP_SUPPORT_DIR + 'Plex Media Server'
PMS_PLUGIN_DIR = PMS_SUPPORT_DIR + 'Plug-ins'
PMS_PLUGIN_DATA_DIR = PMS_SUPPORT_DIR + 'Plug-in Support'
PMS_BIN = PLEX_SUPPORT_DIR + 'Plex Media Server.app/Contents/MacOS/Plex Media Server'
+def config(env=:release)
+ @config ||= YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml')[env.to_s]
+end
+
+PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_"
+
+# files to blow away with a `rake clean` and `clobber`. Clobber also cleans.
+CLEAN.include(PLUGIN_BUILD_DIR.to_s)
+CLOBBER.include(PLUGIN_DIST_DIR)
+
+# ==============================================================================
+# = HELPERS
+# ==============================================================================
+
class File
def self.binary?(name)
fstat = stat(name)
@@ -44,7 +60,7 @@ class File
end
end
-def add_env(env, bundle_dir)
+def add_env_file(env, bundle_dir)
File.open(File.join(bundle_dir, 'Contents', 'env'), 'w') do |f|
f.write env.to_s
end
@@ -54,6 +70,7 @@ def bundle_name(config)
(config['PLUGIN_BUNDLE_NAME'] ? config['PLUGIN_BUNDLE_NAME'] : config['PLUGIN_NAME']) + '.bundle'
end
+# Really lo-fi 'erb' :-)
def erb(config, file)
warning = <<-EOW
DO NOT EDIT THIS FILE
@@ -84,24 +101,17 @@ def erb(config, file)
mv(temp.path, file, :verbose => false)
end
-def load_config(env=:release)
- YAML.load_file(PLUGIN_BUNDLE_DIR + 'Contents/config.yml'))[env.to_s]
-end
-
-config = load_config
-
-PLUGIN_PACKAGE_NAME = "#{config['PLUGIN_NAME']}-#{config['PLUGIN_VERSION']}".gsub " ", "_"
-
-# files to blow away with a `rake clobber`
-CLOBBER.include(PLUGIN_BUILD_DIR, "#{PLUGIN_PACKAGE_NAME}.tar.gz")
+# ==============================================================================
+# = TASKS
+# ==============================================================================
task :default => :build
namespace :build do
def build_templates(config, build_dir)
FileList[PLUGIN_TEMPLATE_DIR + '**/*'].each do |file|
if File.file?(file)
- dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.length + 1, file.length])
+ dest_dir = File.join build_dir, File.dirname(file[PLUGIN_TEMPLATE_DIR.to_s.length + 1, file.length])
dest_file = File.join dest_dir, File.basename(file)
mkdir_p dest_dir
@@ -112,11 +122,11 @@ namespace :build do
end
def build(env, config)
- File.rm_if_exists File.join(PLUGIN_BUILD_DIR)
+ File.rm_if_exists PLUGIN_BUILD_DIR
mkdir_p PLUGIN_BUILD_DIR
bundle_dir = PLUGIN_BUILD_DIR + bundle_name(config)
cp_r PLUGIN_BUNDLE_DIR, bundle_dir
- add_env env, bundle_dir
+ add_env_file env, bundle_dir
rm FileList[PLUGIN_BUILD_DIR + '**/*.pyc']
@@ -126,22 +136,25 @@ namespace :build do
desc 'Build a dev distribution.'
task :development do
- build_templates load_config(:development), PLUGIN_BUNDLE_DIR
- build :development, load_config(:development)
+ build_templates config(:development), PLUGIN_BUNDLE_DIR
+ build :development, config(:development)
end
task :dev => :development
desc 'Build a release distribution.'
task :release do
+ build_templates config, File.join(PLUGIN_BUILD_DIR, bundle_name(config))
build :release, config
- build_templates config, File.join( PLUGIN_BUILD_DIR, bundle_name(config))
end
end
-desc 'Alias for build:release'
-task :build => 'build:release'
+desc 'Alias for build:development'
+task :build => 'build:development'
namespace :package do
def package(config)
+ File.rm_if_exists PLUGIN_DIST_DIR
+ mkdir_p PLUGIN_DIST_DIR
+
Appscript.app('AppMaker').activate
se = Appscript.app('System Events')
@@ -169,29 +182,27 @@ namespace :package do
am_window.UI_elements['Create Package'].click
am.keystroke('g', :using => [ :command_down, :shift_down ])
- am.keystroke(PLUGIN_BUILD_DIR + "\r")
+ am.keystroke(PLUGIN_DIST_DIR.to_s + "\r")
am.keystroke((config['PLUGIN_NAME'] + '-' + config['PLUGIN_VERSION'].to_s).gsub(' ', '_') + "\r")
# wait for save
am_window.text_fields[1].focused.set(true)
Appscript.app('AppMaker').quit
-
end
desc 'Create a dev-mode, installable Plex app'
task :development => 'build:development' do
- package load_config(:development)
+ package config(:development)
end
task :dev => :development
desc 'Create an installable Plex app'
task :release => 'build:release' do
- package config
+ package config(:release)
end
end
-task :package => 'package:release' do
-end
+task :package => 'package:release'
namespace :pms do
task :restart => [ :stop, :start ]
@@ -202,7 +213,7 @@ namespace :pms do
end
task :stop do
- system 'killall', 'Plex Media Server'
+ system 'killall', 'Plex Media Server'
end
end
task :pms => 'pms:restart'
@@ -213,21 +224,20 @@ namespace :install do
desc 'Install a development version of the plugin'
task :development => [ 'build:development', :uninstall ] do
- config = load_config :development
- ln_s(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config))
- add_env :development, PLUGIN_BUNDLE_DIR
+ ln_s(PLUGIN_BUNDLE_DIR, PMS_PLUGIN_DIR + bundle_name(config(:development)))
+ add_env_file :development, PLUGIN_BUNDLE_DIR
end
task :dev => :development
desc 'Install a release version of the plugin'
task :release => [ 'build:release', :uninstall ] do
mkdir_p(PMS_PLUGIN_DIR + bundle_name(config))
cp_r(PLUGIN_BUILD_DIR + bundle_name(config), PMS_PLUGIN_DIR)
- add_env :release, PLUGIN_BUNDLE_DIR
+ add_env_file :release, PLUGIN_BUNDLE_DIR
end
end
-desc 'Alias for install:release'
-task :install => 'install:release'
+desc 'Alias for install:development'
+task :install => 'install:development'
namespace :uninstall do
desc 'Remove the installed bundle, but leave data behind.'
@@ -0,0 +1,43 @@
+# Plugin configuration
+#
+# This configuration setup allows for easy, environment-specific configuration.
+# Its settings can be inserted into other files at build-time, or loaded by
+# python code at run-time with PyYAML.
+
+# Default settings. This is never read directly. Instead, it's extended by
+# other sections below.
+default: &default
+ PLUGIN_ID: com.plexapp.plugins.vimcasts
+ PLUGIN_NAME: Vimcasts
+ PLUGIN_PREFIX: /video/vimcasts
+ PLUGIN_VERSION: 0.9.0
+ PLUGIN_AUTHOR: Ches Martin <ches@whiskeyandgrits.net>
+ PLUGIN_DESCRIPTION: |
+ Vimcasts publishes regular screencasts about the Vim text editor. Episodes
+ are kept short – typically less than 5 minutes, never more than 10. The aim
+ is to provide something in each episode that you can take away and use.
+
+ Vimcasts is produced by Drew Neil (aka nelstrom).
+
+ VERSION_IN_PLUGIN_NAME: false
+
+ CACHE_TTL: 3600
+
+ PLIST_DEBUG: 0
+ PLIST_DEV_MODE: 0
+
+# override some values when building a dev release
+development:
+ <<: *default
+ VERSION_IN_PLUGIN_NAME: true
+
+ # disable caching
+ CACHE_TTL: 0
+
+ # turn on dev mode (no auto-updates), and debug
+ PLIST_DEBUG: 1
+ PLIST_DEV_MODE: 1
+
+# release version inherits defaults
+release:
+ <<: *default
@@ -19,7 +19,7 @@
<key>PlexPluginMode</key>
<string>AlwaysOn</string>
<key>PlexFrameworkVersion</key>
- <string>1</string>
+ <string>2</string>
<key>PlexPluginDebug</key>
<string><%= PLIST_DEBUG %></string>
<key>PlexPluginDevMode</key>

0 comments on commit aa52ff4

Please sign in to comment.