fanforce 0.2.4 → 0.2.5

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/Gemfile CHANGED
@@ -3,6 +3,7 @@ gemspec
3
3
 
4
4
  gem 'multi_json'
5
5
  gem 'rest-client'
6
+ gem 'querystring'
6
7
 
7
8
  group :development, :test do
8
9
  gem 'rake'
data/Gemfile.lock CHANGED
@@ -1,15 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fanforce (0.1.5)
4
+ fanforce (0.2.5)
5
5
  multi_json (~> 1.3.6)
6
6
  rest-client (~> 1.6.7)
7
+ rest-client (~> 1.6.7)
7
8
 
8
9
  GEM
9
10
  remote: http://rubygems.org/
10
11
  specs:
11
12
  mime-types (1.19)
12
13
  multi_json (1.3.6)
14
+ querystring (0.1.0)
13
15
  rake (0.9.2.2)
14
16
  rest-client (1.6.7)
15
17
  mime-types (>= 1.16)
@@ -20,5 +22,6 @@ PLATFORMS
20
22
  DEPENDENCIES
21
23
  fanforce!
22
24
  multi_json
25
+ querystring
23
26
  rake
24
27
  rest-client
data/Rakefile CHANGED
@@ -4,54 +4,10 @@ require 'fileutils'
4
4
  include FileUtils
5
5
 
6
6
  # Default Rake task is compile
7
- task :default => :compile
7
+ task :default => :build
8
8
 
9
9
  ########################################################################
10
10
 
11
- def make(makedir)
12
- Dir.chdir(makedir) { sh 'make' }
13
- end
14
-
15
- def extconf(dir)
16
- Dir.chdir(dir) { ruby "extconf.rb" }
17
- end
18
-
19
- def setup_extension(dir, extension)
20
- ext = "ext/#{dir}"
21
- ext_so = "#{ext}/#{extension}.#{RbConfig::CONFIG['DLEXT']}"
22
- ext_files = FileList[
23
- "#{ext}/*.c",
24
- "#{ext}/*.h",
25
- "#{ext}/extconf.rb",
26
- "#{ext}/Makefile",
27
- "lib"
28
- ]
29
-
30
- task "lib" do
31
- directory "lib"
32
- end
33
-
34
- desc "Builds just the #{extension} extension"
35
- task extension.to_sym => ["#{ext}/Makefile", ext_so ]
36
-
37
- file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
38
- extconf "#{ext}"
39
- end
40
-
41
- file ext_so => ext_files do
42
- make "#{ext}"
43
- cp ext_so, "lib"
44
- end
45
- end
46
-
47
- ########################################################################
48
-
49
- setup_extension("", "pr_query_parser")
50
-
51
- desc "Compile the extension"
52
- task :compile => [:pr_query_parser]
53
-
54
-
55
11
  Rake::TestTask.new do |t|
56
12
  t.libs.push "lib"
57
13
  t.libs.push "test"
data/fanforce.gemspec CHANGED
@@ -14,12 +14,11 @@ Gem::Specification.new do |gem|
14
14
  gem.homepage = "http://github.com/mlabs/fanforce-ruby"
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.extensions = ["ext/extconf.rb", "ext/extconf.rb"]
20
18
  gem.require_paths = ["lib"]
21
19
 
22
20
  gem.add_development_dependency 'rake'
23
21
  gem.add_runtime_dependency 'rest-client', '~> 1.6.7'
24
- gem.add_runtime_dependency 'multi_json', '~> 1.3.6'
22
+ gem.add_runtime_dependency 'rest-client', '~> 1.6.7'
23
+ gem.add_runtime_dependency 'querystring', '~> 0.1.0'
25
24
  end
@@ -1,5 +1,5 @@
1
1
  require 'uri'
2
- require 'query_string_parser'
2
+ require 'querystring'
3
3
 
4
4
  module Fanforce::Utils
5
5
  def self.included(base) base.extend(self) end
@@ -55,7 +55,7 @@ module Fanforce::Utils
55
55
  def parse_url(raw_url)
56
56
  return if is_blank?(raw_url)
57
57
  url = URI::parse(raw_url)
58
- query_params = QueryStringParser.qs_parse(url.query).inject({}) do |result, (k,v)|
58
+ query_params = QueryString.parse(url.query).inject({}) do |result, (k,v)|
59
59
  result[k] = v if k !~ /^ff_.+/
60
60
  result
61
61
  end
