maccman-bowline 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.txt CHANGED
@@ -22,8 +22,8 @@ http://twitter.com/maccman
22
22
 
23
23
  = Usage - Building a basic Twitter client
24
24
 
25
- Build Titanium by following the instructions here:
26
- http://wiki.github.com/marshall/titanium/build-instructions
25
+ Install the Titanium SDK:
26
+ http://www.appcelerator.com/products/download-titanium/download/
27
27
 
28
28
  Install the gem:
29
29
  >> sudo gem install maccman-bowline --source http://gems.github.com
@@ -95,27 +95,33 @@ Usage for a collection (of users):
95
95
 
96
96
  <html>
97
97
  <head>
98
- <script src="jquery.js" type="text/javascript" charset="utf-8"></script>
99
- <script src="chain.js" type="text/javascript" charset="utf-8"></script>
100
- <script src="bowline.js" type="text/javascript" charset="utf-8"></script>
98
+ <script src="javascripts/jquery.js" type="text/javascript"></script>
99
+ <script src="javascripts/jquery.chain.js" type="text/javascript"></script>
100
+ <script src="javascripts/jquery.bowline.js" type="text/javascript"></script>
101
+ <script src="javascripts/application.js" type="text/javascript"></script>
101
102
  <script type="text/javascript" charset="utf-8">
102
103
  jQuery(function($){
103
- // Bind the element users to UserBinder
104
- var users = $('#users').bowline('users', function(){
105
- var self = $(this);
106
- self.find('.destroy').click(function(){
107
- self.invoke('destroy');
108
- return false;
109
- })
110
- });
104
+ $.bowline.ready(function(){
105
+ // Bind the element users to UserBinder
106
+ var users = $('#users').bowline('users', function(){
107
+ var self = $(this);
108
+ self.find('.destroy').click(function(){
109
+ self.invoke('destroy');
110
+ return false;
111
+ })
112
+ });
111
113
 
112
- $('#showAdmins').click(function(){
113
- users.invoke('admins');
114
- return false;
115
- });
114
+ $('#showAdmins').click(function(){
115
+ users.invoke('admins');
116
+ return false;
117
+ });
116
118
 
117
- // Populate with all the users
118
- users.invoke('index');
119
+ // Populate with all the users
120
+ users.invoke('index');
121
+
122
+ // Invoke a helper
123
+ var time = $.bowline.helper('current_time');
124
+ });
119
125
  });
120
126
  </script>
121
127
  </head>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.3
data/bowline.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{bowline}
5
- s.version = "0.3.1"
5
+ s.version = "0.3.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alex MacCaw"]
9
- s.date = %q{2009-07-10}
9
+ s.date = %q{2009-07-13}
10
10
  s.default_executable = %q{bowline-gen}
11
11
  s.description = %q{Ruby/JS GUI framework}
12
12
  s.email = %q{alex@leadthinking.com}
@@ -38,11 +38,25 @@ Gem::Specification.new do |s|
38
38
  "lib/bowline/commands/console.rb",
39
39
  "lib/bowline/commands/generate.rb",
40
40
  "lib/bowline/commands/run.rb",
41
+ "lib/bowline/dependencies/FAQ.markdown",
42
+ "lib/bowline/dependencies/MIT-LICENSE",
43
+ "lib/bowline/dependencies/README.markdown",
44
+ "lib/bowline/dependencies/Rakefile",
45
+ "lib/bowline/dependencies/TODO.markdown",
46
+ "lib/bowline/dependencies/init.rb",
47
+ "lib/bowline/dependencies/lib/dependencies.rb",
48
+ "lib/bowline/dependencies/lib/dependencies/dependency.rb",
49
+ "lib/bowline/dependencies/lib/dependencies/reader.rb",
50
+ "lib/bowline/dependencies/lib/dependencies/repository.rb",
51
+ "lib/bowline/dependencies/lib/ext/common.rb",
52
+ "lib/bowline/dependencies/lib/ext/rubygems.rb",
53
+ "lib/bowline/dependencies/lib/template/app_script.rb",
54
+ "lib/bowline/dependencies/spec/spec.opts",
55
+ "lib/bowline/dependencies/tasks/dependencies.rake",
41
56
  "lib/bowline/ext/array.rb",
42
57
  "lib/bowline/ext/class.rb",
43
58
  "lib/bowline/ext/object.rb",
44
59
  "lib/bowline/ext/string.rb",
45
- "lib/bowline/gem_dependency.rb",
46
60
  "lib/bowline/generators.rb",
47
61
  "lib/bowline/generators/application.rb",
48
62
  "lib/bowline/generators/binder.rb",
@@ -56,6 +70,7 @@ Gem::Specification.new do |s|
56
70
  "lib/bowline/tasks/app.rake",
57
71
  "lib/bowline/tasks/bowline.rb",
58
72
  "lib/bowline/tasks/database.rake",
73
+ "lib/bowline/tasks/gems.rake",
59
74
  "lib/bowline/tasks/log.rake",
60
75
  "lib/bowline/tasks/misc.rake",
61
76
  "lib/bowline/version.rb",
@@ -5,24 +5,22 @@
5
5
  <head>
6
6
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
7
  <title>Twitter</title>
8
- <!--
9
- <script src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js" type="text/javascript"></script>
10
- -->
11
8
  <script src="javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
12
9
  <script src="javascripts/jquery.chain.js" type="text/javascript" charset="utf-8"></script>
13
10
  <script src="javascripts/jquery.bowline.js" type="text/javascript" charset="utf-8"></script>
