我是 Haskell 初学者。我有来自 Project Gutenberg 的 RDF XML,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xml:base="http://www.gutenberg.org/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:dcam="http://purl.org/dc/dcam/"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:pgterms="http://www.gutenberg.org/2009/pgterms/"
>
<cc:Work rdf:about="">
<rdfs:comment>Archives containing the RDF files for *all* our books can be downloaded at
http://www.gutenberg.org/wiki/Gutenberg:Feeds#The_Complete_Project_Gutenberg_Catalog</rdfs:comment>
<cc:license rdf:resource="https://creativecommons.org/publicdomain/zero/1.0/"/>
</cc:Work>
<pgterms:ebook rdf:about="ebooks/20">
<pgterms:bookshelf>
<rdf:Description rdf:nodeID="N3f8445072d8e4499b2646626f94866e0">
<rdf:value>Poetry</rdf:value>
<dcam:memberOf rdf:resource="2009/pgterms/Bookshelf"/>
</rdf:Description>
</pgterms:bookshelf>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.rdf">
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-16T05:01:13.615047</dcterms:modified>
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">12133</dcterms:extent>
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:format>
<rdf:Description rdf:nodeID="N735ba077c8424051b6470a92682aaa5e">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">application/rdf+xml</rdf:value>
</rdf:Description>
</dcterms:format>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1991-10-01</dcterms:issued>
<dcterms:title>Paradise Lost</dcterms:title>
<dcterms:subject>
<rdf:Description rdf:nodeID="Ne259525c666c4886a996acbdddca0682">
<rdf:value>PR</rdf:value>
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCC"/>
</rdf:Description>
</dcterms:subject>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/files/20/20.txt">
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">507133</dcterms:extent>
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2011-03-02T06:33:54</dcterms:modified>
<dcterms:format>
<rdf:Description rdf:nodeID="Nbd1740a2927845058b0fe43326dcc48b">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/plain; charset=us-ascii</rdf:value>
</rdf:Description>
</dcterms:format>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.epub.images">
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:format>
<rdf:Description rdf:nodeID="Nb08f3d2980e64e91a402eb5b205c10bc">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">application/epub+zip</rdf:value>
</rdf:Description>
</dcterms:format>
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">232622</dcterms:extent>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-01T01:04:17.425321</dcterms:modified>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.kindle.images">
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">933970</dcterms:extent>
<dcterms:format>
<rdf:Description rdf:nodeID="Nff1df57b9552466d96b114f20424b5a2">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">application/x-mobipocket-ebook</rdf:value>
</rdf:Description>
</dcterms:format>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-01T01:04:21.321235</dcterms:modified>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:language>
<rdf:Description rdf:nodeID="N91273d0bffc74be393cda307d2b05137">
<rdf:value rdf:datatype="http://purl.org/dc/terms/RFC4646">en</rdf:value>
</rdf:Description>
</dcterms:language>
<dcterms:subject>
<rdf:Description rdf:nodeID="N5e35fb378b37483ca6ef7a08f27cf936">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCSH"/>
<rdf:value>Eve (Biblical figure) -- Poetry</rdf:value>
</rdf:Description>
</dcterms:subject>
<dcterms:license rdf:resource="license"/>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.html.images">
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">614618</dcterms:extent>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-01T01:04:16.685338</dcterms:modified>
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:format>
<rdf:Description rdf:nodeID="N7567260ec2fd48c0be3d2858e08ac35d">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/html</rdf:value>
</rdf:Description>
</dcterms:format>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.epub.noimages">
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-01T01:04:17.695324</dcterms:modified>
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">232623</dcterms:extent>
<dcterms:format>
<rdf:Description rdf:nodeID="Nb640302bc2a84a31b0e154318df817d1">
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">application/epub+zip</rdf:value>
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
</rdf:Description>
</dcterms:format>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.kindle.noimages">
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">933967</dcterms:extent>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-01T01:04:24.846165</dcterms:modified>
<dcterms:format>
<rdf:Description rdf:nodeID="N1857bba1f5484e3d84846e1a554ec593">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">application/x-mobipocket-ebook</rdf:value>
</rdf:Description>
</dcterms:format>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:publisher>Project Gutenberg</dcterms:publisher>
<dcterms:rights>Public domain in the USA.</dcterms:rights>
<dcterms:creator>
<pgterms:agent rdf:about="2009/agents/17">
<pgterms:deathdate rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1674</pgterms:deathdate>
<pgterms:webpage rdf:resource="http://en.wikipedia.org/wiki/John_Milton"/>
<pgterms:name>Milton, John</pgterms:name>
<pgterms:birthdate rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1608</pgterms:birthdate>
</pgterms:agent>
</dcterms:creator>
<dcterms:type>
<rdf:Description rdf:nodeID="N0f6e6d76b1ff4ea9a2c5c37949efe82b">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/DCMIType"/>
<rdf:value>Text</rdf:value>
</rdf:Description>
</dcterms:type>
<dcterms:subject>
<rdf:Description rdf:nodeID="N202624c4b5994d39a3ab8bf0a2a31d95">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCSH"/>
<rdf:value>Adam (Biblical figure) -- Poetry</rdf:value>
</rdf:Description>
</dcterms:subject>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.html.noimages">
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">614618</dcterms:extent>
<dcterms:format>
<rdf:Description rdf:nodeID="N79f919d14da448e19eb05c444322ddd2">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/html</rdf:value>
</rdf:Description>
</dcterms:format>
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-01T01:04:16.955332</dcterms:modified>
</pgterms:file>
</dcterms:hasFormat>
<pgterms:bookshelf>
<rdf:Description rdf:nodeID="Nec598f664c934ed49ba3c0168ef09615">
<rdf:value>Banned Books from Anne Haight's list</rdf:value>
<dcam:memberOf rdf:resource="2009/pgterms/Bookshelf"/>
</rdf:Description>
</pgterms:bookshelf>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/ebooks/20.txt.utf-8">
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">507105</dcterms:extent>
<dcterms:format>
<rdf:Description rdf:nodeID="N069b84f8b10844e9a6c713f4c163880b">
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/plain</rdf:value>
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
</rdf:Description>
</dcterms:format>
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-03-01T01:04:15.953358</dcterms:modified>
</pgterms:file>
</dcterms:hasFormat>
<dcterms:subject>
<rdf:Description rdf:nodeID="Nb489692851fa496d96b1a7fdf7a71b21">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCSH"/>
<rdf:value>Fall of man -- Poetry</rdf:value>
</rdf:Description>
</dcterms:subject>
<pgterms:downloads rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2088</pgterms:downloads>
<dcterms:subject>
<rdf:Description rdf:nodeID="Naa6849a7660b4039baadec8af58f0c58">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCSH"/>
<rdf:value>Bible. Genesis -- History of Biblical events -- Poetry</rdf:value>
</rdf:Description>
</dcterms:subject>
<dcterms:hasFormat>
<pgterms:file rdf:about="http://www.gutenberg.org/files/20/20.zip">
<dcterms:extent rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">205748</dcterms:extent>
<dcterms:format>
<rdf:Description rdf:nodeID="N19cf968278bc4922bd87b17209c20d94">
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">text/plain; charset=us-ascii</rdf:value>
</rdf:Description>
</dcterms:format>
<dcterms:isFormatOf rdf:resource="ebooks/20"/>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2011-03-02T06:34:42</dcterms:modified>
<dcterms:format>
<rdf:Description rdf:nodeID="N94c2881f340a49c18246b69af3abcf12">
<rdf:value rdf:datatype="http://purl.org/dc/terms/IMT">application/zip</rdf:value>
<dcam:memberOf rdf:resource="http://purl.org/dc/terms/IMT"/>
</rdf:Description>
</dcterms:format>
</pgterms:file>
</dcterms:hasFormat>
</pgterms:ebook>
<rdf:Description rdf:about="http://en.wikipedia.org/wiki/John_Milton">
<dcterms:description>Wikipedia</dcterms:description>
</rdf:Description>
</rdf:RDF>
我想将这些信息转换成我可以查询和操作的常规 Haskell 数据结构。例如,我可能想查询这部作品的标题,或者获取它的所有维基百科 URL。
我注意到有 an RDF library in Haskell, rdh4h并且它有一个 XML 解析器。但是我无法对文档做出正面或反面的说明,而且似乎到处都没有教程。
我考虑过的另一件事是将所有这些 RDF/XML 文件导入某种数据库,然后使用 Haskell 以某种方式查询该数据库。但我不确定哪个数据库是合适的,或者这是否可能。
当然,我可以将其视为 XML 数据,而忽略 RDF 方面,但这似乎需要大量工作,而且我必须为这个 XML 文件中我想要的所有内容编写一些非常长的数据结构出去。
有没有人知道如何使用 Haskell 查询这样的数据?
最佳答案
I notice that there's an RDF library in Haskell, rdh4h and that it has an XML parser. But I can't make heads or tails of the documentation, and there doesn't seem to be a tutorial around anywhere.
这是我对文档进行正面或反面的尝试。 (对它持保留态度,因为我对 RDF 一无所知,也没有真正尝试使用该库。)
如果我们打开 the docs for Data.RDF ,顶级模块,我们发现了三个看似相关的功能:parseString , parseFile和 parseURL . The documentation for parseString ,例如,是:
parseString :: Rdf a => p -> Text -> Either ParseFailure (RDF a)
Parse RDF from the given text, yielding a failure with error message or the resultant RDF.
要调用它,我们需要提供一个 p和一个 Text (要解析的字符串)。但什么是 p ?如果我们向上滚动一点,我们会注意到 parseString是 RdfParser 的一种方法类(class)。实例列表——这对理解类型类有很大帮助——表明 XmlParser是 RdfParser 的实例.看起来很有用!
如果我们现在点击链接到 the XmlParser documentation entry ,我们了解到它有一个公开的(或“公共(public)”,如果你愿意的话)构造函数:
XmlParser (Maybe BaseUrl) (Maybe Text)
我们可以进一步点击链接了解BaseUrl只是Text附近的新类型.不过,似乎没有关于构造函数的参数应该是什么的有用文档。除了呼吁 the source code of the module 别无其他, 也可以通过链接访问。令人惊讶的是,这揭示了与那里的功能相关的有用文档。这是 RdfParser 的相关实例:
-- |'XmlParser' is an instance of 'RdfParser'.
instance RdfParser XmlParser where
parseString (XmlParser bUrl dUrl) = parseXmlRDF bUrl dUrl
parseFile (XmlParser bUrl dUrl) = parseFile' bUrl dUrl
parseURL (XmlParser bUrl dUrl) = parseURL' bUrl dUrl
这里的 Haddock 评论是多余的;然而,黑线鳕对 parseURL' 的评论中提供了有用的信息...
-- |Parse the document at the given location URL as an XML document, using an optional @BaseUrl@
-- as the base URI, and using the given document URL as the URI of the XML document itself.
--
-- The @BaseUrl@ is used as the base URI within the document for resolving any relative URI references.
-- It may be changed within the document using the @\@base@ directive. At any given point, the current
-- base URI is the most recent @\@base@ directive, or if none, the @BaseUrl@ given to @parseURL@, or
-- if none given, the document URL given to @parseURL@. For example, if the @BaseUrl@ were
-- @http:\/\/example.org\/@ and a relative URI of @\<b>@ were encountered (with no preceding @\@base@
-- directive), then the relative URI would expand to @http:\/\/example.org\/b@.
--
-- The document URL is for the purpose of resolving references to 'this document' within the document,
-- and may be different than the actual location URL from which the document is retrieved. Any reference
-- to @\<>@ within the document is expanded to the value given here. Additionally, if no @BaseUrl@ is
-- given and no @\@base@ directive has appeared before a relative URI occurs, this value is used as the
-- base URI against which the relative URI is resolved.
--p
-- Returns either a @ParseFailure@ or a new RDF containing the parsed triples.
parseURL' :: (Rdf a) =>
Maybe BaseUrl -- ^ The optional base URI of the document.
-> Maybe T.Text -- ^ The document URI (i.e., the URI of the document itself); if Nothing, use location URI.
-> String -- ^ The location URI from which to retrieve the XML document.
-> IO (Either ParseFailure (RDF a))
-- ^ The parse result, which is either a @ParseFailure@ or the RDF
-- corresponding to the XML document.
parseURL' bUrl docUrl = _parseURL (parseXmlRDF bUrl docUrl)
... 和 parseXmlRDF :
-- |Parse a xml T.Text to an RDF representation
parseXmlRDF :: (Rdf a)
=> Maybe BaseUrl -- ^ The base URL for the RDF if required
-> Maybe T.Text -- ^ DocUrl: The request URL for the RDF if available
-> T.Text -- ^ The contents to parse
-> Either ParseFailure (RDF a) -- ^ The RDF representation of the triples or ParseFailure
parseXmlRDF bUrl dUrl xmlStr = case runParseArrow of
(_,r:_) -> Right r
_ -> Left (ParseFailure "XML parsing failed")
where runParseArrow = runSLA (xreadDoc >>> isElem >>> addMetaData bUrl dUrl >>> getRDF) initState (T.unpack xmlStr)
initState = GParseState { stateGenId = 0 }
这些 Haddock 注释不会出现在实际文档中,因为它们所属的函数未导出。
总而言之,我认为这个库的文档可以改进。不过,在这种情况下,了解如何绕过 Hackage 文档可以减轻打击。
So I tried
parsed <- parseURL (XmlParser Nothing Nothing) testText, but it saysAmbiguous type variable ‘a0’ arising from a use of ‘parseURL’ prevents the constraint ‘(Rdf a0)’ from being solved. Probable fix: use a type annotation to specify what ‘a0’ should be.
错误告诉你必须指定什么 a在……
parseURL :: Rdf a => p -> String -> IO (Either ParseFailure (RDF a))
...通过在需要具体类型的地方使用它或通过添加类型注释。
文档中的进一步链接表明 Rdf is a class with two instances ( TList 和 AdjHashMap )和那个 RDF is a data family .既然如此,你想要这样的东西:
parsed <- parseURL (XmlParser Nothing Nothing) testText :: IO (Either ParseFailure (RDF TList))
(请注意类型注释如何与 parseURL 的签名指定的结果类型相匹配。)
或者,启用 ScopedTypeVariables可以这样写:
parsed :: Either ParseFailure (RDF TList) <- parseURL (XmlParser Nothing Nothing) testText
关于xml - 如何使用 Haskell 查询 RDF 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49310194/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t