Compass/Sinatra Loading Modules - css

I'm trying to load the CSS3 and reset modules within my SCSS files, but I'm getting an error when trying to import any Compass-specific module.
Sinatra App:
require 'rubygems'
require 'sinatra'
require 'sass'
require 'compass'
configure do
set :scss, {:style => :compact, :debug_info => false}
Compass.add_project_configuration(File.join(Sinatra::Application.root, 'config', 'compass.rb'))
end
get '/css/:name.css' do
content_type 'text/css', :charset => 'utf-8'
scss(:"stylesheets/#{params[:name]}" )
end
style.scss:
#import "compass/reset";
#import "compass/css3";
Error Message:
Sass::SyntaxError at /css/style.css
File to import not found or unreadable: compass/reset. Load path: /Users/work/repos/mysite
Is there a gem I can install to automatically pull these modules, or do I have to move the Compass files into my Sinatra application?

After a correct configuration in your compass.rb, usually is enough to add something like:
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
sass params[:name].to_sym, Compass.sass_engine_options
end
to your routes. Sinatra Integration, Sample project, or something you may consider useful: Better Compass integration for Sinatra (extracted from BigBand)
In a modular Modular App I use something like:
module Assets
# #Sass/Compass Handler
class Stylesheets < Sinatra::Base
register CompassInitializer
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
sass params[:name].to_sym, Compass.sass_engine_options
end
end
end
and I have in my lib folder a file compass_plugin.rb
module CompassInitializer
def self.registered(app)
require 'sass/plugin/rack'
Compass.configuration do |config|
config.project_path = Padrino.root
config.sass_dir = "app/stylesheets"
config.project_type = :stand_alone
config.http_path = "/"
config.css_dir = "public/stylesheets"
config.images_dir = "public/images"
config.javascripts_dir = "public/javascripts"
config.output_style = :compressed
end
Compass.configure_sass_plugin!
Compass.handle_configuration_change!
app.use Sass::Plugin::Rack
end
end
which is shamelessly stolen from Padrino framework

I think you should just:
$ gem install compass
$ compass create

Related

cx_freeze include css file and image in dash app

I have some difficulties to apply a css file to my dash app when using cx_freeze. If I run python app.py the layout is properly applied, however not if I am executing the .exe generated by cx_freeze. Then the default html layout is displayed. The css and the image appear in the same directory where the .exe is located.
This is how my setup.py looks like.
from setuptools import find_packages
from cx_Freeze import setup, Executable
options = {
'build_exe': {
'includes': [
'cx_Logging', 'idna', 'idna.idnadata'
],
'packages': [
'asyncio', 'flask', 'jinja2', 'dash', 'plotly', 'waitress'
],
'excludes': ['tkinter'],
'include_files': [
'assets/logo.jpg', 'assets/style.css'
],
}
}
executables = [
Executable('server.py',
base='console',
targetName='dash_app.exe')
]
setup(
name='BI_Report',
packages=find_packages(),
version='0.0.1',
description='rig',
executables=executables,
options=options
)
To load the external files I use a helper function as suggested here:
def find_data_file(filename):
if getattr(sys, 'frozen', False):
# The application is frozen
datadir = os.path.dirname(sys.executable)
else:
# The application is not frozen
# Change this bit to match where you store your data files:
datadir = os.path.dirname(__file__)
return os.path.join(datadir, filename)
app = dash.Dash(__name__,
assets_folder=find_data_file('assets/'))
I am using:
Python 3.7.6
dash 1.9.1
cx-freeze 6.1
Any help much appreciated!

simplecov-rcov is throwing a Encoding::UndefinedConversionError