14
- <script src="../script/init" type="text/ruby" charset="utf-8"></script>
15
11
  <script src="javascripts/application.js" type="text/javascript" charset="utf-8"></script>
16
12
  <link rel="stylesheet" href="stylesheets/application.css" type="text/css" charset="utf-8">
17
13
  <script type="text/javascript" charset="utf-8">
18
14
  jQuery(function($){
19
- var tweets = $('#tweets').bowline('tweets');
20
- tweets.invoke('index');
15
+ $.bowline.ready(function(){
16
+ var tweets = $('#tweets').bowline('tweets');
17
+ tweets.invoke('index');
21
18
 
22
- $('#updateSubmit').click(function(){
23
- tweets.invoke('update', $('#updateText').val());
24
- return false;
25
- })
19
+ $('#updateSubmit').click(function(){
20
+ tweets.invoke('update', $('#updateText').val());
21
+ return false;
22
+ });
23
+ });
26
24
  });
27
25
  </script>
28
26
  </head>
data/lib/bowline.rb CHANGED
@@ -32,7 +32,7 @@ require 'bowline/ext/class'
32
32
  require 'bowline/ext/string'
33
33
 
34
34
  require 'bowline/helpers'
35
- require 'bowline/gem_dependency'
35
+ require 'bowline/dependencies/lib/dependencies'
36
36
  require 'bowline/initializer'
37
37
 
38
38
  require 'bowline/jquery'
