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.
Files changed (81) hide show
  1. data/README.markdown +1 -1
  2. data/Rakefile +2 -0
  3. data/doc/NilClass.html +178 -0
  4. data/doc/Ray/CLI.html +211 -197
  5. data/doc/Ray/Extension/Git.html +435 -0
  6. data/doc/Ray/Extension/RubyGem.html +858 -0
  7. data/doc/Ray/Extension/Zip.html +453 -0
  8. data/doc/Ray/Extension.html +755 -0
  9. data/doc/Ray/{Cache.html → Search/Cache.html} +108 -256
  10. data/doc/Ray/{GitHub.html → Search/GitHub.html} +167 -81
  11. data/doc/Ray/{RubyGems.html → Search/RubyGems.html} +118 -68
  12. data/doc/Ray/Search.html +822 -0
  13. data/doc/Ray.html +89 -34
  14. data/doc/String.html +99 -29
  15. data/doc/_index.html +1 -1
  16. data/doc/file.LICENSE.html +1 -1
  17. data/doc/file.README.html +2 -4
  18. data/doc/index.html +1 -1
  19. data/doc/top-level-namespace.html +3 -3
  20. data/lib/ray/cli.rb +146 -193
  21. data/lib/ray/constants.rb +7 -12
  22. data/lib/ray/extension.rb +203 -89
  23. data/lib/ray/search.rb +198 -43
  24. data/lib/ray/utility.rb +31 -0
  25. data/lib/ray.rb +2 -7
  26. data/spec/fixtures/cache_single.yml +2 -1
  27. data/spec/fixtures/cassettes/combined_search_empty.yml +71 -0
  28. data/spec/fixtures/cassettes/combined_search_multiple.yml +264 -0
  29. data/spec/fixtures/cassettes/combined_search_single.yml +108 -0
  30. data/spec/fixtures/cassettes/github_reorder_children_zip_file.yml +487 -0
  31. data/spec/fixtures/cassettes/github_sitemap_xml_zip_file.yml +553 -0
  32. data/spec/fixtures/cassettes/{github_v2_api_no_matches.yml → github_v2_search_empty.yml} +3 -3
  33. data/spec/fixtures/cassettes/github_v2_search_multiple.yml +225 -0
  34. data/spec/fixtures/cassettes/github_v2_search_single.yml +76 -0
  35. data/spec/fixtures/cassettes/{zip_file.yml → github_zip_file.yml} +3 -3
  36. data/spec/fixtures/cassettes/{rubygems_v1_api_gem_info.yml → rubygems_v1_gem_info.yml} +5 -5
  37. data/spec/fixtures/cassettes/{rubygems_v1_api_no_matches.yml → rubygems_v1_search_empty.yml} +3 -3
  38. data/spec/fixtures/cassettes/rubygems_v1_search_multiple.yml +40 -0
  39. data/spec/fixtures/cassettes/{rubygems_v1_api_search_reorder_children.yml → rubygems_v1_search_single.yml} +6 -6
  40. data/spec/fixtures/dummy.zip +0 -0
  41. data/spec/ray/extension_spec.rb +172 -0
  42. data/spec/ray/search_spec.rb +300 -0
  43. data/spec/spec_helper.rb +36 -9
  44. metadata +50 -85
  45. data/doc/Extension.html +0 -1189
  46. data/doc/Ray/Gem.html +0 -760
  47. data/doc/Ray/Git.html +0 -278
  48. data/doc/Ray/Zip.html +0 -300
  49. data/doc/Search.html +0 -433
  50. data/lib/ray/extension/gem.rb +0 -96
  51. data/lib/ray/extension/git.rb +0 -30
  52. data/lib/ray/extension/zip.rb +0 -44
  53. data/lib/ray/search/cache.rb +0 -61
  54. data/lib/ray/search/github.rb +0 -40
  55. data/lib/ray/search/rubygems.rb +0 -36
  56. data/lib/ray/string.rb +0 -18
  57. data/spec/fixtures/Gemfile +0 -4
  58. data/spec/fixtures/cassettes/github_v2_api_search_no_matches.yml +0 -38
  59. data/spec/fixtures/cassettes/github_v2_api_search_reorder_children.yml +0 -75
  60. data/spec/fixtures/cassettes/github_v2_api_search_single.yml +0 -74
  61. data/spec/fixtures/cassettes/github_v3_api_owner_name.yml +0 -75
  62. data/spec/fixtures/cassettes/rubygems_v1_api_search_no_matches.yml +0 -34
  63. data/spec/fixtures/cassettes/rubygems_v1_api_search_reorder.yml +0 -36
  64. data/spec/fixtures/cassettes/rubygems_v1_api_search_single.yml +0 -41
  65. data/spec/fixtures/dummy/README +0 -1
  66. data/spec/fixtures/dummy/Rakefile +0 -109
  67. data/spec/fixtures/dummy/config/initializers/radiant_config.rb +0 -3
  68. data/spec/fixtures/dummy/config/locales/en.yml +0 -3
  69. data/spec/fixtures/dummy/config/routes.rb +0 -5
  70. data/spec/fixtures/dummy/dummy_extension.rb +0 -21
  71. data/spec/fixtures/dummy/lib/radiant-dummy-extension.rb +0 -8
  72. data/spec/fixtures/dummy/lib/tasks/dummy_extension_tasks.rake +0 -47
  73. data/spec/fixtures/dummy/public/stylesheets/extensions/dummy/dummy.css +0 -0
  74. data/spec/fixtures/dummy/radiant-dummy-extension.gemspec +0 -29
  75. data/spec/ray/extension/gem_spec.rb +0 -214
  76. data/spec/ray/extension/git_spec.rb +0 -216
  77. data/spec/ray/extension/zip_spec.rb +0 -239
  78. data/spec/ray/search/cache_spec.rb +0 -74
  79. data/spec/ray/search/github_spec.rb +0 -137
  80. data/spec/ray/search/rubygems_spec.rb +0 -127
  81. data/spec/ray/string_spec.rb +0 -30