I have the following setup
Gemfile
gem 'simplecov', require: false
gem 'simplecov-rcov', require: false
spec_helper.rb
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start 'rails'
In the specs I have tests for views.
After the tests are run and rcov tries to save the rcov_result I receive the following error:
/.rvm/gems/ruby-2.5.1/gems/simplecov-rcov-0.2.3/lib/simplecov-rcov.rb:52:in `write': "\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
Is there a way to solve this?
Update the simplecov and simplecov-rcov gems to the latest versions and place the following code in your test/spec-helpers:
class SimpleCov::Formatter::RcovFormatter
def write_file(template, output_filename, binding)
rcov_result = template.result( binding )
File.open( output_filename, 'wb' ) do |file_result|
file_result.write rcov_result
end
end
end
More information here on files modes: File opening mode in Ruby

cocoapods dylib dependency use_frameworks

I have built a dynamic library (to add ICU support in this case) which i need to add as a dependency to a pod. For that I created a pod with the following podspec (I removed things like authors, license, ... to keep it short)
Pod::Spec.new do |s|
s.name = 'unicode'
s.version = '57.0'
s.source = { :git => "git#bitbucket.org:mycompany/unicode.git", :tag => "#{s.version}" }
s.requires_arc = false
s.platform = :ios, '8.0'
s.default_subspecs = 'all'
s.subspec 'all' do |ss|
ss.header_mappings_dir = 'icu4c/include'
ss.source_files = 'icu4c/include/**/*.h'
ss.public_header_files = 'icu4c/include/**/*.h'
ss.vendored_libraries = 'Frameworks/lib*.dylib'
end
end
Here i have a second pod where i need to link these libraries too
Pod::Spec.new do |s|
s.name = 'sqlite3'
s.version = '3.14.2'
s.summary = 'SQLite is an embedded SQL database engine'
s.documentation_url = 'https://sqlite.org/docs.html'
s.homepage = 'https://github.com/clemensg/sqlite3pod'
s.authors = { 'Clemens Gruber' => 'clemensgru#gmail.com' }
v = s.version.to_s.split('.')
archive_name = "sqlite-amalgamation-"+v[0]+v[1].rjust(2, '0')+v[2].rjust(2, '0')+"00"
#s.source = { :http => "https://www.sqlite.org/#{Time.now.year}/#{archive_name}.zip" }
s.source = { :git => "git#bitbucket.org:wrthphoenixspeedy/sqlite3.git", :tag => "#{s.version}" }
s.requires_arc = false
s.platform = :ios, '8.0'
s.default_subspecs = 'common'
s.subspec 'common' do |ss|
ss.source_files = "#{archive_name}/sqlite*.{h,c}"
ss.osx.pod_target_xcconfig = { 'OTHER_CFLAGS' => '$(inherited) -DHAVE_USLEEP=1' }
# Disable OS X / AFP locking code on mobile platforms (iOS, tvOS, watchOS)
sqlite_xcconfig_ios = { 'OTHER_CFLAGS' => '$(inherited) -DHAVE_USLEEP=1 -DSQLITE_ENABLE_LOCKING_STYLE=0' }
ss.ios.pod_target_xcconfig = sqlite_xcconfig_ios
ss.tvos.pod_target_xcconfig = sqlite_xcconfig_ios
ss.watchos.pod_target_xcconfig = sqlite_xcconfig_ios
end
# enable support for icu - International Components for Unicode
s.subspec 'icu' do |ss|
ss.dependency 'sqlite3/common'
ss.pod_target_xcconfig = { 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_ENABLE_ICU=1' }
ss.dependency 'unicode', '57.0'
ss.libraries = 'icucore', 'icudata.57.1', 'icui18n.57.1', 'icuio.57.1', 'icule.57.1', 'iculx.57.1', 'icutu.57.1', 'icuuc.57.1'
end
end
And with these i am able to compile it. Cocoapods is copying these libraries on build time into the folder ../Frameworks/ rather than to do while on run time. Instead it fails because it says that it doesn't find the library in ../lib.
dyld: Library not loaded: ../lib/libicudata.57.1.dylib
Referenced from: /var/containers/Bundle/Application/9663CB3A-6ACD-487E-A92D-48F8AFE5260C/MyApp.app/MyApp
Reason: image not found
I have to use use_frameworks! because i am using some Swift frameworks too.
So i am doing something wrong... the question is, can i link a dylib from one pod to another pod? and if so... how?
Based on the disparity between "libs" and "Frameworks", this looks like an issue with either runpath search paths (the running app is not looking for the library from Frameworks), or with the install name of the library not matching the location where it's placed relative to where it is dynamically loaded from.
Make sure that in the app that bundles the dynamic library you have the following paths included in your "Runpath Search Path": #executable_path/../Frameworks, #loader_path/../Frameworks
Make sure that the "Dynamic Library Install Name" name of the library being loaded is set to the equivalent of #rpath/$(EXECUTABLE_PATH) (i.e. in your case it should be "#rpath/libicudata.57.1.dylib"). You can set it during build time using the -install_name compiler (linker?) flag, or with install_name_tool, like so: install_name_tool -id "#rpath/libicudata.57.1.dylib" libicudata.57.1.dylib . Hopefully doesn't come to this though.

Compiling files with laravel + elixir

I am taking over a laravel project that uses elixir to compile various sass, coffeescript, and javascript files:
elixir(function(mix) {
mix.sass('main.scss')
.coffee(['methods.coffee', 'details.coffee', 'cars.coffee', 'context-menu.coffee', 'content.coffee', 'projects.coffee', 'main.coffee'])
.styles(['main.css'], 'public/css/all.css', 'public/css')
.scripts(['app.js'], 'public/js/all.js', 'public/js')
.version(['css/all.css', 'js/all.js']);
});
My questions:
What is the destination of the files below after they are compiled?
.coffee(['methods.coffee', 'details.coffee', 'cars.coffee', 'context-menu.coffee', 'content.coffee', 'projects.coffee', 'main.coffee'])
Does the line below compile the app.js file as all.js and store it in public/js?
.scripts(['app.js'], 'public/js/all.js', 'public/js')
Similarly, does the line below compile the main.css file as all.css and store it in public/css?
.styles(['main.css'], 'public/css/all.css', 'public/css')
Thanks in advance!
By default, the task will place the compiled in:
sass = public/css/app.css
coffee = public/js/app.js
scripts= public/js/all.js
styles = public/css/all.css
UPDATE
To change the output path just pass a second argument to the method
e.g.
mix.styles([
'bundle.css'
], 'public/css/aloha');

Can I call js module in grunt configuration file gruntfile.coffee?

I'm using gruntjs to building my project. I want to utilize js module for multi-projects i.e. multi-gruntfile.
I see the API and search grunt plugins but not find what I want. It seems the only way is taking advantage of grunt.config and load-grunt-tasks plugin.
So I created js module file in the tasks folder and set configuration data in it like the following(by coffeescript):
module.exports = (grunt) ->
_ret=null
environmentObj=
test: "test"
verify: "beta"
formal: "release"
grunt.config.set('executeCustomTasks', (arg, arg1, arr) ->
str = constructPromptStr();
_ret = getVerInfo(arg1, arg)
setArg()
...
)
setArg = ->
if _ret.verName is 'formal'
_ret.verName = ''
grunt.config.set('state',_ret.verName)
grunt.config.set('date',_ret.verNum)
and call it like this:
grunt.task.registerTask('default', 'execute tasks by param by grunt cli', (arg, arg1) ->
grunt.config.get('executeCustomTasks')(arg, arg1,getTasksArr(arg))
)
Is what I do correct? Is it the best practice?
Best Regards
I understand now. grunt.task.loadTasks(path) can Load task-related files so I can create and reference the files in the path.
reference links:
http://gruntjs.com/api/grunt.task
https://github.com/cowboy/wesbos/commit/5a2980a7818957cbaeedcd7552af9ce54e05e3fb

Resources