@@ -0,0 +1,6 @@
1
+ FAQ
2
+ ===
3
+
4
+ 1. gem install or uninstall fails with gem >= 0 message
5
+ > gems/gems/ directory is likely dirty, remove any specifications, cache, doc, gems, or bin folders beneath it.
6
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ Dependencies
2
+ ============
3
+
4
+ A port of Merb's dependency system to a Rails plugin.
5
+
6
+ Usage
7
+ =====
8
+
9
+ 1. Install the plugin
10
+
11
+ script/plugin install git://github.com/ddollar/dependencies.git
12
+
13
+ 2. Add the following line to your config/environment.rb
14
+
15
+ config.plugins = [:dependencies, :all]
16
+
17
+ 3. Add the following line to your .gitignore
18
+
19
+ gems
20
+
21
+ 4. Create a config/dependencies.rb file that looks like:
22
+
23
+ dependency 'gem'
24
+ dependency 'gem', '1.0.1'
25
+ dependency 'gem', :require_as => 'Gem'
26
+ dependency 'gem', :only => %w(test staging)
27
+ dependency 'gem', :except => 'production'
28
+
29
+ with_options(:only => 'test') do |test|
30
+ test.dependency 'tester-gem'
31
+ end
32
+
33
+ 5. Remove or comment out any config.gem lines from config/environment.rb or config/environments/*.rb
34
+
35
+ 6. Install the gems into your project and keep them up to date using:
36
+
37
+ rake dependencies:sync
38
+
39
+ 7. Alternatively you can use the following rake task to read your existing config.gem declarations and output a file suitable for this plugin. This task will appropriately handle any gems that you are currently loading on a per-environment basis as well.
40
+
41
+ rake dependencies:import
42
+
43
+
44
+ About
45
+ =====
46
+
47
+ Initial idea and Rubygems extension code from [Merb](http://merbivore.com/)
48
+
49
+ Rewritten for Rails by [David Dollar](http://daviddollar.org) ([@ddollar](http://twitter.com/ddollar))
50
+
51
+ Documentation, testing, ideas by Steven Soroka ([@ssoroka](http://twitter.com/ssoroka))
@@ -0,0 +1,10 @@
1
+ require 'spec/rake/spectask'
2
+ require 'rcov'
3
+
4
+ task :default => :spec
5
+
6
+ desc "Run all specs"
7
+ Spec::Rake::SpecTask.new(:spec) do |t|
8
+ t.spec_opts = ['--options', 'spec/spec.opts']
9
+ t.spec_files = FileList['spec/**/*_spec.rb']
10
+ end
@@ -0,0 +1,4 @@
1
+ To Do
2
+ =====
3
+
4
+ * Better handling of gems that depend on Rails to load.
@@ -0,0 +1,41 @@
1
+ unless $block_dependencies_plugin_init
2
+
3
+ require File.join(File.dirname(__FILE__), 'lib', 'dependencies')
4
+
5
+ Gem.clear_paths
6
+ Gem.path.unshift(File.join(Rails.root, 'gems'))
7
+
8
+ deps = ::Dependencies::Reader.read_file(File.join(Rails.root, 'config', 'dependencies.rb'))
9
+
10
+ deps.each do |dep|
11
+ current_environment = ENV['RAILS_ENV'] || 'development'
12
+
13
+ options = {
14
+ :only => [current_environment],
15
+ :except => [],
16
+ :require_as => dep.name
17
+ }.merge(dep.options)
18
+
19
+ # swap their :only and :except to an array if they used a not-Array
20
+ [ :only, :except ].each do |option|
21
+ options[option] = [options[option].to_s] unless options[option].is_a?(Array)
22
+ end
23
+
24
+ # don't run if require_as is nil or false
25
+ next if [nil, false].include?(options[:require_as])
26
+
27
+ # don't run if the dependency wants an env that is not the current one
28
+ next unless options[:only].include?(current_environment)
29
+
30
+ # don't run if the dependency does not want to load in the current env
31
+ next if options[:except].include?(current_environment)
32
+
33
+ begin
34
+ require options[:require_as]
35
+ rescue LoadError => e
36
+ puts "was unable to require #{dep.name} as '#{options[:require_as]}'
37
+ Reason: #{e.class.name} error raised with message: #{e.message}"
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,9 @@
1
+ module Dependencies; end
2
+
3
+ Dir[File.join(File.dirname(__FILE__), 'ext', '*.rb')].each do |file|
4
+ require file
5
+ end
6
+
7
+ Dir[File.join(File.dirname(__FILE__), 'dependencies', '*.rb')].each do |file|
8
+ require file
9
+ end
@@ -0,0 +1,12 @@
1
+ class Dependencies::Dependency
2
+ attr_accessor :name, :versions, :options
3
+
4
+ def initialize(name, *options)
5
+ opts = options.last.is_a?(Hash) ? options.pop : {}
6
+ vers = options
7
+
8
+ @name = name
9
+ @versions = vers
10
+ @options = opts
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ require 'active_support/core_ext/hash/deep_merge'
2
+ require 'active_support/option_merger'
3
+
4
+ class Dependencies::Reader
5
+
6
+ attr_reader :dependencies
7
+
8
+ def self.read(definitions)
9
+ reader = new
10
+ reader.instance_eval(definitions)
11
+ reader.dependencies
12
+ end
13
+
14
+ def self.read_file(filename)
15
+ self.read(File.read(filename))
16
+ end
17
+
18
+ def initialize
19
+ @dependencies = []
20
+ end
21
+
22
+ def dependency(name, *options)
23
+ @dependencies << ::Dependencies::Dependency.new(name, *options)
24
+ end
25
+
26
+ def with_options(options)
27
+ yield ActiveSupport::OptionMerger.new(self, options)
28
+ end
29
+
30
+ end
@@ -0,0 +1,64 @@
1
+ class Dependencies::Repository
2
+
3
+ def initialize(base)
4
+ @paths = {
5
+ :gems => File.join(base),
6
+ :bin => File.join(base, 'bin'),
7
+ :specs => File.join(base, 'specifications')
8
+ }
9
+ end
10
+
11
+ def index
12
+ @index ||= reload_index!
13
+ end
14
+
15
+ def reload_index!
16
+ @index = ::Gem::SourceIndex.new.load_gems_in(@paths[:specs])
17
+ end
18
+
19
+ def gem(name, versions=[])
20
+ ::Gem::Dependency.new(name, versions)
21
+ end
22
+
23
+ def search(gem)
24
+ index.search(gem)
25
+ end
26
+
27
+ def install(gem)
28
+ reload_index!
29
+ return if index.search(gem).last
30
+
31
+ installer = ::Gem::DependencyInstaller.new(
32
+ :bin_dir => @paths[:bin],
33
+ :install_dir => @paths[:gems],
34
+ :user_install => false)
35
+
36
+ begin
37
+ installer.install gem.name, gem.version_requirements
38
+ rescue ::Gem::GemNotFoundException => e
39
+ puts "Cannot find #{gem.name} #{gem.version_requirements}"
40
+ rescue ::Gem::RemoteFetcher::FetchError => e
41
+ puts "Problem with fetch, retrying..."
42
+ retry
43
+ end
44
+ end
45
+
46
+ def uninstall(name, version)
47
+ uninstaller = ::Gem::Uninstaller.new(name,
48
+ :version => version,
49
+ :bin_dir => @paths[:bin],
50
+ :install_dir => @paths[:gems],
51
+ :ignore => true,
52
+ :executables => true
53
+ )
54
+ uninstaller.uninstall
55
+ end
56
+
57
+ def installed
58
+ Dir[File.join(@paths[:gems], 'gems', '*')].map! { |n| File.basename(n) }
59
+ end
60
+
61
+ def gems
62
+ end
63
+
64
+ end
@@ -0,0 +1,68 @@
1
+ # This was added via Merb's bundler
2
+
3
+ require "rubygems"
4
+ require "rubygems/source_index"
5
+
6
+ module Gem
7
+ BUNDLED_SPECS = File.join(Dir.pwd, "gems", "specifications")
8
+ MAIN_INDEX = Gem::SourceIndex.from_gems_in(BUNDLED_SPECS)
9
+ FALLBACK_INDEX = Gem::SourceIndex.from_installed_gems
10
+
11
+ def self.source_index
12
+ MultiSourceIndex.new
13
+ end
14
+
15
+ def self.searcher
16
+ MultiPathSearcher.new
17
+ end
18
+
19
+ class ArbitrarySearcher < GemPathSearcher
20
+ def initialize(source_index)
21
+ @source_index = source_index
22
+ super()
23
+ end
24
+
25
+ def init_gemspecs
26
+ @source_index.map { |_, spec| spec }.sort { |a,b|
27
+ (a.name <=> b.name).nonzero? || (b.version <=> a.version)
28
+ }
29
+ end
30
+ end
31
+
32
+ class MultiPathSearcher
33
+ def initialize
34
+ @main_searcher = ArbitrarySearcher.new(MAIN_INDEX)
35
+ @fallback_searcher = ArbitrarySearcher.new(FALLBACK_INDEX)
36
+ end
37
+
38
+ def find(path)
39
+ try = @main_searcher.find(path)
40
+ return try if try
41
+ @fallback_searcher.find(path)
42
+ end
43
+
44
+ def find_all(path)
45
+ try = @main_searcher.find_all(path)
46
+ return try unless try.empty?
47
+ @fallback_searcher.find_all(path)
48
+ end
49
+ end
50
+
51
+ class MultiSourceIndex
52
+ # Used by merb.thor to confirm; not needed when MSI is in use
53
+ def load_gems_in(*args)
54
+ end
55
+
56
+ def search(*args)
57
+ try = MAIN_INDEX.search(*args)
58
+ return try unless try.empty?
59
+ FALLBACK_INDEX.search(*args)
60
+ end
61
+
62
+ def find_name(*args)
63
+ try = MAIN_INDEX.find_name(*args)
64
+ return try unless try.empty?
65
+ FALLBACK_INDEX.find_name(*args)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,125 @@
1
+ require 'erb'
2
+ require 'rubygems'
3
+ require 'rubygems/dependency_installer'
4
+
5
+ Gem.pre_install_hooks.push(proc do |installer|
6
+ unless File.file?(File.join(installer.bin_dir, "common.rb"))
7
+ FileUtils.mkdir_p(installer.bin_dir)
8
+ FileUtils.cp(File.join(File.dirname(__FILE__), "common.rb"),
9
+ File.join(installer.bin_dir, "common.rb"))
10
+ end
11
+
12
+ name = installer.spec.name
13
+
14
+ puts "+ #{name}"
15
+
16
+ if $GEMS && versions = ($GEMS.assoc(name) || [])[1]
17
+ dep = Gem::Dependency.new(name, versions)
18
+ unless dep.version_requirements.satisfied_by?(installer.spec.version)
19
+ raise "Cannot install #{installer.spec.full_name} " \
20
+ "for #{$INSTALLING}; " \
21
+ "you required #{dep}"
22
+ end
23
+ end
24
+ end)
25
+
26
+ class ::Gem::Uninstaller
27
+ def self._with_silent_ui
28
+
29
+ ui = Gem::DefaultUserInteraction.ui
30
+ def ui.say(str)
31
+ puts "- #{str}"
32
+ end
33
+
34
+ yield
35
+
36
+ class << Gem::DefaultUserInteraction.ui
37
+ remove_method :say
38
+ end
39
+ end
40
+
41
+ def self._uninstall(source_index, name, op, version)
42
+ unless source_index.find_name(name, "#{op} #{version}").empty?
43
+ uninstaller = Gem::Uninstaller.new(
44
+ name,
45
+ :version => "#{op} #{version}",
46
+ :install_dir => Dir.pwd / "gems",
47
+ :all => true,
48
+ :ignore => true,
49
+ :executables => true
50
+ )
51
+ _with_silent_ui { uninstaller.uninstall }
52
+ end
53
+ end
54
+
55
+ def self._uninstall_others(source_index, name, version)
56
+ _uninstall(source_index, name, "<", version)
57
+ _uninstall(source_index, name, ">", version)
58
+ end
59
+ end
60
+
61
+ Gem.post_install_hooks.push(proc do |installer|
62
+ source_index = installer.instance_variable_get("@source_index")
63
+ ::Gem::Uninstaller._uninstall_others(
64
+ source_index, installer.spec.name, installer.spec.version
65
+ )
66
+ end)
67
+
68
+ class ::Gem::DependencyInstaller
69
+ alias old_fg find_gems_with_sources
70
+
71
+ def find_gems_with_sources(dep)
72
+ if @source_index.any? { |_, installed_spec|
73
+ installed_spec.satisfies_requirement?(dep)
74
+ }
75
+ return []
76
+ end
77
+
78
+ old_fg(dep)
79
+ end
80
+ end
81
+
82
+ class ::Gem::SpecFetcher
83
+ alias old_fetch fetch
84
+ def fetch(*args) # in rubygems 1.3.2 fetch takes 4 parameters
85
+ dependency, all, matching_platform, prerelease = *args
86
+ idx = Gem::SourceIndex.from_installed_gems
87
+
88
+ reqs = dependency.version_requirements.requirements
89
+
90
+ if reqs.size == 1 && reqs[0][0] == "="
91
+ dep = idx.search(dependency).sort.last
92
+ end
93
+
94
+ if dep
95
+ file = dep.loaded_from.dup
96
+ file.gsub!(/specifications/, "cache")
97
+ file.gsub!(/gemspec$/, "gem")
98
+ spec = ::Gem::Format.from_file_by_path(file).spec
99
+ [[spec, file]]
100
+ else
101
+ old_fetch(*args)
102
+ end
103
+ end
104
+ end
105
+
106
+ class ::Gem::Installer
107
+ def app_script_text(bin_file_name)
108
+ template = File.read(File.join(File.dirname(__FILE__), '..', 'template' , "app_script.rb"))
109
+ erb = ERB.new(template)
110
+ erb.result(binding)
111
+ end
112
+ end
113
+
114
+ class ::Gem::Specification
115
+ def recursive_dependencies(from, index = Gem.source_index)
116
+ specs = self.runtime_dependencies.map do |dep|
117
+ spec = index.search(dep).last
118
+ unless spec
119
+ raise "Needed #{dep} for #{from}, but could not find it"
120
+ end
121
+ spec
122
+ end
123
+ specs + specs.map {|s| s.recursive_dependencies(self, index)}.flatten.uniq
124
+ end
125
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This was added by Merb's bundler
4
+
5
+ require "rubygems"
6
+ require File.join(File.dirname(__FILE__), "common")
7
+
8
+ gems_dir = File.join(File.dirname(__FILE__), '..', 'gems')
9
+
10
+ if File.directory?(gems_dir)
11
+ $BUNDLE = true
12
+ Gem.clear_paths
13
+ Gem.path.replace([File.expand_path(gems_dir)])
14
+ ENV["PATH"] = "#{File.dirname(__FILE__)}:#{ENV["PATH"]}"
15
+
16
+ gem_file = File.join(gems_dir, "specifications", "<%= spec.name %>-*.gemspec")
17
+
18
+ if local_gem = Dir[gem_file].last
19
+ version = File.basename(local_gem)[/-([\.\d]+)\.gemspec$/, 1]
20
+ end
21
+ end
22
+
23
+ version ||= "<%= Gem::Requirement.default %>"
24
+
25
+ if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
26
+ version = $1
27
+ ARGV.shift
28
+ end
29
+
30
+ gem '<%= @spec.name %>', version
31
+ load '<%= bin_file_name %>'
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,164 @@
1
+ require "rubygems"
2
+ require "rubygems/source_index"
3
+ require "rubygems/dependency_installer"
4
+ require "rubygems/uninstaller"
5
+ require "fileutils"
6
+
7
+ # there has got to be a better way to do this
8
+ unless ARGV.first == 'dependencies:import'
9
+ Gem.clear_paths
10
+ Gem.path.unshift(File.join(RAILS_ROOT, 'gems'))
11
+ end
12
+
13
+ namespace :dependencies do
14
+
15
+ task :setup do
16
+ # avoid requiring environment by working up from vendor/plugins/dependencies/tasks
17
+ rails_root = File.expand_path(File.join(File.dirname(__FILE__), %w(.. .. .. ..)))
18
+
19
+ # Dependencies isn't loaded when running from rake. This is a good place to load it.
20
+ require File.expand_path(File.join(File.dirname(__FILE__), %w(.. lib dependencies))) unless defined?(Dependencies)
21
+
22
+ SETTINGS = {
23
+ :dependencies_file => File.join(rails_root, 'config', 'dependencies.rb'),
24
+ :gem_dir => File.join(rails_root, 'gems')
25
+ }
26
+ FileUtils.mkdir(SETTINGS[:gem_dir]) unless File.exists?(SETTINGS[:gem_dir])
27
+ end
28
+
29
+ task :load => :setup do
30
+ SETTINGS[:dependencies] = ::Dependencies::Reader.read_file(SETTINGS[:dependencies_file])
31
+ end
32
+
33
+ namespace :transaction do
34
+ task :setup do
35
+ SETTINGS[:gem_original_dir] = SETTINGS[:gem_dir]
36
+ SETTINGS[:gem_dir] = SETTINGS[:gem_dir] + '.install'
37
+ end
38
+
39
+ task :begin => :setup do
40
+ FileUtils.rm_rf(SETTINGS[:gem_dir])
41
+ FileUtils.cp_r(SETTINGS[:gem_original_dir], SETTINGS[:gem_dir])
42
+ end
43
+
44
+ task :commit => :setup do
45
+ FileUtils.rm_rf(SETTINGS[:gem_original_dir])
46
+ FileUtils.mv(SETTINGS[:gem_dir], SETTINGS[:gem_original_dir])
47
+ end
48
+
49
+ task :rollback => :setup do
50
+ FileUtils.rm_rf(SETTINGS[:gem_dir])
51
+ end
52
+ end
53
+
54
+ desc 'synchronize the stuff'
55
+ task :sync => [ :setup, :load ] do
56
+ Rake::Task['dependencies:transaction:begin'].invoke
57
+
58
+ begin
59
+ repo = Dependencies::Repository.new(SETTINGS[:gem_dir])
60
+
61
+ SETTINGS[:dependencies].each do |dep|
62
+ gem = repo.gem(dep.name, dep.versions)
63
+ next unless repo.search(gem).empty?
64
+ repo.install(gem)
65
+ end
66
+
67
+ repo.reload_index!
68
+
69
+ full_list = SETTINGS[:dependencies].map do |dep|
70
+ gem = repo.gem(dep.name, dep.versions)
71
+ spec = repo.index.search(gem).last
72
+ unless spec
73
+ # Rake::Task['dependencies:transaction:rollback'].invoke # gets run on rescue below.
74
+ raise Exception.new("A required dependency #{gem} was not found")
75
+ end
76
+ deps = spec.recursive_dependencies(gem, repo.index)
77
+ [spec] + deps
78
+ end.flatten.uniq.map do |spec|
79
+ "#{spec.name}-#{spec.version}"
80
+ end
81
+
82
+ (repo.installed - full_list).each do |g|
83
+ /^(.*)\-(.*)$/ =~ g
84
+ repo.uninstall($1, $2)
85
+ end
86
+
87
+ #confirm(gems)
88
+
89
+ Rake::Task['dependencies:transaction:commit'].invoke
90
+
91
+ rescue Exception => ex
92
+ puts ex.message
93
+ puts ex.backtrace
94
+ Rake::Task['dependencies:transaction:rollback'].invoke
95
+ end
96
+ end
97
+
98
+ desc 'Build a dependencies.rb from old config.gem style declarations'
99
+ task :import do
100
+
101
+ # gross
102
+ $block_dependencies_plugin_init = true
103
+ $gems_rake_task = true
104
+ $gems_build_rake_task = true
105
+
106
+ Rake::Task['environment'].invoke
107
+ environments = %w( development test production )
108
+
109
+ gems = environments.inject({}) do |memo, environment|
110
+ begin
111
+ ENV['RAILS_ENV'] = environment
112
+ RAILS_ENV = environment
113
+ load File.join(RAILS_ROOT, 'config', 'environment.rb')
114
+ rescue StandardError => ex
115
+ puts "Something went wrong: #{ex.message}"
116
+ exit 1
117
+ end
118
+
119
+ Rails.configuration.gems.each do |gem|
120
+ signature = [gem.name, gem.requirement.to_s]
121
+ memo[signature] ||= {
122
+ :name => gem.name,
123
+ :version => gem.requirement.to_s,
124
+ :require_as => gem.lib,
125
+ :environments => []
126
+ }
127
+ memo[signature][:environments] << environment
128
+ end
129
+
130
+ memo
131
+ end
132
+
133
+ all_environments, some_environments = gems.values.partition do |gem|
134
+ gem[:environments].sort == environments.sort
135
+ end
136
+
137
+ all_environments.each do |gem|
138
+ puts dependency_declaration_from_hash(gem)
139
+ end
140
+
141
+ environments.each do |environment|
142
+ gems = some_environments.select do |gem|
143
+ gem[:environments].include?(environment)
144
+ end
145
+
146
+ unless gems.length.zero?
147
+ puts
148
+ puts "with_options(:only => '#{environment}') do |#{environment}|"
149
+ gems.each do |gem|
150
+ puts " #{environment}." + dependency_declaration_from_hash(gem)
151
+ end
152
+ puts 'end'
153
+ end
154
+ end
155
+ end
156
+ end
157
+
158
+ def dependency_declaration_from_hash(gem)
159
+ declaration = []
160
+ declaration << "dependency '#{gem[:name]}'"
161
+ declaration << "'#{gem[:version]}'" unless gem[:version].blank?
162
+ declaration << ":require_as => '#{gem[:lib]}'" unless gem[:lib] == nil
163
+ declaration.join(', ')
164
+ end
@@ -65,7 +65,7 @@ module Bowline
65
65
  end
