sinatra-assets_linker 2.0.2 → 3.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,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODhiOTM1MGU1NWY4ZmM2MGFhZjU4YzNiZWMzNDkxZjBlOGU0NWY4OQ==
5
- data.tar.gz: !binary |-
6
- YzA0NmJmOGYwZTg3YmRjODNkZWVmNWE5OGQ5Zjg3YTJjYzhjNzZlNA==
2
+ SHA1:
3
+ metadata.gz: 68e7f5a193a1fcb2121ca09bc5cc503a4b7ac0df
4
+ data.tar.gz: fa86d5cb4a923074eddafde6391723311eba6b90
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YzY1MzZhODRkODQ4MzIxY2Y1OGVkZWIxOWJjMGRlZDdjMTMxNDk0YzQwMzEy
10
- ZTQ4ZDJlYjE0NGU1NTA5ZWU3M2VhODAzMzFjMGUwM2Y0ZWRiMzlkYTc1NWE3
11
- MzJlMWFlNGNhNmNkNTNiZTMzODVmYzE0YWY4OTcyOTQ4MGM3MjA=
12
- data.tar.gz: !binary |-
13
- NzI5ZTMzY2YxOWY5YmE0YjEzYzI1MDJmYjcwZDMxOThjMzAwODMwOGYwN2Iw
14
- YmIxZDkxZGZkMjgxMDZkZmRmZjM0NmE3NTdiYjlmMmFkNmVlN2VhODA1N2Y5
15
- NDBlODk5OTk2ZTM2YmQzNGE1NjJlNDhmMmRiNGQzZjg3YThjM2I=
6
+ metadata.gz: 69089ac7a508f5872de83feb987544645fbc3a9c121efaa27b718613671b8ef56ede977059e0152c4bbe55968b662649609da2fc0cdc8b8dd90f099bcfe5122f
7
+ data.tar.gz: e7d94a630c774cbcfbfc38925dfb0e21843abff11ca94f7eeac61228a9ca519c256ed33b6bd4a61251ee587d5e8212f18d65df5293f1b870b8744aff06f9aab6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ === 3.0.0 (2016.10.06)
2
+
3
+ * use minitest instead of rspec
4
+ * add additional class for configuration
5
+ * refactoring and cleanup
6
+
1
7
  === 2.0.2 (2015.07.17)
2
8
 
3
9
  * docker ref
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ # Specify your gem's dependencies in mayaml.gemspec
3
4
  gemspec
data/README.md CHANGED
@@ -25,8 +25,25 @@ Or install it yourself as:
25
25
 
26
26
  $ gem install sinatra-assets_linker
27
27
 
28
+ ## Configuration
29
+
30
+ Through `SinatraAssetsLinker::Config` class:
31
+
32
+ ```ruby
33
+ config = SinatraAssetsLinker::Config.new(
34
+ "project_css_dir" => "css_dir" # default: "stylesheets"
35
+ "project_javascripts_dir" => "js_dir" # default: "javascripts"
36
+ "project_js_compressed_dir" => "cjs_dir" # default: "js"
37
+ "project_images_dir" => "img_dir" # default: "images"
38
+ "project_assets_verbose" => true # default: false
39
+ "project_cdn_url" => "http://cdn.net" # default: nil
40
+ )
41
+ ```
42
+
28
43
  ## Usage
29
44
 
45
+ Above methods look for configuration under: `settings.assets_linker_config`, so:
46
+
30
47
  ```ruby
31
48
  require 'sinatra/base'
32
49
  require 'sinatra/assets_linker'
@@ -35,16 +52,8 @@ class MyApp < Sinatra::Base
35
52
  helpers Sinatra::AssetsLinker
36
53
 
37
54
  configure do
38
- # define assets dirs
39
- set :project_css_dir, 'css_dir'
40
- set :project_js_dir, 'js_dir'
41
- set :project_img_dir, 'img_dir'
42
-
43
- # optionally
44
- set :project_cdn_url, 'http://cdn.net'
45
- set :project_assets_verbose, true
55
+ set :assets_linker_config, SinatraAssetsLinker::Config.new(ENV.to_h)
46
56
  end
47
-
48
57
  end
49
58
  ```
50
59
 
@@ -56,7 +65,7 @@ js_uri('file.js') # -> /js_dir/file.js
56
65
  img_uri('file.jpg') # -> /img_dir/file.jpg
57
66
  ```
58
67
 
59
- if you set `:cdn_url` before, you get:
68
+ if you set `"project_cdn_url"` before, you get:
60
69
 
61
70
  ```ruby
62
71
  css_uri('file.css') # -> http://cdn.net/css_dir/file.css
@@ -64,19 +73,10 @@ js_uri('file.js') # -> http://cdn.net/js_dir/file.js
64
73
  img_uri('file.jpg') # -> http://cdn.net/img_dir/file.jpg
65
74
  ```
66
75
 
67
- ## Configuration and defaults
68
-
69
- * :project_css_dir [stylesheets]
70
- * :project_js_dir [javastripts]
71
- * :project_rjs_dir [js]
72
- * :project_cdn_url [nil]
73
- * :project_assets_verbose [false]
74
-
75
- ## Requirejs integration
76
+ ## Assets verbose
76
77
 
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`.
78
+ If you set `"project_assets_verbose"` to `true`, then the `js_uri` method will
79
+ use `project_javascripts_dir` instead of `project_js_compressed_dir`
80
80
 
