bobkit 0.0.2 → 0.0.3

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: 7db6c694ea1adaf5fec4c8dab145d0204744aca3
4
- data.tar.gz: 369d8e39afb9dea61523f7f8208283946d840b9f
3
+ metadata.gz: ded1105026bb28b99fef542edb1421bbeb61d6a4
4
+ data.tar.gz: 4f544c6cc88490ebcbbc42417a1e0a906e9cc594
5
5
  SHA512:
6
- metadata.gz: ed1294af999ff86255b1fd08091085478b19c3440955c706b220de5ed0dd86b029b3be09974cc9a36376a3691d5b8201fa2842600cc0a6214bc9134b1712a458
7
- data.tar.gz: f88938070983f3e62cbf2705449a66de85b4d5512624851d93e1b76b03ee85728b79634e94d42930a6a44d6ff10a171c93db607062e182a51c065ec653641890
6
+ metadata.gz: b17f6df9d253d6067e3503d1b28f28b9978ccf25efac452aa2dd8a6c28676a75ba46755a5d67d201b448acae18d430d2696244171e1a4a442da287ac9378c1df
7
+ data.tar.gz: b815b313bbad1238f78e3cbe0929f4c9075f790bd512c6396dbfe89683608688769ba7feee9fa02f7887d558e18da79de57ff75315ca4e4b052beade5b1a4716
data/README.md CHANGED
@@ -19,7 +19,7 @@ The design intentions were:
19
19
  - To be packaged as a library, and not a command line tool.
20
20
  - To provide sensible default locations that are easily overridable.
21
21
  - To add `render` and `layout` support to Slim (Rails-like).
22
- - To add `@import 'globbing/*`` support to SCSS (Rails-like).
22
+ - To add `@import 'globbing/*'` support to SCSS (Rails-like).
23
23
 
24
24
  ---
25
25
 
@@ -50,7 +50,7 @@ The basic usage pattern is this:
50
50
 
51
51
  ```ruby
52
52
  require 'bobkit'
53
- include Bobkit::Actions
53
+ include Bobkit::Tasks
54
54
 
55
55
  # Convert Slim to HTML string
56
56
  html = render 'youtube', video: 'hi9tOILaiNs'
@@ -190,12 +190,34 @@ create_folder_for 'some/folder/with/file.png'
190
190
  ```
191
191
 
192
192
 
193
+ ### File Watcher
194
+
195
+ Bobkit comes bundled with FileWatcher, and has a shortcut method to
196
+ use it.
197
+
198
+ ```ruby
199
+ include Bobkit::Watcher
200
+
201
+ watch do |filename, event|
202
+ puts "#{event}: #{filename}"
203
+ generate
204
+ end
205
+
206
+ def generate
207
+ # Your generation logic here
208
+ end
209
+ ```
210
+
211
+ The watch command is just like
212
+ `FileWatcher.new([...]).watch() do |filename, event|`
213
+ with the exception that the array of paths to watch is optional. If none
214
+ provided, we will watch all the input folders.
215
+
193
216
  Todo
194
217
  --------------------------------------------------
195
218
 
196
219
  - [ ] YAML loader (data_folder?)
197
220
  - [ ] CSV Loader (data_folder?)
198
- - [ ] Maybe: Include file watcher and auto generate
199
221
  - [ ] Maybe: Render from/to Markdown
200
222
  - [ ] Maybe: Render to JSON
201
223
 
@@ -3,14 +3,19 @@ require 'sass'
3
3
  require 'sass-globbing'
4
4
  require 'slim'
5
5
  require 'coffee_script'
6
+ require 'filewatcher'
6
7
 
7
8
  require 'bobkit/options_base'
8
9
  require 'bobkit/location_options'
9
10
  require 'bobkit/file_helpers'
11
+ require 'bobkit/scope_options'
12
+ require 'bobkit/sass_options'
10
13
  require 'bobkit/sass_bridge'
14
+ require 'bobkit/slim_options'
11
15
  require 'bobkit/slim_bridge'
12
16
  require 'bobkit/coffee_bridge'
13
17
  require 'bobkit/assets'
18
+ require 'bobkit/watcher'
14
19
 
15
20
  require 'bobkit/scope'
16
- require 'bobkit/actions'
21
+ require 'bobkit/tasks'
@@ -1,6 +1,7 @@
1
1
  module Bobkit
2
2
  module SassBridge
3
3
  include FileHelpers
4
+ include SassOptions
4
5
 
5
6
  def compile_css(file, options={})
6
7
  @file = "#{styles_folder}/#{file}.scss"
@@ -0,0 +1,16 @@
1
+ module Bobkit
2
+ module SassOptions
3
+ def scss_options(options=nil)
4
+ setopt :scss_options, options, scss_defaults
5
+ end
6
+ alias_method :sass_options, :scss_options
7
+
8
+
9
+ protected
10
+
11
+ def scss_defaults
12
+ { cache: true, syntax: :scss, style: :nested,
13
+ load_paths: [styles_folder] }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ module Bobkit
2
+ module ScopeOptions
3
+ include OptionsBase
4
+
5
+ def scope(scope=nil)
6
+ scope ? setopt(:scope, Scope.new(scope)) : options[:scope]
7
+ end
8
+ end
9
+ end
@@ -1,6 +1,7 @@
1
1
  module Bobkit
2
2
  module SlimBridge
3
3
  include FileHelpers
4
+ include SlimOptions
4
5
 
5
6
  def render(options={}, extra_options={})
6
7
  options = { partial: options }.merge(extra_options) if options.is_a? String
@@ -0,0 +1,13 @@
1
+ module Bobkit
2
+ module SlimOptions
3
+ def slim_options(options=nil)
4
+ setopt :slim_options, options, slim_defaults
5
+ end
6
+
7
+ protected
8
+
9
+ def slim_defaults
10
+ { pretty: true, disable_escape: true }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Bobkit
2
+ module Tasks
3
+ include OptionsBase
4
+ include LocationOptions
5
+ include SassBridge
6
+ include SlimBridge
7
+ include CoffeeBridge
8
+ include SlimOptions
9
+ include SassOptions
10
+ include ScopeOptions
11
+ include Assets
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Bobkit
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,27 @@
1
+ module Bobkit
2
+ module Watcher
3
+ def watch(paths=nil, &block)
4
+ # :nocov:
5
+ @paths = paths
6
+ filewatcher.watch &block
7
+ # :nocov:
8
+ end
9
+
10
+ def filewatcher
11
+ FileWatcher.new(paths)
12
+ end
13
+
14
+ protected
15
+
16
+ def paths
17
+ @paths ||= all_input_paths
18
+ end
19
+
20
+ def all_input_paths
21
+ [ templates_folder, layouts_folder, styles_folder,
22
+ coffee_folder, assets_folder ]
23
+ end
24
+ end
25
+ end
26
+
27
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bobkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: filewatcher
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.5'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.5'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: runfile
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -116,16 +130,20 @@ extra_rdoc_files: []
116
130
  files:
117
131
  - README.md
118
132
  - lib/bobkit.rb
119
- - lib/bobkit/actions.rb
120
133
  - lib/bobkit/assets.rb
121
134
  - lib/bobkit/coffee_bridge.rb
122
135
  - lib/bobkit/file_helpers.rb
123
136
  - lib/bobkit/location_options.rb
124
137
  - lib/bobkit/options_base.rb
125
138
  - lib/bobkit/sass_bridge.rb
139
+ - lib/bobkit/sass_options.rb
126
140
  - lib/bobkit/scope.rb
141
+ - lib/bobkit/scope_options.rb
127
142
  - lib/bobkit/slim_bridge.rb
143
+ - lib/bobkit/slim_options.rb
144
+ - lib/bobkit/tasks.rb
128
145
  - lib/bobkit/version.rb
146
+ - lib/bobkit/watcher.rb
129
147
  homepage: https://github.com/DannyBen/bobkit
130
148
  licenses:
131
149
  - MIT
@@ -1,34 +0,0 @@
1
- module Bobkit
2
- module Actions
3
- include OptionsBase
4
- include LocationOptions
5
- include SassBridge
6
- include SlimBridge
7
- include CoffeeBridge
8
- include Assets
9
-
10
- def slim_options(options=nil)
11
- setopt :slim_options, options, slim_defaults
12
- end
13
-
14
- def scss_options(options=nil)
15
- setopt :scss_options, options, scss_defaults
16
- end
17
-
18
- def scope(scope=nil)
19
- scope ? setopt(:scope, Scope.new(scope)) : options[:scope]
20
- end
21
-
22
- protected
23
-
24
- def slim_defaults
25
- { pretty: true, disable_escape: true }
26
- end
27
-
28
- def scss_defaults
29
- { cache: true, syntax: :scss, style: :nested,
30
- load_paths: [styles_folder] }
31
- end
32
-
33
- end
34
- end