66
66
 
67
67
  def set_load_path
68
- load_paths = configuration.load_paths + configuration.framework_paths
68
+ load_paths = configuration.load_paths
69
69
  load_paths.reverse_each { |dir| $LOAD_PATH.unshift(dir) if File.directory?(dir) }
70
70
  $LOAD_PATH.uniq!
71
71
  end
@@ -172,18 +172,26 @@ module Bowline
172
172
  end
173
173
  end
174
174
 
175
- def initialize_rubygems
175
+ def initialize_gems
176
176
  require 'rubygems'
177
- end
178
-
179
- def add_gem_load_paths
180
- unless configuration.gems.empty?
181
- configuration.gems.each { |gem| gem.add_load_paths }
182
- end
177
+ Gem.clear_paths
178
+ Gem.path.unshift(configuration.gem_path)
183
179
  end
184
180
 
185
181
  def load_gems
186
- configuration.gems.each { |gem| gem.load }
182
+ configuration.gems.each do |dep|
183
+ options = {
184
+ :lib => dep.name
185
+ }.merge(dep.options)
186
+
187
+ begin
188
+ gem dep.name, *dep.versions
189
+ require options[:lib]
190
+ rescue LoadError => e
191
+ puts "was unable to require #{dep.name} as '#{options[:lib]}'
192
+ Reason: #{e.class.name} error raised with message: #{e.message}"
193
+ end
194
+ end
187
195
  end
