dyndoc-ruby 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dyn-html +30 -19
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4db8863fa13cb6e5535c8292cd9a5307d51d087
4
- data.tar.gz: de633b07d80fefaae256eeab6475d22b9160ca3f
3
+ metadata.gz: 2b104002585f67910c6674bd6d9937221cffe185
4
+ data.tar.gz: 5014c79451e427798d0b2dac7307d0c55c83ccd9
5
5
  SHA512:
6
- metadata.gz: 4faf962339f5fa30f5293adc54fbfb874b06e92348a2dd40db505401bc8b93c72d6734950e0f18a1b244fc88d57d44108ddc4d6f348e1e373e92182f2eee56e4
7
- data.tar.gz: fd84c5e9e8d25b4651922584ae85b44a6429d4c71c2c94fe742bc26d7bc3afa9bbd3a00761df64c2a0e991bb62b2e7b34d2803d54d99152f8dec2f36b8ed4445
6
+ metadata.gz: 0ca0e8ddfd72441ad99174c31615946580bb135ddafbb4c8719faafd61f629060d93560440cdf5874c69dfef44921a064c2f037b6b446afb324dee56f47b8a8f
7
+ data.tar.gz: 2d2d3e9eced1d1d0ce9ff6ed8e69134ed4c014f3a6e80cafb2a7ecde337e52973e3bbcd8c1cf64c7f95953852e4539bad62029a4f19cee7416532dcfd11b15bd
@@ -29,10 +29,11 @@ $VERBOSE = nil
29
29
  ## 1) global mode:
30
30
  ## dyn-html /dev/R/test.dyn
31
31
  ## 2) user mode: relative path used instead of ~ since ~ is interpreted in bash mode!
32
+ ## dyn-html cfies2017/index.dyn:index # -u <default_user_email>
32
33
  ## dyn-html -u remy.drouilhet@upmf-grenoble.fr cfies2017/index.dyn:index
33
34
  ## dyn-html -u remy.drouilhet@upmf-grenoble.fr cfies2017/index.dyn:all
34
35
 
35
- options={watching: nil, refresh: nil, first: true}
36
+ options={watching: nil, refresh: :auto, first: true}
36
37
 
37
38
  OptionParser.new do |opts|
38
39
  opts.banner = "Usage: dyn-html [-u email_user] [-w] [-r <url-to-refresh-when-watched>] [/]<relative_path>/<file>.dyn"
@@ -45,18 +46,17 @@ OptionParser.new do |opts|
45
46
  options[:watching]=true
46
47
  end
47
48
 
48
- opts.on( '-r', '--refresh HTML', 'refresh page' ) do |html|
49
+ opts.on( '-r', '--refresh HTML', 'page to refresh (only for MacOsX)' ) do |html|
49
50
  options[:refresh]=html
50
51
  end
51
52
 
52
- end.parse!(args)
53
-
53
+ opts.on('--no-refresh', 'no refresh page' ) do
54
+ options[:refresh]=nil
55
+ end
54
56
 
55
- ## THIS IS A COPY FROM edit.rb
56
- ## TODO: TO PLACE IN SOME COMMON LIBRARY!
57
+ end.parse!(args)
57
58
 
58
59
  ## Mandatory input
59
- p args
60
60
  dyn_file,doc_tag=args[0].split(":")
61
61
  doc_tag="" unless doc_tag
62
62
  doc_tag="__ALL_DOC_TAG__" if doc_tag.downcase == "all"
@@ -72,6 +72,15 @@ if dyn_file and (dyn_file=~/(.*)(?:\.dyn|_html.dyn)$/)
72
72
  ##p [:html_files,html_files]
73
73
  html_file=html_files[doc_tag] || html_files[""]
74
74
 
75
+ if options[:refresh] and options[:refresh] == :auto
76
+ options[:refresh] = File.join(cfg["localhost_url"] || "http://localhost:9292",File.dirname(dyn_file),File.basename(dyn_file,".*"))
77
+ end
78
+
79
+ output=""
80
+ output << "Watching "+dyn_file if options[:watching]
81
+ output << (options[:watching] ? " and refreshing " : "Refreshing ")+options[:refresh] if options[:refresh]
82
+ puts output unless output.empty?
83
+
75
84
  # Ex for opts:
76
85
  # rdrouilh : [:dyn_opts, {:dyn_root=>"/Users/remy/RCqls/RodaServer/edit", :html_root=>"/Users/remy/RCqls/RodaServer/public/pages", :user=>"rdrouilh@gmail.com", :doc_tag=>"bio", :html_files=>{""=>"/dev/R/test.html", "ssd"=>"/dev/R/ssd.html", "bio"=>"/dev/R/bio.html", "tmp"=>"/dev/R/tmp.html", "cours"=>"/dev/R/cours.html"}}]
77
86
  # remy.drouilhet : [:dyn_opts, {:dyn_root=>"/Users/remy/RCqls/RodaServer/edit", :html_root=>"/Users/remy/RCqls/RodaServer/public/pages", :user=>"remy.drouilhet@upmf-grenoble.fr", :doc_tag=>"index", :html_files=>{""=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/index.html", "index"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/index.html", "dates"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/dates.html", "sc"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/sc.html", "orga"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/orga.html"}}]
@@ -85,7 +94,7 @@ if dyn_file and (dyn_file=~/(.*)(?:\.dyn|_html.dyn)$/)
85
94
  ##p opts
86
95
  file_to_process=File.join(opts[:dyn_root],dyn_file)
87
96
  cmd_to_open=nil
88
- if options[:refresh]
97
+ if options[:refresh] and RUBY_PLATFORM =~ /darwin/
89
98
  cmd_to_open='tell application "Safari" to set URL of current tab of front window to "'+options[:refresh]+'"'
90
99
  cmd_to_refresh='tell application "System Events"' + "\n" + 'tell process "Safari"' + "\n" + 'keystroke "r" using {command down}' + "\n" + 'delay 60' + "\n" + 'end tell' + "\n" + 'end tell'
91
100
  end
@@ -104,17 +113,19 @@ if dyn_file and (dyn_file=~/(.*)(?:\.dyn|_html.dyn)$/)
104
113
  if Dyndoc::Linter.check_file(file_to_process).empty?
105
114
  Dyndoc.cli_convert_from_file(dyn_file[1..-1],html_file, opts)
106
115
  puts dyn_file[1..-1]+" processed!"
107
- if options[:first]
108
- `osascript -e '#{cmd_to_open}'`
109
- options[:first]=nil
110
- else
111
- %x{osascript<<-ENDREFRESH
112
- tell app "Safari" to activate
113
- tell application "System Events"
114
- keystroke "r" using {command down}
115
- end tell
116
- ENDREFRESH
117
- }
116
+ if options[:refresh] and RUBY_PLATFORM =~ /darwin/
117
+ if options[:first]
118
+ `osascript -e '#{cmd_to_open}'`
119
+ options[:first]=nil
120
+ else
121
+ %x{osascript<<ENDREFRESH
122
+ tell app "Safari" to activate
123
+ tell application "System Events"
124
+ keystroke "r" using {command down}
125
+ end tell
126
+ ENDREFRESH
127
+ }
128
+ end
118
129
  end
119
130
  else
120
131
  puts dyn_file[1..-1]+" not well-formed!"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyndoc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - CQLS