radiant-ray-extension 3.0.0.alpha → 3.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/Rakefile +2 -0
- data/doc/NilClass.html +178 -0
- data/doc/Ray/CLI.html +211 -197
- data/doc/Ray/Extension/Git.html +435 -0
- data/doc/Ray/Extension/RubyGem.html +858 -0
- data/doc/Ray/Extension/Zip.html +453 -0
- data/doc/Ray/Extension.html +755 -0
- data/doc/Ray/{Cache.html → Search/Cache.html} +108 -256
- data/doc/Ray/{GitHub.html → Search/GitHub.html} +167 -81
- data/doc/Ray/{RubyGems.html → Search/RubyGems.html} +118 -68
- data/doc/Ray/Search.html +822 -0
- data/doc/Ray.html +89 -34
- data/doc/String.html +99 -29
- data/doc/_index.html +1 -1
- data/doc/file.LICENSE.html +1 -1
- data/doc/file.README.html +2 -4
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +3 -3
- data/lib/ray/cli.rb +146 -193
- data/lib/ray/constants.rb +7 -12
- data/lib/ray/extension.rb +203 -89
- data/lib/ray/search.rb +198 -43
- data/lib/ray/utility.rb +31 -0
- data/lib/ray.rb +2 -7
- data/spec/fixtures/cache_single.yml +2 -1
- data/spec/fixtures/cassettes/combined_search_empty.yml +71 -0
- data/spec/fixtures/cassettes/combined_search_multiple.yml +264 -0
- data/spec/fixtures/cassettes/combined_search_single.yml +108 -0
- data/spec/fixtures/cassettes/github_reorder_children_zip_file.yml +487 -0
- data/spec/fixtures/cassettes/github_sitemap_xml_zip_file.yml +553 -0
- data/spec/fixtures/cassettes/{github_v2_api_no_matches.yml → github_v2_search_empty.yml} +3 -3
- data/spec/fixtures/cassettes/github_v2_search_multiple.yml +225 -0
- data/spec/fixtures/cassettes/github_v2_search_single.yml +76 -0
- data/spec/fixtures/cassettes/{zip_file.yml → github_zip_file.yml} +3 -3
- data/spec/fixtures/cassettes/{rubygems_v1_api_gem_info.yml → rubygems_v1_gem_info.yml} +5 -5
- data/spec/fixtures/cassettes/{rubygems_v1_api_no_matches.yml → rubygems_v1_search_empty.yml} +3 -3
- data/spec/fixtures/cassettes/rubygems_v1_search_multiple.yml +40 -0
- data/spec/fixtures/cassettes/{rubygems_v1_api_search_reorder_children.yml → rubygems_v1_search_single.yml} +6 -6
- data/spec/fixtures/dummy.zip +0 -0
- data/spec/ray/extension_spec.rb +172 -0
- data/spec/ray/search_spec.rb +300 -0
- data/spec/spec_helper.rb +36 -9
- metadata +50 -85
- data/doc/Extension.html +0 -1189
- data/doc/Ray/Gem.html +0 -760
- data/doc/Ray/Git.html +0 -278
- data/doc/Ray/Zip.html +0 -300
- data/doc/Search.html +0 -433
- data/lib/ray/extension/gem.rb +0 -96
- data/lib/ray/extension/git.rb +0 -30
- data/lib/ray/extension/zip.rb +0 -44
- data/lib/ray/search/cache.rb +0 -61
- data/lib/ray/search/github.rb +0 -40
- data/lib/ray/search/rubygems.rb +0 -36
- data/lib/ray/string.rb +0 -18
- data/spec/fixtures/Gemfile +0 -4
- data/spec/fixtures/cassettes/github_v2_api_search_no_matches.yml +0 -38
- data/spec/fixtures/cassettes/github_v2_api_search_reorder_children.yml +0 -75
- data/spec/fixtures/cassettes/github_v2_api_search_single.yml +0 -74
- data/spec/fixtures/cassettes/github_v3_api_owner_name.yml +0 -75
- data/spec/fixtures/cassettes/rubygems_v1_api_search_no_matches.yml +0 -34
- data/spec/fixtures/cassettes/rubygems_v1_api_search_reorder.yml +0 -36
- data/spec/fixtures/cassettes/rubygems_v1_api_search_single.yml +0 -41
- data/spec/fixtures/dummy/README +0 -1
- data/spec/fixtures/dummy/Rakefile +0 -109
- data/spec/fixtures/dummy/config/initializers/radiant_config.rb +0 -3
- data/spec/fixtures/dummy/config/locales/en.yml +0 -3
- data/spec/fixtures/dummy/config/routes.rb +0 -5
- data/spec/fixtures/dummy/dummy_extension.rb +0 -21
- data/spec/fixtures/dummy/lib/radiant-dummy-extension.rb +0 -8
- data/spec/fixtures/dummy/lib/tasks/dummy_extension_tasks.rake +0 -47
- data/spec/fixtures/dummy/public/stylesheets/extensions/dummy/dummy.css +0 -0
- data/spec/fixtures/dummy/radiant-dummy-extension.gemspec +0 -29
- data/spec/ray/extension/gem_spec.rb +0 -214
- data/spec/ray/extension/git_spec.rb +0 -216
- data/spec/ray/extension/zip_spec.rb +0 -239
- data/spec/ray/search/cache_spec.rb +0 -74
- data/spec/ray/search/github_spec.rb +0 -137
- data/spec/ray/search/rubygems_spec.rb +0 -127
- data/spec/ray/string_spec.rb +0 -30
data/lib/ray/cli.rb
CHANGED
@@ -3,264 +3,217 @@ require "ray"
|
|
3
3
|
|
4
4
|
module Ray
|
5
5
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# Ray's command line interface.
|
7
|
+
# See the [User Manual](http://johnmuhl.github.com/radiant-ray-extension/)
|
8
|
+
# for complete command line usage.
|
9
9
|
class CLI < Thor
|
10
10
|
|
11
11
|
include Thor::Actions
|
12
12
|
include Thor::Shell
|
13
13
|
|
14
|
-
no_tasks do
|
15
|
-
def self.man task
|
16
|
-
%Q{
|
17
|
-
See also
|
18
|
-
http://johnmuhl.github.com/radiant-ray-extension##{task.to_s}
|
19
|
-
}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
map "-v" => "version"
|
24
|
-
|
25
14
|
default_task :help
|
26
15
|
|
27
|
-
desc "version", "
|
16
|
+
desc "version", "Current version of Ray"
|
28
17
|
def version
|
29
|
-
say
|
30
|
-
say "Version: #{Ray::VERSION}"
|
18
|
+
say Ray::VERSION
|
31
19
|
end
|
32
20
|
|
33
|
-
desc "search [QUERY]", "Search for extensions"
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
method_option :rubygems,
|
48
|
-
:aliases => "-r",
|
49
|
-
:desc => "Only search RubyGems",
|
50
|
-
:type => :boolean
|
51
|
-
method_option :live,
|
52
|
-
:aliases => "-l",
|
53
|
-
:desc => "Bypass local cache",
|
54
|
-
:type => :boolean
|
55
|
-
def search query
|
21
|
+
desc "search [QUERY]", "Search for extensions by name or keyword"
|
22
|
+
method_option :github, :desc => "Restrict search to GitHub",
|
23
|
+
:aliases => "-g", :type => :boolean
|
24
|
+
method_option :rubygems, :desc => "Restrict search to RubyGems",
|
25
|
+
:aliases => "-r", :type => :boolean
|
26
|
+
method_option :live, :desc => "Bypass local cache",
|
27
|
+
:aliases => "-l", :type => :boolean
|
28
|
+
# Search for extensions
|
29
|
+
# @example
|
30
|
+
# ray search blog
|
31
|
+
# ray search blog --live
|
32
|
+
# ray search blog --github
|
33
|
+
# ray search blog --rubygems
|
34
|
+
def search query = nil
|
56
35
|
search = case
|
57
|
-
when options["github"]
|
58
|
-
Ray::GitHub.new query
|
59
36
|
when options["rubygems"]
|
60
|
-
Ray::RubyGems.new query
|
37
|
+
Ray::Search::RubyGems.new query
|
38
|
+
when options["github"]
|
39
|
+
Ray::Search::GitHub.new query
|
61
40
|
when options["live"]
|
62
|
-
Ray::
|
63
|
-
|
64
|
-
|
65
|
-
Ray::GitHub.new(query).merge Ray::RubyGems.new(query)
|
66
|
-
else
|
67
|
-
Ray::Cache.new query
|
68
|
-
end
|
41
|
+
Ray::Search.new query, :live
|
42
|
+
when options.empty?
|
43
|
+
Ray::Search.new query
|
69
44
|
end
|
70
|
-
|
71
45
|
search.cache
|
72
46
|
say search.output
|
73
47
|
end
|
74
48
|
|
75
|
-
desc "install [
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
:aliases => "-z",
|
89
|
-
:banner => "URL",
|
90
|
-
:desc => "Install from zip archive"
|
49
|
+
desc "install [EXTENSION]", "Install extensions"
|
50
|
+
method_option :git, :desc => "Install extension from Git repository",
|
51
|
+
:aliases => "-g"
|
52
|
+
method_option :rubygem, :desc => "Install extension from RubyGems",
|
53
|
+
:aliases => "-r"
|
54
|
+
method_option :zip, :desc => "Install extension from zip archive",
|
55
|
+
:aliases => "-z"
|
56
|
+
# Install extensions
|
57
|
+
# @example
|
58
|
+
# ray install reorder-children
|
59
|
+
# ray install reorder-children --git
|
60
|
+
# ray install reorder-children --rubygem
|
61
|
+
# ray install reorder-children --zip
|
91
62
|
def install *extensions
|
92
|
-
if extensions.empty?
|
93
|
-
say "You didn't list any extensions to install", :red
|
94
|
-
say "Try: ray help install"
|
95
|
-
exit 1
|
96
|
-
end
|
97
|
-
|
98
63
|
case
|
99
|
-
when options["
|
100
|
-
if options["
|
64
|
+
when options["zip"]
|
65
|
+
if extensions.size > 1 && options["zip"] != "zip"
|
66
|
+
say "You can only list one extension at a time", :red
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
if options["zip"] == "zip"
|
101
70
|
extensions.each do |extension|
|
102
|
-
search = Ray::
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
search.
|
108
|
-
info[:uri] =~ /rubygems/
|
109
|
-
end.map do |extension|
|
110
|
-
results[extension.first] = extension.last # rebuild the results hash
|
111
|
-
end
|
112
|
-
if results.empty?
|
113
|
-
search = Ray::RubyGems.new extension
|
114
|
-
else
|
115
|
-
search.results = results # reset the results hash
|
116
|
-
end
|
71
|
+
search = Ray::Search.new extension.to_extension_name
|
72
|
+
search.cache
|
73
|
+
if search.results.size == 1
|
74
|
+
extension = search.results.first.last
|
75
|
+
else
|
76
|
+
extension = search.multiple_choice
|
117
77
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
extension
|
124
|
-
|
125
|
-
|
126
|
-
else # a uri was passed to --gem
|
127
|
-
extension = Ray::Gem.new({ # instantiate with minimal info
|
128
|
-
:name => extensions.first, # nothing works without a name
|
129
|
-
:uri => options["gem"] # uri should be a git repo
|
130
|
-
})
|
131
|
-
say "#{extension.name} => Adding to Gemfile..."
|
132
|
-
name = "radiant-#{extension.name}-extension"
|
133
|
-
File.open Ray::GEMFILE, "a" do |gemfile|
|
134
|
-
gemfile.puts "gem \"#{name}\", :git => \"#{extension.uri}\"" # add it to the gemfile
|
78
|
+
zip = Ray::Extension::Zip.new extension[:name], extension[:uri]
|
79
|
+
say "#{extension[:name]} => Downloading...", :yellow
|
80
|
+
zip.download
|
81
|
+
say "#{extension[:name]} => Extracting...", :yellow
|
82
|
+
zip.extract
|
83
|
+
say "#{extension[:name]} => Running tasks...", :yellow
|
84
|
+
zip.install
|
85
|
+
say "#{extension[:name]} => Installation complete.", :green
|
135
86
|
end
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
say "#{
|
87
|
+
else
|
88
|
+
name = extensions.first.to_extension_name
|
89
|
+
zip = Ray::Extension::Zip.new name, options["zip"]
|
90
|
+
say "#{name} => Downloading...", :yellow
|
91
|
+
zip.download
|
92
|
+
say "#{name} => Extracting...", :yellow
|
93
|
+
zip.extract
|
94
|
+
say "#{name} => Running tasks...", :yellow
|
95
|
+
zip.install
|
96
|
+
say "#{name} => Installation complete.", :green
|
140
97
|
end
|
141
98
|
when options["git"]
|
99
|
+
if extensions.size > 1 && options["git"] != "git"
|
100
|
+
say "You can only list one extension at a time", :red
|
101
|
+
exit 1
|
102
|
+
end
|
142
103
|
if options["git"] == "git"
|
143
104
|
extensions.each do |extension|
|
144
|
-
search = Ray::
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
search.
|
150
|
-
info[:uri] =~ /github/
|
151
|
-
end.map do |extension|
|
152
|
-
results[extension.first] = extension.last # rebuild the results hash
|
153
|
-
end
|
154
|
-
if results.empty?
|
155
|
-
search = Ray::GitHub.new extension
|
156
|
-
else
|
157
|
-
search.results = results # reset the results hash
|
158
|
-
end
|
105
|
+
search = Ray::Search::GitHub.new extension.to_extension_name
|
106
|
+
search.cache
|
107
|
+
if search.results.size == 1
|
108
|
+
extension = search.results.first.last
|
109
|
+
else
|
110
|
+
extension = search.multiple_choice
|
159
111
|
end
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
extension
|
166
|
-
say "#{extension.name} => Installed!", :green
|
112
|
+
git = Ray::Extension::Git.new extension[:name], extension[:repository]
|
113
|
+
say "#{extension[:name]} => Cloning...", :yellow
|
114
|
+
git.clone
|
115
|
+
say "#{extension[:name]} => Running tasks...", :yellow
|
116
|
+
git.install
|
117
|
+
say "#{extension[:name]} => Installation complete.", :green
|
167
118
|
end
|
168
119
|
else
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
120
|
+
name = extensions.first.to_extension_name
|
121
|
+
git = Ray::Extension::Git.new name, options["git"]
|
122
|
+
say "#{name} => Cloning...", :yellow
|
123
|
+
git.clone
|
124
|
+
say "#{name} => Running tasks...", :yellow
|
125
|
+
git.install
|
126
|
+
say "#{name} => Installation complete.", :green
|
175
127
|
end
|
176
|
-
when options["
|
177
|
-
if options["
|
128
|
+
when options["rubygem"]
|
129
|
+
if extensions.size > 1 && options["rubygem"] != "rubygem"
|
130
|
+
say "You can only list one extension at a time", :red
|
131
|
+
exit 1
|
132
|
+
end
|
133
|
+
if options["rubygem"] == "rubygem"
|
178
134
|
extensions.each do |extension|
|
179
|
-
search = Ray::
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
search.
|
185
|
-
info[:uri] =~ /github/
|
186
|
-
end.map do |extension|
|
187
|
-
results[extension.first] = extension.last # rebuild the results hash
|
188
|
-
end
|
189
|
-
if results.empty?
|
190
|
-
search = Ray::GitHub.new extension
|
191
|
-
else
|
192
|
-
search.results = results # reset the results hash
|
193
|
-
end
|
135
|
+
search = Ray::Search::RubyGems.new extension.to_extension_name
|
136
|
+
search.cache
|
137
|
+
if search.results.size == 1
|
138
|
+
extension = search.results.first.last
|
139
|
+
else
|
140
|
+
extension = search.multiple_choice
|
194
141
|
end
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
extension.install # install the extension
|
202
|
-
say "#{extension.name} => Installed!", :green
|
142
|
+
rubygem = Ray::Extension::RubyGem.new extension[:name], extension[:repository]
|
143
|
+
say "#{extension[:name]} => Bundling...", :yellow
|
144
|
+
rubygem.bundle
|
145
|
+
say "#{extension[:name]} => Running tasks...", :yellow
|
146
|
+
rubygem.install
|
147
|
+
say "#{extension[:name]} => Installation complete.", :green
|
203
148
|
end
|
204
149
|
else
|
205
|
-
|
206
|
-
:name => extensions.first, # nothing works without a name
|
207
|
-
:uri => options["zip"] # uri should be a zip archive
|
208
|
-
})
|
209
|
-
extension.install # install the extension
|
210
|
-
say "#{extension.name} => Installed!", :green
|
150
|
+
# not sure what to do here, probably nothing
|
211
151
|
end
|
212
152
|
else
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
153
|
+
extensions.each do |extension|
|
154
|
+
search = Ray::Search.new extension.to_extension_name
|
155
|
+
search.cache
|
156
|
+
if search.results.size == 1
|
157
|
+
extension = search.results.first.last
|
158
|
+
else
|
159
|
+
extension = search.multiple_choice
|
160
|
+
end
|
161
|
+
if extension[:version] == "latest"
|
162
|
+
git = Ray::Extension::Git.new extension[:name], extension[:repository]
|
163
|
+
say "#{extension[:name]} => Cloning...", :yellow
|
164
|
+
git.clone
|
165
|
+
say "#{extension[:name]} => Running tasks...", :yellow
|
166
|
+
git.install
|
167
|
+
say "#{extension[:name]} => Installation complete.", :green
|
168
|
+
else
|
169
|
+
rubygem = Ray::Extension::RubyGem.new extension[:name], extension[:repository]
|
170
|
+
say "#{extension[:name]} => Bundling...", :yellow
|
171
|
+
rubygem.bundle
|
172
|
+
say "#{extension[:name]} => Running tasks...", :yellow
|
173
|
+
rubygem.install
|
174
|
+
say "#{extension[:name]} => Installation complete.", :green
|
175
|
+
end
|
176
|
+
end
|
224
177
|
end
|
225
178
|
end
|
226
179
|
|
227
|
-
desc "disable [
|
180
|
+
desc "disable [EXTENSION]", "Disable extensions"
|
228
181
|
def disable *extensions
|
229
182
|
extensions.each do |x|
|
230
183
|
extension = x.to_extension_name
|
231
|
-
if File.exist? "#{
|
232
|
-
Ray::
|
184
|
+
if File.exist? "#{EXT_DIR}/#{extension}"
|
185
|
+
Ray::Extension.new(extension).disable
|
233
186
|
say "#{extension} => Disabled.", :green
|
234
187
|
elsif `bundle exec gem list`.include? "radiant-#{extension}-extension"
|
235
|
-
Ray::
|
188
|
+
Ray::Extension::RubyGem.new(extension).disable
|
236
189
|
say "#{extension} => Disabled.", :green
|
237
190
|
end
|
238
191
|
end
|
239
192
|
end
|
240
193
|
|
241
|
-
desc "enable [
|
194
|
+
desc "enable [EXTENSION]", "Enable extensions"
|
242
195
|
def enable *extensions
|
243
196
|
extensions.each do |x|
|
244
197
|
extension = x.to_extension_name
|
245
|
-
if File.exist? "#{
|
246
|
-
Ray::
|
198
|
+
if File.exist? "#{EXT_DIR}/.disabled/#{extension}"
|
199
|
+
Ray::Extension.new(extension).enable
|
247
200
|
say "#{extension} => Enabled.", :green
|
248
201
|
elsif `gem list`.include? "radiant-#{extension}-extension"
|
249
|
-
Ray::
|
202
|
+
Ray::Extension::RubyGem.new(extension).enable
|
250
203
|
say "#{extension} => Enabled.", :green
|
251
204
|
end
|
252
205
|
end
|
253
206
|
end
|
254
207
|
|
255
|
-
desc "uninstall [
|
208
|
+
desc "uninstall [EXTENSION]", "Uninstall extensions"
|
256
209
|
def uninstall *extensions
|
257
210
|
extensions.each do |x|
|
258
211
|
extension = x.to_extension_name
|
259
|
-
if File.exist? "#{
|
260
|
-
Ray::
|
212
|
+
if File.exist? "#{EXT_DIR}/#{extension}"
|
213
|
+
Ray::Extension.new(extension).uninstall
|
261
214
|
say "#{extension} => Uninstalled.", :green
|
262
215
|
elsif `bundle exec gem list`.include? "radiant-#{extension}-extension"
|
263
|
-
Ray::
|
216
|
+
Ray::Extension::RubyGem.new(extension).uninstall
|
264
217
|
say "#{extension} => Uninstalled.", :green
|
265
218
|
end
|
266
219
|
end
|
data/lib/ray/constants.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
# Friendly extension management for Radiant CMS
|
2
2
|
module Ray
|
3
3
|
|
4
|
-
VERSION
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
GEMFILE
|
11
|
-
EXT_DIR = "#{ROOT}/vendor/extensions"
|
12
|
-
TMP_DIR = "#{ROOT}/tmp/ray"
|
13
|
-
RG_V1_API = "http://rubygems.org/api/v1"
|
14
|
-
GH_V2_API = "http://github.com/api/v2/json"
|
15
|
-
GH_V3_API = "https://api.github.com"
|
4
|
+
VERSION = "3.0.0.pre" # current version
|
5
|
+
RAY = File.expand_path "~/.ray" # global settings directory
|
6
|
+
TMP = File.expand_path "#{Dir.pwd}/tmp/ray" # tmp directory
|
7
|
+
ROOT = Dir.pwd # current directory usually Rails.root
|
8
|
+
CACHE = File.expand_path "#{RAY}/cache.yml" # global cache file
|
9
|
+
EXT_DIR = File.expand_path "#{Dir.pwd}/vendor/extensions" # install location for "classic" extensions
|
10
|
+
GEMFILE = File.expand_path "#{Dir.pwd}/Gemfile" # project Gemfile
|
16
11
|
|
17
12
|
end
|