188
196
 
189
197
  def load_plugins
@@ -260,8 +268,7 @@ module Bowline
260
268
  Bowline.configuration = configuration
261
269
 
262
270
  set_load_path
263
- initialize_rubygems
264
- add_gem_load_paths
271
+ initialize_gems
265
272
 
266
273
  require_frameworks
267
274
  set_autoload_paths
@@ -324,8 +331,6 @@ module Bowline
324
331
  attr_accessor :bowline
325
332
 
326
333
  attr_accessor :frameworks
327
-
328
- attr_accessor :framework_paths
329
334
 
330
335
  # Whether or not classes should be cached (set to false if you want
331
336
  # application classes to be reloaded on each request)
@@ -378,7 +383,7 @@ module Bowline
378
383
  # An array of gems that this Bowline application depends on. Bowline will automatically load
379
384
  # these gems during installation, and allow you to install any missing gems with:
380
385
  #
381
- # rake gems:install
386
+ # rake gems:sync
382
387
  #
383
388
  # You can add gems with the #gem method.
384
389
  attr_accessor :gems
@@ -394,11 +399,12 @@ module Bowline
394
399
  # To require a library be installed, but not attempt to load it, pass :lib => false
395
400
  #
396
401
  # config.gem 'qrp', :version => '0.4.1', :lib => false