@@ -1,3 +1,3 @@
1
1
  class Fanforce
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -44,13 +44,29 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: 1.6.7
46
46
  - !ruby/object:Gem::Dependency
47
- name: multi_json
47
+ name: rest-client
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.6.7
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.7
62
+ - !ruby/object:Gem::Dependency
63
+ name: querystring
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
51
67
  - - ~>
52
68
  - !ruby/object:Gem::Version
53
- version: 1.3.6
69
+ version: 0.1.0
54
70
  type: :runtime
55
71
  prerelease: false
56
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,13 +74,12 @@ dependencies:
58
74
  requirements:
59
75
  - - ~>
60
76
  - !ruby/object:Gem::Version
61
- version: 1.3.6
77
+ version: 0.1.0
62
78
  description: Ruby API wrapper that interfaces with all six Fanforce APIs.
63
79
  email:
64
80
  - cclark@fanforce.com
65
81
  executables: []
66
- extensions:
67
- - ext/extconf.rb
82
+ extensions: []
68
83
  extra_rdoc_files: []
69
84
  files:
70
85
  - .gitignore
@@ -75,12 +90,6 @@ files:
75
90
  - LICENSE.md
76
91
  - README.md
77
92
  - Rakefile
78
- - ext/Makefile
79
- - ext/extconf.rb
80
- - ext/mkmf.log
81
- - ext/pr_query_parser.bundle
82
- - ext/pr_query_parser.c
83
- - ext/pr_query_parser.o
84
93
  - fanforce.gemspec
85
94
  - lib/fanforce.rb
86
95
  - lib/fanforce/config.rb
@@ -88,8 +97,6 @@ files:
88
97
  - lib/fanforce/main.rb
89
98
  - lib/fanforce/utils.rb
90
99
  - lib/fanforce/version.rb
91
- - lib/pr_query_parser.bundle
92
- - lib/query_string_parser.rb
93
100
  - test/fanforce_test.rb
94
101
  homepage: http://github.com/mlabs/fanforce-ruby
95
102
  licenses: []