81
81
  ## Versioning
82
82
 
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (C) 2015 Szymon Kopciewski
3
+ # Copyright (C) 2015,2016 Szymon Kopciewski
4
4
  #
5
5
  # This file is part of SinatraAssetsLinker.
6
6
  #
@@ -22,26 +22,26 @@ require "sinatra/base"
22
22
  module Sinatra
23
23
  module AssetsLinker
24
24
  def css_uri(file_name, add_script_name = true)
25
- css_dir = get_settings(:project_css_dir, "stylesheets")
25
+ css_dir = get_settings(:project_css_dir)
26
26
  generate_uri(css_dir, file_name, add_script_name)
27
27
  end
28
28
 
29
29
  def js_uri(file_name, add_script_name = true)
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) ? js_dir : rjs_dir
30
+ javascript_dir = get_settings(:project_javascripts_dir)
31
+ js_dir = get_settings(:project_js_compressed_dir)
32
+ choosen_dir = get_settings(:project_assets_verbose) ? javascript_dir : js_dir
33
33
  generate_uri(choosen_dir, file_name, add_script_name)
34
34
  end
35
35
 
36
36
  def img_uri(file_name, add_script_name = true)
37
- img_dir = get_settings(:project_img_dir, "images")
37
+ img_dir = get_settings(:project_images_dir)
38
38
  generate_uri(img_dir, file_name, add_script_name)
39
39
  end
40
40
 
41
41
  private
42
42
 
43
- def get_settings(key, default = nil)
44
- settings.respond_to?(key) ? settings.send(key) : default
43
+ def get_settings(key)
44
+ settings.assets_linker_config.fetch(key.to_s)
45
45
  end
46
46
 
47
47
  def generate_uri(assets_dir, file_name, add_script_name)
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2015,2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of SinatraAssetsLinker.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "piko_model"
21
+
22
+ module SinatraAssetsLinker
23
+ class Config < PikoModel::Model
24
+ field "project_css_dir", default: "stylesheets"
25
+ field "project_javascripts_dir", default: "javascripts"
26
+ field "project_js_compressed_dir", default: "js"
27
+ field "project_images_dir", default: "images"
28
+ field "project_assets_verbose", default: false
29
+ field "project_cdn_url", default: nil
30
+ end
31
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (C) 2015 Szymon Kopciewski
3
+ # Copyright (C) 2015,2016 Szymon Kopciewski
4
4
  #
5
5
  # This file is part of SinatraAssetsLinker.
6
6
  #
@@ -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 = "2.0.2"
21
+ VERSION = "3.0.0".freeze
22
22
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (C) 2015 Szymon Kopciewski
3
+ # Copyright (C) 2015,2016 Szymon Kopciewski
4
4
  #
5
5
  # This file is part of SinatraAssetsLinker.
6
6
  #
@@ -18,3 +18,4 @@
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  require "sinatra/assets_linker"
21
+ require "sinatra-assets_linker/config"
metadata CHANGED
@@ -1,87 +1,130 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-assets_linker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 3.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-17 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: piko_model
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ! '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ! '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ! '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ! '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rspec-given
70
+ name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ! '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ! '>='
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rack-test
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - ! '>='
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: codeclimate-test-reporter
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
74
116
  - !ruby/object:Gem::Version
75
117
  version: '0'
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
- - - ! '>='
122
+ - - ">="
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
83
- description: Provides the methods for generating the assets urls.
84
- email: s.kopciewski@gmail.com
125
+ description: Provides methods for generating assets urls.
126
+ email:
127
+ - s.kopciewski@gmail.com
85
128
  executables: []
86
129
  extensions: []
87
130
  extra_rdoc_files: []
@@ -91,6 +134,7 @@ files:
91
134
  - LICENSE
92
135
  - README.md
93
136
  - lib/sinatra-assets_linker.rb
137
+ - lib/sinatra-assets_linker/config.rb
94
138
  - lib/sinatra-assets_linker/version.rb
95
139
  - lib/sinatra/assets_linker.rb
96
140
  homepage: https://github.com/skopciewski/sinatra-assets_linker
@@ -103,17 +147,17 @@ require_paths:
103
147
  - lib
104
148
  required_ruby_version: !ruby/object:Gem::Requirement
105
149
  requirements:
106
- - - ! '>='
150
+ - - ">="
107
151
  - !ruby/object:Gem::Version
108
152
  version: '0'
109
153
  required_rubygems_version: !ruby/object:Gem::Requirement
110
154
  requirements:
111
- - - ! '>='
155
+ - - ">="
112
156
  - !ruby/object:Gem::Version
113
157
  version: '0'
114
158
  requirements: []
115
159
  rubyforge_project:
116
- rubygems_version: 2.2.5
160
+ rubygems_version: 2.4.8
117
161
  signing_key:
118
162
  specification_version: 4
119
163
  summary: The Sinatra helper for the assets links.