stitch-plus 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +2 -0
- data/README.md +8 -5
- data/lib/stitch-plus.rb +10 -8
- data/lib/stitch-plus/version.rb +1 -1
- data/test/test.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzhlZjFmOGVjNzAzNWQ5NDY3MWY0MDEzNzZjZjE1MDQ2Njc0M2YyYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTFmYjU5OGE3NmVjZGNkNzY0MTAxYTNkNDUzMjk1Yjc3NGJlNTQ2MA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmNiYWM1NmEwN2E3YTAzZjYwMjEyMjNhNjUyMjIxM2M3YzA0NTlkZmE3NTBj
|
10
|
+
ZDEwOGM0MDIyMDdiMDE0MzBhMDNlMDUwYWU4YTA0NzlmNzc2ODBlNTE1ODQ0
|
11
|
+
YmVjYTRmZTNmNDRkYzI0MjdkZThmZmQ1OTIyMTI1YTM5ZDA5N2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmIxZTRiMzJlMDE1Nzc0MzBkNmYzNjg2ZWU2ZDZlZTQwNTVhNjNhZTU0MTZl
|
14
|
+
N2VkOWI0ZGI4MGJiYTcwYjExY2I1ZTQxMjIxN2QyNjc4ODYzYzc0YjkwNTU3
|
15
|
+
MjVkNjFkY2E2MTk3ODE0MmFlNzJjZTJiOGNmMDcwZGYyNTY0ODI=
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
|
|
25
25
|
## Usage
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
# options can be a hash or a path to a
|
28
|
+
# options can be a hash or a path to a YAML file
|
29
29
|
s = StitchPlus.new(options)
|
30
30
|
|
31
31
|
# Returns compiled javascript
|
@@ -53,7 +53,6 @@ s.options
|
|
53
53
|
|
54
54
|
All methods will accept an options hash which will temporarily override previous options options, for example:
|
55
55
|
|
56
|
-
|
57
56
|
```
|
58
57
|
s.write({fingerprint: 'false'})
|
59
58
|
```
|
@@ -63,10 +62,11 @@ This will disable fingerprinting of the filename temporarily and write to app.js
|
|
63
62
|
|
64
63
|
## Configuration
|
65
64
|
|
66
|
-
|
65
|
+
Stitch Plus will accept a hash of options or a string containing a path to a YAML file.
|
67
66
|
|
68
67
|
| Config | Description | Default |
|
69
68
|
|:-----------------|:---------------------------------------------------------------------------|:------------|
|
69
|
+
| `config` | A path to a YAML file containing stitch configurations | nil |
|
70
70
|
| `dependencies` | Array of files/directories to be added first as global javascripts | nil |
|
71
71
|
| `paths` | Array of directories where javascripts will be wrapped as CommonJS modules | nil |
|
72
72
|
| `output` | A path to write the compiled javascript | 'all.js' |
|
@@ -75,7 +75,10 @@ You can configure StichPlus as like this.
|
|
75
75
|
| `uglify` | Smash javascript using the Uglifier gem | false |
|
76
76
|
| `uglify_options` | Options for the Uglifier gem. See the [Uglifier docs](https://github.com/lautis/uglifier#usage) for details. | {} |
|
77
77
|
|
78
|
-
|
78
|
+
Note: Configurations loaded from a YAML file will override any settings in your config hash. So `{config: 'stitch.yml', uglify: false}` will be overwritten if the yaml
|
79
|
+
file sets `uglify: true`.
|
80
|
+
|
81
|
+
### Configuring with YAML
|
79
82
|
|
80
83
|
Stitch can also read configurations from a YAML file. For example, you could
|
81
84
|
create a `stitch.yml` containing the following:
|
@@ -91,7 +94,7 @@ stitch:
|
|
91
94
|
Then you could call stitch like this:
|
92
95
|
|
93
96
|
```ruby
|
94
|
-
js = StitchPlus.new('stitch.yml').compile
|
97
|
+
js = StitchPlus.new({config: 'stitch.yml'}).compile
|
95
98
|
```
|
96
99
|
|
97
100
|
### Regarding "Dependencies"
|
data/lib/stitch-plus.rb
CHANGED
@@ -15,7 +15,8 @@ class StitchPlus
|
|
15
15
|
:fingerprint => false,
|
16
16
|
:cleanup => true,
|
17
17
|
:uglify => false,
|
18
|
-
:uglify_options => {}
|
18
|
+
:uglify_options => {},
|
19
|
+
:config => nil
|
19
20
|
}
|
20
21
|
|
21
22
|
set_options(options)
|
@@ -33,9 +34,8 @@ class StitchPlus
|
|
33
34
|
@old_options = @options if temporary
|
34
35
|
|
35
36
|
# If options is a file path, read options from yaml
|
36
|
-
if options.class == String
|
37
|
-
|
38
|
-
end
|
37
|
+
options = { :config => options } if options.class == String
|
38
|
+
options = load_options(options)
|
39
39
|
|
40
40
|
@options = @options.merge symbolize_keys(options)
|
41
41
|
|
@@ -47,7 +47,6 @@ class StitchPlus
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
@options
|
51
50
|
end
|
52
51
|
|
53
52
|
def temp_options(options)
|
@@ -201,9 +200,12 @@ class StitchPlus
|
|
201
200
|
end
|
202
201
|
end
|
203
202
|
|
204
|
-
def load_options(
|
205
|
-
options
|
206
|
-
|
203
|
+
def load_options(options)
|
204
|
+
if options[:config] and File.exist? options[:config]
|
205
|
+
config = YAML::load(File.open(options[:config]))
|
206
|
+
config = config['stitch'] unless config['stitch'].nil?
|
207
|
+
options = options.merge config
|
208
|
+
end
|
207
209
|
options
|
208
210
|
end
|
209
211
|
|
data/lib/stitch-plus/version.rb
CHANGED
data/test/test.rb
CHANGED