rails-lineman 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c09ae443fbfb59c625e0f4fa722ef0d09cca2a65
4
- data.tar.gz: bd59365df1100576f3c5010fc8053a3a2a7b57d3
3
+ metadata.gz: 393afef3baaba42183a406dfe785f5f40cc1181e
4
+ data.tar.gz: 005f1a6ab2183d4aae257a4153944c9832ea0c40
5
5
  SHA512:
6
- metadata.gz: e8dd5b4b9ce0ad9f88fa9f9a81e66a6e5a5c921264c8ed1dba7104c9e836e4ef81305a8c3e2913529c98007443ce177adb801f33823d1103434fc5347f6885f3
7
- data.tar.gz: 33a965e03d745a86cae21c21d146c52d88ab8c03cb2ca7cbfc0b5976286034a3bf7f2aeca40995deba0ecbe5fa5584d34a93480a27234b96726927fb86c79309
6
+ metadata.gz: 607f4c45e287b5f15e2aa661e6cea34ecfab56e64f4487a0a2d60f1e02946a7a59b3b4fa7886e0658e827c70f2222ecbea9f4f1c372f8e8265bce97acf09c373
7
+ data.tar.gz: fccde6fca9d205c157f31a41691510ba15807d59826dc660e1de32fbc2996384af683f087067144ccd1b5c84daa34a35440b687a64ddbf17820f01870b139472
data/README.md CHANGED
@@ -15,6 +15,28 @@ config.rails_lineman.lineman_project_location = "some-directory"
15
15
 
16
16
  You can also set an environment variable named `LINEMAN_PROJECT_LOCATION`
17
17
 
18
+ ### Pointing at multiple lineman projects
19
+
20
+ If you want to include multiple lineman projects, then you can provide a hash of logical names mapping to their path location.
21
+
22
+ ```
23
+ config.rails_lineman.lineman_project_location = {
24
+ "my-app" => "app1",
25
+ "admin-ui" => "app2"
26
+ }
27
+ ```
28
+
29
+ The `LINEMAN_PROJECT_LOCATION` env variable will be ignored in this case, but you can of course bring your own like so:
30
+
31
+ ```
32
+ config.rails_lineman.lineman_project_location = {
33
+ "my-app" => ENV['APP1_PATH'],
34
+ "admin-ui" => ENV['APP2_PATH']
35
+ }
36
+ ```
37
+
38
+ A hash configuration will result in your lineman assets being namespaced under "lineman/<app-name>", as opposed to at the root "lineman/" like they usually are. Keep this in mind when referencing your assets (e.g. you would need in this example to reference the second app's CSS as `<%= stylesheet_link_tag "lineman/admin-ui/app" %>`)
39
+
18
40
  ## Specifying asset types
19
41
 
20
42
  By default, rails-lineman will only copy `dist/js` and `dist/css` from your Lineman
@@ -3,15 +3,7 @@ module RailsLineman
3
3
  def initialize(config, descriptor)
4
4
  @descriptor = descriptor.strip
5
5
  @source = File.join(config.lineman_project_location, "dist", descriptor, ".")
6
- @destination = destination
7
- end
8
-
9
- def destination
10
- if is_precompilable?
11
- Rails.root.join(File.join("tmp", "rails_lineman", "lineman"))
12
- else
13
- Rails.root.join(File.join("public", "assets", @descriptor))
14
- end
6
+ @destination = determine_destination(config.lineman_project_namespace)
15
7
  end
16
8
 
17
9
  def ensure_directories
@@ -20,23 +12,31 @@ module RailsLineman
20
12
  end
21
13
  end
22
14
 
15
+ def add_if_precompilable
16
+ return unless is_precompilable?
17
+ Rails.application.config.assets.precompile += Dir.glob("#{@destination}/**/*.#{@descriptor}")
18
+ end
19
+
23
20
  def copy
24
21
  FileUtils.cp_r(@source, @destination)
25
22
  end
26
23
 
27
- def add_if_precompilable
28
- if(is_precompilable?)
29
- Rails.application.config.assets.precompile +=
30
- Dir.glob("#{@destination}/**/*.#{@descriptor}")
31
- end
24
+ def delete
25
+ FileUtils.rm_rf(@destination)
32
26
  end
33
27
 
34
- def is_precompilable?
35
- ["js", "css"].member? @descriptor
28
+ private
29
+
30
+ def determine_destination(namespace)
31
+ if is_precompilable?
32
+ Rails.root.join(File.join(*["tmp", "rails_lineman", "lineman", namespace].compact))
33
+ else
34
+ Rails.root.join(File.join(*["public", "assets", namespace, @descriptor].compact))
35
+ end
36
36
  end
37
37
 
38
- def delete
39
- FileUtils.rm_rf(@destination)
38
+ def is_precompilable?
39
+ ["js", "css"].include?(@descriptor)
40
40
  end
41
41
  end
42
42
  end
@@ -65,18 +65,17 @@ module RailsLineman
65
65
  end
66
66
 
67
67
  def install_node_js_on_heroku
68
- if heroku?
69
- puts "It looks like we're on heroku, so let's install Node.js"
70
- system <<-BASH
71
- node_version=$(curl --silent --get https://semver.io/node/resolve)
72
- node_url="http://s3pository.heroku.com/node/v$node_version/node-v$node_version-linux-x64.tar.gz"
73
- curl "$node_url" -s -o - | tar xzf - -C .
74
- mv node-v$node_version-linux-x64 heroku_node_install
75
- chmod +x heroku_node_install/bin/*
76
- export PATH="$PATH:$(pwd)/heroku_node_install/bin"
77
- BASH
78
- ENV['PATH'] += ":#{Dir.pwd}/heroku_node_install/bin"
79
- end
68
+ return unless heroku? && !ENV['PATH'].include?("#{Dir.pwd}/heroku_node_install/bin")
69
+ puts "It looks like we're on heroku, so let's install Node.js"
70
+ system <<-BASH
71
+ node_version=$(curl --silent --get https://semver.io/node/resolve)
72
+ node_url="http://s3pository.heroku.com/node/v$node_version/node-v$node_version-linux-x64.tar.gz"
73
+ curl "$node_url" -s -o - | tar xzf - -C .
74
+ mv node-v$node_version-linux-x64 heroku_node_install
75
+ chmod +x heroku_node_install/bin/*
76
+ export PATH="$PATH:$(pwd)/heroku_node_install/bin"
77
+ BASH
78
+ ENV['PATH'] += ":#{Dir.pwd}/heroku_node_install/bin"
80
79
  end
81
80
 
82
81
  def heroku?
@@ -0,0 +1,29 @@
1
+ require 'rails_lineman/lineman_doer'
2
+
3
+ module RailsLineman
4
+ class MetaLinemanDoer
5
+ def initialize(config)
6
+ @lineman_doers = options_per_project(config).map {|c| LinemanDoer.new(c) }
7
+ end
8
+
9
+ def precompile_assets
10
+ @lineman_doers.map(&:precompile_assets)
11
+ end
12
+
13
+ def destroy_assets
14
+ @lineman_doers.map(&:destroy_assets)
15
+ end
16
+
17
+ private
18
+
19
+ def options_per_project(config)
20
+ return [config] unless config.lineman_project_location.respond_to?(:keys)
21
+ config.lineman_project_location.map do |(name, location)|
22
+ config.dup.tap do |single_project_config|
23
+ single_project_config.lineman_project_location = location
24
+ single_project_config.lineman_project_namespace = name.to_s
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -3,6 +3,7 @@ module RailsLineman
3
3
  config.rails_lineman = ActiveSupport::OrderedOptions.new
4
4
 
5
5
  config.rails_lineman.lineman_project_location = ENV['LINEMAN_PROJECT_LOCATION']
6
+ config.rails_lineman.lineman_project_namespace = nil
6
7
  config.rails_lineman.lineman_assets = ENV['LINEMAN_ASSETS'] || [:js, :css]
7
8
  config.rails_lineman.remove_lineman_assets_after_asset_pipeline_precompilation = false
8
9
  config.rails_lineman.skip_build = false
@@ -13,7 +14,7 @@ module RailsLineman
13
14
  load(File.join(File.dirname(__FILE__), '..', 'tasks', 'assets_precompile.rake'))
14
15
  end
15
16
 
16
- initializer "rails_jasmine.add_asset_paths" do
17
+ initializer "rails_lineman.add_asset_paths" do
17
18
  Rails.application.config.assets.paths |= config.rails_lineman.asset_paths.map { |path| Rails.root.join(path) }
18
19
  end
19
20
  end
@@ -1,3 +1,3 @@
1
1
  module RailsLineman
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,16 +1,22 @@
1
1
  require 'rails_lineman/task_helpers'
2
2
 
3
- require 'rails_lineman/lineman_doer'
3
+ require 'rails_lineman/meta_lineman_doer'
4
4
 
5
5
  namespace :assets do
6
6
  desc 'Compile all the assets named in config.assets.precompile (Wrapped by rails-lineman)'
7
7
  RailsLineman::TaskHelpers.override_task :precompile => :environment do
8
8
  begin
9
- lineman_doer = RailsLineman::LinemanDoer.new(Rails.application.config.rails_lineman)
10
- lineman_doer.precompile_assets
9
+ config = Rails.application.config.rails_lineman
10
+ if config.lineman_project_location.present?
11
+ lineman_doer = RailsLineman::MetaLinemanDoer.new(config)
12
+ lineman_doer.precompile_assets
13
+ else
14
+ puts "WARNING: No Lineman project location was set (see: `config.rails_lineman.lineman_project_location`). Skipping Lineman build"
15
+ end
16
+
11
17
  Rake::Task["assets:precompile:original"].execute
12
18
  ensure
13
- lineman_doer.destroy_assets
19
+ lineman_doer.try(:destroy_assets)
14
20
  end
15
21
  end
16
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-lineman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-28 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -55,6 +55,7 @@ files:
55
55
  - lib/rails_lineman/asset.rb
56
56
  - lib/rails_lineman/ext/rake/task_manager.rb
57
57
  - lib/rails_lineman/lineman_doer.rb
58
+ - lib/rails_lineman/meta_lineman_doer.rb
58
59
  - lib/rails_lineman/railtie.rb
59
60
  - lib/rails_lineman/task_helpers.rb
60
61
  - lib/rails_lineman/version.rb
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  version: '0'
81
82
  requirements: []
82
83
  rubyforge_project:
83
- rubygems_version: 2.0.3
84
+ rubygems_version: 2.0.14
84
85
  signing_key:
85
86
  specification_version: 4
86
87
  summary: Helps Rails apps integrate a Lineman into their build by wrapping rake assets:precompile.