fanforce 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +59 -0
- data/ext/Makefile +213 -0
- data/ext/mkmf.log +38 -0
- data/ext/pr_query_parser.bundle +0 -0
- data/ext/pr_query_parser.o +0 -0
- data/lib/fanforce/main.rb +1 -2
- data/lib/fanforce/utils.rb +14 -13
- data/lib/fanforce/version.rb +1 -1
- data/lib/pr_query_parser.bundle +0 -0
- data/test/fanforce_test.rb +18 -0
- metadata +9 -2
data/Rakefile
CHANGED
@@ -1 +1,60 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# Default Rake task is compile
|
7
|
+
task :default => :compile
|
8
|
+
|
9
|
+
########################################################################
|
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
|
+
Rake::TestTask.new do |t|
|
56
|
+
t.libs.push "lib"
|
57
|
+
t.libs.push "test"
|
58
|
+
t.pattern = 'test/**/*_test.rb'
|
59
|
+
t.verbose = false
|
60
|
+
end
|
data/ext/Makefile
ADDED
@@ -0,0 +1,213 @@
|
|
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/mkmf.log
ADDED
@@ -0,0 +1,38 @@
|
|
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
|
Binary file
|
data/lib/fanforce/main.rb
CHANGED
@@ -46,7 +46,7 @@ class Fanforce
|
|
46
46
|
case response.code
|
47
47
|
when 200, 201
|
48
48
|
begin
|
49
|
-
response =
|
49
|
+
response = decode_json(response)
|
50
50
|
rescue
|
51
51
|
raise UnknownError.new(response, request, path, query)
|
52
52
|
end
|
@@ -85,5 +85,4 @@ class Fanforce
|
|
85
85
|
'http://' + $API_DOMAIN + path
|
86
86
|
end
|
87
87
|
|
88
|
-
|
89
88
|
end
|
data/lib/fanforce/utils.rb
CHANGED
@@ -2,27 +2,24 @@ require 'uri'
|
|
2
2
|
require 'query_string_parser'
|
3
3
|
|
4
4
|
module Fanforce::Utils
|
5
|
+
def self.included(base) base.extend(self) end
|
5
6
|
|
6
|
-
def
|
7
|
-
base.extend(Fanforce::Utils)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.blank?(obj)
|
7
|
+
def blank?(obj)
|
11
8
|
obj.respond_to?(:empty?) ? obj.empty? : !obj
|
12
9
|
end
|
13
10
|
|
14
|
-
def
|
11
|
+
def present?(obj)
|
15
12
|
!blank?(obj)
|
16
13
|
end
|
17
14
|
|
18
|
-
def
|
15
|
+
def valid_request?(params)
|
19
16
|
return false if !params.is_a?(Hash)
|
20
17
|
return false if blank?(params[:fanforce_id])
|
21
18
|
return false if blank?(params[:app_id]) and blank?(params[:behavior_id]) and blank?(params[:module_id]) and blank?(params[:widget_id])
|
22
19
|
return true
|
23
20
|
end
|
24
21
|
|
25
|
-
def
|
22
|
+
def valid_install_request?(params)
|
26
23
|
return false if !params.is_a?(Hash)
|
27
24
|
return false if blank?(params[:fanforce_id])
|
28
25
|
return false if blank?(params[:app_id]) and blank?(params[:behavior_id]) and blank?(params[:module_id]) and blank?(params[:widget_id])
|
@@ -30,7 +27,7 @@ module Fanforce::Utils
|
|
30
27
|
return true
|
31
28
|
end
|
32
29
|
|
33
|
-
def
|
30
|
+
def valid_uninstall_request?(params)
|
34
31
|
return false if !params.is_a?(Hash)
|
35
32
|
return false if blank?(params[:fanforce_id])
|
36
33
|
return false if blank?(params[:app_id]) and blank?(params[:behavior_id]) and blank?(params[:module_id]) and blank?(params[:widget_id])
|
@@ -38,7 +35,7 @@ module Fanforce::Utils
|
|
38
35
|
return true
|
39
36
|
end
|
40
37
|
|
41
|
-
def
|
38
|
+
def parse_params(params)
|
42
39
|
if present?(params[:app_id])
|
43
40
|
plugin_type = :app
|
44
41
|
plugin_id = params[:app_id]
|
@@ -55,7 +52,7 @@ module Fanforce::Utils
|
|
55
52
|
{:"#{plugin_type}_id" => params["#{plugin_type}_id"], plugin_type: plugin_type, plugin_id: plugin_id, fanforce_id: params[:fanforce_id], api_key: params[:api_key]}
|
56
53
|
end
|
57
54
|
|
58
|
-
def
|
55
|
+
def parse_url(raw_url)
|
59
56
|
return if blank?(raw_url)
|
60
57
|
url = URI::parse(raw_url)
|
61
58
|
query_params = QueryStringParser.qs_parse(url.query).inject({}) do |result, (k,v)|
|
@@ -69,7 +66,7 @@ module Fanforce::Utils
|
|
69
66
|
{ _external_id: _external_id, clean_url: clean_url, raw_url: raw_url, query_params: query_params, query_string: query_string, scheme: url.scheme, host: url.host, port: url.port, path: url.path, fragment: url.fragment }
|
70
67
|
end
|
71
68
|
|
72
|
-
def
|
69
|
+
def to_query_string(params, namespace = nil)
|
73
70
|
if params.is_a?(String)
|
74
71
|
params
|
75
72
|
elsif params.is_a?(Array)
|
@@ -81,9 +78,13 @@ module Fanforce::Utils
|
|
81
78
|
end
|
82
79
|
end
|
83
80
|
|
84
|
-
def
|
81
|
+
def to_query_chunk(value,key)
|
85
82
|
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
|
86
83
|
"#{CGI.escape(to_query_string(key))}=#{CGI.escape(to_query_string(value).to_s)}"
|
87
84
|
end
|
88
85
|
|
86
|
+
def decode_json(str, symbolize_keys=true)
|
87
|
+
MultiJson.load(str, :symbolize_keys => symbolize_keys)
|
88
|
+
end
|
89
|
+
|
89
90
|
end
|
data/lib/fanforce/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
require 'fanforce'
|
6
|
+
|
7
|
+
describe Fanforce do
|
8
|
+
|
9
|
+
it "should test if var is blank" do
|
10
|
+
assert Fanforce.blank?(nil)
|
11
|
+
assert !Fanforce.blank?("value")
|
12
|
+
|
13
|
+
ff = Fanforce.new
|
14
|
+
assert ff.blank?(nil)
|
15
|
+
assert !ff.blank?("value")
|
16
|
+
end
|
17
|
+
|
18
|
+
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -75,8 +75,12 @@ files:
|
|
75
75
|
- LICENSE.md
|
76
76
|
- README.md
|
77
77
|
- Rakefile
|
78
|
+
- ext/Makefile
|
78
79
|
- ext/extconf.rb
|
80
|
+
- ext/mkmf.log
|
81
|
+
- ext/pr_query_parser.bundle
|
79
82
|
- ext/pr_query_parser.c
|
83
|
+
- ext/pr_query_parser.o
|
80
84
|
- fanforce.gemspec
|
81
85
|
- lib/fanforce.rb
|
82
86
|
- lib/fanforce/config.rb
|
@@ -84,7 +88,9 @@ files:
|
|
84
88
|
- lib/fanforce/main.rb
|
85
89
|
- lib/fanforce/utils.rb
|
86
90
|
- lib/fanforce/version.rb
|
91
|
+
- lib/pr_query_parser.bundle
|
87
92
|
- lib/query_string_parser.rb
|
93
|
+
- test/fanforce_test.rb
|
88
94
|
homepage: http://github.com/mlabs/fanforce-ruby
|
89
95
|
licenses: []
|
90
96
|
post_install_message:
|
@@ -109,4 +115,5 @@ rubygems_version: 1.8.23
|
|
109
115
|
signing_key:
|
110
116
|
specification_version: 3
|
111
117
|
summary: Ruby API wrapper for Fanforce
|
112
|
-
test_files:
|
118
|
+
test_files:
|
119
|
+
- test/fanforce_test.rb
|