data/ext/Makefile DELETED
@@ -1,213 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- # V=0 quiet, V=1 verbose. other values don't work.
5
- V = 0
6
- Q1 = $(V:1=)
7
- Q = $(Q1:0=@)
8
- n=$(NULLCMD)
9
- ECHO1 = $(V:1=@$n)
10
- ECHO = $(ECHO1:0=@echo)
11
-
12
- #### Start of system configuration section. ####
13
-
14
- srcdir = .
15
- topdir = /Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1
16
- hdrdir = /Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1
17
- arch_hdrdir = /Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/$(arch)
18
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
- prefix = $(DESTDIR)/Users/calebclark/.rbenv/versions/1.9.3-p194
20
- rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
21
- exec_prefix = $(prefix)
22
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
23
- sitehdrdir = $(rubyhdrdir)/site_ruby
24
- rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
25
- vendordir = $(rubylibprefix)/vendor_ruby
26
- sitedir = $(rubylibprefix)/site_ruby
27
- ridir = $(datarootdir)/$(RI_BASE_NAME)
28
- mandir = $(datarootdir)/man
29
- localedir = $(datarootdir)/locale
30
- libdir = $(exec_prefix)/lib
31
- psdir = $(docdir)
32
- pdfdir = $(docdir)
33
- dvidir = $(docdir)
34
- htmldir = $(docdir)
35
- infodir = $(datarootdir)/info
36
- docdir = $(datarootdir)/doc/$(PACKAGE)
37
- oldincludedir = $(DESTDIR)/usr/include
38
- includedir = $(prefix)/include
39
- localstatedir = $(prefix)/var
40
- sharedstatedir = $(prefix)/com
41
- sysconfdir = $(prefix)/etc
42
- datadir = $(datarootdir)
43
- datarootdir = $(prefix)/share
44
- libexecdir = $(exec_prefix)/libexec
45
- sbindir = $(exec_prefix)/sbin
46
- bindir = $(exec_prefix)/bin
47
- rubylibdir = $(rubylibprefix)/$(ruby_version)
48
- archdir = $(rubylibdir)/$(arch)
49
- sitelibdir = $(sitedir)/$(ruby_version)
50
- sitearchdir = $(sitelibdir)/$(sitearch)
51
- vendorlibdir = $(vendordir)/$(ruby_version)
52
- vendorarchdir = $(vendorlibdir)/$(sitearch)
53
-
54
- NULLCMD = :
55
-
56
- CC = gcc
57
- CXX = g++
58
- LIBRUBY = $(LIBRUBY_A)
59
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
60
- LIBRUBYARG_SHARED =
61
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
62
- OUTFLAG = -o
63
- COUTFLAG = -o
64
-
65
- RUBY_EXTCONF_H =
66
- cflags = $(optflags) $(debugflags) $(warnflags)
67
- optflags = -O3
68
- debugflags = -ggdb
69
- warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
70
- CFLAGS = -fno-common $(cflags) -pipe $(ARCH_FLAG)
71
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
72
- DEFS =
73
- CPPFLAGS = -I'/Users/calebclark/.rbenv/versions/1.9.3-p194/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
74
- CXXFLAGS = $(CFLAGS) $(cxxflags)
75
- ldflags = -L. -L'/Users/calebclark/.rbenv/versions/1.9.3-p194/lib' -L/usr/local/lib
76
- dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
77
- ARCH_FLAG =
78
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
79
- LDSHARED = $(CC) -dynamic -bundle
80
- LDSHAREDXX = $(CXX) -dynamic -bundle
81
- AR = ar
82
- EXEEXT =
83
-
84
- RUBY_BASE_NAME = ruby
85
- RUBY_INSTALL_NAME = ruby
86
- RUBY_SO_NAME = ruby
87
- arch = x86_64-darwin12.1.0
88
- sitearch = $(arch)
89
- ruby_version = 1.9.1
90
- ruby = /Users/calebclark/.rbenv/versions/1.9.3-p194/bin/ruby
91
- RUBY = $(ruby)
92
- RM = rm -f
93
- RM_RF = $(RUBY) -run -e rm -- -rf
94
- RMDIRS = rmdir -p
95
- MAKEDIRS = mkdir -p
96
- INSTALL = /usr/bin/install -c
97
- INSTALL_PROG = $(INSTALL) -m 0755
98
- INSTALL_DATA = $(INSTALL) -m 644
99
- COPY = cp
100
-
101
- #### End of system configuration section. ####
102
-
103
- preload =
104
-
105
- libpath = . $(libdir)
106
- LIBPATH = -L. -L$(libdir)
107
- DEFFILE =
108
-
109
- CLEANFILES = mkmf.log
110
- DISTCLEANFILES =
111
- DISTCLEANDIRS =
112
-
113
- extout =
114
- extout_prefix =
115
- target_prefix =
116
- LOCAL_LIBS =
117
- LIBS = -lcurl -lpthread -ldl -lobjc
118
- SRCS = pr_query_parser.c
119
- OBJS = pr_query_parser.o
120
- TARGET = pr_query_parser
121
- DLLIB = $(TARGET).bundle
122
- EXTSTATIC =
123
- STATIC_LIB =
124
-
125
- BINDIR = $(bindir)
126
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
127
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
128
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
129
- HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
130
- ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
131
-
132
- TARGET_SO = $(DLLIB)
133
- CLEANLIBS = $(TARGET).bundle
134
- CLEANOBJS = *.o *.bak
135
-
136
- all: $(DLLIB)
137
- static: $(STATIC_LIB)
138
- .PHONY: all install static install-so install-rb
139
- .PHONY: clean clean-so clean-rb
140
-
141
- clean-rb-default::
142
- clean-rb::
143
- clean-so::
144
- clean: clean-so clean-rb-default clean-rb
145
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
146
-
147
- distclean-rb-default::
148
- distclean-rb::
149
- distclean-so::
150
- distclean: clean distclean-so distclean-rb-default distclean-rb
151
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
152
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
153
- @-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
154
-
155
- realclean: distclean
156
- install: install-so install-rb
157
-
158
- install-so: $(RUBYARCHDIR)
159
- install-so: $(RUBYARCHDIR)/$(DLLIB)
160
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
161
- @-$(MAKEDIRS) $(@D)
162
- $(INSTALL_PROG) $(DLLIB) $(@D)
163
- install-rb: pre-install-rb install-rb-default
164
- install-rb-default: pre-install-rb-default
165
- pre-install-rb: Makefile
166
- pre-install-rb-default: Makefile
167
- pre-install-rb-default:
168
- $(ECHO) installing default pr_query_parser libraries
169
- $(RUBYARCHDIR):
170
- $(Q) $(MAKEDIRS) $@
171
-
172
- site-install: site-install-so site-install-rb
173
- site-install-so: install-so
174
- site-install-rb: install-rb
175
-
176
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
177
-
178
- .cc.o:
179
- $(ECHO) compiling $(<)
180
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
181
-
182
- .mm.o:
183
- $(ECHO) compiling $(<)
184
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
185
-
186
- .cxx.o:
187
- $(ECHO) compiling $(<)
188
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
189
-
190
- .cpp.o:
191
- $(ECHO) compiling $(<)
192
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
193
-
194
- .C.o:
195
- $(ECHO) compiling $(<)
196
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
197
-
198
- .c.o:
199
- $(ECHO) compiling $(<)
200
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
201
-
202
- .m.o:
203
- $(ECHO) compiling $(<)
204
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
205
-
206
- $(DLLIB): $(OBJS) Makefile
207
- $(ECHO) linking shared-object $(DLLIB)
208
- @-$(RM) $(@)
209
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
210
-
211
-
212
-
213
- $(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
data/ext/extconf.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'mkmf'
2
-
3
- #$CFLAGS = "-Wall -Werror -Wextra"
4
-
5
- extension_name = 'pr_query_parser'
6
- dir_config(extension_name)
7
-
8
- have_library('curl', 'curl_easy_unescape')
9
- create_makefile(extension_name)
data/ext/mkmf.log DELETED
@@ -1,38 +0,0 @@
1
- have_library: checking for curl_easy_unescape() in -lcurl... -------------------- yes
2
-
3
- "gcc -o conftest -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/x86_64-darwin12.1.0 -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1 -I. -I'/Users/calebclark/.rbenv/versions/1.9.3-p194/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I'/Users/calebclark/.rbenv/versions/1.9.3-p194/include' -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -pipe conftest.c -L. -L/Users/calebclark/.rbenv/versions/1.9.3-p194/lib -L. -L'/Users/calebclark/.rbenv/versions/1.9.3-p194/lib' -L/usr/local/lib -lruby-static -lpthread -ldl -lobjc "
4
- checked program was:
5
- /* begin */
6
- 1: #include "ruby.h"
7
- 2:
8
- 3: int main() {return 0;}
9
- /* end */
10
-
11
- "gcc -o conftest -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/x86_64-darwin12.1.0 -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1 -I. -I'/Users/calebclark/.rbenv/versions/1.9.3-p194/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I'/Users/calebclark/.rbenv/versions/1.9.3-p194/include' -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -pipe conftest.c -L. -L/Users/calebclark/.rbenv/versions/1.9.3-p194/lib -L. -L'/Users/calebclark/.rbenv/versions/1.9.3-p194/lib' -L/usr/local/lib -lruby-static -lcurl -lpthread -ldl -lobjc "
12
- conftest.c: In function ‘t’:
13
- conftest.c:5: error: ‘curl_easy_unescape’ undeclared (first use in this function)
14
- conftest.c:5: error: (Each undeclared identifier is reported only once
15
- conftest.c:5: error: for each function it appears in.)
16
- checked program was:
17
- /* begin */
18
- 1: #include "ruby.h"
19
- 2:
20
- 3: /*top*/
21
- 4: int main() {return 0;}
22
- 5: int t() { void ((*volatile p)()); p = (void ((*)()))curl_easy_unescape; return 0; }
23
- /* end */
24
-
25
- "gcc -o conftest -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/x86_64-darwin12.1.0 -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/calebclark/.rbenv/versions/1.9.3-p194/include/ruby-1.9.1 -I. -I'/Users/calebclark/.rbenv/versions/1.9.3-p194/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I'/Users/calebclark/.rbenv/versions/1.9.3-p194/include' -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -pipe conftest.c -L. -L/Users/calebclark/.rbenv/versions/1.9.3-p194/lib -L. -L'/Users/calebclark/.rbenv/versions/1.9.3-p194/lib' -L/usr/local/lib -lruby-static -lcurl -lpthread -ldl -lobjc "
26
- conftest.c: In function ‘t’:
27
- conftest.c:5: warning: implicit declaration of function ‘curl_easy_unescape’
28
- checked program was:
29
- /* begin */
30
- 1: #include "ruby.h"
31
- 2:
32
- 3: /*top*/
33
- 4: int main() {return 0;}
34
- 5: int t() { curl_easy_unescape(); return 0; }
35
- /* end */
36
-
37
- --------------------
38
-
Binary file
@@ -1,137 +0,0 @@
1
- #include "ruby.h"
2
-
3
- #include <stdio.h>
4
- #include <ctype.h>
5
- #include <curl/curl.h>
6
-
7
- static void
8
- pr_set_param(VALUE params, char *key, char *value)
9
- {
10
- VALUE rkey, rvalue, cur;
11
- char *v;
12
-
13
- /* no key do nothing */
14
- if (key == NULL || *key == 0) return;
15
-
16
- /* strip [] from the key name */
17
- v = curl_easy_unescape(NULL, key, 0, NULL);
18
- if (strlen(v) > 2)
19
- {
20
- char *t = v;
21
- char *open_bracket = NULL;
22
-
23
- while (*(t + 1) != 0)
24
- {
25
- if (*t == '[') open_bracket = t;
26
- t++;
27
- }
28
-
29
- if ((*t == ']') && (open_bracket != NULL))
30
- {
31
- char *pos = (open_bracket + 1);
32
- int is_digit = 1;
33
-
34
- while (pos != t)
35
- {
36
- if (!isdigit(*pos))
37
- {
38
- is_digit = 0;
39
- break;
40
- }
41
- pos ++;
42
- }
43
-
44
- if ((*t == ']') && (*(t - 1) == '['))
45
- {
46
- *(t - 1) = 0;
47
- }
48
- else if ((*t == ']') && (*open_bracket == '[') && is_digit)
49
- {
50
- *open_bracket = 0;
51
- }
52
- }
53
- }
54
-
55
- /* key was only [], do nothing */
56
- if (v == NULL || *v == 0) return;
57
-
58
- rkey = rb_str_new2(v);
59
- free(v);
60
-
61
- v = curl_easy_unescape(NULL, value, 0, NULL);
62
- rvalue = rb_str_new2(v);
63
- free(v);
64
-
65
- cur = rb_hash_aref(params, rkey);
66
- if (NIL_P(cur))
67
- {
68
- rb_hash_aset(params, rkey, rvalue);
69
- }
70
- else
71
- {
72
- VALUE arry;
73
- if (rb_obj_is_kind_of(cur, rb_cArray) == Qtrue)
74
- {
75
- arry = cur;
76
- }
77
- else
78
- {
79
- arry = rb_ary_new();
80
- rb_ary_push(arry, cur);
81
- rb_hash_aset(params, rkey, arry);
82
- }
83
- rb_ary_push(arry, rvalue);
84
- }
85
- }
86
-
87
- VALUE
88
- pr_query_parser(VALUE self, VALUE query_string, VALUE delim)
89
- {
90
- VALUE params = Qnil;
91
- char *qs, *p, *s, *key = NULL;
92
- char delimiter = RSTRING_PTR(delim)[0];
93
-
94
- params = rb_hash_new();
95
- qs = strdup(RSTRING_PTR(query_string));
96
- for (s = qs, p = qs; *p != 0; p++)
97
- {
98
- if (*p == delimiter)
99
- {
100
- *p = 0;
101
- if (key != NULL)
102
- {
103
- pr_set_param(params, key, s);
104
- key = NULL;
105
- }
106
- else
107
- {
108
- pr_set_param(params, s, s);
109
- }
110
- s = (p + 1);
111
- }
112
- else if ((*p == '=') && (key == NULL))
113
- {
114
- *p = 0;
115
- key = s;
116
- s = (p + 1);
117
- }
118
- }
119
-
120
- if (s != NULL)
121
- {
122
- if (key != NULL) pr_set_param(params, key, s);
123
- else pr_set_param(params, s, s);
124
- }
125
- free(qs);
126
-
127
- return params;
128
- self = self;
129
- }
130
-
131
- void
132
- Init_pr_query_parser(void)
133
- {
134
- VALUE QueryStringParser = rb_define_module("QueryStringParser");
135
-
136
- rb_define_module_function(QueryStringParser, "pr_query_parser", pr_query_parser, 2);
137
- }
Binary file
Binary file
@@ -1,13 +0,0 @@
1
- require 'pr_query_parser'
2
-
3
- module QueryStringParser
4
- module_function
5
-
6
- def qs_parse(query_string, delim = '&')
7
- return {} if query_string.nil? || query_string == ""
8
-
9
- ret = (query_string + "\x20").force_encoding('UTF-8').encode('UTF-16', :invalid => :replace, :replace => '').encode('UTF-8')[0..-2]
10
- pr_query_parser(ret, delim)
11
- end
12
-
13
- end