397
- def gem(name, options = {})
398
- # todo
399
- @gems << Bowline::GemDependency.new(name, options)
402
+ def gem(*args)
403
+ @gems << Dependencies::Dependency.new(*args)
400
404
  end
401
405
 
406
+ attr_accessor :gem_path
407
+
402
408
  # Sets the default +time_zone+. Setting this will enable +time_zone+
403
409
  # awareness for Active Record models and set the Active Record default
404
410
  # timezone to <tt>:utc</tt>.
@@ -420,13 +426,11 @@ module Bowline
420
426
  attr_accessor :sdk
421
427
  attr_accessor :copyright
422
428
 
423
- # Create a new Configuration instance, initialized with the default
424
- # values.
429
+ # Create a new Configuration instance, initialized with the default values.
425
430
  def initialize
426
431
  set_root_path!
427
432
 
428
433
  self.frameworks = default_frameworks
429
- self.framework_paths = default_framework_paths
430
434
  self.load_paths = default_load_paths
431
435
  self.load_once_paths = default_load_once_paths
432
436
  self.eager_load_paths = default_eager_load_paths
@@ -438,6 +442,7 @@ module Bowline
438
442
  self.database_configuration_file = default_database_configuration_file
439
443
  self.app_config_file = default_app_config_file
440
444
  self.gems = default_gems
