stitch-plus 1.0.3 → 1.0.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzQ0NDc2ZjVkNmEyMGY4ZDVjYjUwOTBhN2FiNjBhODM3MDQ4NTBhNw==
4
+ MzhlZjFmOGVjNzAzNWQ5NDY3MWY0MDEzNzZjZjE1MDQ2Njc0M2YyYg==
5
5
  data.tar.gz: !binary |-
6
- MTk3MWNkYTY3ZGQ2MDY5ZGViMmEyMWZjNWVjNWU3Y2FjMDdjNjU5Yg==
6
+ OTFmYjU5OGE3NmVjZGNkNzY0MTAxYTNkNDUzMjk1Yjc3NGJlNTQ2MA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Yjg5ZTM0M2E4MGFiMzkyOTQ0N2M1NWY1NjQ2OTc2MzUwNmY4ZTM3MGU4MjZl
10
- ODI5NTczNTRmZWZjNmY5MTFiMmNiOWYyNDIxZDA1MzE2ZjNkNTQyODMxZWMz
11
- MGY1M2Y4MDQ3NGQ2ZDFkNGIwNTA1ODZiZDlhZWVlNzI3YzlkZjM=
9
+ NmNiYWM1NmEwN2E3YTAzZjYwMjEyMjNhNjUyMjIxM2M3YzA0NTlkZmE3NTBj
10
+ ZDEwOGM0MDIyMDdiMDE0MzBhMDNlMDUwYWU4YTA0NzlmNzc2ODBlNTE1ODQ0
11
+ YmVjYTRmZTNmNDRkYzI0MjdkZThmZmQ1OTIyMTI1YTM5ZDA5N2I=
12
12
  data.tar.gz: !binary |-
13
- MjBkNDcyZDRiNTk0ZWJjMmM3Yzc5NjgwNmI0ZTNhMjA1Y2EzYTU4ZmQzNTNk
14
- YzYyMWJhYjA4ZWQwZWM5ODEzMDljZDlhMmM3OWZlMTgxZGUwYmZlOWQ2MzNm
15
- YjM4Y2UxOGM3YTAxYjVhMjc2MmZkYWU1Yzc1ZjMyZjFmMDExMzg=
13
+ NmIxZTRiMzJlMDE1Nzc0MzBkNmYzNjg2ZWU2ZDZlZTQwNTVhNjNhZTU0MTZl
14
+ N2VkOWI0ZGI4MGJiYTcwYjExY2I1ZTQxMjIxN2QyNjc4ODYzYzc0YjkwNTU3
15
+ MjVkNjFkY2E2MTk3ODE0MmFlNzJjZTJiOGNmMDcwZGYyNTY0ODI=
data/CHANGELOG.md CHANGED
@@ -16,3 +16,5 @@
16
16
  ## 1.0.3
17
17
  - Fixed an issue where write was attempting to call old build method.
18
18
 
19
+ ## 1.0.4
20
+ - Options hash now accepts `config` which can point to a YAML file to load configurations.
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 yaml file
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
- You can configure StichPlus as like this.
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
- ### Reading configuration from a file
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 and File.exist? options
37
- options = load_options(options)
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(file)
205
- options = YAML::load(File.open(file)) if File.exist? file
206
- options = options['stitch'] unless options['stitch'].nil?
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
 
@@ -1,3 +1,3 @@
1
1
  module StitchPlusVersion
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
data/test/test.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require '../lib/stitch-plus'
2
2
 
3
3
 
4
- s = StitchPlus.new('stitch.yml')
4
+ s = StitchPlus.new({config: 'stitch.yml'})
5
5
 
6
6
  puts "Javascripts to be compiled:"
7
7
  puts s.all_files.map { |f| " #{f}"}
8
8
 
9
- puts s.compile
9
+ s.write
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stitch-plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis