fanforce-internal-utils 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzFjMzdiMDVkODljM2MwZDViYTU4NGMwMGUyMDM5MjQ4MDlhNjVkOA==
4
+ NGQzYWQ0MGI5YzE2MTBhY2JkYzIwZmY5MDM3ZmNkYTJjNmM2NjVlYw==
5
5
  data.tar.gz: !binary |-
6
- OGY3YTYxMTBhOWQ5OGQyNTAwN2VmMDViNmNjZjgwYmQ0NzNhMmE3Mg==
6
+ ZTFkODYwOTc5ZTdlYmE0MmE0NzAwYzAyZWExNjMxODc4MGQ0MjI4Yw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWMxZTEwM2JkOTkyNzBjNzJhZWNiNzgyNzIxZWY4MGIwNzQ5ZDA2YzZiYjQ1
10
- NTZiMjMzODA3MWVjODBjYzJkM2Q2OTlhMmZmYWIzYzcyYWZhZGRhNWIyYjli
11
- NDgwZTJiMzJkNjg4NzQ2MDA5ZGNhMjBhNWMwMzNkYTVlMjZjN2Y=
9
+ ZjU4MTEzODM5YWE1MWJmMzEyZWI2MmIzYmYxNjllZWNmNzU4NzRjZmQ5MDcx
10
+ YWQyMTA5ZWUwYmEzMjdjOTQ5NGNhYTBlNTBlZmIwOTNhNGRmZjI5MzliNDRm
11
+ NzliNmQ2MzJlOGQ1OTVhZGE5Yjc1ZThiMzI0NDE2YmVkODkxODk=
12
12
  data.tar.gz: !binary |-
13
- MjQ2MTI3YjJhMTg2OTMyMjY0ODdlYTQ4MDUyMDY2YmM3YjYxNjAzZGFiYWIy
14
- M2RiZjEzZjM4NDBmZjg5YzI4ODlkN2IxOGVhMWE3YTM5YmQ0OTY3NjQ4OTky
15
- ZGI5OGM3YmMwMmQzZjM4MDMxYTg4NjdkY2U2ODJmNDlhOWE4OWI=
13
+ YjZmZjZhOTJhMDhlNjAzYTJhODc4ZjM2OTIxODE2OWM3NGEzZmM1YjAyM2Mw
14
+ ZDA0NjAwYjVjN2ZlMjZhOWE1MzIzNWY2ZjVkZDg1ZWU0ZDQ0MzY4ZWE4ZTQ4
15
+ Mzc2YjI3NjJjZjEwNjFlNzE1M2U4NWJkZjJiNTE2YmQ1ZThkOGE=
@@ -64,6 +64,33 @@ module Fanforce::Utils
64
64
  end
65
65
  end
66
66
 
67
+ def decode_json(str, symbolize_keys=true)
68
+ MultiJson.load(str, :symbolize_keys => symbolize_keys)
69
+ end
70
+
71
+ # Creates a string representation of a javascript object for $.tmpl
72
+ def compile_jquery_tmpls(options={}, &block)
73
+ begin require 'haml' rescue LoadError raise "You must have the haml gem installed for Fanforce.compile_jquery_templates to work." end
74
+ context = Object.new
75
+ class << context
76
+ include Haml::Helpers
77
+ end
78
+ context.init_haml_helpers
79
+
80
+ format = if options[:format] == 'html' then :html else options[:callback].present? ? :jsonp : :json end
81
+
82
+ return context.capture_haml(&block) if format == :html
83
+ single_line_html = context.capture_haml(&block).split(/\r?\n/).inject('') {|sl, l| sl += l.strip + ' ' }
84
+ matches = single_line_html.scan(/<script id=[\"'](.*?)[\"'](?:.*?)>(.*?)(?:<\/script>)/mi)
85
+
86
+ templates = matches.inject({}) {|t,m| t[m[0]] = m[1]; t }
87
+ if format == :jsonp
88
+ "#{options[:callback]}(#{templates.to_json})"
89
+ else
90
+ templates.to_json
91
+ end
92
+ end
93
+
67
94
  end
68
95
 
69
96
  module Fanforce::InternalUtils
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  module Utils
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-internal-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark