rails-lineman 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6790909aea1e6314f0f4921f925d6d7e2c54f461
4
- data.tar.gz: 5af34142f627fc34fb0622614d6af9aa650cb188
3
+ metadata.gz: c09ae443fbfb59c625e0f4fa722ef0d09cca2a65
4
+ data.tar.gz: bd59365df1100576f3c5010fc8053a3a2a7b57d3
5
5
  SHA512:
6
- metadata.gz: 0aa9f969c8c098b687533f461c9c52849d76707705a8b0928df86ff856654b9bbf657bbef7e5cda6ed1d9d1e0e7f03711ebdf8e03a91902cc176d1a8af716443
7
- data.tar.gz: 4fd7bcb19b3c025444dc1c3c3c54ce6c0344f8b3417c5c83da34ea44122885b0fa07699dd0b52df287a6f25a909b566b93671498a5be1ede486c4d2d45bf6ebc
6
+ metadata.gz: e8dd5b4b9ce0ad9f88fa9f9a81e66a6e5a5c921264c8ed1dba7104c9e836e4ef81305a8c3e2913529c98007443ce177adb801f33823d1103434fc5347f6885f3
7
+ data.tar.gz: 33a965e03d745a86cae21c21d146c52d88ab8c03cb2ca7cbfc0b5976286034a3bf7f2aeca40995deba0ecbe5fa5584d34a93480a27234b96726927fb86c79309
data/README.md CHANGED
@@ -50,3 +50,18 @@ From your templates you'll be able to require lineman-built JS & CSS like so:
50
50
  <%= javascript_include_tag "lineman/app" %>
51
51
  ```
52
52
 
53
+ ## Build environments that don't support node.js
54
+
55
+ Sometimes your existing deployment environment will support Ruby (because your
56
+ app runs there), but will lack a proper Node.js runtime environment. In those
57
+ cases, you may desire to cook up your own way to push the `dist` directory from
58
+ your lineman application to your deployment server such that when *it* runs
59
+ `rake assets:precompile` that the lineman assets will be in the proper place
60
+ and copied at the appropriate moment despite not having been built on the actual
61
+ server.
62
+
63
+ In cases like these, you may set:
64
+
65
+ ```
66
+ config.rails_lineman.skip_build = true
67
+ ```
@@ -0,0 +1,42 @@
1
+ module RailsLineman
2
+ class Asset
3
+ def initialize(config, descriptor)
4
+ @descriptor = descriptor.strip
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
15
+ end
16
+
17
+ def ensure_directories
18
+ [@source, @destination].each do |path|
19
+ FileUtils.mkdir_p(path)
20
+ end
21
+ end
22
+
23
+ def copy
24
+ FileUtils.cp_r(@source, @destination)
25
+ end
26
+
27
+ def add_if_precompilable
28
+ if(is_precompilable?)
29
+ Rails.application.config.assets.precompile +=
30
+ Dir.glob("#{@destination}/**/*.#{@descriptor}")
31
+ end
32
+ end
33
+
34
+ def is_precompilable?
35
+ ["js", "css"].member? @descriptor
36
+ end
37
+
38
+ def delete
39
+ FileUtils.rm_rf(@destination)
40
+ end
41
+ end
42
+ end
@@ -1,83 +1,47 @@
1
1
  require 'pathname'
2
2
  require 'fileutils'
3
+ require 'rails_lineman/asset'
3
4
 
4
5
  module RailsLineman
5
-
6
- class Asset
7
- def initialize(config, descriptor)
8
- @descriptor = descriptor.strip
9
- @source = File.join(config.lineman_project_location, "dist", descriptor, ".")
10
- @destination = destination
11
- end
12
-
13
- def destination
14
- if is_precompilable?
15
- Rails.root.join(File.join("tmp", "rails_lineman", "lineman"))
16
- else
17
- Rails.root.join(File.join("public", "assets", @descriptor))
18
- end
19
- end
20
-
21
- def ensure_directories
22
- [@source, @destination].each do |path|
23
- FileUtils.mkdir_p(path)
24
- end
25
- end
26
-
27
- def copy
28
- FileUtils.cp_r(@source, @destination)
29
- end
30
-
31
- def add_if_precompilable
32
- if(is_precompilable?)
33
- Rails.application.config.assets.precompile +=
34
- Dir.glob("#{@destination}/**/*.#{@descriptor}")
35
- end
36
- end
37
-
38
- def is_precompilable?
39
- ["js", "css"].member? @descriptor
40
- end
41
-
42
- def delete
43
- FileUtils.rm_rf(@destination)
44
- end
45
- end
46
-
47
6
  class LinemanDoer
48
7
  def initialize(config)
49
8
  gather_assets(config)
50
9
  @lineman_project_location = config.lineman_project_location
10
+ @skip_build = config.skip_build
51
11
  @tmp_dir = Rails.root.join(config.tmp_dir)
52
12
  @remove_lineman_assets_after_asset_pipeline_precompilation = config.remove_lineman_assets_after_asset_pipeline_precompilation
53
13
  end
54
14
 
15
+ def precompile_assets
16
+ absolutify_lineman_path
17
+ perform_lineman_build unless @skip_build
18
+ ensure_directories_exist
19
+ copy
20
+ add_to_precompile_list
21
+ end
22
+
23
+ def destroy_assets
24
+ delete_some_assets_for_whatever_reason if @remove_lineman_assets_after_asset_pipeline_precompilation
25
+ delete_tmp_dir
26
+ end
27
+
28
+ private
29
+
55
30
  def gather_assets(config)
56
31
  @assets = config.lineman_assets.collect do |d|
57
32
  Asset.new(config, d.to_s)
58
33
  end
59
34
  end
60
35
 
61
- def build
62
- absolutify_lineman_path
36
+ def perform_lineman_build
63
37
  chdir @lineman_project_location do
64
38
  install_node_js_on_heroku
65
39
  run_npm_install
66
40
  run_lineman_build
67
41
  delete_node_js_from_heroku
68
42
  end
69
- ensure_directories_exist
70
- copy
71
- add_to_precompile_list
72
- end
73
-
74
- def destroy
75
- delete_some_assets_for_whatever_reason if @remove_lineman_assets_after_asset_pipeline_precompilation
76
- delete_tmp_dir
77
43
  end
78
44
 
79
- private
80
-
81
45
  def absolutify_lineman_path
82
46
  @lineman_project_location = Pathname.new(@lineman_project_location).realpath.to_s
83
47
  rescue => error
@@ -5,7 +5,7 @@ module RailsLineman
5
5
  config.rails_lineman.lineman_project_location = ENV['LINEMAN_PROJECT_LOCATION']
6
6
  config.rails_lineman.lineman_assets = ENV['LINEMAN_ASSETS'] || [:js, :css]
7
7
  config.rails_lineman.remove_lineman_assets_after_asset_pipeline_precompilation = false
8
-
8
+ config.rails_lineman.skip_build = false
9
9
  config.rails_lineman.tmp_dir = File.join("tmp", "rails_lineman")
10
10
  config.rails_lineman.asset_paths = [ config.rails_lineman.tmp_dir ]
11
11
 
@@ -1,3 +1,3 @@
1
1
  module RailsLineman
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -7,10 +7,10 @@ namespace :assets do
7
7
  RailsLineman::TaskHelpers.override_task :precompile => :environment do
8
8
  begin
9
9
  lineman_doer = RailsLineman::LinemanDoer.new(Rails.application.config.rails_lineman)
10
- lineman_doer.build
10
+ lineman_doer.precompile_assets
11
11
  Rake::Task["assets:precompile:original"].execute
12
12
  ensure
13
- lineman_doer.destroy
13
+ lineman_doer.destroy_assets
14
14
  end
15
15
  end
16
16
  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.1.1
4
+ version: 0.2.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-12 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -52,6 +52,7 @@ files:
52
52
  - README.md
53
53
  - Rakefile
54
54
  - lib/rails-lineman.rb
55
+ - lib/rails_lineman/asset.rb
55
56
  - lib/rails_lineman/ext/rake/task_manager.rb
56
57
  - lib/rails_lineman/lineman_doer.rb
57
58
  - lib/rails_lineman/railtie.rb