tog 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ Edge
2
+ ----
3
+
4
+ 0.5.4
5
+ ----
6
+ * Updated tog gem to require Desert 0.5.2 that fix some "Plugin schema migrations should successfully convert from the 'old' scheme to the 'new' scheme"" [Thanks Andrei!]
7
+
8
+ 0.5.3
9
+ ----
10
+
11
+ 0.5.2
12
+ ----
13
+
14
+ 0.5.1
15
+ ----
16
+
17
+ 0.5.0
18
+ ----
19
+
20
+ 0.4.4
21
+ ----
22
+
23
+ 0.4.2
24
+ ----
25
+ * #106 New "tog:plugins:db:version" task
26
+ 0.4.0
27
+ ----
28
+ * Changed the list_specs based on files by one based on classes
29
+ * togify: Use github's tarballs instead of a git clone to a) remove git dependecy on togify and b) use a tagged release of tog plugins instead of the edge
30
+
31
+ 0.3.0
32
+ ----
33
+ * Rubigen dependency added to gemspec.
34
+
35
+ 0.2.1
36
+ ----
37
+ * [#89 status:resolved] From now tog:plugins:copy_resources don't copy .svn dirs to app's public directory...
38
+ * tog-desert dependency added.
39
+ * 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.
40
+
41
+ 0.2.0
42
+ -----
43
+ * Initial public code release
@@ -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.
@@ -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
@@ -0,0 +1,3 @@
1
+
2
+ For more information on tog, see https://github.com/tog/tog
3
+
@@ -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
@@ -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,196 @@
1
+ require 'tog'
2
+ require 'zip/zip'
3
+ require 'net/http'
4
+
5
+ class TogifyGenerator < RubiGen::Base
6
+
7
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
8
+ Config::CONFIG['ruby_install_name'])
9
+
10
+ default_options :author => nil
11
+
12
+ attr_reader :name
13
+
14
+ def initialize(runtime_args, runtime_options = {})
15
+ super
16
+ usage if args.empty?
17
+ @destination_root = File.expand_path(args.shift)
18
+ @name = base_name
19
+ extract_options
20
+ end
21
+
22
+ def manifest
23
+ record do |m|
24
+ BASEDIRS.each { |path| m.directory path }
25
+
26
+ # Include tog rake tasks on the app
27
+ include_tog_rake_tasks("#{destination_root}/Rakefile")
28
+
29
+ # Install desert dependency
30
+ require_desert_on_environment("#{destination_root}/config/environment.rb")
31
+
32
+ # PLugins
33
+ plugins = install_default_plugins
34
+
35
+ # Migrations
36
+ m.migration_template 'integrate_tog.rb', 'db/migrate', :assigns => {
37
+ :migration_name => "IntegrateTog",
38
+ :plugins => plugins
39
+ },:migration_file_name => 'integrate_tog'
40
+ end
41
+ end
42
+
43
+ protected
44
+ def banner
45
+ <<-EOS
46
+ Apply tog platform to an existing Rails app
47
+
48
+ USAGE: #{spec.name} name
49
+ EOS
50
+ end
51
+
52
+ def add_options!(opts)
53
+ opts.separator ''
54
+ opts.separator 'Options:'
55
+ # For each option below, place the default
56
+ # at the top of the file next to "default_options"
57
+ # opts.on("-a", "--author=\"Your Name\"", String,
58
+ # "Some comment about this option",
59
+ # "Default: none") { |options[:author]| }
60
+ opts.on("--skip-tog_user",
61
+ "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 }
62
+ opts.on("--development",
63
+ "Clone the repositories from the private clone urls allowing the developers to develop the plugins on a togified app.") { |v| options[:development] = v }
64
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
65
+ end
66
+
67
+ def extract_options
68
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
69
+ # Templates can access these value via the attr_reader-generated methods, but not the
70
+ # raw instance variable value.
71
+ # @author = options[:author]
72
+ end
73
+
74
+ def include_tog_rake_tasks(rakefile)
75
+ sentinel = "require 'tasks/rails'"
76
+ logger.create "require tog rake tasks"
77
+ unless options[:pretend]
78
+ gsub_file rakefile, /(#{Regexp.escape(sentinel)})/mi do |match|
79
+ "#{match}\n\nrequire 'tasks/tog'\n"
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ def require_desert_on_environment(env_file)
86
+ sentinel = 'Rails::Initializer.run do |config|'
87
+ logger.create "require 'desert' on environment"
88
+ unless options[:pretend]
89
+ gsub_file env_file, /(#{Regexp.escape(sentinel)})/mi do |match|
90
+ "require 'desert'\n#{match}\n "
91
+ end
92
+ end
93
+ end
94
+
95
+ # Tog plugins
96
+ def default_plugins
97
+ plugins = %w{ tog_core }
98
+ plugins << "tog_user" unless options[:skip_tog_user]
99
+ plugins += %w{tog_social tog_mail}
100
+ end
101
+
102
+ def install_default_plugins
103
+ default_plugins.collect{|plugin|
104
+ plugin_path = "#{destination_root}/vendor/plugins/#{plugin}"
105
+ checkout_code(plugin_path, plugin)
106
+ logger.create "vendor/plugins/#{plugin}"
107
+ route_from_plugins("#{destination_root}/config/routes.rb", plugin)
108
+ {:name => plugin,:current_migration => current_migration_number(plugin_path) }
109
+ }
110
+ end
111
+
112
+ def checkout_code(plugin_path, plugin)
113
+ options[:development] ? clone_repo(plugin_path, plugin): tarball_repo(plugin_path, plugin)
114
+ end
115
+ # "vendor/plugins/tog_core", "tog_core"
116
+ def tarball_repo(plugin_path, plugin)
117
+ uri = "http://github.com/tog/#{plugin}/zipball/v#{Tog::Version::STRING}"
118
+ zip = tarball_fetch(uri)
119
+ tarball_unpack(zip, plugin)
120
+ end
121
+
122
+ def tarball_fetch(uri, redirect_limit = 10)
123
+ raise ArgumentError, "HTTP redirect too deep trying to get #{uri}" if redirect_limit == 0
124
+ response = Net::HTTP.get_response(URI.parse(uri))
125
+ case response
126
+ when Net::HTTPSuccess
127
+ temp_zip = Time.now.to_i.to_s
128
+ open(temp_zip, "wb") { |file|
129
+ file.write(response.read_body)
130
+ }
131
+ temp_zip
132
+ when Net::HTTPRedirection then tarball_fetch(response['location'], redirect_limit - 1)
133
+ else
134
+ tarball_fetch(uri, redirect_limit - 1)
135
+ end
136
+ end
137
+
138
+ def tarball_unpack(file, plugin)
139
+ destination = "#{destination_root}/vendor/plugins"
140
+ begin
141
+ Zip::ZipFile.open(file) { |zip_file|
142
+ zip_file.each { |f|
143
+ f_path=File.join(destination, f.name)
144
+ FileUtils.mkdir_p(File.dirname(f_path))
145
+ zip_file.extract(f, f_path) unless File.exist?(f_path)
146
+ }
147
+ }
148
+ temp = Dir.glob(File.join(destination, "tog-#{plugin}*")).first
149
+ FileUtils.mv temp, File.join(destination, plugin)
150
+ FileUtils.rm_rf file
151
+
152
+ rescue Exception => e
153
+ logger.error "There has been a problem trying to unpack the #{plugin} tarball downloaded from github. Remove the changes made on your app by togify and try again. Sorry for the inconveniences."
154
+ exit(-1)
155
+ end
156
+ end
157
+
158
+ def clone_repo(plugin_path, plugin)
159
+ repository = "git@github.com:tog/#{plugin}.git"
160
+ revision = "head"
161
+ FileUtils.rm_rf(plugin_path)
162
+ system("git clone #{repository} #{plugin_path}")
163
+ end
164
+
165
+
166
+ def current_migration_number(plugin_path)
167
+ Dir.glob("#{plugin_path}/db/migrate/*.rb").inject(0) do |max, file_path|
168
+ n = File.basename(file_path).split('_', 2).first.to_i
169
+ if n > max then n else max end
170
+ end
171
+ end
172
+
173
+ def route_from_plugins(routes_file, plugin)
174
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
175
+ logger.route "map.routes_from_plugin #{plugin}"
176
+ unless options[:pretend]
177
+ gsub_file routes_file, /(#{Regexp.escape(sentinel)})/mi do |match|
178
+ "#{match}\n map.routes_from_plugin '#{plugin}'\n"
179
+ end
180
+ end
181
+ end
182
+ def gsub_file(path, regexp, *args, &block)
183
+ content = File.read(path).gsub(regexp, *args, &block)
184
+ File.open(path, 'wb') { |file| file.write(content) }
185
+ end
186
+
187
+ BASEDIRS = %w(
188
+ config
189
+ db
190
+ db/migrate
191
+ lib
192
+ lib/tasks
193
+ vendor
194
+ vendor/plugins
195
+ )
196
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'active_record'
5
+ require 'rubigen'
6
+
7
+ if %w(-v --version).include? ARGV.first
8
+ require 'tog/version'
9
+ puts "#{File.basename($0)} #{Tog::Version::STRING}"
10
+ exit(0)
11
+ end
12
+
13
+ require 'rubigen/scripts/generate'
14
+ source = RubiGen::PathSource.new(:application, File.join(File.dirname(__FILE__), "../app_generators"))
15
+ RubiGen::Base.reset_sources
16
+ RubiGen::Base.append_sources source
17
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'togify')
@@ -0,0 +1,50 @@
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
+ ['newgem', '>= 1.0.3'],
14
+ ['desert', '>= 0.5.2'],
15
+ ['RedCloth', '>= 3.0.4'],
16
+ ['rubyzip', '>= 0.9.1'],
17
+ ['oauth', '>= 0.2.7']
18
+ ]
19
+
20
+ REV = nil
21
+ # UNCOMMENT IF REQUIRED:
22
+ # REV = YAML.load(`svn info`)['Revision']
23
+ VERS = Tog::Version::STRING + (REV ? ".#{REV}" : "")
24
+
25
+ class Hoe
26
+ def extra_deps
27
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
28
+ @extra_deps
29
+ end
30
+ end
31
+
32
+ # Generate all the Rake tasks
33
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
34
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
35
+ DEVELOPERS.each{|dev|
36
+ p.developer(dev[0], dev[1])
37
+ }
38
+ p.description = p.summary = "extensible open source social network platform"
39
+ p.url = "http://github.com/tog/tog"
40
+ p.test_globs = ["test/**/test_*.rb"]
41
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
42
+
43
+ # == Optional
44
+ p.post_install_message = File.open(File.dirname(__FILE__) + "/../POST_INSTALL").read rescue ""
45
+ p.changes = p.paragraphs_of("CHANGELOG.md", 0..1).join("\n\n") rescue ""
46
+ p.extra_deps = EXTRA_DEPENDENCIES
47
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
48
+ end
49
+
50
+ require 'newgem/tasks'
@@ -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,121 @@
1
+ namespace :tog do
2
+ namespace :plugins do
3
+ namespace :db do
4
+ desc "Retrieves the current schema version numbers of the tog plugins in this app. Use PLUGIN=plugin_name to retrieves a specific plugin version."
5
+ task :version do
6
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
7
+ require File.expand_path(File.join(RAILS_ROOT, "config","environment"))
8
+ name = File.basename(directory)
9
+ Desert::PluginMigrations::Migrator.current_plugin = Desert::Manager.find_plugin(name)
10
+ current_version = Desert::PluginMigrations::Migrator.current_version
11
+ max_version = max_migration_number(directory)
12
+ msg = "[#{name}] Current Version : #{current_version}"
13
+ msg << " (This plugin is NOT uptodate. Most recent migration available: #{max_version})" if max_version > current_version
14
+ puts msg
15
+ end
16
+ end
17
+ end
18
+ 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."
19
+ task :update do
20
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
21
+ puts "Pulling changes of #{File.basename(directory)}"
22
+ chdir directory do
23
+ output = %x{git pull}
24
+ end
25
+ end
26
+ end
27
+
28
+ 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."
29
+ task :install do
30
+ plugin = ENV["PLUGIN"]
31
+ force = ENV["FORCE"] || false
32
+ puts "Installing #{plugin} on vendor/plugins/#{plugin}"
33
+ cmd = "script/plugin install git@github.com:tog/#{plugin}.git"
34
+ cmd << " --force" if force
35
+ output = %x{#{cmd}}
36
+ puts "Generating migration to integrate #{plugin} in the app"
37
+
38
+ to_version = max_migration_number("#{RAILS_ROOT}/vendor/plugins/#{plugin}")
39
+ from_version = 0
40
+ cmd = "script/generate tog_migration Integrate#{plugin.classify}Version#{to_version}From#{from_version}"
41
+ output = %x{#{cmd}}
42
+
43
+ end
44
+
45
+ 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."
46
+ task :copy_resources do
47
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
48
+ plugin_name = File.basename(directory)
49
+ dest_public_dir = File.join(RAILS_ROOT, "public", plugin_name)
50
+ orig_public_dir = File.join(directory, "public")
51
+ if File.exists?(orig_public_dir)
52
+ puts "Copying the public resources of #{plugin_name} to #{dest_public_dir}"
53
+ FileUtils.mkdir_p(dest_public_dir)
54
+ is_svn_dir = proc {|path| path =~ /\.svn/}
55
+ Dir[orig_public_dir].reject(&is_svn_dir).each do |file|
56
+ FileUtils.cp_r(Dir["#{orig_public_dir}/*"], dest_public_dir )
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ desc "Runs tests on all available Tog Plugins. Pass PLUGIN=plugin_name to test a single plugin."
63
+ task :test do
64
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
65
+ if File.directory?(File.join(directory, 'test'))
66
+ chdir directory do
67
+ if RUBY_PLATFORM =~ /win32/
68
+ system "rake.cmd test"
69
+ else
70
+ system "rake test"
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ desc "List the names of tog plugins test methods in a specification like format. Pass PLUGIN=plugin_name to list a single plugin."
77
+ task :list_specs do
78
+ require File.expand_path(File.join(RAILS_ROOT, "config","environment"))
79
+ require 'test/unit'
80
+ require 'rubygems'
81
+ require 'active_support'
82
+
83
+ # bug in test unit. Set to true to stop from running.
84
+ Test::Unit.run = true
85
+
86
+ plugin_roots(ENV["PLUGIN"]).each do |directory|
87
+ if File.directory?(File.join(directory, 'test'))
88
+ chdir directory do
89
+ test_files = Dir.glob(File.join('test', '**', '*_test.rb'))
90
+ test_files.each do |file|
91
+ load file
92
+ klass = File.read(file)[/class\s(.*Test)\s</, 1].constantize
93
+
94
+ puts klass.name.gsub('Test', '')
95
+
96
+ test_methods = klass.instance_methods.grep(/^test/).map {|s| s.gsub(/^test: /, '')}.sort
97
+ test_methods.each {|m| puts " " + m }
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ def plugin_roots(plugin=nil)
107
+ roots = Dir[File.join(RAILS_ROOT, 'vendor', 'plugins', 'tog_*')]
108
+ if plugin
109
+ roots = roots.select {|x| /\/(\d+_)?#{plugin}$/ === x }
110
+ if roots.empty?
111
+ puts "Sorry, the plugin '#{plugin}' is not installed."
112
+ end
113
+ end
114
+ roots
115
+ end
116
+ def max_migration_number(plugin)
117
+ to_version=Dir.glob("#{plugin}/db/migrate/*.rb").inject(0) do |max, file_path|
118
+ n = File.basename(file_path).split('_', 2).first.to_i
119
+ if n > max then n else max end
120
+ end
121
+ end
@@ -0,0 +1,2 @@
1
+ # Load tog rakefile extensions
2
+ Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
@@ -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,19 @@
1
+ module Tog
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 5
5
+ TINY = 4
6
+ MODULE = "Io"
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+
9
+ class << self
10
+ def to_s
11
+ STRING
12
+ end
13
+ def full_version
14
+ "#{MODULE} #{STRING}"
15
+ end
16
+ alias :to_str :to_s
17
+ end
18
+ end
19
+ end
@@ -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,60 @@
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 'active_record'
25
+ require 'rubigen'
26
+ rescue LoadError
27
+ require 'rubygems'
28
+ require 'active_record'
29
+ require 'rubigen'
30
+ end
31
+ require 'rubigen/helpers/generator_test_helper'
32
+
33
+ def copy_to_fake (orig, dest)
34
+ FileUtils.cp(File.join(File.dirname(__FILE__), orig), File.join(APP_ROOT, dest))
35
+ end
36
+ def setup_fake_tog_app
37
+ bare_setup
38
+ FileUtils.mkdir_p(File.join(APP_ROOT, "/config"))
39
+ copy_to_fake("/templates/environment.rb", "/config/environment.rb")
40
+ copy_to_fake("/templates/routes.rb", "/config/routes.rb")
41
+ copy_to_fake("/templates/Rakefile", "/Rakefile")
42
+ @plugins = %w{ tog_core tog_social tog_mail tog_user}
43
+ end
44
+ def teardown_fake_tog_app
45
+ bare_teardown
46
+ end
47
+
48
+ def assert_has_require(body,*requires)
49
+ requires.each do |req|
50
+ assert body=~/require '#{req.to_s}'/,"should have require '#{req.to_s}'"
51
+ yield( req, $1 ) if block_given?
52
+ end
53
+ end
54
+
55
+ def assert_has_plugin_routes(body,*routes)
56
+ routes.each do |route|
57
+ assert body=~/map.routes_from_plugin '#{route.to_s}'/,"should have routes '#{route.to_s}'"
58
+ yield( route, $1 ) if block_given?
59
+ end
60
+ 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
@@ -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,62 @@
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
+ }
31
+ generated_migration = Dir.glob("#{APP_ROOT}/db/migrate/*_integrate_tog.rb")[0]
32
+ assert generated_migration, "should be a IntegrateTog migration in the togified app"
33
+ File.open(generated_migration, "r") do |file|
34
+ 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"
35
+ end
36
+ end
37
+
38
+
39
+ def test_generator_with_dev_repositories
40
+ run_generator('togify', [APP_ROOT], sources, {:development => true})
41
+ @plugins.each{|plugin|
42
+ assert_remote_origin_of_plugin(plugin, "git@github.com:tog/(.*).git")
43
+ }
44
+ end
45
+
46
+ private
47
+ def sources
48
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))]
49
+ end
50
+
51
+ def generator_path
52
+ "app_generators"
53
+ end
54
+
55
+ def assert_remote_origin_of_plugin(plugin, match)
56
+ FileUtils.chdir File.join(APP_ROOT, "vendor", "plugins", "#{plugin}") do
57
+ remote_origin = %x{git config remote.origin.url}
58
+ assert remote_origin.match(match)
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,62 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{tog}
5
+ s.version = "0.5.4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Aitor Garc\303\255a", "Alberto Molpeceres", "Roberto Salicio"]
9
+ s.date = %q{2009-08-27}
10
+ s.default_executable = %q{togify}
11
+ s.description = %q{extensible open source social network platform}
12
+ s.email = ["aitor@linkingpaths.com", "alberto@linkingpaths.com", "roberto@linkingpaths.com"]
13
+ s.executables = ["togify"]
14
+ s.extra_rdoc_files = ["Manifest.txt", "README.txt"]
15
+ 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"]
16
+ s.has_rdoc = true
17
+ s.homepage = %q{http://github.com/tog/tog}
18
+ s.post_install_message = %q{
19
+ For more information on tog, see https://github.com/tog/tog
20
+
21
+ }
22
+ s.rdoc_options = ["--main", "README.txt"]
23
+ s.require_paths = ["lib"]
24
+ s.rubyforge_project = %q{tog}
25
+ s.rubygems_version = %q{1.3.1}
26
+ s.summary = %q{extensible open source social network platform}
27
+ 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"]
28
+
29
+ if s.respond_to? :specification_version then
30
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
31
+ s.specification_version = 2
32
+
33
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
34
+ s.add_runtime_dependency(%q<will_paginate>, [">= 2.3.2"])
35
+ s.add_runtime_dependency(%q<rubigen>, [">= 1.3.2"])
36
+ s.add_runtime_dependency(%q<newgem>, [">= 1.0.3"])
37
+ s.add_runtime_dependency(%q<desert>, [">= 0.5.2"])
38
+ s.add_runtime_dependency(%q<RedCloth>, [">= 3.0.4"])
39
+ s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.1"])
40
+ s.add_runtime_dependency(%q<oauth>, [">= 0.2.7"])
41
+ s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
42
+ else
43
+ s.add_dependency(%q<will_paginate>, [">= 2.3.2"])
44
+ s.add_dependency(%q<rubigen>, [">= 1.3.2"])
45
+ s.add_dependency(%q<newgem>, [">= 1.0.3"])
46
+ s.add_dependency(%q<desert>, [">= 0.5.2"])
47
+ s.add_dependency(%q<RedCloth>, [">= 3.0.4"])
48
+ s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
49
+ s.add_dependency(%q<oauth>, [">= 0.2.7"])
50
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<will_paginate>, [">= 2.3.2"])
54
+ s.add_dependency(%q<rubigen>, [">= 1.3.2"])
55
+ s.add_dependency(%q<newgem>, [">= 1.0.3"])
56
+ s.add_dependency(%q<desert>, [">= 0.5.2"])
57
+ s.add_dependency(%q<RedCloth>, [">= 3.0.4"])
58
+ s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
59
+ s.add_dependency(%q<oauth>, [">= 0.2.7"])
60
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
61
+ end
62
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.4
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: 2009-08-27 00:00:00 +02:00
15
+ default_executable: togify
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: will_paginate
19
+ type: :runtime
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 2.3.2
26
+ version:
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubigen
29
+ type: :runtime
30
+ version_requirement:
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.3.2
36
+ version:
37
+ - !ruby/object:Gem::Dependency
38
+ name: newgem
39
+ type: :runtime
40
+ version_requirement:
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.3
46
+ version:
47
+ - !ruby/object:Gem::Dependency
48
+ name: desert
49
+ type: :runtime
50
+ version_requirement:
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.5.2
56
+ version:
57
+ - !ruby/object:Gem::Dependency
58
+ name: RedCloth
59
+ type: :runtime
60
+ version_requirement:
61
+ version_requirements: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 3.0.4
66
+ version:
67
+ - !ruby/object:Gem::Dependency
68
+ name: rubyzip
69
+ type: :runtime
70
+ version_requirement:
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.1
76
+ version:
77
+ - !ruby/object:Gem::Dependency
78
+ name: oauth
79
+ type: :runtime
80
+ version_requirement:
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.2.7
86
+ version:
87
+ - !ruby/object:Gem::Dependency
88
+ name: hoe
89
+ type: :development
90
+ version_requirement:
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.3.2
96
+ version:
97
+ description: extensible open source social network platform
98
+ email:
99
+ - aitor@linkingpaths.com
100
+ - alberto@linkingpaths.com
101
+ - roberto@linkingpaths.com
102
+ executables:
103
+ - togify
104
+ extensions: []
105
+
106
+ extra_rdoc_files:
107
+ - Manifest.txt
108
+ - README.txt
109
+ files:
110
+ - CHANGELOG.md
111
+ - MIT-LICENSE
112
+ - Manifest.txt
113
+ - POST_INSTALL
114
+ - README.txt
115
+ - Rakefile
116
+ - app_generators/togify/USAGE
117
+ - app_generators/togify/templates/integrate_tog.rb
118
+ - app_generators/togify/togify_generator.rb
119
+ - bin/togify
120
+ - config/hoe.rb
121
+ - config/requirements.rb
122
+ - generators/tog_migration/USAGE
123
+ - generators/tog_migration/templates/migration.rb
124
+ - generators/tog_migration/tog_migration_generator.rb
125
+ - generators/tog_plugin/USAGE
126
+ - generators/tog_plugin/tog_plugin_generator.rb
127
+ - lib/tasks/platform.rake
128
+ - lib/tasks/tog.rb
129
+ - lib/tog.rb
130
+ - lib/tog/version.rb
131
+ - test/templates/Rakefile
132
+ - test/templates/environment.rb
133
+ - test/templates/routes.rb
134
+ - test/test_generator_helper.rb
135
+ - test/test_helper.rb
136
+ - test/test_rake_tasks.rb
137
+ - test/test_tog.rb
138
+ - test/test_tog_plugin_generator.rb
139
+ - test/test_togify_generator.rb
140
+ - tog.gemspec
141
+ has_rdoc: true
142
+ homepage: http://github.com/tog/tog
143
+ licenses: []
144
+
145
+ post_install_message: |+
146
+
147
+ For more information on tog, see https://github.com/tog/tog
148
+
149
+ rdoc_options:
150
+ - --main
151
+ - README.txt
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: "0"
159
+ version:
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: "0"
165
+ version:
166
+ requirements: []
167
+
168
+ rubyforge_project: tog
169
+ rubygems_version: 1.3.5
170
+ signing_key:
171
+ specification_version: 2
172
+ summary: extensible open source social network platform
173
+ test_files:
174
+ - test/test_generator_helper.rb
175
+ - test/test_helper.rb
176
+ - test/test_rake_tasks.rb
177
+ - test/test_tog.rb
178
+ - test/test_tog_plugin_generator.rb
179
+ - test/test_togify_generator.rb