wolfram 0.1.0 → 0.1.1

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/.gemspec CHANGED
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + "/lib/wolfram/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "wolfram"
7
7
  s.version = Wolfram::VERSION
8
- s.authors = ["Gabriel Horner"]
8
+ s.authors = ["Gabriel Horner", "Ian White"]
9
9
  s.email = "gabriel.horner@gmail.com"
10
10
  s.homepage = "http://github.com/cldwalker/wolfram"
11
11
  s.summary = "Wolfram V2 API client"
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.1.1
2
+ * Fix requerying by state
3
+
1
4
  == 0.1.0
2
5
  * Initial release
3
6
 
data/lib/wolfram/pod.rb CHANGED
@@ -52,7 +52,7 @@ module Wolfram
52
52
  include XmlContainer
53
53
 
54
54
  def self.collection(xml, options = {})
55
- Nokogiri::XML(xml.to_s).search('subpod').map {|s_xml| new(s_xml, options)}
55
+ Nokogiri::XML(xml.to_s).search('subpod').map {|s_xml| new(s_xml, options) }
56
56
  end
57
57
 
58
58
  def initialize(xml, options = {})
@@ -71,14 +71,17 @@ module Wolfram
71
71
  end
72
72
 
73
73
  class State
74
- attr_reader :name
74
+ attr_reader :name, :input
75
75
 
76
76
  def self.collection(xml, options = {})
77
- Nokogiri::XML(xml.to_s).search('state').map {|s_xml| new(s_xml['name'], options)}
77
+ Nokogiri::XML(xml.to_s).search('state').map {|s_xml|
78
+ new(s_xml['name'], options.merge(:input => s_xml['input']))
79
+ }
78
80
  end
79
81
 
80
82
  def initialize(name, options = {})
81
83
  @query = options[:query]
84
+ @input = options[:input]
82
85
  @name = name
83
86
  end
84
87
 
@@ -95,12 +98,7 @@ module Wolfram
95
98
  end
96
99
 
97
100
  def requery
98
- if podstate = @query.params[:podstate]
99
- podstate = State.new("#{podstate.name},#{name}", :query => @query)
100
- else
101
- podstate = self
102
- end
103
-
101
+ podstate = @query.params[:podstate] ? [@query.params[:podstate], input] : input
104
102
  Query.new(@query.input, @query.options.merge(:podstate => podstate))
105
103
  end
106
104
 
data/lib/wolfram/query.rb CHANGED
@@ -25,8 +25,8 @@ module Wolfram
25
25
  end
26
26
 
27
27
  # the uri that this query will issue a get request to
28
- def uri
29
- "#{query_uri}?#{Util.to_param(params)}"
28
+ def uri(hash=params)
29
+ "#{query_uri}?#{Util.to_param(hash)}"
30
30
  end
31
31
 
32
32
  def params
@@ -5,7 +5,7 @@ module Wolfram
5
5
  include Enumerable
6
6
  extend Util
7
7
 
8
- delegate :[], :each, :to => :pods
8
+ delegate :each, :to => :pods
9
9
  delegate :uri, :to => :query
10
10
 
11
11
  attr_reader :assumptions, :pods, :query
@@ -19,6 +19,10 @@ module Wolfram
19
19
  types.each {|mod| extend mod}
20
20
  end
21
21
 
22
+ def [](key)
23
+ key.is_a?(String) ? pods.find {|e| e.title == key } : pods[key]
24
+ end
25
+
22
26
  def success?
23
27
  success
24
28
  end
data/lib/wolfram/util.rb CHANGED
@@ -5,6 +5,7 @@ module Wolfram
5
5
 
6
6
  # From activesupport
7
7
  def self.to_query(obj, key)
8
+ obj.is_a?(Array) ? obj.map {|e| to_query(e, key) } * '&' :
8
9
  "#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') }}=#{CGI.escape(obj.to_s)}"
9
10
  end
10
11
 
@@ -1,3 +1,3 @@
1
1
  module Wolfram
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,21 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolfram
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gabriel Horner
14
+ - Ian White
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-01-24 00:00:00 -05:00
19
+ date: 2011-02-01 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency