tog-tog 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ Edge
2
+ ----
3
+ * Rubigen dependency added to gemspec.
4
+ 0.2.1
5
+ ----
6
+ * [#89 status:resolved] From now tog:plugins:copy_resources don't copy .svn dirs to app's public directory...
7
+ * tog-desert dependency added.
8
+ * New `--development` flag on togify. This'll clone the tog core plugins from `git@github.com:tog/#{plugin}.git` instead of `git://github.com/tog/#{plugin}.git` allowing developers to change tog plugins inside a togified app.
9
+
10
+
11
+ 0.2.0
12
+ -----
13
+ * Initial public code release
data/MIT-LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 Keras Software Development
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,31 @@
1
+ CHANGELOG.md
2
+ MIT-LICENSE
3
+ Manifest.txt
4
+ POST_INSTALL
5
+ README.txt
6
+ Rakefile
7
+ app_generators/togify/USAGE
8
+ app_generators/togify/templates/integrate_tog.rb
9
+ app_generators/togify/togify_generator.rb
10
+ bin/togify
11
+ config/hoe.rb
12
+ config/requirements.rb
13
+ generators/tog_migration/USAGE
14
+ generators/tog_migration/templates/migration.rb
15
+ generators/tog_migration/tog_migration_generator.rb
16
+ generators/tog_plugin/USAGE
17
+ generators/tog_plugin/tog_plugin_generator.rb
18
+ lib/tasks/platform.rake
19
+ lib/tasks/tog.rb
20
+ lib/tog.rb
21
+ lib/tog/version.rb
22
+ test/templates/Rakefile
23
+ test/templates/environment.rb
24
+ test/templates/routes.rb
25
+ test/test_generator_helper.rb
26
+ test/test_helper.rb
27
+ test/test_rake_tasks.rb
28
+ test/test_tog.rb
29
+ test/test_tog_plugin_generator.rb
30
+ test/test_togify_generator.rb
31
+ tog.gemspec
data/POST_INSTALL ADDED
@@ -0,0 +1,3 @@
1
+
2
+ For more information on tog, see https://github.com/tog/tog
3
+
data/README.txt ADDED
@@ -0,0 +1,27 @@
1
+ tog
2
+ ============
3
+ tog is the gem that boostraps the process of _togifing_ your app/site.
4
+
5
+ Install
6
+ -------
7
+
8
+ <pre>sudo gem install tog</pre>
9
+
10
+ Or from source (you will need Hoe >=1.5.3 and mislav-will_paginate ~> 2.3.2):
11
+
12
+ <pre>
13
+ git clone git@github.com:tog/tog.git
14
+ cd tog
15
+ rake install_gem
16
+ </pre>
17
+
18
+
19
+ More
20
+ -------
21
+
22
+ [http://github.com/tog/tog](http://github.com/tog/tog)
23
+
24
+ [http://github.com/tog/tog/wikis](http://github.com/tog/tog/wikis)
25
+
26
+
27
+ Copyright (c) 2008 Keras Software Development, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ namespace :manifest do
5
+ desc 'Recreate Manifest.txt to include ALL files'
6
+ task :refresh do
7
+ `rake check_manifest | patch -p0 > Manifest.txt`
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,9 @@
1
+ class <%= migration_name %> < ActiveRecord::Migration
2
+ def self.up<% plugins.each do |plugin| %>
3
+ migrate_plugin "<%= plugin[:name] %>", <%= plugin[:current_migration] %><%- end %>
4
+ end
5
+
6
+ def self.down<% plugins.reverse.each do |plugin| %>
7
+ migrate_plugin "<%= plugin[:name] %>", 0 <%- end %>
8
+ end
9
+ end
@@ -0,0 +1,145 @@
1
+ class TogifyGenerator < RubiGen::Base
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
+ Config::CONFIG['ruby_install_name'])
5
+
6
+ default_options :author => nil
7
+
8
+ attr_reader :name
9
+
10
+ def initialize(runtime_args, runtime_options = {})
11
+ super
12
+ usage if args.empty?
13
+ @destination_root = File.expand_path(args.shift)
14
+ @name = base_name
15
+ extract_options
16
+ end
17
+
18
+ def manifest
19
+ record do |m|
20
+ BASEDIRS.each { |path| m.directory path }
21
+
22
+ # Include tog rake tasks on the app
23
+ include_tog_rake_tasks("#{destination_root}/Rakefile")
24
+
25
+ # Install desert dependency
26
+ require_desert_on_environment("#{destination_root}/config/environment.rb")
27
+
28
+ # PLugins
29
+ plugins = install_default_plugins
30
+
31
+ # Migrations
32
+ m.migration_template 'integrate_tog.rb', 'db/migrate', :assigns => {
33
+ :migration_name => "IntegrateTog",
34
+ :plugins => plugins
35
+ },:migration_file_name => 'integrate_tog'
36
+ end
37
+ end
38
+
39
+ protected
40
+ def banner
41
+ <<-EOS
42
+ Apply tog platform to an existing Rails app
43
+
44
+ USAGE: #{spec.name} name
45
+ EOS
46
+ end
47
+
48
+ def add_options!(opts)
49
+ opts.separator ''
50
+ opts.separator 'Options:'
51
+ # For each option below, place the default
52
+ # at the top of the file next to "default_options"
53
+ # opts.on("-a", "--author=\"Your Name\"", String,
54
+ # "Some comment about this option",
55
+ # "Default: none") { |options[:author]| }
56
+ opts.on("--skip-tog_user",
57
+ "Don't add tog_user in the tog integration process. Use this if you have a User model and signup process already working") { |v| options[:skip_tog_user] = v }
58
+ opts.on("--development",
59
+ "Clone the repositories from the private clone urls allowing the developers to develop the plugins on a togified app.") { |v| options[:development] = v }
60
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
61
+ end
62
+
63
+ def extract_options
64
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
65
+ # Templates can access these value via the attr_reader-generated methods, but not the
66
+ # raw instance variable value.
67
+ # @author = options[:author]
68
+ end
69
+
70
+ def include_tog_rake_tasks(rakefile)
71
+ sentinel = "require 'tasks/rails'"
72
+ logger.create "require tog rake tasks"
73
+ unless options[:pretend]
74
+ gsub_file rakefile, /(#{Regexp.escape(sentinel)})/mi do |match|
75
+ "#{match}\n\nrequire 'tasks/tog'\n"
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+ def require_desert_on_environment(env_file)
82
+ sentinel = 'Rails::Initializer.run do |config|'
83
+ logger.create "require 'desert' on environment"
84
+ unless options[:pretend]
85
+ gsub_file env_file, /(#{Regexp.escape(sentinel)})/mi do |match|
86
+ "require 'desert'\n#{match}\n "
87
+ end
88
+ end
89
+ end
90
+
91
+ # Tog plugins
92
+ def default_plugins
93
+ plugins = %w{ tog_core }
94
+ plugins << "tog_user" unless options[:skip_tog_user]
95
+ plugins += %w{tog_social tog_mail}
96
+ end
97
+
98
+ def install_default_plugins
99
+ default_plugins.collect{|plugin|
100
+ plugin_path = "#{destination_root}/vendor/plugins/#{plugin}"
101
+ checkout_code(plugin_path, plugin)
102
+ logger.create "vendor/plugins/#{plugin}"
103
+ route_from_plugins("#{destination_root}/config/routes.rb", plugin)
104
+ {:name => plugin,:current_migration => current_migration_number(plugin_path) }
105
+ }
106
+ end
107
+
108
+ def checkout_code(plugin_path, plugin)
109
+ repository = options[:development] ? "git@github.com:tog/#{plugin}.git": "git://github.com/tog/#{plugin}.git"
110
+ revision = "head"
111
+
112
+ FileUtils.rm_rf(plugin_path)
113
+ system("git clone #{repository} #{plugin_path}")
114
+ end
115
+ def current_migration_number(plugin_path)
116
+ Dir.glob("#{plugin_path}/db/migrate/*.rb").inject(0) do |max, file_path|
117
+ n = File.basename(file_path).split('_', 2).first.to_i
118
+ if n > max then n else max end
119
+ end
120
+ end
121
+
122
+ def route_from_plugins(routes_file, plugin)
123
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
124
+ logger.route "map.routes_from_plugin #{plugin}"
125
+ unless options[:pretend]
126
+ gsub_file routes_file, /(#{Regexp.escape(sentinel)})/mi do |match|
127
+ "#{match}\n map.routes_from_plugin '#{plugin}'\n"
128
+ end
129
+ end
130
+ end
131
+ def gsub_file(path, regexp, *args, &block)
132
+ content = File.read(path).gsub(regexp, *args, &block)
133
+ File.open(path, 'wb') { |file| file.write(content) }
134
+ end
135
+
136
+ BASEDIRS = %w(
137
+ config
138
+ db
139
+ db/migrate
140
+ lib
141
+ lib/tasks
142
+ vendor
143
+ vendor/plugins
144
+ )
145
+ end
data/bin/togify ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'tog/version'
8
+ puts "#{File.basename($0)} #{Tog::VERSION::STRING}"
9
+ exit(0)
10
+ end
11
+
12
+ require 'rubigen/scripts/generate'
13
+ source = RubiGen::PathSource.new(:application, File.join(File.dirname(__FILE__), "../app_generators"))
14
+ RubiGen::Base.reset_sources
15
+ RubiGen::Base.append_sources source
16
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'togify')
data/config/hoe.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'tog/version'
2
+
3
+ DEVELOPERS = [
4
+ ["Aitor García", "aitor@linkingpaths.com"],
5
+ ["Alberto Molpeceres", "alberto@linkingpaths.com"],
6
+ ["Roberto Salicio", "roberto@linkingpaths.com"]
7
+ ]
8
+
9
+ GEM_NAME = 'tog'
10
+ EXTRA_DEPENDENCIES = [
11
+ ['mislav-will_paginate', '>= 2.3.2'],
12
+ ['rubigen', '>= 1.3.2'],
13
+ ['tog-desert', '>= 0.3.4']
14
+ ]
15
+
16
+ REV = nil
17
+ # UNCOMMENT IF REQUIRED:
18
+ # REV = YAML.load(`svn info`)['Revision']
19
+ VERS = Tog::VERSION::STRING + (REV ? ".#{REV}" : "")
20
+
21
+ class Hoe
22
+ def extra_deps
23
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
24
+ @extra_deps
25
+ end
26
+ end
27
+
28
+ # Generate all the Rake tasks
29
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
30
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
31
+ DEVELOPERS.each{|dev|
32
+ p.developer(dev[0], dev[1])
33
+ }
34
+ p.description = p.summary = "extensible open source social network platform"
35
+ p.url = "http://github.com/tog/tog"
36
+ p.test_globs = ["test/**/test_*.rb"]
37
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
38
+
39
+ # == Optional
40
+ p.post_install_message = File.open(File.dirname(__FILE__) + "/../POST_INSTALL").read rescue ""
41
+ p.changes = p.paragraphs_of("CHANGELOG.md", 0..1).join("\n\n") rescue ""
42
+ p.extra_deps = EXTRA_DEPENDENCIES
43
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
44
+ end
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,9 @@
1
+ class <%= class_name.underscore.camelize %> < ActiveRecord::Migration
2
+ def self.up<% plugins.each do |plugin| %>
3
+ migrate_plugin "<%= plugin[:name] %>", <%= plugin[:to_version] %><%- end %>
4
+ end
5
+
6
+ def self.down<% plugins.reverse.each do |plugin| %>
7
+ migrate_plugin "<%= plugin[:name] %>", <%= plugin[:from_version] %><%- end %>
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ class TogMigrationGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ m.migration_template 'migration.rb', 'db/migrate', :assigns => get_local_assigns
5
+ end
6
+ end
7
+
8
+
9
+ private
10
+ def get_local_assigns
11
+ returning(assigns = {}) do
12
+ if class_name.underscore =~ /^integrate_(.*)_(?:version)(.*)_(?:from)(.*)/
13
+ assigns[:plugins] = [{:name => $1, :to_version => $2, :from_version => $3 }]
14
+ else
15
+ assigns[:plugins] = []
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,53 @@
1
+ class TogPluginGenerator < RubiGen::Base
2
+
3
+ default_options :author => nil
4
+
5
+ attr_reader :name
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @name = args.shift
11
+ extract_options
12
+ end
13
+
14
+ def manifest
15
+ record do |m|
16
+ # Ensure appropriate folder(s) exists
17
+ m.directory 'some_folder'
18
+
19
+ # Create stubs
20
+ # m.template "template.rb", "some_file_after_erb.rb"
21
+ # m.template_copy_each ["template.rb", "template2.rb"]
22
+ # m.file "file", "some_file_copied"
23
+ # m.file_copy_each ["path/to/file", "path/to/file2"]
24
+ end
25
+ end
26
+
27
+ protected
28
+ def banner
29
+ <<-EOS
30
+ Creates a ...
31
+
32
+ USAGE: #{$0} #{spec.name} name
33
+ EOS
34
+ end
35
+
36
+ def add_options!(opts)
37
+ # opts.separator ''
38
+ # opts.separator 'Options:'
39
+ # For each option below, place the default
40
+ # at the top of the file next to "default_options"
41
+ # opts.on("-a", "--author=\"Your Name\"", String,
42
+ # "Some comment about this option",
43
+ # "Default: none") { |options[:author]| }
44
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
45
+ end
46
+
47
+ def extract_options
48
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
49
+ # Templates can access these value via the attr_reader-generated methods, but not the
50
+ # raw instance variable value.
51
+ # @author = options[:author]
52
+ end
53
+ end
@@ -0,0 +1,104 @@
1
+ namespace :tog do
2
+ namespace :plugins do
3
+
4
+ desc "Update the tog plugins on this app. This will pull the changes on the HEAD of every tog plugins on your app. Use PLUGIN=plugin_name to update a specific plugin."
5
+ task :update do
6
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
7
+ puts "Pulling changes of #{File.basename(directory)}"
8
+ chdir directory do
9
+ output = %x{git pull}
10
+ end
11
+ end
12
+ end
13
+
14
+ desc "Install a new tog plugin. Use PLUGIN parameter to specify the plugin to install e.g. PLUGIN=tog_vault. Use FORCE=true to overwrite the plugin if it's currently installed."
15
+ task :install do
16
+ plugin = ENV["PLUGIN"]
17
+ force = ENV["FORCE"] || false
18
+ puts "Installing #{plugin} on vendor/plugins/#{plugin}"
19
+ cmd = "script/plugin install git@github.com:tog/#{plugin}.git"
20
+ cmd << " --force" if force
21
+ output = %x{#{cmd}}
22
+ puts "Generating migration to integrate #{plugin} in the app"
23
+
24
+ to_version=Dir.glob("#{RAILS_ROOT}/vendor/plugins/#{plugin}/db/migrate/*.rb").inject(0) do |max, file_path|
25
+ n = File.basename(file_path).split('_', 2).first.to_i
26
+ if n > max then n else max end
27
+ end
28
+ from_version=0
29
+ cmd = "script/generate tog_migration Integrate#{plugin.classify}Version#{to_version}From#{from_version}"
30
+ output = %x{#{cmd}}
31
+
32
+ end
33
+
34
+ desc "Copy the public resources stored on the /public folder of every tog plugin on the app's public folder with the plugin name used as prefix. Pass PLUGIN=plugin_name to copy the resources of a single plugin."
35
+ task :copy_resources do
36
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
37
+ plugin_name = File.basename(directory)
38
+ dest_public_dir = File.join(RAILS_ROOT, "public", plugin_name)
39
+ orig_public_dir = File.join(directory, "public")
40
+ if File.exists?(orig_public_dir)
41
+ puts "Copying the public resources of #{plugin_name} to #{dest_public_dir}"
42
+ FileUtils.mkdir_p(dest_public_dir)
43
+ is_svn_dir = proc {|path| path =~ /\.svn/}
44
+ Dir[orig_public_dir].reject(&is_svn_dir).each do |file|
45
+ FileUtils.cp_r(Dir["#{orig_public_dir}/*"], dest_public_dir )
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ desc "Runs tests on all available Tog Plugins. Pass PLUGIN=plugin_name to test a single plugin."
52
+ task :test do
53
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
54
+ if File.directory?(File.join(directory, 'test'))
55
+ chdir directory do
56
+ if RUBY_PLATFORM =~ /win32/
57
+ system "rake.cmd test"
58
+ else
59
+ system "rake test"
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ desc "List the names of tog plugins test methods in a specification like format. Pass PLUGIN=plugin_name to list a single plugin."
66
+ task :list_specs do
67
+ require File.expand_path(File.join(RAILS_ROOT, "config","environment"))
68
+ require 'test/unit'
69
+ require 'rubygems'
70
+ require 'active_support'
71
+
72
+ # bug in test unit. Set to true to stop from running.
73
+ Test::Unit.run = true
74
+
75
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
76
+ if File.directory?(File.join(directory, 'test'))
77
+ chdir directory do
78
+ test_files = Dir.glob(File.join('test', '**', '*_test.rb'))
79
+ test_files.each do |file|
80
+ load file
81
+ klass = File.basename(file, '.rb').classify.constantize
82
+
83
+ puts klass.name.gsub('Test', '')
84
+
85
+ test_methods = klass.instance_methods.grep(/^test/).map {|s| s.gsub(/^test: /, '')}.sort
86
+ test_methods.each {|m| puts " " + m }
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ def plugin_roots(plugin=nil)
96
+ roots = Dir[File.join(RAILS_ROOT, 'vendor', 'plugins', 'tog_*')]
97
+ if plugin
98
+ roots = roots.select {|x| /\/(\d+_)?#{plugin}$/ === x }
99
+ if roots.empty?
100
+ puts "Sorry, the plugin '#{plugin}' is not installed."
101
+ end
102
+ end
103
+ roots
104
+ end
data/lib/tasks/tog.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Load tog rakefile extensions
2
+ Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
@@ -0,0 +1,18 @@
1
+ module Tog
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 2
5
+ TINY = 1
6
+ # http://en.wikipedia.org/wiki/Moons_of_Jupiter
7
+ CODENAME = 'Adrastea'
8
+ STRING = [MAJOR, MINOR, TINY].join('.')
9
+
10
+ class << self
11
+ def to_s
12
+ "#{CODENAME} #{STRING}"
13
+ end
14
+ alias :to_str :to_s
15
+ end
16
+
17
+ end
18
+ end
data/lib/tog.rb ADDED
@@ -0,0 +1,7 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
2
+
3
+ module Tog
4
+
5
+ end
6
+
7
+ require "tog/version"
@@ -0,0 +1,10 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ require 'tasks/rails'
@@ -0,0 +1,9 @@
1
+ RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
2
+ require File.join(File.dirname(__FILE__), 'boot')
3
+ Rails::Initializer.run do |config|
4
+ config.time_zone = 'UTC'
5
+ config.action_controller.session = {
6
+ :session_key => '_tog_app_session',
7
+ :secret => 'c06f15cbc11cb6b70d45df5f9b527aeb18003879c5527b734a862558e596dfc9c4e96e841a7ff5dd44c129aba275cf50f244301956347815699432ba3a1fd53a'
8
+ }
9
+ end
@@ -0,0 +1,4 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.connect ':controller/:action/:id'
3
+ map.connect ':controller/:action/:id.:format'
4
+ end
@@ -0,0 +1,58 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+ rescue LoadError
4
+ require 'test/unit'
5
+ end
6
+ require 'fileutils'
7
+
8
+ # Must set before requiring generator libs.
9
+ TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
10
+ PROJECT_NAME = "tog" unless defined?(PROJECT_NAME)
11
+ app_root = File.join(TMP_ROOT, PROJECT_NAME)
12
+ if defined?(APP_ROOT)
13
+ APP_ROOT.replace(app_root)
14
+ else
15
+ APP_ROOT = app_root
16
+ end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
22
+
23
+ begin
24
+ require 'rubigen'
25
+ rescue LoadError
26
+ require 'rubygems'
27
+ require 'rubigen'
28
+ end
29
+ require 'rubigen/helpers/generator_test_helper'
30
+
31
+ def copy_to_fake (orig, dest)
32
+ FileUtils.cp(File.join(File.dirname(__FILE__), orig), File.join(APP_ROOT, dest))
33
+ end
34
+ def setup_fake_tog_app
35
+ bare_setup
36
+ FileUtils.mkdir_p(File.join(APP_ROOT, "/config"))
37
+ copy_to_fake("/templates/environment.rb", "/config/environment.rb")
38
+ copy_to_fake("/templates/routes.rb", "/config/routes.rb")
39
+ copy_to_fake("/templates/Rakefile", "/Rakefile")
40
+ @plugins = %w{ tog_core tog_social tog_mail tog_user}
41
+ end
42
+ def teardown_fake_tog_app
43
+ bare_teardown
44
+ end
45
+
46
+ def assert_has_require(body,*requires)
47
+ requires.each do |req|
48
+ assert body=~/require '#{req.to_s}'/,"should have require '#{req.to_s}'"
49
+ yield( req, $1 ) if block_given?
50
+ end
51
+ end
52
+
53
+ def assert_has_plugin_routes(body,*routes)
54
+ routes.each do |route|
55
+ assert body=~/map.routes_from_plugin '#{route.to_s}'/,"should have routes '#{route.to_s}'"
56
+ yield( route, $1 ) if block_given?
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/tog'
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+ require "rake"
3
+
4
+ class TestRakeTasks < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ setup_fake_tog_app
9
+ run_generator('togify', [APP_ROOT], sources)
10
+ @rake = Rake::Application.new
11
+ Rake.application = @rake
12
+ load File.join(File.dirname(__FILE__), "..", "lib", "tasks", "platform.rake")
13
+
14
+ @tog_core_resources_on_public = File.join(APP_ROOT, "public", "tog_core")
15
+ end
16
+
17
+ def teardown
18
+ teardown_fake_tog_app
19
+ end
20
+
21
+ def test_copy_resources
22
+ @rake["tog:plugins:copy_resources"].invoke
23
+ assert File.exists?(@tog_core_resources_on_public)
24
+ end
25
+
26
+ def test_copy_resources_not_copy_svn_dirs
27
+ svn_dir_on_tog_core = File.join(APP_ROOT, "vendor", "plugins", "tog_core", "public", ".svn")
28
+ FileUtils.mkdir_p(svn_dir_on_tog_core)
29
+ assert File.exists?(svn_dir_on_tog_core)
30
+
31
+ @rake["tog:plugins:copy_resources"].invoke
32
+
33
+ assert !File.exists?(File.join(@tog_core_resources_on_public, ".svn"))
34
+ end
35
+
36
+
37
+ private
38
+ def sources
39
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))]
40
+ end
41
+
42
+ def generator_path
43
+ "app_generators"
44
+ end
45
+
46
+ end
data/test/test_tog.rb ADDED
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTog < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,45 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+
4
+ class TestTogPluginGenerator < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ bare_setup
9
+ end
10
+
11
+ def teardown
12
+ bare_teardown
13
+ end
14
+
15
+ # Some generator-related assertions:
16
+ # assert_generated_file(name, &block) # block passed the file contents
17
+ # assert_directory_exists(name)
18
+ # assert_generated_class(name, &block)
19
+ # assert_generated_module(name, &block)
20
+ # assert_generated_test_for(name, &block)
21
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
22
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
23
+ #
24
+ # Other helper methods are:
25
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
26
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
27
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
28
+
29
+ def test_generator_without_options
30
+ name = "myapp"
31
+ run_generator('tog_plugin', [name], sources)
32
+ #todo implement this
33
+ #assert_generated_file("some_file")
34
+ end
35
+
36
+ private
37
+ def sources
38
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
39
+ ]
40
+ end
41
+
42
+ def generator_path
43
+ "generators"
44
+ end
45
+ end
@@ -0,0 +1,63 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+ class TestTogifyGenerator < Test::Unit::TestCase
4
+ include RubiGen::GeneratorTestHelper
5
+
6
+ def setup
7
+ setup_fake_tog_app
8
+ end
9
+
10
+ def teardown
11
+ teardown_fake_tog_app
12
+ end
13
+
14
+ def test_generator_without_options
15
+ run_generator('togify', [APP_ROOT], sources)
16
+
17
+ assert_generated_file "Rakefile" do |body|
18
+ assert_has_require body, 'tasks/tog'
19
+ end
20
+
21
+ assert_generated_file "config/environment.rb" do |body|
22
+ assert_has_require body, 'desert'
23
+ end
24
+
25
+ @plugins.each{|plugin|
26
+ assert_directory_exists("vendor/plugins/#{plugin}")
27
+ assert_generated_file "config/routes.rb" do |body|
28
+ assert_has_plugin_routes body, plugin
29
+ end
30
+ assert_remote_origin_of_plugin (plugin, "git://github.com/tog/(.*).git")
31
+ }
32
+ generated_migration = Dir.glob("#{APP_ROOT}/db/migrate/*_integrate_tog.rb")[0]
33
+ assert generated_migration, "should be a IntegrateTog migration in the togified app"
34
+ File.open(generated_migration, "r") do |file|
35
+ assert file.read=~/tog_core.*tog_user.*tog_social.*tog_mail.*tog_mail.*tog_social.*tog_user.*tog_core/m,"plugins migrations should be in correct order"
36
+ end
37
+ end
38
+
39
+
40
+ def test_generator_with_dev_repositories
41
+ run_generator('togify', [APP_ROOT], sources, {:development => true})
42
+ @plugins.each{|plugin|
43
+ assert_remote_origin_of_plugin (plugin, "git@github.com:tog/(.*).git")
44
+ }
45
+ end
46
+
47
+ private
48
+ def sources
49
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))]
50
+ end
51
+
52
+ def generator_path
53
+ "app_generators"
54
+ end
55
+
56
+ def assert_remote_origin_of_plugin(plugin, match)
57
+ FileUtils.chdir File.join(APP_ROOT, "vendor", "plugins", "#{plugin}") do
58
+ remote_origin = %x{git config remote.origin.url}
59
+ assert remote_origin.match(match)
60
+ end
61
+ end
62
+
63
+ end
data/tog.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{tog}
3
+ s.version = "0.2.1"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Aitor Garc\303\255a", "Alberto Molpeceres", "Roberto Salicio"]
7
+ s.date = %q{2008-09-27}
8
+ s.default_executable = %q{togify}
9
+ s.description = %q{extensible open source social network platform}
10
+ s.email = ["aitor@linkingpaths.com", "alberto@linkingpaths.com", "roberto@linkingpaths.com"]
11
+ s.executables = ["togify"]
12
+ s.extra_rdoc_files = ["Manifest.txt", "README.txt"]
13
+ s.files = ["CHANGELOG.md", "MIT-LICENSE", "Manifest.txt", "POST_INSTALL", "README.txt", "Rakefile", "app_generators/togify/USAGE", "app_generators/togify/templates/integrate_tog.rb", "app_generators/togify/togify_generator.rb", "bin/togify", "config/hoe.rb", "config/requirements.rb", "generators/tog_migration/USAGE", "generators/tog_migration/templates/migration.rb", "generators/tog_migration/tog_migration_generator.rb", "generators/tog_plugin/USAGE", "generators/tog_plugin/tog_plugin_generator.rb", "lib/tasks/platform.rake", "lib/tasks/tog.rb", "lib/tog.rb", "lib/tog/version.rb", "test/templates/Rakefile", "test/templates/environment.rb", "test/templates/routes.rb", "test/test_generator_helper.rb", "test/test_helper.rb", "test/test_rake_tasks.rb", "test/test_tog.rb", "test/test_tog_plugin_generator.rb", "test/test_togify_generator.rb", "tog.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/tog/tog}
16
+ s.post_install_message = %q{
17
+ For more information on tog, see https://github.com/tog/tog
18
+
19
+ }
20
+ s.rdoc_options = ["--main", "README.txt"]
21
+ s.require_paths = ["lib"]
22
+ s.rubyforge_project = %q{tog}
23
+ s.rubygems_version = %q{1.2.0}
24
+ s.summary = %q{extensible open source social network platform}
25
+ s.test_files = ["test/test_generator_helper.rb", "test/test_helper.rb", "test/test_rake_tasks.rb", "test/test_tog.rb", "test/test_tog_plugin_generator.rb", "test/test_togify_generator.rb"]
26
+
27
+ if s.respond_to? :specification_version then
28
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
29
+ s.specification_version = 2
30
+
31
+ if current_version >= 3 then
32
+ s.add_runtime_dependency(%q<mislav-will_paginate>, [">= 2.3.2"])
33
+ s.add_runtime_dependency(%q<rubigen>, [">= 1.3.2"])
34
+ s.add_runtime_dependency(%q<tog-desert>, [">= 0.3.4"])
35
+ s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
36
+ else
37
+ s.add_dependency(%q<mislav-will_paginate>, [">= 2.3.2"])
38
+ s.add_dependency(%q<rubigen>, [">= 1.3.2"])
39
+ s.add_dependency(%q<tog-desert>, [">= 0.3.4"])
40
+ s.add_dependency(%q<hoe>, [">= 1.7.0"])
41
+ end
42
+ else
43
+ s.add_dependency(%q<mislav-will_paginate>, [">= 2.3.2"])
44
+ s.add_dependency(%q<rubigen>, [">= 1.3.2"])
45
+ s.add_dependency(%q<tog-desert>, [">= 0.3.4"])
46
+ s.add_dependency(%q<hoe>, [">= 1.7.0"])
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tog-tog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - "Aitor Garc\xC3\xADa"
8
+ - Alberto Molpeceres
9
+ - Roberto Salicio
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2008-09-27 00:00:00 -07:00
15
+ default_executable: togify
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: mislav-will_paginate
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.3.2
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: rubigen
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.2
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: tog-desert
37
+ version_requirement:
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.3.4
43
+ version:
44
+ - !ruby/object:Gem::Dependency
45
+ name: hoe
46
+ version_requirement:
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 1.7.0
52
+ version:
53
+ description: extensible open source social network platform
54
+ email:
55
+ - aitor@linkingpaths.com
56
+ - alberto@linkingpaths.com
57
+ - roberto@linkingpaths.com
58
+ executables:
59
+ - togify
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - Manifest.txt
64
+ - README.txt
65
+ files:
66
+ - CHANGELOG.md
67
+ - MIT-LICENSE
68
+ - Manifest.txt
69
+ - POST_INSTALL
70
+ - README.txt
71
+ - Rakefile
72
+ - app_generators/togify/USAGE
73
+ - app_generators/togify/templates/integrate_tog.rb
74
+ - app_generators/togify/togify_generator.rb
75
+ - bin/togify
76
+ - config/hoe.rb
77
+ - config/requirements.rb
78
+ - generators/tog_migration/USAGE
79
+ - generators/tog_migration/templates/migration.rb
80
+ - generators/tog_migration/tog_migration_generator.rb
81
+ - generators/tog_plugin/USAGE
82
+ - generators/tog_plugin/tog_plugin_generator.rb
83
+ - lib/tasks/platform.rake
84
+ - lib/tasks/tog.rb
85
+ - lib/tog.rb
86
+ - lib/tog/version.rb
87
+ - test/templates/Rakefile
88
+ - test/templates/environment.rb
89
+ - test/templates/routes.rb
90
+ - test/test_generator_helper.rb
91
+ - test/test_helper.rb
92
+ - test/test_rake_tasks.rb
93
+ - test/test_tog.rb
94
+ - test/test_tog_plugin_generator.rb
95
+ - test/test_togify_generator.rb
96
+ - tog.gemspec
97
+ has_rdoc: true
98
+ homepage: http://github.com/tog/tog
99
+ post_install_message: |+
100
+
101
+ For more information on tog, see https://github.com/tog/tog
102
+
103
+ rdoc_options:
104
+ - --main
105
+ - README.txt
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ version:
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ version:
120
+ requirements: []
121
+
122
+ rubyforge_project: tog
123
+ rubygems_version: 1.2.0
124
+ signing_key:
125
+ specification_version: 2
126
+ summary: extensible open source social network platform
127
+ test_files:
128
+ - test/test_generator_helper.rb
129
+ - test/test_helper.rb
130
+ - test/test_rake_tasks.rb
131
+ - test/test_tog.rb
132
+ - test/test_tog_plugin_generator.rb
133
+ - test/test_togify_generator.rb