netzpirat-subito 0.1.0

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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ .idea
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Michael Kessler
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.
data/README.markdown ADDED
@@ -0,0 +1,222 @@
1
+ Subito
2
+ ======
3
+
4
+ `subito` is a Git *Submodule Inspection Tool* and helps to manage your Radiant extensions and Rails Plugins.
5
+ If you just want to manage your Radiant extensions then [Ray](http://github.com/johnmuhl/radiant-ray-extension/tree/master) is your friend.
6
+
7
+ show
8
+ ----
9
+
10
+ The `show` command visualizes the submodule tree:
11
+
12
+ subito show
13
+
14
+ The `show` command has two options:
15
+
16
+ * --remotes adds submodule remotes to the view
17
+ * --verbose adds verbose output to the tree
18
+
19
+ ### sample output
20
+
21
+ Show a verbose project structure with remotes: `subito show --remotes --verbose`
22
+
23
+ extranett (Radiant Project)
24
+ +--+ Extensions
25
+ | +- dav
26
+ | | +- origin/master -> git@github.com:netzpirat/radiant-dav-extension.git
27
+ | +- gallery
28
+ | | +- pilu/master -> git://github.com/pilu/radiant-gallery.git
29
+ | | +- origin/master -> git@github.com:netzpirat/radiant-gallery-extension.git
30
+ | +- page_preview
31
+ | | +- vigetlabs/master -> git://github.com/vigetlabs/radiant_page_preview_extension.git
32
+ | | +- saturnflyer/master -> git://github.com/saturnflyer/radiant_page_preview_extension.git
33
+ | | +- origin/master -> git@github.com:netzpirat/radiant-page-preview-extension.git
34
+ | +- ray
35
+ | | +- johnmuhl/experimental -> git://github.com/johnmuhl/radiant-ray-extension.git
36
+ | | +- origin/experimental -> git@github.com:netzpirat/radiant-ray-extension.git
37
+ | +- sns
38
+ | | +- SwankInnovations/master -> git://github.com/SwankInnovations/radiant-sns-extension.git
39
+ | | +- MrGossett/master -> git://github.com/MrGossett/radiant-sns-extension.git
40
+ | | +- origin/master -> git@github.com:netzpirat/radiant-sns-extension.git
41
+ | +- wym_editor_filter
42
+ | +- origin/master -> git@github.com:netzpirat/radiant-wym-editor-filter-extension.git
43
+ | +- jomz/master -> git://github.com/jomz/wymeditor-for-radiant.git
44
+ +--+ Plugins
45
+ | +- attachment_fu
46
+ | +- origin/master -> git://github.com/technoweenie/attachment_fu.git
47
+ +--+ Radiant
48
+ | +- origin/master -> git@github.com:netzpirat/radiant.git
49
+ | +- radiant/master -> git://github.com/radiant/radiant.git
50
+ +--+ Plugins
51
+ +- dataset
52
+ | +- origin/ -> git://github.com/aiwilliams/dataset.git
53
+ +- spec_integration
54
+ | +- origin/ -> git://github.com/aiwilliams/spec_integration.git
55
+ +- vizres
56
+ +- origin/ -> git://github.com/pelargir/vizres.git
57
+
58
+ status
59
+ ------
60
+
61
+ The `status` command visualizes the submodules tree and each modules status:
62
+
63
+ subito status
64
+
65
+ ### sample output
66
+
67
+ extranett
68
+ +--+ Extensions
69
+ | +- admin_breadcrumbs
70
+ | +- application_theme
71
+ | +- blog
72
+ | +- change_author
73
+ | +- comments
74
+ | +- conditional_tags
75
+ | +- copy_move -> Changed but not updated.
76
+ | +- dashboard -> Changed but not updated.
77
+ | +- dav
78
+ | +- gallery -> Changed but not updated.
79
+ | +- gallery_multisite -> Changed but not updated.
80
+ | +- help
81
+ | +- import_export
82
+ | +- index_page
83
+ | +- multi_site -> Changed but not updated.
84
+ | +- navigation_tags
85
+ | +- page_preview
86
+ | +- paginate
87
+ | +- paperclipped -> Your branch is ahead of 'origin/master' by 9 commits.
88
+ | +- paperclipped_multisite
89
+ | +- ray
90
+ | +- scoped_admin
91
+ | +- search
92
+ | +- search_multi_site
93
+ | +- seo_help
94
+ | +- settings
95
+ | +- share_layouts -> Changed but not updated.
96
+ | +- sibling_tags
97
+ | +- site_watcher
98
+ | +- sns -> Changed but not updated.
99
+ | +- sns_minifier
100
+ | +- sns_multisite
101
+ | +- sns_sass_filter
102
+ | +- tags
103
+ | +- wordpress_migrator
104
+ | +- wym_editor_filter -> Your branch is ahead of 'origin/master' by 8 commits.
105
+ +--+ Plugins
106
+ | +- has_many_polymorphs
107
+ | +- attachment_fu
108
+ | +- exceptional
109
+ | +- rpm
110
+ | +- will_paginate
111
+ +--+ Radiant
112
+ +--+ Plugins
113
+ +- dataset -> Your branch is behind 'origin/master' by 21 commits, and can be fast-forwarded.
114
+ +- spec_integration -> Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.
115
+ +- vizres -> Your branch is behind 'origin/master' by 5 commits, and can be fast-forwarded.
116
+
117
+ log
118
+ ----
119
+
120
+ The `log` command visualizes the submodule tree and each modules last log entry:
121
+
122
+ subito log
123
+
124
+ The `log` command has one option:
125
+
126
+ * --remotes adds submodule remotes to the view
127
+
128
+ ### sample output
129
+
130
+ Show a project submodule logs: `subito log`
131
+
132
+ extranett
133
+ +--+ Extensions
134
+ | +- admin_breadcrumbs -> Changed deprecated page_edit_path(page) to edit_admin_page_path(page)
135
+ | +- application_theme -> updated docs
136
+ | +- blog -> configurable home location for blog posts when dashboard is installed
137
+ | +- change_author -> properly find the current_user
138
+ | +- comments -> Use application_controller in Radiant 0.8.0 due upgrade to Rails 2.3.2
139
+ | +- conditional_tags -> Ready for v0.4
140
+ | +- copy_move -> The Copy Move Extension is now aware of multi site installations
141
+ | +- dashboard -> Merge branch 'master' of git://github.com/saturnflyer/radiant-dashboard-extension
142
+ | +- dav -> Don't use tempfile 'cause it generates ugly file names.
143
+ | +- gallery -> Merge branch 'master' of git://github.com/pilu/radiant-gallery
144
+ | +- gallery_multisite -> Fixed wrong call to import path without a site
145
+ | +- help -> Use application_controller in Radiant 0.8.0 due upgrade to Rails 2.3.2
146
+ | +- import_export -> Updated for Edge. Radiant::ExtensionsMeta no longer extant.
147
+ | +- index_page -> avoiding siteLanguage ext. error..
148
+ | +- multi_site -> Site.several? causes a 'ArgumentError (A copy of MultiSite::ScopedValidation has been removed from the module tree but is still active)' in development mode
149
+ | +- navigation_tags -> including TagHelper
150
+ | +- page_preview -> Use application_controller in Radiant 0.8.0 due upgrade to Rails 2.3.2
151
+ | +- paginate -> Merge branch 'master' of git://github.com/saturnflyer/radiant-paginate-extension
152
+ | +- paperclipped -> Merge branch 'master' of git://github.com/kbingman/paperclipped
153
+ | +- paperclipped_multisite -> Merge branch 'master' of git://github.com/spanner/radiant-paperclipped_multisite-extension
154
+ | +- ray -> fix broken output message on install, when there was no exact match but some possible matches. i.e. ray:i name=calendar
155
+ | +- scoped_admin -> Merge branch 'master' of git://github.com/spanner/radiant-scoped-admin-extension
156
+ | +- search -> spec
157
+ | +- search_multi_site -> Initial import
158
+ | +- seo_help -> added inherit to r:meta
159
+ | +- settings -> Converted settings description to a text area, and added a few styling improvements.
160
+ | +- share_layouts -> Prevent <r:date /> from breaking when using a dummy page.
161
+ | +- sibling_tags -> Switched README format to markdown.
162
+ | +- site_watcher -> Fix nil reference when site has no 404 page
163
+ | +- sns -> Updated specs (and some application code) for 0.7.
164
+ | +- sns_minifier -> A few minor changes to be compatible with radiant/radiant-sns-extension. 1) Rename app/views/admin/text_asset app/views/admin/text_assets, 2) In sns_minifier_extension.rb change admin.text_asset.edit.add to admin.text_assets.edit.add. Pretty simple just keeping up with the pluralizations. '
165
+ | +- sns_multisite -> Pluralize admin ui for text asset
166
+ | +- sns_sass_filter -> Updated descriptions for v0.3
167
+ | +- tags -> Updated has_many_polymorphs
168
+ | +- wordpress_migrator -> extra fixes
169
+ | +- wym_editor_filter -> Merge branch 'master' of git://github.com/netzpirat/radiant-wym-editor-filter-extension
170
+ +--+ Plugins
171
+ | +- has_many_polymorphs -> Changelog.
172
+ | +- attachment_fu -> ruby 1.9 syntax compatibility fixes
173
+ | +- exceptional -> Change my email address
174
+ | +- rpm -> Agent release 2.8.11
175
+ | +- will_paginate -> release v2.3.8 for Rails 2.3
176
+ +--+ Radiant
177
+ +--+ Plugins
178
+ +- dataset -> name_to_sym for naming models
179
+ +- spec_integration -> Don't alias rescue_action_without_fast_errors...instead call it directly when in an integration example
180
+ +- vizres -> updated readme
181
+
182
+ bundle
183
+ ------
184
+
185
+ The `bundle` command can `generate` a bundle from an actual submodule configuration within a project.
186
+ The bundle file will be written to `config\extensions.yml` in the project root.
187
+
188
+ ### generate
189
+
190
+ subito bundle generate
191
+
192
+ The `bundle generate` command has two options:
193
+
194
+ * --remotes adds submodule remotes to the view
195
+ * --verbose adds verbose output to the tree
196
+
197
+ #### sample output
198
+
199
+ Generate a bundle with remotes: `subito bundle generate --remotes`
200
+
201
+ ---
202
+ - name: dav
203
+ hub: netzpirat
204
+ - name: gallery
205
+ hub: netzpirat
206
+ - remote: pilu/radiant-gallery
207
+ - name: page_preview
208
+ hub: netzpirat
209
+ - remote: vigetlabs/radiant_page_preview_extension
210
+ - remote: saturnflyer/radiant_page_preview_extension
211
+ - name: ray
212
+ hub: netzpirat
213
+ - remote: johnmuhl/radiant-ray-extension
214
+ - name: sns
215
+ hub: netzpirat
216
+ - remote: SwankInnovations/radiant-sns-extension
217
+ - remote: MrGossett/radiant-sns-extension
218
+ - name: wym_editor_filter
219
+ hub: netzpirat
220
+ - remote: jomz/wymeditor-for-radiant
221
+
222
+ As you can see the format is compatible with [Ray's extensions.yml](http://wiki.github.com/johnmuhl/radiant-ray-extension/usage)
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rake'
2
+
3
+ $LOAD_PATH.unshift('lib')
4
+
5
+ gem 'git'
6
+ require 'git'
7
+
8
+ begin
9
+ require 'jeweler'
10
+ Jeweler::Tasks.new do |gem|
11
+ gem.name = "subito"
12
+ gem.summary = "Submodule Inspection Tool"
13
+ gem.email = "michi@netzpiraten.ch"
14
+ gem.homepage = "http://github.com/netzpirat/subito"
15
+ gem.description = "helps to manage your Radiant extensions and Rails Plugins"
16
+ gem.authors = ["Michael Kessler"]
17
+ end
18
+ rescue LoadError
19
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'rake/rdoctask'
23
+ Rake::RDocTask.new do |rdoc|
24
+ rdoc.rdoc_dir = 'rdoc'
25
+ rdoc.title = 'jeweler'
26
+ rdoc.rdoc_files.include('README.markdown')
27
+ rdoc.rdoc_files.include('lib/**/*.rb')
28
+ end
data/TODO ADDED
@@ -0,0 +1,52 @@
1
+ Commit submodule
2
+ ----------------
3
+ subito commit -m "Submodule update" -> commit submodule and parent git repo (allows -a)
4
+
5
+ Pull submodule and remotes
6
+ --------------------------
7
+
8
+ subito pull all -> pulls all submodules
9
+ subito pull all --remote -> pulls all submodules and remotes
10
+ subito pull copy_move -> pulls copy_move submodule
11
+ subito pull copy_move --remot -> pulls copy_move submodule and remotes
12
+
13
+ Install
14
+ -------
15
+
16
+ subito install copy_move -> installs the copy move extension
17
+ subito install netzpirat/copy-move -> installs the copy move extension
18
+ subito install -p thoughtbot/paperclip -> installs the paperclip plugin
19
+ subito install -g mini_magick -> installs the mini_magick gem
20
+
21
+ copy_move name mapping:
22
+ 1. github.user/radiant-copy-move-extension
23
+ 2. github.user/radiant-copy_move-extension
24
+ 3. github.user/copy_move
25
+ 4. radiant/radiant-copy-move-extension
26
+
27
+ netzpirat/copy-move name mapping:
28
+ 1. netzpirat/radiant-copy-move-extension
29
+ 2. netzpirat/radiant-copy-move-extension
30
+ 3. netzpirat/copy_move
31
+
32
+ Must resolve http://wiki.github.com/johnmuhl/radiant-ray-extension/extension-dependencies
33
+
34
+ Uninstall/Enable/Disable
35
+ ------------------------
36
+
37
+ subito uninstall copy_move
38
+ subito disable copy_move
39
+ subito enable copy_move
40
+
41
+ Checks also dependencies.
42
+
43
+ Bundle
44
+ ------
45
+
46
+ subito install bundle -> Installs from config/extensions.yml
47
+
48
+ Radiant
49
+ -------
50
+ subito show radiant versions -> list radiant tags
51
+ subito install radiant -> install radiant edge
52
+ subito install radiant 0.6.9 -> install radiant 0.6.9
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/subito ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib_dir = File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
5
+
6
+ require 'subito'
7
+ Subito.start(ARGV)
@@ -0,0 +1,108 @@
1
+ class Bundle
2
+
3
+ BUNDLE = "config/extensions.yml"
4
+
5
+ #
6
+ # Generates a bundle file with the submodule configuration
7
+ # +project+ the project to install its bundle
8
+ # +options+ the command line options
9
+ #
10
+ def self.generate(project, options)
11
+ File.open(project.root + BUNDLE, 'w') do |file|
12
+ file.write("---\n")
13
+ project.extensions.each do |extension|
14
+
15
+ file.write("- name: #{extension.to_s}\n")
16
+ file.write(" hub: #{hub(extension.to_s, extension.remotes['origin'])}\n")
17
+
18
+ extension.remotes.delete('origin')
19
+
20
+ if options.remotes?
21
+ file.write(" remotes:\n")
22
+ extension.remotes.each do |name, url|
23
+ remote = hub(extension.to_s, url, true)
24
+ file.write(" - #{remote}\n")
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ puts "Bundle written to " + BUNDLE
31
+ end
32
+
33
+ File.open(project.root + BUNDLE).each { |line| puts line } if options.verbose?
34
+ end
35
+
36
+ #
37
+ # Installs the submodules from the bundle
38
+ # +project+ the project to install its bundle
39
+ # +options+ the command line options
40
+ #
41
+ def self.install(project, options)
42
+ bundle = YAML::load_file(project.root + BUNDLE)
43
+ installed = project.extensions.map{|e| e.root.basename.to_s }
44
+
45
+ bundle.each do |extension|
46
+ name = extension['name']
47
+ if not installed.include?(name)
48
+ puts "TODO: Installing " + name
49
+ end
50
+ if extension['remotes']
51
+ extension['remotes'].each do |remote|
52
+ Dir.chdir(project.root + "vendor/extensions" + name) do
53
+ puts "Registering #{remote} remote for #{name}" if options.verbose?
54
+ `git remote add #{remote} git://github.com/#{remote}/#{name}.git`
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ #
64
+ # Gets the hub from the repositories url
65
+ # +name+ name of the extension
66
+ # +url+ the url to the extensions repository
67
+ # +remote+ true if remote
68
+ #
69
+ def self.hub(name, url, remote = false)
70
+ if url =~ /git(@|:\/\/)github.com(:|\/)([a-zA-z0-9_\-]+)\/([a-zA-z0-9_\-]+).git/
71
+ if remote and not known_format?(Regexp.last_match(4), name)
72
+ return Regexp.last_match(3) + '/' + Regexp.last_match(4)
73
+ else
74
+ return Regexp.last_match(3)
75
+ end
76
+ else
77
+ return url
78
+ end
79
+ end
80
+
81
+ #
82
+ # Is the format of the radiant extension naming known?
83
+ # +full_name+ full name of the extension, eg. radiant-comments-extension
84
+ # +name+ name of the extension, e.g. comments
85
+ #
86
+ def self.known_format?(full_name, name)
87
+ decline_radiant_extension(name).include?(full_name)
88
+ end
89
+
90
+ #
91
+ # Returns an array of known radiant extension naming variants
92
+ # +name+ name of the extension
93
+ #
94
+ def self.decline_radiant_extension(name)
95
+ [
96
+ "radiant-#{name}-extension",
97
+ "radiant-#{name.to_s.gsub('_','-')}-extension",
98
+ "radinat-#{name}",
99
+ "radiant-#{name.to_s.gsub('_','-')}",
100
+ "#{name}",
101
+ "#{name}.gsub('_','-')",
102
+ "radiant_#{name}_extension",
103
+ "radiant_#{name.to_s.gsub('_','-')}_extension",
104
+ "radinat_#{name}",
105
+ "radiant_#{name.to_s.gsub('_','-')}",
106
+ ]
107
+ end
108
+ end
data/lib/helper/fix.rb ADDED
@@ -0,0 +1,19 @@
1
+ class Fix
2
+
3
+ #
4
+ # Fix the no branch warning when currently no branch
5
+ # is selected in some submodules
6
+ # +project+ the project to install its bundle
7
+ #
8
+ def self.no_branch(project)
9
+ project.submodules.each do |submodule|
10
+ if submodule.branch.empty?
11
+ puts "***".blue + "Fix submodule ".dark_green + "'#{submodule.to_s}'".yellow
12
+ submodule.checkout(:master)
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # Adds colorization to String class
3
+ #
4
+ class String
5
+ def red; colorize(self, "\e[1m\e[31m"); end
6
+ def dark_red; colorize(self, "\e[31m"); end
7
+
8
+ def green; colorize(self, "\e[1m\e[32m"); end
9
+ def dark_green; colorize(self, "\e[32m"); end
10
+
11
+ def yellow; colorize(self, "\e[1m\e[33m"); end
12
+ def dark_yellow; colorize(self, "\e[33m"); end
13
+
14
+ def blue; colorize(self, "\e[1m\e[34m"); end
15
+ def dark_blue; colorize(self, "\e[34m"); end
16
+
17
+ def magenta; colorize(self, "\e[1m\e[35m"); end
18
+ def dark_magenta; colorize(self, "\e[35m"); end
19
+
20
+ def cyan; colorize(self, "\e[1m\e[36m"); end
21
+ def dark_cyan; colorize(self, "\e[36m"); end
22
+
23
+ def white; colorize(self, "\e[1m\e[37m"); end
24
+ def dark_white; colorize(self, "\e[37m"); end
25
+
26
+ def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
27
+ end
@@ -0,0 +1,144 @@
1
+ class Tree
2
+
3
+ #
4
+ # Show the tree representation of the project and each submodule last log entry
5
+ # +project+ the project to visualize
6
+ # +options+ the command line options
7
+ #
8
+ def self.log(project, options)
9
+ show project, options, :log
10
+ end
11
+
12
+ #
13
+ # Show the tree representation of the project and each submodule status
14
+ # +project+ the project to visualize
15
+ # +options+ the command line options
16
+ #
17
+ def self.status(project, options)
18
+ show project, options, :status
19
+ end
20
+
21
+ #
22
+ # Show the tree representation of the project
23
+ # +project+ the project to visualize
24
+ # +options+ the command line options
25
+ # +command+ additional command to visualize in the tree
26
+ #
27
+ def self.show(project, options, command = '')
28
+ print "#{project.to_s}".dark_green
29
+
30
+ # Project type
31
+ if options.verbose?
32
+ if project.radiant_project?
33
+ puts " (Radiant Project)".magenta
34
+ else
35
+ puts " (Rails Project)".magenta
36
+ end
37
+ else
38
+ print "\n"
39
+ end
40
+
41
+ # Radiant extensions
42
+ connection = project.plugins_installed? || project.radiant_installed? ? "|" : " "
43
+
44
+ if project.extensions_installed?
45
+ puts '+--+'.blue + ' Extensions'.dark_green
46
+ project.extensions.each do |extension|
47
+ process_command command, extension do
48
+ print "#{connection} +- ".blue + "#{extension.to_s}".yellow
49
+ end
50
+ indent = extension == project.extensions.last ? "#{connection} " : "#{connection} | "
51
+ self.put_remotes(extension, indent, options, command) if options.remotes?
52
+ end
53
+ end
54
+
55
+ # Plugins
56
+ connection = project.radiant_installed? ? "|" : " "
57
+
58
+ if project.plugins_installed?
59
+ puts '+--+ '.blue + 'Plugins'.dark_green
60
+ project.plugins.each do |plugin|
61
+ process_command command, plugin do
62
+ print "#{connection} +- ".blue + "#{plugin.to_s}".yellow
63
+ end
64
+ indent = plugin == project.plugins.last ? "#{connection} " : "#{connection} | "
65
+ self.put_remotes(plugin, indent, options, command) if options.remotes?
66
+ end
67
+ end
68
+
69
+ # Radiant in vendor
70
+ if project.radiant_installed?
71
+
72
+ # Radiant itself
73
+ puts '+--+ '.blue + 'Radiant'.dark_green
74
+ self.put_remotes(project.radiant.first, " | ", options, command) if options.remotes?
75
+
76
+ # Radiant Plugins
77
+ if project.radiant_plugins_installed?
78
+ puts ' +--+ '.blue + 'Plugins'.dark_green
79
+ project.radiant_plugins.each do |plugin|
80
+ process_command command, plugin do
81
+ print " +- ".blue + "#{plugin.to_s}".yellow
82
+ end
83
+ indent = plugin == project.radiant_plugins.last ? " " : " | "
84
+ self.put_remotes(plugin, indent, options, command) if options.remotes?
85
+ end
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ private
92
+
93
+ #
94
+ # Prints the submodules remotes
95
+ # +submodule+ the submodule the display
96
+ # +indent+ the indent of the output
97
+ # +options+ the command line options
98
+ # +command+ command to process, currently :log and :status is known
99
+ #
100
+ def self.put_remotes(submodule, indent, options, command)
101
+ submodule.remotes.each do |name, url|
102
+ if options.verbose?
103
+ if submodule.branch.empty?
104
+ process_command command, submodule do
105
+ print "#{indent}+- ".blue + "#{name}".cyan + "/".blue + "NO BRANCH".red + " -> ".blue + "#{url}".dark_white
106
+ end
107
+ else
108
+ process_command command, submodule do
109
+ print "#{indent}+- ".blue + "#{name}".cyan + "/#{submodule.branch} -> ".blue + "#{url}".dark_white
110
+ end
111
+ end
112
+ else
113
+ process_command command, submodule do
114
+ print "#{indent}+- ".blue + "#{name}".cyan
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+ #
121
+ # Process a given command and append its output the the
122
+ # tree view
123
+ # +command+ command to process, currently :log and :status is known
124
+ # +submodule+ the submodule to execute the command
125
+ #
126
+ def self.process_command(command, submodule)
127
+ yield
128
+ case command
129
+ when :log
130
+ puts " -> ".blue + submodule.last_log
131
+
132
+ when :status
133
+ status = submodule.status
134
+ if status =~ /nothing/
135
+ puts ""
136
+ else
137
+ puts " -> ".blue + submodule.status.sub("updated:", "updated.")
138
+ end
139
+
140
+ else puts ""
141
+ end
142
+ end
143
+
144
+ end
data/lib/subito.rb ADDED
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'thor'
3
+ require 'pathname'
4
+ require 'subito/project'
5
+ require 'subito/submodule'
6
+ require 'helper/tree'
7
+ require 'helper/string'
8
+ require 'helper/bundle'
9
+ require 'helper/fix'
10
+
11
+ class Subito < Thor
12
+
13
+ #
14
+ # Shows a tree of the project submodule configuration
15
+ # * --verbose prints more information: project type, remote URI's
16
+ # * --remotes prints the remotes of each subproject
17
+ #
18
+ desc 'show', 'shows all submodules'
19
+ method_options :verbose => :boolean, :remotes => :boolean
20
+ def show
21
+ Tree.show(Project.new, options)
22
+ end
23
+
24
+ #
25
+ # Shows a tree of the project submodule and its last log entry
26
+ # * --verbose prints more information: project type, remote URI's
27
+ # * --remotes prints the remotes of each subproject its last log entry
28
+ #
29
+ desc 'log', 'shows all submodules last log entry'
30
+ method_options :verbose => :boolean, :remotes => :boolean
31
+ def log
32
+ Tree.log(Project.new, options)
33
+ end
34
+
35
+ #
36
+ # Shows a tree of the project submodule and its status
37
+ # * --verbose prints more information: project type, remote URI's
38
+ # * --remotes prints the remotes of each subproject and its status
39
+ #
40
+ desc 'status', 'shows all submodule commit status'
41
+ method_options :verbose => :boolean, :remotes => :boolean
42
+ def status
43
+ Tree.status(Project.new, options)
44
+ end
45
+
46
+ #
47
+ # Handles bundles
48
+ # * generate - saves a new bundle from the actual project configuration
49
+ # * install - loads a bundle and installs missing parts
50
+ #
51
+ desc 'bundle', 'generate and install bundle'
52
+ method_options :verbose => :boolean, :remotes => :boolean
53
+ def bundle(action = '')
54
+ if action == 'generate'
55
+ Bundle.generate(Project.new, options)
56
+
57
+ elsif action == 'install'
58
+ Bundle.install(Project.new, options)
59
+
60
+ else
61
+ puts "`bundle' was called incorrectly. Call as `bundle (install|generate) [--remotes] [--verbose]'"
62
+ end
63
+ end
64
+
65
+ #
66
+ # Fixes missing branches
67
+ #
68
+ desc 'fix', 'checkout master where no branch is currently selected'
69
+ def fix
70
+ Fix.no_branch(Project.new)
71
+ end
72
+ end
@@ -0,0 +1,102 @@
1
+ class Project
2
+
3
+ attr_reader :root, :submodules, :extensions, :plugins, :radiant, :radiant_plugins
4
+
5
+ ENVIRONMENT = 'config/environment.rb'
6
+
7
+ #
8
+ # Initialize a rails/radiant project:
9
+ # * Find project root
10
+ # * Find submodules and classify by type
11
+ #
12
+ def initialize
13
+ @root = Project.find_rails_root(Pathname.pwd)
14
+ @submodules = find_submodules
15
+
16
+ # Rails plugins
17
+ @plugins = @submodules.select { |s| s.plugin? && !s.radiant_vendor? }
18
+
19
+ # Radiant specific
20
+ if radiant_project?
21
+ @extensions = @submodules.select { |s| s.extension? }
22
+ @radiant = @submodules.select { |s| s.radiant? }
23
+ @radiant_plugins = @submodules.select { |s| s.plugin? && s.radiant_vendor? }
24
+ end
25
+ end
26
+
27
+ #
28
+ # Does the project has any extensions as submodule installed?
29
+ #
30
+ def extensions_installed?
31
+ !@extensions.empty?
32
+ end
33
+
34
+ #
35
+ # Does the project has any plugins as submodule installed?
36
+ #
37
+ def plugins_installed?
38
+ !@plugins.empty?
39
+ end
40
+
41
+ #
42
+ # Does the project has radiant as submodule installed?
43
+ #
44
+ def radiant_installed?
45
+ !@radiant.empty?
46
+ end
47
+
48
+ #
49
+ # Does the project has any plugins in vendor/radiant as submodule installed?
50
+ #
51
+ def radiant_plugins_installed?
52
+ !@radiant_plugins.empty?
53
+ end
54
+
55
+ #
56
+ # Is it a radiant project
57
+ #
58
+ def radiant_project?
59
+ File.open(@root + ENVIRONMENT).grep(/Radiant::Initializer/) do |line|
60
+ return true
61
+ end
62
+ false
63
+ end
64
+
65
+ #
66
+ # Name of the project
67
+ #
68
+ def to_s
69
+ @root.basename
70
+ end
71
+
72
+ private
73
+
74
+ #
75
+ # Traverses the actual directory up until it finds the rails root.
76
+ # Exits if the file system root has been reached.
77
+ #
78
+ def self.find_rails_root(directory)
79
+
80
+ # check for radiant initializer in the environment file
81
+ env_file = directory + ENVIRONMENT
82
+ return directory if File.exists?(env_file)
83
+
84
+ if directory.root?
85
+ puts 'Error: Subito has to run inside a Rails or Radiant project!'
86
+ exit 1
87
+ end
88
+
89
+ # search parent directory
90
+ return Project.find_rails_root(Pathname.new(directory).parent)
91
+ end
92
+
93
+ #
94
+ # Returns all submodules of the project
95
+ #
96
+ def find_submodules
97
+ Dir.chdir(@root) do
98
+ return Dir.glob('**/.git').reject{|p| p == '.git'}.collect{|p| Submodule.new(@root + p) }
99
+ end
100
+ end
101
+
102
+ end
@@ -0,0 +1,97 @@
1
+ class Submodule
2
+
3
+ attr_reader :git, :root
4
+
5
+ CONFIG = 'config'
6
+ HEAD = 'HEAD'
7
+
8
+ #
9
+ # Initialize a new submodule
10
+ # +git+ the git directory of the submodule
11
+ #
12
+ def initialize(git)
13
+ @git = git
14
+ @root = git.parent
15
+ end
16
+
17
+ #
18
+ # Is the submodule an installed radiant extension?
19
+ #
20
+ def extension?
21
+ @root.parent.basename.to_s == 'extensions'
22
+ end
23
+
24
+ #
25
+ # Is the submodule a plugin?
26
+ #
27
+ def plugin?
28
+ @root.parent.basename.to_s == 'plugins'
29
+ end
30
+
31
+ #
32
+ # Is the submodule the Radiant submodule?
33
+ #
34
+ def radiant?
35
+ @root.basename.to_s == 'radiant'
36
+ end
37
+
38
+ #
39
+ # Is the submodule installed in the radiant vendor folder
40
+ #
41
+ def radiant_vendor?
42
+ begin
43
+ @root.parent.parent.parent.basename.to_s == 'radiant'
44
+ rescue
45
+ end
46
+ end
47
+
48
+ #
49
+ # Get all remotes
50
+ #
51
+ def remotes
52
+ @remotes ||= Hash[File.open(@git + CONFIG).read.scan(/\[remote "([a-zA-z0-9\-_]+)"\]\n\s+url\s=\s([a-zA-Z\-_\/\.:@]+.git)\n/m)]
53
+ end
54
+
55
+ #
56
+ # Get actual branch
57
+ #
58
+ def branch
59
+ @branch ||= File.open(@git + HEAD).read.scan(/ref: refs\/heads\/(.*)/)
60
+ end
61
+
62
+ #
63
+ # Name of the submodule
64
+ #
65
+ def to_s
66
+ @root.basename
67
+ end
68
+
69
+ #
70
+ # Checkout given branch
71
+ # +branch+ the name of the branch to check out
72
+ def checkout(branch)
73
+ Dir.chdir @root do
74
+ `git checkout #{branch}`
75
+ end
76
+ end
77
+
78
+ #
79
+ # Returns the last log entry of the submodule
80
+ #
81
+ def last_log
82
+ Dir.chdir @root do
83
+ `git log -1 --format=oneline | awk '{ $1=""; print $0 }'`
84
+ end
85
+ end
86
+
87
+ #
88
+ # Returns the status of the submodule
89
+ #
90
+ def status
91
+ Dir.chdir @root do
92
+ status = `git status | head -n 2 | tail -n 1 | sed -e 's/# //g'`
93
+
94
+ end
95
+ end
96
+
97
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netzpirat-subito
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Kessler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-14 00:00:00 -07:00
13
+ default_executable: subito
14
+ dependencies: []
15
+
16
+ description: helps to manage your Radiant extensions and Rails Plugins
17
+ email: michi@netzpiraten.ch
18
+ executables:
19
+ - subito
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.markdown
25
+ files:
26
+ - .gitignore
27
+ - LICENSE
28
+ - README.markdown
29
+ - Rakefile
30
+ - TODO
31
+ - VERSION
32
+ - bin/subito
33
+ - lib/helper/bundle.rb
34
+ - lib/helper/fix.rb
35
+ - lib/helper/string.rb
36
+ - lib/helper/tree.rb
37
+ - lib/subito.rb
38
+ - lib/subito/project.rb
39
+ - lib/subito/submodule.rb
40
+ has_rdoc: false
41
+ homepage: http://github.com/netzpirat/subito
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.2.0
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Submodule Inspection Tool
66
+ test_files: []
67
+