dashdog 0.1.1 → 0.2.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bd9f5b8483bb4fc4ab8b73b881f6dcb61e4044a
4
- data.tar.gz: bbda047cb690cb840671b4a67f3609f7ebb49cab
3
+ metadata.gz: e5a209f39a8e469b2ff1a4ae3c37c9ef0f29a9fe
4
+ data.tar.gz: 75e706697dfad0acaf3bd8e2cf0a34820d5d2a19
5
5
  SHA512:
6
- metadata.gz: ec7c47d5d7cee288898c25d011fe61a5dab41a21182693bef17bbf5fd229aab910b4833d056b182120044b49a1ba31a746a0c6ded30955d71615d04b043356a2
7
- data.tar.gz: 5595e13d9e51c71daf046e80e26c22363a86516e193a62a13c67b29ab8f9d15d956d1d1c374c2ed445b008f8589c1389bc3937bdafbb83168cf6990f14a9bd84
6
+ metadata.gz: 382cca04591f69297f3bbc7b41ec2c736bf03f52ee9be2486f4f09b552bb3d0c66a13e2c00358e95f8c4ba01180b9172a76ae3c16d7e5021225a52c56d548bc0
7
+ data.tar.gz: 11c397cdfedf957a1f9fd38b2aa83ccf80a62b0a8656a4ab07139f82dfa07d6a8c40c5da1ccab1fe1f937815fadd75ad88dd66927085714e20f9c86d6e6c893b
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
  /tmp/
10
10
  /vendor
11
11
  .envrc
12
+ Boardfile
13
+ /*.rb
data/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
+ ## 0.2.0
2
+
3
+ - Add `split` opton [#4][] ([@winebarrel][])
4
+
1
5
  ## 0.1.1
2
6
 
3
7
  - Add color option / check stdout tty [#3][] ([@winebarrel][])
4
8
  - Use parallel for speeding up [#2][] ([@winebarrel][])
5
9
  - Bugfix: Error occurs when widgets is nil. [#1][] ([@winebarrel][])
6
- - Fix strange diff colorize
10
+ - Fix a strange diff colorize
7
11
 
8
12
  ## 0.1.0
9
13
 
@@ -13,4 +17,5 @@
13
17
  [#1]: https://github.com/serverworks/dashdog/issues/1
14
18
  [#2]: https://github.com/serverworks/dashdog/issues/2
15
19
  [#3]: https://github.com/serverworks/dashdog/issues/3
20
+ [#4]: https://github.com/serverworks/dashdog/issues/4
16
21
  [@winebarrel]: https://github.com/winebarrel
data/README.md CHANGED
@@ -55,6 +55,7 @@ Usage:
55
55
 
56
56
  Options:
57
57
  -w, [--write], [--no-write] # Write the configuration to the file
58
+ [--split], [--no-split] # Split configuration file
58
59
  -f, [--file=FILE] # Configuration file
59
60
  # Default: Boardfile
60
61
  [--color], [--no-color] # Disable colorize
@@ -13,18 +13,23 @@ module Dashdog
13
13
  def export(options)
14
14
  dsl = @converter.timeboards_to_dsl(@client.get_timeboards)
15
15
  dsl << @converter.screenboards_to_dsl(@client.get_screenboards)
16
- Dashdog::Utils.print_ruby(dsl, color: options[:color])
17
- File.write(options['file'], dsl) if options['write']
16
+ if options['write']
17
+ _export_to_file(dsl, options)
18
+ else
19
+ Dashdog::Utils.print_ruby(dsl, color: options[:color])
20
+ end
18
21
  end
19
22
 
20
23
  def apply(options)
21
24
  dry_run = options['dry_run'] ? '[Dry run] ' : ''
22
- conf = @converter.to_h(File.read(options['file']))
25
+ conf = @converter.to_h(options['file'])
23
26
 
24
27
  _apply_timeboards(conf['timeboards'], @client.get_timeboards, dry_run)
25
28
  _apply_screenboards(conf['screenboards'], @client.get_screenboards, dry_run)
26
29
  end
27
30
 
31
+ private
32
+
28
33
  def _apply_timeboards(local, remote, dry_run)
29
34
  local.each do |l|
30
35
  r = _choice_by_title(remote, l['title'])
@@ -95,5 +100,31 @@ module Dashdog
95
100
  nil
96
101
  end
97
102
 
103
+ def _export_to_file(dsl, options)
104
+ file = options['file']
105
+
106
+ if options['split']
107
+ dsls = dsl.strip.split(/^(timeboard|screenboard)\b/).slice(1..-1).each_slice(2).map(&:join)
108
+ requires = []
109
+
110
+ dsls.each do |splitted|
111
+ splitted.strip!
112
+ title = splitted.each_line.first.strip.gsub(/\A(?:timeboard|screenboard)\s+"([^"]+)"\s+do/, '\\1')
113
+ title.gsub!(/\W+/, '_')
114
+ requires << title
115
+ File.write("#{title}.rb", splitted + "\n")
116
+ info("Write '#{title}.rb'")
117
+ end
118
+
119
+ open(file, 'w') do |f|
120
+ requires.each {|r| f.puts "require #{r.inspect}" }
121
+ end
122
+
123
+ info("Write '#{file}'")
124
+ else
125
+ File.write(file, dsl)
126
+ info("Write '#{file}'")
127
+ end
128
+ end
98
129
  end
99
130
  end
data/lib/dashdog/cli.rb CHANGED
@@ -12,6 +12,7 @@ module Dashdog
12
12
 
13
13
  desc "export", "Export the dashboard configurations"
14
14
  option :write, aliases: '-w', desc: 'Write the configuration to the file', type: :boolean, default: false
15
+ option :split, desc: 'Split configuration file', type: :boolean, default: false
15
16
  def export
16
17
  @actions.export(options)
17
18
  end
@@ -60,13 +60,26 @@ EOS
60
60
  ret
61
61
  end
62
62
 
63
- def to_h(dsl)
64
- instance_eval(dsl)
63
+ def to_h(dsl_file)
64
+ @_dsl_file = dsl_file
65
+ instance_eval(File.read(dsl_file), dsl_file)
65
66
  @boards
66
67
  end
67
68
 
68
69
  private
69
70
 
71
+ def require(file)
72
+ boardfile = (file =~ %r|\A/|) ? file : File.expand_path(File.join(File.dirname(@_dsl_file), file))
73
+
74
+ if File.exist?(boardfile)
75
+ instance_eval(File.read(boardfile), boardfile)
76
+ elsif File.exist?(boardfile + '.rb')
77
+ instance_eval(File.read(boardfile + '.rb'), boardfile + '.rb')
78
+ else
79
+ Kernel.require(file)
80
+ end
81
+ end
82
+
70
83
  def timeboard(value = nil, &block)
71
84
  hash = Dslh.eval(
72
85
  allow_empty_args: true,
@@ -1,3 +1,3 @@
1
1
  module Dashdog
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serverworks Co.,Ltd.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dogapi