445
+ self.gem_path = default_gem_path
441
446
  self.plugin_glob = default_plugin_glob
442
447
  self.helper_glob = default_helper_glob
443
448
  self.initializer_glob = default_initalizer_glob
@@ -501,16 +506,7 @@ module Bowline
501
506
  def default_frameworks
502
507
  [:active_support, :bowline]
503
508
  end
504
-
505
- def default_framework_paths
506
- [
507
- File.join(root_path, 'vendor', 'bowline', 'lib'),
508
- File.join(root_path, 'vendor', 'rails', 'activesupport', 'lib'),
509
- File.join(root_path, 'vendor', 'rails', 'activerecord', 'lib'),
510
- File.join(root_path, 'vendor', 'rails', 'activeresource', 'lib')
511
- ]
512
- end
513
-
509
+
514
510
  def default_load_paths
515
511
  paths = []
516
512
 
@@ -571,7 +567,14 @@ module Bowline
571
567
  end
572
568
 
573
569
  def default_gems
574
- []
570
+ gems = []
571
+ gems << Dependencies::Dependency.new("bowline", Bowline::Version::STRING)
572
+ gems << Dependencies::Dependency.new("activesupport")
573
+ gems
574
+ end
575
+
576
+ def default_gem_path
577
+ File.join(root_path, *%w{ vendor gems })
575
578
  end
576
579
 
577
580
  def default_plugin_glob
@@ -86,7 +86,14 @@ tiprocess:0.4.4
86
86
  Rake::Task['app:configure'].invoke
87
87
  end
88
88
 
89
- # Todo - check gem dependencies
89
+ conf = Bowline.configuration
90
+ repo = Dependencies::Repository.new(
91
+ conf.gem_path
92
+ )
93
+ if conf.gems.length > repo.installed.length
94
+ Rake::Task['gems:sync'].invoke
95
+ end
96
+
90
97
  FileUtils.rm_rf(app_path)
91
98
  FileUtils.makedirs(app_path)
92
99
 
@@ -118,14 +125,30 @@ tiprocess:0.4.4
118
125
  build_path = File.join(APP_ROOT, 'build')
119
126
  app_path = File.join(build_path, 'app')
120
127
 
121
- # Todo - cross OS
122
- ti_path = ENV['TIPATH'] || '/Library/Application Support/Titanium'
123
- ti_lib_path = Dir[File.join(ti_path, "sdk", "*", "*")][0]
124
-
125
- # Space in path
128
+ ti_path = ENV['TIPATH'] || begin
129
+ if RUBY_PLATFORM =~ /darwin/
130
+ '/Library/Application Support/Titanium'
131
+ elsif RUBY_PLATFORM =~ /win/
132
+ 'C:/ProgramData/Titanium'
133
+ elsif RUBY_PLATFORM =~ /linux/
134
+ '/opt/titanium'
135
+ else
136
+ raise "Unknown platform"
137
+ end
138
+ end
139
+
140
+ unless File.directory?(ti_path)
141
+ raise "Titanium SDK not found, " \
142
+ "install the SDK or " \
143
+ "specify the ENV variable TIPATH"
144
+ end
145
+
146
+ ti_lib_path = Dir[File.join(ti_path, "sdk", "*", "*")][-1]
147
+
148
+ # Space in osx path
126
149
  ti_path.gsub!(' ', '\ ')
127
150
  ti_lib_path.gsub!(' ', '\ ')
128
-
151
+
129
152
  command = []
130
153
  command << File.join(ti_lib_path, "tibuild.py")
131
154
  command << "-d #{build_path}"
@@ -0,0 +1,34 @@
1
+ namespace :gems do
2
+ desc "Install gems locally"
3
+ task :sync => [:environment] do
4
+ conf = Bowline.configuration
5
+ repo = Dependencies::Repository.new(
6
+ conf.gem_path
7
+ )
8
+
9
+ conf.gems.each do |dep|
10
+ gem = repo.gem(dep.name, dep.versions)
11
+ next unless repo.search(gem).empty?
12
+ repo.install(gem)
13
+ end
14
+
15
+ repo.reload_index!
16
+
17
+ full_list = conf.gems.map do |dep|
18
+ gem = repo.gem(dep.name, dep.versions)
19
+ spec = repo.index.search(gem).last
20
+ unless spec
21
+ raise Exception.new("A required dependency #{gem} was not found")
22
+ end
23
+ deps = spec.recursive_dependencies(gem, repo.index)
24
+ [spec] + deps
25
+ end.flatten.uniq.map do |spec|
26
+ "#{spec.name}-#{spec.version}"
27
+ end
28
+
29
+ (repo.installed - full_list).each do |g|
30
+ /^(.*)\-(.*)$/ =~ g
31
+ repo.uninstall($1, $2)
32
+ end
33
+ end
34
+ end
@@ -2,7 +2,7 @@ module Bowline
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
@@ -3,9 +3,10 @@
3
3
 
