sinatra-assets_linker 1.0.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzljZmNhZTM1OTFjMGZjMGJlMTMzNWZlYjRmYjZlZjc3NGQyZDA4MQ==
4
+ YjY4YjZhYTZmY2NmYTlmNGQwNWU4OTZkZTQwNDI1N2MyNzkyMmFhMw==
5
5
  data.tar.gz: !binary |-
6
- YTI4MDJjZDc2YWMwZGJjYTA0NjI1NTZkZjI5OTljYzQxN2YzNTY1MQ==
6
+ N2JlNzMwMWU3NWJjNmUyMTdjODVmOWE1N2JjZDdmZDdlY2UxZTk2Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWQ4ZTJlZjA5ZmI3YTQ5YWQ2NDY1ZTg3YTVjNGE2NjNiMDRlNWUzZjZmYzI3
10
- NzljNGIyMTI5NmZiNDRkYjYwYjQ4ZTcwYmQwNDVhNjA0YmQxN2EyNWUyZjU2
11
- OGQxNjVkZDE5YmJmNjc1MGI3YjA0MTAwNzZmMzBkMGNlOGJhZTQ=
9
+ NGI0YWE3NDA4Njk2NmIyZTQ4ZjU1OTc5OTA3OGE1NDhkMjVmMjhlY2Y5MDJj
10
+ YWRiYmUwNmEzMmY5OWY2NTk2MjE5YjY0NzNhYWM2Y2Y2MzQzNWY3ZTE3NjY0
11
+ MzRmM2NiZmNmNjIxYTIzZDFhMDA3NWI2NmJmNjVkN2U3NmRlN2M=
12
12
  data.tar.gz: !binary |-
13
- NmIwODM3YWMwYTI3ZjU4M2NhN2U5MWNhZTA4ZTZlNjI0Mzg4YTMwMTRiNTgw
14
- MjFkZjY0MTdiYTNjZDdkNDMyODYyNDBkZWNmOTE2NGRjMDMzMmI4YzFhNzY4
15
- MWQ3NjlhNjVmMjcxN2MxZWIwMTdlYzRiYjRjOWUxZWEyOTg0MDY=
13
+ ZGZkNTRhYjIzMGU4ZTI0YzA0MDQ0MmZiYjExZjY0NDlmM2EwYWIyYTMzMjUz
14
+ ZWIwMzRlNDc0ZjQ1YmYwMzYzNGU1MjBkNWZmYWI1YzY1ZDg2MmM5NDZjY2Fm
15
+ OWE5YzY3NDA0ZWMwOWE5NDg5MmFjMWU5OWE5NjgzZTMwYWI0NzA=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ === 2.0.0 (2015.07.04)
2
+
3
+ * rename settings variables
4
+ * add configs to integrate r.js outputs into js_uri
5
+
1
6
  === 1.0.5 (2015.07.01)
2
7
 
3
8
  * refactor
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/README.md CHANGED
@@ -8,8 +8,8 @@ Provided methods:
8
8
  * `js_uri(file_name, add_script_name = true)`
9
9
  * `img_uri(file_name, add_script_name = true)`
10
10
 
11
- They extend the [`uri`][uri] method from the Sinatra.
12
- Always returns relative paths, unless you set `:cdn_url`.
11
+ They extend the [`uri`][uri] method from the Sinatra.
12
+ Always returns relative paths, unless you set `:project_cdn_url`.
13
13
 
14
14
  ## Installation
15
15
 
@@ -36,12 +36,13 @@ class MyApp < Sinatra::Base
36
36
 
37
37
  configure do
38
38
  # define assets dirs
39
- set :css_dir, 'css_dir'
40
- set :js_dir, 'js_dir'
41
- set :img_dir, 'img_dir'
39
+ set :project_css_dir, 'css_dir'
40
+ set :project_js_dir, 'js_dir'
41
+ set :project_img_dir, 'img_dir'
42
42
 
43
43
  # optionally
44
- set :cdn_url, 'http://cdn.net'
44
+ set :project_cdn_url, 'http://cdn.net'
45
+ set :project_assets_verbose, true
45
46
  end
46
47
 
47
48
  end
@@ -62,6 +63,21 @@ css_uri('file.css') # -> http://cdn.net/css_dir/file.css
62
63
  js_uri('file.js') # -> http://cdn.net/js_dir/file.js
63
64
  img_uri('file.jpg') # -> http://cdn.net/img_dir/file.jpg
64
65
  ```
66
+
67
+ ## Configuration and defaults
68
+
69
+ * :project_css_dir [stylesheets]
70
+ * :project_js_dir [javascripts]
71
+ * :project_rjs_dir [js]
72
+ * :project_cdn_url [nil]
73
+ * :project_assets_env [development]
74
+
75
+ ## Requirejs integration
76
+
77
+ If you compile your javastripts into the other directory, you can set it by
78
+ editing the `:project_rjs_dir` option, and switch loading assets from that
79
+ dir by setting: `project_assets_verbose` to `true`.
80
+
65
81
  ## Versioning
66
82
 
67
83
  See [semver.org][semver]
@@ -17,23 +17,24 @@
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
- require 'sinatra/base'
20
+ require "sinatra/base"
21
21
 
22
22
  module Sinatra
23
23
  module AssetsLinker
24
-
25
24
  def css_uri(file_name, add_script_name = true)
26
- css_dir = get_settings(:css_dir, 'stylesheets')
25
+ css_dir = get_settings(:project_css_dir, "stylesheets")
27
26
  generate_uri(css_dir, file_name, add_script_name)
28
27
  end
29
28
 
30
29
  def js_uri(file_name, add_script_name = true)
31
- js_dir = get_settings(:js_dir, 'javascripts')
32
- generate_uri(js_dir, file_name, add_script_name)
30
+ js_dir = get_settings(:project_js_dir, "javascripts")
31
+ rjs_dir = get_settings(:project_rjs_dir, "js")
32
+ choosen_dir = get_settings(:project_assets_verbose, false) ? rjs_dir : js_dir
33
+ generate_uri(choosen_dir, file_name, add_script_name)
33
34
  end
34
35
 
35
36
  def img_uri(file_name, add_script_name = true)
36
- img_dir = get_settings(:img_dir, 'images')
37
+ img_dir = get_settings(:project_img_dir, "images")
37
38
  generate_uri(img_dir, file_name, add_script_name)
38
39
  end
39
40
 
@@ -46,10 +47,9 @@ module Sinatra
46
47
  def generate_uri(assets_dir, file_name, add_script_name)
47
48
  absolute_path = false
48
49
  relative_url = uri(File.join(assets_dir, file_name), absolute_path, add_script_name)
49
- cdn_url = get_settings(:cdn_url)
50
+ cdn_url = get_settings(:project_cdn_url)
50
51
  return File.join(cdn_url, relative_url) unless cdn_url.nil?
51
52
  relative_url
52
53
  end
53
-
54
54
  end
55
55
  end
@@ -18,5 +18,5 @@
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module SinatraAssetsLinker
21
- VERSION = '1.0.5'
21
+ VERSION = "2.0.0"
22
22
  end
@@ -17,4 +17,4 @@
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
- require 'sinatra/assets_linker'
20
+ require "sinatra/assets_linker"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-assets_linker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Kopciewski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra