guppy 0.0.5 → 1.0.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.
- checksums.yaml +4 -4
- data/lib/guppy.rb +5 -190
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1226746a87a129789de84a8da69fa4b4dd615223
|
|
4
|
+
data.tar.gz: fb1eaba484f9a3f0531e17fd56ffe2ab12994ac9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95ad8b41e0e0713ec7730691c8c47d04c6882cbbf1e6ed8b68e086e22e259f58e0bedc6ca569e83253b058be0a91f479a795116f7b3f521d645a28eeaea27293
|
|
7
|
+
data.tar.gz: cee88bb20bfc9683507c90723e9b4d281829e011b2a7e223e9f19d9902862d49ba0481f75324a738caa6b3c5c2205104275261ca25395eab12ed24678cac5a2c
|
data/lib/guppy.rb
CHANGED
|
@@ -2,199 +2,11 @@ require 'rack'
|
|
|
2
2
|
require 'rack/request'
|
|
3
3
|
require 'sass'
|
|
4
4
|
require 'remote-sass'
|
|
5
|
-
require 'hashie'
|
|
6
|
-
require 'hashie/mash'
|
|
7
5
|
require 'net/http'
|
|
8
6
|
require 'time'
|
|
9
7
|
require 'open-uri'
|
|
10
8
|
|
|
11
|
-
RemoteSass.location =
|
|
12
|
-
|
|
13
|
-
module Sass::Script::Functions
|
|
14
|
-
|
|
15
|
-
def yml(path)
|
|
16
|
-
Guppy::Client.new('/code/guppy/config.yml')
|
|
17
|
-
params = path.to_s.gsub(/"|^ +| $+|\n/i,'').split('/')
|
|
18
|
-
if params.count > 1
|
|
19
|
-
res = (Guppy.config[params.first][params.last]).to_s
|
|
20
|
-
if res.to_s.include?('#')
|
|
21
|
-
# puts 'it is color ' + res
|
|
22
|
-
# puts 'THAT COLOR' if res.eql?('#fafafa')
|
|
23
|
-
# puts res.class.to_s
|
|
24
|
-
# puts 'response: '
|
|
25
|
-
resp = Sass::Script::Value::Color.from_hex(unquote(res))
|
|
26
|
-
else
|
|
27
|
-
resp = Sass::Script::Value::String.new(res)
|
|
28
|
-
end
|
|
29
|
-
# puts resp
|
|
30
|
-
resp
|
|
31
|
-
else
|
|
32
|
-
puts 'one param'
|
|
33
|
-
opts = {}
|
|
34
|
-
Guppy.config[params.first].each do |item, val|
|
|
35
|
-
# resp += item.to_s + ' ' + val.to_s + ","
|
|
36
|
-
# opts.push(Sass::Script::Value::List.new([item.to_s, val.to_s].shift.strip, :space))
|
|
37
|
-
if !val.is_a?(Hash) && val.include?('#')
|
|
38
|
-
to_assign = Sass::Script::Value::Color.from_hex(unquote(val.to_s))
|
|
39
|
-
else
|
|
40
|
-
to_assign = Sass::Script::Value::String.new(val.to_s)
|
|
41
|
-
end
|
|
42
|
-
opts[Sass::Script::Value::String.new(item.to_s)] = to_assign
|
|
43
|
-
end
|
|
44
|
-
# resp = resp[0..-3]
|
|
45
|
-
# puts opts.to_s
|
|
46
|
-
# vals = resp.split(',')
|
|
47
|
-
# res = Sass::Script::Value::List.new(opts, :comma)
|
|
48
|
-
# puts res.to_a.to_s
|
|
49
|
-
puts opts.inspect
|
|
50
|
-
Sass::Script::Value::Map.new(opts)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# def load(url)
|
|
55
|
-
# Guppy::Client.new('/code/guppy/config.yml')
|
|
56
|
-
# filename = URI.parse(url).path
|
|
57
|
-
# puts 'FNAME: ' + filename
|
|
58
|
-
# content = IO.readlines(url)
|
|
59
|
-
# open("#{Guppy.config.options.scss}/guppy/_#{filename}.scss", 'w') do |f|
|
|
60
|
-
# content.each do |line|
|
|
61
|
-
# f.puts(line)
|
|
62
|
-
# end
|
|
63
|
-
# end
|
|
64
|
-
# end
|
|
65
|
-
|
|
66
|
-
declare :yml, [:string]
|
|
67
|
-
# declare :load, [:string]
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# twitter login implementation module
|
|
72
|
-
module Guppy
|
|
73
|
-
|
|
74
|
-
# twitter login implementation class
|
|
75
|
-
class NoConfig < Exception; end
|
|
76
|
-
class NoModule < Exception; end
|
|
77
|
-
|
|
78
|
-
class << self
|
|
79
|
-
attr_accessor :config
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
class Client
|
|
83
|
-
|
|
84
|
-
def initialize(filename = '')
|
|
85
|
-
Guppy.config ||= Hashie::Mash.load(filename)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def sass(name)
|
|
89
|
-
Sass::Engine.new(
|
|
90
|
-
File.read("#{Guppy.config.options.scss}/#{name}.scss"),
|
|
91
|
-
{
|
|
92
|
-
syntax: :scss,
|
|
93
|
-
style: :compressed,
|
|
94
|
-
load_paths: [Guppy.config.options.scss]
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def module_exists?(name)
|
|
100
|
-
if File.exists?("#{Guppy.config.options.scss}/#{name}.scss")
|
|
101
|
-
p "#{name} exists"
|
|
102
|
-
else
|
|
103
|
-
p "#{name} dont exists"
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def render(modss)
|
|
108
|
-
# parse_variables
|
|
109
|
-
mods = (modss.instance_of?(String) ? modss.split(',') : [modss])
|
|
110
|
-
sass_response ||= ''
|
|
111
|
-
mods.insert(0, 'general')
|
|
112
|
-
mods.insert(1, 'mixins')
|
|
113
|
-
mods.insert(1, 'animations')
|
|
114
|
-
if mods.include?('no-animations')
|
|
115
|
-
mods
|
|
116
|
-
.pop(mods.index('animations'))
|
|
117
|
-
.pop(mods.index('no-animations'))
|
|
118
|
-
end
|
|
119
|
-
mods.uniq.each do |mod|
|
|
120
|
-
sass_response +=
|
|
121
|
-
sass("#{mod}")
|
|
122
|
-
.render
|
|
123
|
-
.to_s if module_exists?("#{mod}.scss")
|
|
124
|
-
end
|
|
125
|
-
sass_response
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
#
|
|
130
|
-
# module Sass
|
|
131
|
-
# class Engine
|
|
132
|
-
# DIRECTIVES.add(:remote)
|
|
133
|
-
#
|
|
134
|
-
# def initialize(template, options = {})
|
|
135
|
-
# options.merge!(importer: Sass::Importers::HTTP)
|
|
136
|
-
# end
|
|
137
|
-
# end
|
|
138
|
-
#
|
|
139
|
-
# def parse_import_directive(parent, line, root, value, offset)
|
|
140
|
-
# puts 'FUCK YOU'
|
|
141
|
-
# raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath import directives.",
|
|
142
|
-
# :line => @line + 1) unless line.children.empty?
|
|
143
|
-
#
|
|
144
|
-
# scanner = Sass::Util::MultibyteStringScanner.new(value)
|
|
145
|
-
# values = []
|
|
146
|
-
#
|
|
147
|
-
# loop do
|
|
148
|
-
# unless (node = parse_import_arg(scanner, offset + scanner.pos))
|
|
149
|
-
# raise SyntaxError.new(
|
|
150
|
-
# "Invalid @import: expected file to import, was #{scanner.rest.inspect}",
|
|
151
|
-
# :line => @line)
|
|
152
|
-
# end
|
|
153
|
-
# values << node
|
|
154
|
-
# break unless scanner.scan(/,\s*/)
|
|
155
|
-
# end
|
|
156
|
-
#
|
|
157
|
-
# if scanner.scan(/;/)
|
|
158
|
-
# raise SyntaxError.new("Invalid @import: expected end of line, was \";\".",
|
|
159
|
-
# :line => @line)
|
|
160
|
-
# end
|
|
161
|
-
#
|
|
162
|
-
# values
|
|
163
|
-
# end
|
|
164
|
-
#
|
|
165
|
-
# end
|
|
166
|
-
#
|
|
167
|
-
# module Sass
|
|
168
|
-
# module SCSS
|
|
169
|
-
# class Parser
|
|
170
|
-
# @@loaded ||= nil
|
|
171
|
-
# DIRECTIVES.add(:remote)
|
|
172
|
-
#
|
|
173
|
-
# def remote_directive(start_pos)
|
|
174
|
-
# values = []
|
|
175
|
-
# loop do
|
|
176
|
-
# values << expr!(:import_arg)
|
|
177
|
-
# puts 'VALEEEE: ' + values.to_s
|
|
178
|
-
# break if use_css_import?
|
|
179
|
-
# break unless tok(/,/)
|
|
180
|
-
# ss
|
|
181
|
-
# end
|
|
182
|
-
# puts 'VALEEEE: ' + values.to_s
|
|
183
|
-
# values
|
|
184
|
-
# end
|
|
185
|
-
#
|
|
186
|
-
# def import_arg
|
|
187
|
-
# # start_pos = source_position
|
|
188
|
-
# # # return unless (str = string) || (uri = tok?(/url\(/i))
|
|
189
|
-
# # # @@loaded ||= open(str.to_s) {|f| f.read }
|
|
190
|
-
# # rescue => msg
|
|
191
|
-
# # puts msg.backtrace
|
|
192
|
-
# # puts msg.class.to_s
|
|
193
|
-
# # puts msg.message
|
|
194
|
-
# end
|
|
195
|
-
# end
|
|
196
|
-
# end
|
|
197
|
-
# end
|
|
9
|
+
RemoteSass.location = ENV['RACK_ENV'].nil? ? 'http://localhost:4567/load2' : 'http://guppy.io/load'
|
|
198
10
|
|
|
199
11
|
module Sass
|
|
200
12
|
module Importers
|
|
@@ -214,6 +26,7 @@ module Sass
|
|
|
214
26
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
|
215
27
|
filename = File.basename(uri.to_s, File.extname(uri.to_s))
|
|
216
28
|
uri = "#{uri.scheme}://#{uri.host}:#{uri.port}/load/#{filename}"
|
|
29
|
+
# uri = "http://localhost:9876/load/#{filename}"
|
|
217
30
|
# puts 'uri: ' + uri.to_s
|
|
218
31
|
response = http.get uri.to_s
|
|
219
32
|
response.value
|
|
@@ -229,4 +42,6 @@ module Sass
|
|
|
229
42
|
end
|
|
230
43
|
end
|
|
231
44
|
end
|
|
232
|
-
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|