4
4
  APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..")) unless defined?(APP_ROOT)
5
5
 
6
- bowline_path = File.join(APP_ROOT, *%w[vendor bowline lib bowline.rb])
6
+ gems_path = File.join(APP_ROOT, *%w{vendor gems gems})
7
+ bowline_path = Dir[File.join(gems_path, *%w{{maccman-bowline*,bowline*} lib bowline.rb})][-1]
7
8
 
8
- if File.exist?(bowline_path)
9
+ if bowline_path
9
10
  require bowline_path
10
11
  else
11
12
  require "rubygems"
@@ -11,6 +11,6 @@ Bowline::Initializer.run do |config|
11
11
  # config.gem "net-mdns", :lib => 'net/dns/mdns'
12
12
  # config.gem "rack"
13
13
  # config.gem "rubyzip", :lib => 'zip/zip'
14
-
15
- config.frameworks += [:active_record, :active_resource]
14
+ # Bowline Edge:
15
+ # config.gem "maccman-bowline", :lib => "bowline", :source => "http://gems.github.com"
16
16
  end
@@ -5,17 +5,18 @@
5
5
  <head>
6
6
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
7
  <title><%= full_name %></title>
8
- <!--
9
- <script src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js" type="text/javascript"></script>
10
- -->
11
8
  <script src="javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
12
9
  <script src="javascripts/jquery.chain.js" type="text/javascript" charset="utf-8"></script>
13
10
  <script src="javascripts/jquery.bowline.js" type="text/javascript" charset="utf-8"></script>
14
11
  <script src="javascripts/application.js" type="text/javascript" charset="utf-8"></script>
15
12
  <link rel="stylesheet" href="stylesheets/application.css" type="text/css" charset="utf-8">
16
13
  <script type="text/javascript" charset="utf-8">
14
+ // Example:
17
15
  // jQuery(function($){
18
- // $('#assets').bowline('assets');
16
+ // $.bowline.ready(function(){
17
+ // $('#tweets').bowline('tweets');
18
+ // $('#tweets').invoke('index');
19
+ // })
19
20
  // });
20
21
  </script>
21
22
  </head>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maccman-bowline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-10 00:00:00 -07:00
12
+ date: 2009-07-13 00:00:00 -07:00
13
13
  default_executable: bowline-gen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -64,11 +64,25 @@ files:
64
64
  - lib/bowline/commands/console.rb
65
65
  - lib/bowline/commands/generate.rb
66
66
  - lib/bowline/commands/run.rb
67
+ - lib/bowline/dependencies/FAQ.markdown
68
+ - lib/bowline/dependencies/MIT-LICENSE
69
+ - lib/bowline/dependencies/README.markdown
70
+ - lib/bowline/dependencies/Rakefile
71
+ - lib/bowline/dependencies/TODO.markdown
72
+ - lib/bowline/dependencies/init.rb
73
+ - lib/bowline/dependencies/lib/dependencies.rb
74
+ - lib/bowline/dependencies/lib/dependencies/dependency.rb
75
+ - lib/bowline/dependencies/lib/dependencies/reader.rb
76
+ - lib/bowline/dependencies/lib/dependencies/repository.rb
77
+ - lib/bowline/dependencies/lib/ext/common.rb
78
+ - lib/bowline/dependencies/lib/ext/rubygems.rb
79
+ - lib/bowline/dependencies/lib/template/app_script.rb
80
+ - lib/bowline/dependencies/spec/spec.opts
81
+ - lib/bowline/dependencies/tasks/dependencies.rake
67
82
  - lib/bowline/ext/array.rb
68
83
  - lib/bowline/ext/class.rb
69
84
  - lib/bowline/ext/object.rb
70
85
  - lib/bowline/ext/string.rb
71
- - lib/bowline/gem_dependency.rb
72
86
  - lib/bowline/generators.rb
73
87
  - lib/bowline/generators/application.rb
74
88
  - lib/bowline/generators/binder.rb
@@ -82,6 +96,7 @@ files:
82
96
  - lib/bowline/tasks/app.rake
83
97
  - lib/bowline/tasks/bowline.rb
84
98
  - lib/bowline/tasks/database.rake
99
+ - lib/bowline/tasks/gems.rake
85
100
  - lib/bowline/tasks/log.rake
86
101
  - lib/bowline/tasks/misc.rake
87
102
  - lib/bowline/version.rb
@@ -1,42 +0,0 @@
1
- module Bowline
2
- class GemDependency
3
- attr_accessor :lib, :source
4
-
5
- def initialize(name, options = {})
6
- require 'rubygems' unless Object.const_defined?(:Gem)
7
-
8
- if options[:requirement]
9
- req = options[:requirement]
10
- elsif options[:version]
11
- req = Gem::Requirement.create(options[:version])
12
- else
13
- req = Gem::Requirement.default
14
- end
15
-
16
- @dep = Gem::Dependency.new(name, req)
17
- @lib = options[:lib]
18
- @source = options[:source]
19
- end
20
-
21
- def add_load_paths
22
- end
23
-
24
- def name
25
- @dep.name.to_s
26
- end
27
-
28
- def requirement
29
- r = @dep.version_requirements
30
- (r == Gem::Requirement.default) ? nil : r
31
- end
32
-
33
- def load
34
- return if @loaded
35
- require(@lib || name) unless @lib == false
36
- @loaded = true
37
- rescue LoadError
38
- puts $!.to_s
39
- $!.backtrace.each { |b| puts b }
40
- end
41
- end
42
- end