guppy 0.0.3 → 0.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 +232 -0
- metadata +3 -3
- data/lib/sinatra/guppy.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f19f8d0a9823cbda444ddc14dac2f93e2facc0e6
|
|
4
|
+
data.tar.gz: 48963d96954a5b9d9d40e448549f8e6fae39fc42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b686aba1c9b08a1c6c09c191dc887a8b4374846ceab574e56f797e2e5a76e2eca15038605ce274cb2e5152b561dcad8ef9130ad69ccb076d862aecc43df2d2d5
|
|
7
|
+
data.tar.gz: 1c7a29ebee8e9d439f620d9a0f0f9f8626c53495b179505260d191d0cca075d92b0ec0a48d285ff2e239fabec9cfaa29b7581e8be80fb4659deab19ebbccf4c2
|
data/lib/guppy.rb
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
require 'rack'
|
|
2
|
+
require 'rack/request'
|
|
3
|
+
require 'sass'
|
|
4
|
+
require 'remote-sass'
|
|
5
|
+
require 'hashie'
|
|
6
|
+
require 'hashie/mash'
|
|
7
|
+
require 'net/http'
|
|
8
|
+
require 'time'
|
|
9
|
+
require 'open-uri'
|
|
10
|
+
|
|
11
|
+
RemoteSass.location = "http://localhost:4567/load/"
|
|
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
|
|
198
|
+
|
|
199
|
+
module Sass
|
|
200
|
+
module Importers
|
|
201
|
+
class HTTP < Base
|
|
202
|
+
def initialize root
|
|
203
|
+
@root = URI.parse root
|
|
204
|
+
unless scheme_allowed? @root
|
|
205
|
+
raise ArgumentError, "Absolute HTTP URIs only"
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
private
|
|
210
|
+
|
|
211
|
+
def _find uri, options
|
|
212
|
+
raise ArgumentError, "Absolute HTTP URIs only" unless scheme_allowed? uri
|
|
213
|
+
# syntax = get_syntax uri
|
|
214
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
|
215
|
+
filename = File.basename(uri.to_s, File.extname(uri.to_s))
|
|
216
|
+
uri = "#{uri.scheme}://#{uri.host}:#{uri.port}/load/#{filename}"
|
|
217
|
+
# puts 'uri: ' + uri.to_s
|
|
218
|
+
response = http.get uri.to_s
|
|
219
|
+
response.value
|
|
220
|
+
options[:importer] = self
|
|
221
|
+
options[:filename] = uri.to_s
|
|
222
|
+
options[:syntax] = :scss
|
|
223
|
+
Sass::Engine.new response.body, options
|
|
224
|
+
end
|
|
225
|
+
rescue => msg
|
|
226
|
+
puts msg.class.to_s
|
|
227
|
+
puts msg.backtrace
|
|
228
|
+
puts msg.message
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: guppy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 'Max Bugaenko '
|
|
@@ -10,13 +10,13 @@ bindir: bin
|
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2014-12-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
13
|
+
description: Guppy Sass Styles
|
|
14
14
|
email: max.bugaenko@gmail.com
|
|
15
15
|
executables: []
|
|
16
16
|
extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
|
18
18
|
files:
|
|
19
|
-
- lib/
|
|
19
|
+
- lib/guppy.rb
|
|
20
20
|
homepage: http://rubygems.org/gems/guppy
|
|
21
21
|
licenses:
|
|
22
22
|
- MIT
|