@@ -1,47 +0,0 @@
1
- namespace :radiant do
2
- namespace :extensions do
3
- namespace :dummy do
4
-
5
- desc "Runs the migration of the Dummy extension"
6
- task :migrate => :environment do
7
- require 'radiant/extension_migrator'
8
- if ENV["VERSION"]
9
- DummyExtension.migrator.migrate(ENV["VERSION"].to_i)
10
- Rake::Task['db:schema:dump'].invoke
11
- else
12
- DummyExtension.migrator.migrate
13
- Rake::Task['db:schema:dump'].invoke
14
- end
15
- end
16
-
17
- desc "Copies public assets of the Dummy to the instance public/ directory."
18
- task :update => :environment do
19
- is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
20
- puts "Copying assets from DummyExtension"
21
- Dir[DummyExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
22
- path = file.sub(DummyExtension.root, '')
23
- directory = File.dirname(path)
24
- mkdir_p RAILS_ROOT + directory, :verbose => false
25
- cp file, RAILS_ROOT + path, :verbose => false
26
- end
27
- end
28
-
29
- desc "Syncs all available translations for this ext to the English ext master"
30
- task :sync => :environment do
31
- # The main translation root, basically where English is kept
32
- language_root = DummyExtension.root + "/config/locales"
33
- words = TranslationSupport.get_translation_keys(language_root)
34
-
35
- Dir["#{language_root}/*.yml"].each do |filename|
36
- next if filename.match('_available_tags')
37
- basename = File.basename(filename, '.yml')
38
- puts "Syncing #{basename}"
39
- (comments, other) = TranslationSupport.read_file(filename, basename)
40
- words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
41
- other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
42
- TranslationSupport.write_file(filename, basename, comments, other)
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "radiant-dummy-extension"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "radiant-dummy-extension"
7
- s.version = RadiantDummyExtension::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = RadiantDummyExtension::AUTHORS
10
- s.email = RadiantDummyExtension::EMAIL
11
- s.homepage = RadiantDummyExtension::URL
12
- s.summary = RadiantDummyExtension::SUMMARY
13
- s.description = RadiantDummyExtension::DESCRIPTION
14
-
15
- # Define gem dependencies here.
16
- # Don't include a dependency on radiant itself: it causes problems when radiant is in vendor/radiant.
17
- # s.add_dependency "something", "~> 1.0.0"
18
- # s.add_dependency "radiant-some-extension", "~> 1.0.0"
19
-
20
- ignores = if File.exist?('.gitignore')
21
- File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
22
- else
23
- []
24
- end
25
- s.files = Dir['**/*'] - ignores
26
- s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
27
- # s.executables = Dir['bin/*'] - ignores
28
- s.require_paths = ["lib"]
29
- end
@@ -1,214 +0,0 @@
1
- require "spec_helper"
2
- require "ray/extension/gem"
3
-
4
- module Ray
5
-
6
- class Gem
7
- def bundle ; end
8
- def run_task task, options = {} ; "" ; end
9
- end
10
-
11
- end
12
-
13
- describe Ray::Gem do
14
-
15
- describe "install" do
16
-
17
- before do
18
- FileUtils.mkdir_p Ray::ROOT
19
- FileUtils.mkdir_p "#{Ray::ROOT}/lib/tasks"
20
- FileUtils.cp "#{Dir.pwd}/spec/fixtures/Gemfile", "#{Ray::ROOT}/Gemfile"
21
- end
22
-
23
- after { cleanup }
24
-
25
- it "must raise if no name is given" do
26
- proc { Ray::Gem.new.install }.must_raise RuntimeError
27
- end
28
-
29
- it "must install the extension" do
30
- Ray::Gem.new({
31
- :name => "dummy",
32
- :version => "1.0.0"
33
- }).install
34
- `bundle exec gem list`.must_match /radiant-dummy-extension/
35
- end
36
-
37
- end
38
-
39
- describe "add_gem" do
40
-
41
- before do
42
- FileUtils.mkdir_p Ray::ROOT
43
- FileUtils.cp "#{Dir.pwd}/spec/fixtures/Gemfile", "#{Ray::ROOT}/Gemfile"
44
- end
45
-
46
- after { cleanup }
47
-
48
- it "must add the extension to the Gemfile" do
49
- VCR.use_cassette("rubygems_v1_api_gem_info") do
50
- Ray::Gem.new({ :name => "reorder-children" }).add_gem
51
- gemfile = File.read(Ray::GEMFILE)
52
- gemfile.include?('gem "radiant-reorder_children-extension", "~> 1.0.5"').must_equal true
53
- end
54
- end
55
-
56
- end
57
-
58
- describe "bundle" do
59
-
60
- it "must install the gem" do
61
- skip "Assuming bundler works for now"
62
- end
63
-
64
- end
65
-
66
- describe "copy_tasks" do
67
-
68
- before do
69
- FileUtils.mkdir_p "#{Ray::ROOT}/lib/tasks"
70
- end
71
-
72
- after { cleanup }
73
-
74
- it "must copy tasks from the RubyGem" do
75
- Ray::Gem.new({ :name => "dummy", :version => "1.0.0" }).copy_tasks
76
- File.exist?("#{Ray::ROOT}/lib/tasks/dummy_extension_tasks.rake").must_equal true
77
- end
78
-
79
- end
80
-
81
- describe "load_tasks" do
82
-
83
- before do
84
- FileUtils.mkdir_p "#{Ray::ROOT}/lib/tasks"
85
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy/lib/tasks/dummy_extension_tasks.rake", "#{Ray::ROOT}/lib/tasks/dummy_extension_tasks.rake"
86
- end
87
-
88
- after { cleanup }
89
-
90
- it "must load available Rake tasks" do
91
- tasks = Ray::Gem.new({ :name => "dummy", :version => "1.0.0" }).load_tasks - ["default", "spec", "spec:cli"]
92
- tasks.must_equal ["radiant:extensions:dummy:migrate", "radiant:extensions:dummy:sync", "radiant:extensions:dummy:update"]
93
- end
94
-
95
- end
96
-
97
- describe "version" do
98
-
99
- it "must return version 0 if no name is given" do
100
- Ray::Gem.new.version.must_equal 0
101
- end
102
-
103
- it "must return gem version" do
104
- VCR.use_cassette("rubygems_v1_api_gem_info") do
105
- Ray::Gem.new({ :name => "reorder-children" }).version.must_equal "1.0.5"
106
- end
107
- end
108
-
109
- end
110
-
111
- describe "disable" do
112
-
113
- it "must raise if the extension is not installed" do
114
- skip
115
- end
116
-
117
- it "must disable the extension" do
118
- skip
119
- end
120
-
121
- end
122
-
123
- describe "enable" do
124
-
125
- it "must raise if the extension is not disabled" do
126
- skip
127
- end
128
-
129
- it "must enable the extension" do
130
- skip
131
- end
132
-
133
- end
134
-
135
- describe "uninstall" do
136
-
137
- it "must raise if the extension is not installed" do
138
- skip
139
- end
140
-
141
- it "must uninstall the extension" do
142
- skip
143
- end
144
-
145
- end
146
-
147
- describe "run_task" do
148
-
149
- before do
150
- FileUtils.mkdir_p Ray::EXT_DIR
151
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
152
- end
153
-
154
- after { cleanup }
155
-
156
- it "must run Rake tasks" do
157
- task = Ray::Gem.new({ :name => "dummy", :version => "1.0.0" }).run_task "migrate"
158
- task.must_equal ""
159
- end
160
-
161
- end
162
-
163
- describe "run_tasks" do
164
-
165
- before do
166
- FileUtils.mkdir_p Ray::EXT_DIR
167
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
168
- end
169
-
170
- after { cleanup }
171
-
172
- it "must run the appropriate Rake tasks" do
173
- extension = Ray::Gem.new({ :name => "dummy", :version => "1.0.0" })
174
- tasks = extension.run_tasks - ["default", "spec", "spec:cli"]
175
- tasks.must_equal ["radiant:extensions:dummy:migrate", "radiant:extensions:dummy:sync", "radiant:extensions:dummy:update"]
176
- end
177
-
178
- end
179
-
180
- describe "name=" do
181
-
182
- it "must convert the name to a proper extension name" do
183
- extension = Ray::Gem.new
184
- extension.name = "what-ever"
185
- extension.name.must_equal "what_ever"
186
- extension.name = "radiant-what-ever"
187
- extension.name.must_equal "what_ever"
188
- extension.name = "what-ever-extension"
189
- extension.name.must_equal "what_ever"
190
- extension.name = "radiant-what-ever-extension"
191
- extension.name.must_equal "what_ever"
192
- extension.name = "what_ever"
193
- extension.name.must_equal "what_ever"
194
- extension.name = "radiant_what_ever"
195
- extension.name.must_equal "what_ever"
196
- extension.name = "what_ever_extension"
197
- extension.name.must_equal "what_ever"
198
- extension.name = "radiant_what_ever_extension"
199
- extension.name.must_equal "what_ever"
200
- extension.name = "whatever"
201
- extension.name.must_equal "whatever"
202
- extension.name = "radiant_whatever"
203
- extension.name.must_equal "whatever"
204
- extension.name = "whatever_extension"
205
- extension.name.must_equal "whatever"
206
- extension.name = "radiant_whatever_extension"
207
- extension.name.must_equal "whatever"
208
- extension.name = "RADIANT-WHAT-EVER-EXTENSION"
209
- extension.name.must_equal "what_ever"
210
- end
211
-
212
- end
213
-
214
- end
@@ -1,216 +0,0 @@
1
- require "spec_helper"
2
- require "ray/extension/git"
3
-
4
- module Extension
5
- def run_task task, options = {} ; "" ; end
6
- end
7
-
8
- describe Ray::Git do
9
-
10
- describe "install" do
11
-
12
- before do
13
- FileUtils.mkdir_p Ray::EXT_DIR
14
- @extension = Ray::Git.new({
15
- :name => "dummy",
16
- :uri => "file:///#{Dir.pwd}/spec/fixtures/dummy"
17
- })
18
- end
19
-
20
- after { cleanup }
21
-
22
- it "must raise if the extension is already installed" do
23
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
24
- proc { @extension.install }.must_raise RuntimeError
25
- end
26
-
27
- it "must install the extension" do
28
- Dir.chdir "#{Dir.pwd}/spec/fixtures/dummy" do
29
- `git init && git add . && git commit -am "inital commit"`
30
- end
31
- @extension.install
32
- FileUtils.rm_rf "#{Dir.pwd}/spec/fixtures/dummy/.git"
33
- File.exist?("#{Ray::EXT_DIR}/dummy/dummy_extension.rb").must_equal true
34
- end
35
-
36
- end
37
-
38
- describe "clone" do
39
-
40
- before do
41
- FileUtils.mkdir_p Ray::TMP_DIR
42
- @extension = Ray::Git.new({ :name => "dummy" })
43
- end
44
-
45
- after { cleanup }
46
-
47
- it "must raise if the name is not given" do
48
- proc { Ray::Git.new.clone }.must_raise RuntimeError
49
- end
50
-
51
- it "must raise if the uri is not given" do
52
- proc { @extension.clone }.must_raise RuntimeError
53
- end
54
-
55
- it "must clone the repository" do
56
- Dir.chdir "#{Dir.pwd}/spec/fixtures/dummy" do
57
- `git init && git add . && git commit -am "inital commit"`
58
- end
59
- @extension.uri = "file:///#{Dir.pwd}/spec/fixtures/dummy"
60
- @extension.clone
61
- FileUtils.rm_rf "#{Dir.pwd}/spec/fixtures/dummy/.git"
62
- File.exist?("#{Ray::TMP_DIR}/dummy/dummy_extension.rb").must_equal true
63
- end
64
-
65
- end
66
-
67
- describe "disable" do
68
-
69
- before do
70
- FileUtils.mkdir_p Ray::EXT_DIR
71
- FileUtils.mkdir_p Ray::TMP_DIR
72
- @extension = Ray::Git.new({ :name => "dummy" })
73
- end
74
-
75
- after { cleanup }
76
-
77
- it "must raise if the extension is not installed" do
78
- proc { @extension.disable }.must_raise RuntimeError
79
- end
80
-
81
- it "must disable the extension" do
82
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
83
- @extension.disable
84
- File.exist?("#{Ray::EXT_DIR}/.disabled/dummy/dummy_extension.rb").must_equal true
85
- end
86
-
87
- end
88
-
89
- describe "enable" do
90
-
91
- before do
92
- FileUtils.mkdir_p "#{Ray::EXT_DIR}/.disabled"
93
- FileUtils.mkdir_p Ray::TMP_DIR
94
- @extension = Ray::Git.new({ :name => "dummy" })
95
- end
96
-
97
- after { cleanup }
98
-
99
- it "must raise if the extension is not disabled" do
100
- proc { @extension.enable }.must_raise RuntimeError
101
- end
102
-
103
- it "must enable the extension" do
104
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/.disabled/dummy"
105
- @extension.enable
106
- File.exist?("#{Ray::EXT_DIR}/dummy/dummy_extension.rb").must_equal true
107
- end
108
-
109
- end
110
-
111
- describe "uninstall" do
112
-
113
- before do
114
- FileUtils.mkdir_p Ray::EXT_DIR
115
- FileUtils.mkdir_p Ray::TMP_DIR
116
- @extension = Ray::Git.new({ :name => "dummy" })
117
- end
118
-
119
- after { cleanup }
120
-
121
- it "must raise if the extension is not installed" do
122
- proc { @extension.uninstall }.must_raise RuntimeError
123
- end
124
-
125
- it "must uninstall the extension" do
126
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
127
- @extension.uninstall
128
- File.exist?("#{Ray::EXT_DIR}/dummy/dummy_extension.rb").must_equal false
129
- end
130
-
131
- end
132
-
133
- describe "load_tasks" do
134
-
135
- before do
136
- FileUtils.mkdir_p Ray::EXT_DIR
137
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
138
- end
139
-
140
- after { cleanup }
141
-
142
- it "must load available Rake tasks" do
143
- tasks = Ray::Git.new({ :name => "dummy" }).load_tasks - ["default", "spec", "spec:cli"]
144
- tasks.must_equal ["radiant:extensions:dummy:migrate", "radiant:extensions:dummy:sync", "radiant:extensions:dummy:update"]
145
- end
146
-
147
- end
148
-
149
- describe "run_task" do
150
-
151
- before do
152
- FileUtils.mkdir_p Ray::EXT_DIR
153
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
154
- end
155
-
156
- after { cleanup }
157
-
158
- it "must run Rake tasks" do
159
- task = Ray::Git.new({ :name => "dummy" }).run_task "migrate"
160
- task.must_equal ""
161
- end
162
-
163
- end
164
-
165
- describe "run_tasks" do
166
-
167
- before do
168
- FileUtils.mkdir_p Ray::EXT_DIR
169
- FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
170
- end
171
-
172
- after { cleanup }
173
-
174
- it "must run the appropriate Rake tasks" do
175
- extension = Ray::Git.new({ :name => "dummy" })
176
- tasks = extension.run_tasks - ["default", "spec", "spec:cli"]
177
- tasks.must_equal ["radiant:extensions:dummy:migrate", "radiant:extensions:dummy:sync", "radiant:extensions:dummy:update"]
178
- end
179
-
180
- end
181
-
182
- describe "name=" do
183
-
184
- it "must convert the name to a proper extension name" do
185
- extension = Ray::Git.new
186
- extension.name = "what-ever"
187
- extension.name.must_equal "what_ever"
188
- extension.name = "radiant-what-ever"
189
- extension.name.must_equal "what_ever"
190
- extension.name = "what-ever-extension"
191
- extension.name.must_equal "what_ever"
192
- extension.name = "radiant-what-ever-extension"
193
- extension.name.must_equal "what_ever"
194
- extension.name = "what_ever"
195
- extension.name.must_equal "what_ever"
196
- extension.name = "radiant_what_ever"
197
- extension.name.must_equal "what_ever"
198
- extension.name = "what_ever_extension"
199
- extension.name.must_equal "what_ever"
200
- extension.name = "radiant_what_ever_extension"
201
- extension.name.must_equal "what_ever"
202
- extension.name = "whatever"
203
- extension.name.must_equal "whatever"
204
- extension.name = "radiant_whatever"
205
- extension.name.must_equal "whatever"
206
- extension.name = "whatever_extension"
207
- extension.name.must_equal "whatever"
208
- extension.name = "radiant_whatever_extension"
209
- extension.name.must_equal "whatever"
210
- extension.name = "RADIANT-WHAT-EVER-EXTENSION"
211
- extension.name.must_equal "what_ever"
212
- end
213
-
214
- end
215
-
216
- end