Rails 3.1 asset pipeline vendor/assets folder organization - ruby-on-rails-3.1

I'm using the jQuery Tools scrollable library in my Rails 3.1 site with the various assets placed in the vendor/assets folder and it works great.
My question is regarding the best way to organize the various files under vendor/assets. What is the recommended way to organize vendor/assets subfolders? Currently I have this structure:
vendor/assets/
|-- images/
| |-- scrollable/
| <various button/gradient images>
|-- javascripts/
| |-- scrollable/
| jquery.tools.min.js
|-- stylesheets/
| |-- scrollable/
| scrollable-buttons.css
| scrollable-horizontal.css
This is a fairly un-DRY what to do this. I feel that all of the 'scrollable' items should be under one folder.
What is the recommended way to do this without having to manipulate the asset pipeline load paths?
Thanks!

You could organise them this way, which is slightly better in that it keeps stuff related to the plugin in one directory:
vendor/assets/scrollable
|-- images/
| |-- <various button/gradient images>
|-- javascripts/
| |-- jquery.tools.min.js
|-- stylesheets/
| |-- scrollable-buttons.css
| scrollable-horizontal.css
I am pretty sure this will work as rails globs all directories under assets/.

Related

How to specify Dapr component locations with Sidekick?

I'm trying to get started with Sidekick for Dapr, and am having trouble telling Sidekick where the dapr components are.
By default it's going to %USERPROFILE%.dapr\components, but I'd rather it go to a folder local to the solution.
Looking at the code it appears that adding the following to the appsettings.json should work, but it isn't picked up.
"DaprSidekick": {
"RuntimeDirectory": "dapr",
"ComponentsDirectory": "C:\\Dev\\DaprPOC\\components",
}
However the components folder invariably becomes %USERPROFILE%\.dapr\components
Any help on how I specify the component locations with Sidekick?
When you set "RuntimeDirectory": "dapr" Sidekick will automatically look for component files in the dapr/components subdirectory in your solution. Try removing the ComponentsDirectory entry so it returns to defaults, and try a directory structure like this:
|-- MyProject
| |-- MyProject.csproj
| |-- dapr
| | |-- config.yaml
| | |-- components
| | | |-- my_component.yaml
The Dapr Sidecar should then load my_component.yaml.
You can also manually add the components directory in the dependency injection:
services.AddDaprSidekick(configuration, p => p.Sidecar =
new DaprSidecarOptions() { AppId = "daprservice", ComponentsDirectory = "C:\\Dev\\DaprPOC\\components" });

what does Spring Boot multiple modules project's classpath look like?

I am developing a multi-modules project with Spring Boot, and it always confuse me that what does its class path look like .
My project looks like this:
project
|-- module1
| |-- src
| | `-- main
| | |-- java
| | `-- resources
| | |-- /params/applicationContext.xml
| |
| `-- pom.xml
|-- module2
| |-- src
| | `-- main
| | |-- java
| | | `--GetPropertyUtils.java
| | `-- resources
| | `-- /params/batch-jobs.xml
| `-- pom.xml
If Module1 is my web module and module2 is a CommonUtil module,
When the server is started, are two property files(batch-jobs.xml and applicationContext.xml)' classpath the same(which are /resources/params)?
Ist there any document I can learn from?

Spring CLI generates unexpected project structure

When I generate a project with the webpage https://start.spring.io/ and with the configuration: ["group: com.foo", "artifact: bar", "build: maven", "spring boot version: 1.4.2"] I get the following project structure:
folder-name/
|-- mvnw
|-- mvnw.cmd
|-- pom.xml
|-- src
|-- main
| |-- java
| | |-- com
| | |-- foo
| | |--BarApplication.java
| |-- resources
| |-- application.properties
|-- test
|-- java
|-- com
|-- foo
|--BarApplicationTests.java
And when I generate a project with the Spring CLI command:
"spring init -g=com.foo -a=bar -name=bar --build=maven foo-bar" I get the following project structure:
folder-name/
|-- mvnw
|-- mvnw.cmd
|-- pom.xml
|-- src
|-- main
| |-- java
| | |-- com
| | |-- example
| | |--BarApplication.java
| |-- resources
| |-- application.properties
|-- test
|-- java
|-- com
|-- example
|--BarApplicationTests.java
Whatever config I use with Spring CLI. I always get the folder structure "src/java/{top-level domain}/example".
Why is the folder after the top-level domain always named "example", how do I avoid this so that it uses the group and artifact properly so that I get: "src/java/{group's top-level domain}/{group's domain}"?
I guess -a and -g are not correct spring cli params. Only name works fine.
Please referr to How do I use the Paremeters listed in spring init --list.
Specifying the --package-name parameter solved it.

Can I add factorygirl factories to shared gem

I have a set of active_model models I've extracted into a shared gem. I want the gem to also contain their factories for use in rspec tests defined in any of the projects that are using the gem to avoid defining the same factories in each project. Is that possible?
Yeah its possible. You can place the Factories inside your gem. Lets say lib/gem/factories/. Then your other gems can include the factory.
For example when you create the gem 'awesome_gem', you could have the followin structure:
|-- lib
| |-- awesome_gem
| | |-- module1
| | `-- version.rb
| |-- factories
| | |-- factory1.rb
| | `-- factory2.rb
| `-- awesome_gem.rb
|
`-- spec
|-- awesome_gem
`-- spec_helper.rb
Where lib contains your gem code and specs contain your specs.
awesome_gem.rb would define your gem includes such as awesome_gem/version.rb and more includes. However its recommended not to include the factories directory, since an user of your gem could not be using factory_girl.
Once the gem is packed, they can use require awesome_gem/factories/factory1.rb in their tests. Note that you need to specify your factory path in your spec helper to include your shared factories. Note that this solution is not tested, and paths that need to be included may be different. Also you can place the factories directory outside the lib dir, as long it is included by your .gemspec .

How to maven multiple directories in java?

Im having 2 seperate packages under src folder. i wonder how to maven this project?
src
-- com.firstpackage
-- com.secondPackage
As long as they are in one src folder this should not be a problem.
Your typical maven project will look like this:
my-app
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java
So even if you have many packages/folders within src/ that should be no problem.
There is a good guide here how to set up a maven project in 5 mintues.

Resources