diff options
author | Daniel DeLeo <dan@opscode.com> | 2011-02-03 15:49:37 -0800 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2011-02-03 16:07:22 -0800 |
commit | 5b59c478edda1491362d2de560758c3c95bd79eb (patch) | |
tree | 37d4fede68766c2fe9180edef72748ac82eca5d7 | |
parent | c6e5e5b4f7fce87aa9fd63d16896bcfd2af61546 (diff) | |
download | chef-5b59c478edda1491362d2de560758c3c95bd79eb.tar.gz |
remove libxml
-rw-r--r-- | README.rdoc | 4 | ||||
-rw-r--r-- | chef-server-api/app/controllers/search.rb | 3 | ||||
-rw-r--r-- | chef-server-webui/README.rdoc | 4 | ||||
-rw-r--r-- | chef-solr/chef-solr.gemspec | 2 | ||||
-rw-r--r-- | chef/README.rdoc | 2 | ||||
-rw-r--r-- | chef/lib/chef/solr_query.rb | 43 | ||||
-rw-r--r-- | chef/spec/unit/solr_query_spec.rb | 15 |
7 files changed, 16 insertions, 57 deletions
diff --git a/README.rdoc b/README.rdoc index e0f7e3d863..214a1ed1c0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -35,8 +35,6 @@ Install these via your platform's preferred method; for example apt, yum, ports, * Git * CouchDB * RabbitMQ -* libxml2 development package (for webrat) -* libxslt develoment package (for webrat) Install the following RubyGems. @@ -44,7 +42,6 @@ Install the following RubyGems. * rake * rspec * cucumber -* webrat * merb-core * merb-assets * merb-haml @@ -52,7 +49,6 @@ Install the following RubyGems. * merb-param-protection * merb_cucumber * coderay -* libxml-ruby Ohai is also by Opscode and available on GitHub, http://github.com/opscode/ohai/tree/master. diff --git a/chef-server-api/app/controllers/search.rb b/chef-server-api/app/controllers/search.rb index ebc63c7051..ad54dbb422 100644 --- a/chef-server-api/app/controllers/search.rb +++ b/chef-server-api/app/controllers/search.rb @@ -41,9 +41,6 @@ class Search < Application end query = Chef::SolrQuery.new(Chef::Config[:solr_url]) - params[:sort] ||= nil - params[:rows] ||= 20 - params[:type] = params[:id] objects, start, total = query.search(params) diff --git a/chef-server-webui/README.rdoc b/chef-server-webui/README.rdoc index 2c2eaa706b..e35def9d50 100644 --- a/chef-server-webui/README.rdoc +++ b/chef-server-webui/README.rdoc @@ -34,8 +34,6 @@ Install these via your platform's preferred method; for example apt, yum, ports, * Git * CouchDB -* libxml2 development package (for webrat) -* libxslt develoment package (for webrat) Install the following RubyGems. @@ -43,9 +41,7 @@ Install the following RubyGems. * rake * rspec * cucumber -* webrat * merb-core -* roman-merb_cucumber Ohai is also by Opscode and available on GitHub, http://github.com/opscode/ohai/tree/master. diff --git a/chef-solr/chef-solr.gemspec b/chef-solr/chef-solr.gemspec index 6769513bc3..dc1d12a8c7 100644 --- a/chef-solr/chef-solr.gemspec +++ b/chef-solr/chef-solr.gemspec @@ -7,8 +7,6 @@ Gem::Specification.new do |gem| gem.email = "adam@opscode.com" gem.homepage = "http://wiki.opscode.com/display/chef" gem.authors = ["Adam Jacob"] - gem.add_dependency "libxml-ruby", ">=1.1.3" - gem.add_dependency "uuidtools", ">=2.0.0" gem.add_dependency "chef", Chef::Solr::VERSION # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings gem.executables = [ 'chef-solr', 'chef-solr-indexer', 'chef-solr-rebuild' ] diff --git a/chef/README.rdoc b/chef/README.rdoc index 1fc0d9fdb4..80ee9c9cca 100644 --- a/chef/README.rdoc +++ b/chef/README.rdoc @@ -38,7 +38,6 @@ Install these via your platform's preferred method; for example apt, yum, ports, * RabbitMQ[http://www.rabbitmq.com/] * GCC and C Standard Libraries, header files, etc. (i.e., build-essential on debian/ubuntu) * Ruby development package -* libxml2 development package === Runtime Rubygem Dependencies ==== Chef Client and Solo @@ -61,7 +60,6 @@ Install these via your platform's preferred method; for example apt, yum, ports, All of the above, plus the following: * coderay * haml -* libxml-ruby * merb-assets * merb-core * merb-haml diff --git a/chef/lib/chef/solr_query.rb b/chef/lib/chef/solr_query.rb index 97c8a2f4c0..25772440ff 100644 --- a/chef/lib/chef/solr_query.rb +++ b/chef/lib/chef/solr_query.rb @@ -21,7 +21,6 @@ require 'chef/log' require 'chef/config' require 'chef/couchdb' require 'net/http' -require 'libxml' require 'uri' class Chef @@ -191,23 +190,24 @@ class Chef http_request_handler(req, description) end - START_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<add><doc>" - END_XML = "</doc></add>\n" - FIELD_ATTR = '<field name="' - FIELD_ATTR_END = '">' - CLOSE_FIELD = "</field>" + START_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".freeze + START_DELETE_BY_QUERY = "<delete><query>".freeze + END_DELETE_BY_QUERY = "</query></delete>\n".freeze + COMMIT = "<commit/>\n".freeze def solr_commit(opts={}) - post_to_solr(generate_single_element("commit", opts)) + post_to_solr("#{START_XML}#{COMMIT}") end - def solr_delete_by_query(queries) - post_to_solr(generate_delete_document("query", queries)) + def delete_database(db) + query_data = xml_escape("X_CHEF_database_CHEF_X:#{db}") + xml = "#{START_XML}#{START_DELETE_BY_QUERY}#{query_data}#{END_DELETE_BY_QUERY}" + post_to_solr(xml) + solr_commit end def rebuild_index(url=Chef::Config[:couchdb_url], db=Chef::Config[:couchdb_database]) - solr_delete_by_query("X_CHEF_database_CHEF_X:#{db}") - solr_commit + delete_database(db) results = {} [Chef::ApiClient, Chef::Node, Chef::Role].each do |klass| @@ -242,27 +242,6 @@ class Chef true end - def generate_single_element(elem, opts={}) - xml_document = LibXML::XML::Document.new - xml_elem = LibXML::XML::Node.new(elem) - opts.each { |k,v| xml_elem[k.to_s] = xml_escape(v.to_s) } - xml_document.root = xml_elem - xml_document.to_s(:indent => false) - end - - def generate_delete_document(type, list) - list = [list] unless list.is_a?(Array) - xml_document = LibXML::XML::Document.new - xml_delete = LibXML::XML::Node.new("delete") - xml_document.root = xml_delete - list.each do |id| - xml_id = LibXML::XML::Node.new(type) - xml_id.content = id.to_s - xml_delete << xml_id - end - xml_document.to_s(:indent => false) - end - # Thanks to Merb! def to_params(params_hash) params = '' diff --git a/chef/spec/unit/solr_query_spec.rb b/chef/spec/unit/solr_query_spec.rb index ec37047765..9d0c1592d9 100644 --- a/chef/spec/unit/solr_query_spec.rb +++ b/chef/spec/unit/solr_query_spec.rb @@ -153,19 +153,14 @@ describe Chef::SolrQuery do end end - describe "solr_delete_by_query" do + describe "when deleting a database from Solr" do before(:each) do @solr.stub!(:post_to_solr).and_return(true) end - it "should send valid delete id xml to solr" do - @solr.should_receive(:post_to_solr).with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<delete><query>foo:bar</query></delete>\n") - @solr.solr_delete_by_query("foo:bar") - end - - it "should accept multiple ids" do - @solr.should_receive(:post_to_solr).with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<delete><query>foo:bar</query><query>baz:bum</query></delete>\n") - @solr.solr_delete_by_query([ "foo:bar", "baz:bum" ]) + it "should send a valid delete query to solr" do + @solr.should_receive(:post_to_solr).with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<delete><query>X_CHEF_database_CHEF_X:chef</query></delete>\n") + @solr.delete_database("chef") end end @@ -175,7 +170,7 @@ describe Chef::SolrQuery do end it "deletes the index and commits" do - @solr.should_receive(:solr_delete_by_query).with("X_CHEF_database_CHEF_X:chunky_bacon") + @solr.should_receive(:post_to_solr).with("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<delete><query>X_CHEF_database_CHEF_X:chunky_bacon</query></delete>\n") @solr.should_receive(:solr_commit) @solr.stub!(:reindex_all) Chef::DataBag.stub!(:cdb_list).and_return([]) |