design-storyboard 0.8.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd70f23c7735992bce1ddc981b1b60200e749534
4
+ data.tar.gz: bfdc6f0b9fea43bf3f0105968d19d41668ec9b11
5
+ SHA512:
6
+ metadata.gz: d66eaf1cf0d741494f4e9255f9d91bb97509f98669235199b24969d9e31d30bb9e9d61f264781874e7d4902ae7aee0d9dc127d88e20c3a6d42f3e45f2aeb6175
7
+ data.tar.gz: 10baa3489c15105369872e5736fd70994f685b37d9bf9bb2b34d4e06f598487a8fa616d3db5fa9353fce691edc0dadda6b84af253660b6372877c404bf6810ba
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in design_storyboard.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Guanting Chen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # 有空再說明
2
+
3
+ # design-storyboard
4
+
5
+ Easy to building design-storyboard.
6
+
7
+ # Last version
8
+
9
+ 0.8
10
+
11
+ # Install
12
+
13
+ ```shell
14
+ gem install design-storyboard
15
+ ```
16
+
17
+ # How to use?
18
+
19
+ ```shell
20
+ story build [Storyboard-File.txt]
21
+ ```
22
+ or try 「story help」for more information.
23
+
24
+ # License
25
+
26
+ Copyright (c) Guanting Chen (guanting886)
27
+
28
+ Licensed under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/story ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'design_storyboard/cli'
3
+
4
+ DesignStoryboard::Cli.start ARGV
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'design_storyboard/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "design-storyboard"
8
+ spec.version = DesignStoryboard::VERSION
9
+ spec.authors = ["Guanting Chen (guanting886)"]
10
+ spec.email = ["cgt886@gmail.com"]
11
+ spec.summary = %q{Easy to building design-storyboard.}
12
+ # spec.description = %q{easy to building text-storyboard.}
13
+ spec.homepage = "https://github.com/guanting886/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ # spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "thor", "~> 0.18"
24
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require 'design_storyboard'
4
+ require 'thor'
5
+ require 'design_storyboard/version'
6
+
7
+ module DesignStoryboard
8
+ class Cli < Thor
9
+ desc 'build [STORY_FILE_PATH]', 'Build storyboard (html) from file.'
10
+
11
+ def build(path)
12
+ Setting[:story_file_path] = path
13
+ Setting.update_dump_data_path
14
+
15
+ DesignStoryboard.build
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+
3
+ module DesignStoryboard
4
+ module Export
5
+
6
+ def apply_html_template(title, html_syntax)
7
+ html = %Q(
8
+ <!DOCTYPE html>
9
+ <html>
10
+ <head>
11
+ <meta charset="utf-8">
12
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
13
+ <link rel="stylesheet" href="css/storyboard.css">
14
+ </head>
15
+ <body>
16
+ <div class="page-title"><h1>#{title}</h1></div>
17
+ <div class="container">#{html_syntax}</div>
18
+ </body>
19
+ </html>
20
+ )
21
+ end
22
+
23
+ def generate_table_cell(*args)
24
+ html = '<tr>'
25
+
26
+ args.each_with_index do |value, index|
27
+ value.gsub!(/[\r\n]+/, '<br>')
28
+ value.gsub!(/\[(?<tag1>[^\]]+)\]/, '<span class="tag-1">[\k<tag1>]</span>')
29
+ value.gsub!(/\「(?<tag2>[^\」]+)\」/, '<span class="tag-2">「\k<tag2>」</span>')
30
+ value.gsub!(/\((?<tag3>[^\」]+)\)/, '<span class="tag-3">(\k<tag3>)</span>')
31
+ value.gsub!(/\((?<tag3>[^\」]+)\)/, '<span class="tag-3">(\k<tag3>)</span>')
32
+ html << "<td class='td-#{index}'><div>#{value}</div></td>"
33
+ end
34
+
35
+ html << '</tr>'
36
+ end
37
+
38
+ def generate_table_header(*args)
39
+ html = '<tr>'
40
+
41
+ args.each do |value|
42
+ html << "<th>#{value}</th>"
43
+ end
44
+
45
+ html << '</tr>'
46
+ end
47
+
48
+ def generate_table(header_rows_syntax='', content_rows_syntax='')
49
+ html = %Q(
50
+ <table class="storyboard" cellspacing="0" cellpadding="5">
51
+ #{header_rows_syntax}
52
+ #{content_rows_syntax}
53
+ </table>
54
+ )
55
+ end
56
+
57
+ def output_storyboard(title, info_collection)
58
+ start
59
+
60
+ table_header_html = generate_table_header('Step', 'Description', 'Note')
61
+ table_cells_html = ""
62
+
63
+ info_collection.each do |index, info|
64
+ table_cells_html << generate_table_cell(info[:step], info[:description], info[:note])
65
+ end
66
+
67
+ table_html = generate_table(table_header_html, table_cells_html)
68
+ html_document = apply_html_template(title, table_html)
69
+
70
+ save html_document
71
+ end
72
+
73
+ def save(content)
74
+ start
75
+
76
+ File.open(Setting[:dump_file_path], File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
77
+ f.write content
78
+ end
79
+
80
+ done
81
+
82
+ title 'Here you are'
83
+ attention Setting[:dump_file_path]
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ class Object
4
+ def blank?
5
+ respond_to?(:empty?) ? !!empty? : !self
6
+ end
7
+
8
+ def present?
9
+ !blank?
10
+ end
11
+
12
+ def presence
13
+ self if present?
14
+ end
15
+ end
16
+
17
+ class NilClass
18
+ def blank?
19
+ true
20
+ end
21
+ end
22
+
23
+ class FalseClass
24
+ def blank?
25
+ true
26
+ end
27
+ end
28
+
29
+ class TrueClass
30
+ def blank?
31
+ false
32
+ end
33
+ end
34
+
35
+ class Array
36
+ alias_method :blank?, :empty?
37
+ end
38
+
39
+ class Hash
40
+ alias_method :blank?, :empty?
41
+ end
42
+
43
+ class String
44
+ BLANK_RE = /\A[[:space:]]*\z/
45
+
46
+ def blank?
47
+ BLANK_RE === self
48
+ end
49
+
50
+ def remove_white_char
51
+ self.gsub(/^[\t ]+/, '')
52
+ end
53
+ end
54
+
55
+ class Numeric #:nodoc:
56
+ def blank?
57
+ false
58
+ end
59
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ module DesignStoryboard
4
+ module Log
5
+
6
+ def start
7
+ caller_info = caller[0].to_s.match(/`(?<method>[\w\_\-]+)'/)
8
+
9
+ if caller_info.present?
10
+ program_action = caller_info[:method].split('_').map(&:capitalize).join(' ')
11
+
12
+ title program_action
13
+ end
14
+ end
15
+
16
+ def title(title)
17
+ puts " [ #{title} ] ".center(65, "-")
18
+ end
19
+
20
+ def alert(message)
21
+ puts "[*] #{message}"
22
+ end
23
+
24
+ def say(message)
25
+ puts "[ ] #{message}"
26
+ end
27
+
28
+ def runtime_error(exception)
29
+ puts "[!] Runtime Exception: #{exception.message}"
30
+ end
31
+
32
+ def unable(message)
33
+ puts "[!] Unable: #{message}"
34
+ end
35
+
36
+ def attention(message)
37
+ puts
38
+ puts message
39
+ puts
40
+ end
41
+
42
+ def done
43
+ alert "Done."
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ module DesignStoryboard
4
+ module Setting
5
+
6
+ @settings = {}
7
+
8
+ def self.all
9
+ @settings
10
+ end
11
+
12
+ def self.[](key)
13
+ all[key]
14
+ end
15
+
16
+ def self.[]=(key, value)
17
+ all[key] = value
18
+ end
19
+
20
+ def self.update_dump_data_path
21
+ Setting[:dump_file_path] = "#{Setting[:story_file_path]}.html"
22
+
23
+ update_page_title
24
+ end
25
+
26
+ def self.update_page_title
27
+ Setting[:page_title] = File.basename(Setting[:story_file_path], ".*")
28
+ end
29
+
30
+ end
31
+
32
+ Setting[:story_file_path] = ''
33
+ Setting[:dump_file_path] = ''
34
+ Setting[:page_title] = ''
35
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module DesignStoryboard
4
+ VERSION = "0.8.2"
5
+ end
@@ -0,0 +1,77 @@
1
+ # encoding: utf-8
2
+
3
+ require 'design_storyboard/ext'
4
+ require 'design_storyboard/export'
5
+ require 'design_storyboard/log'
6
+ require 'design_storyboard/setting'
7
+
8
+ module DesignStoryboard
9
+ class << self
10
+ include Export
11
+ include Log
12
+
13
+ def build
14
+ info_collection = generate_storyboard_from_story_file
15
+
16
+ if info_collection.present?
17
+ output_storyboard Setting[:page_title], info_collection
18
+ else
19
+ unable "info not found."
20
+ end
21
+ end
22
+
23
+ def generate_storyboard_from_story_file
24
+ start
25
+
26
+ storyboard = {}
27
+ scene = { step: '', description: '', note: '' }
28
+ step_number = ""
29
+ step_number_is_found = false
30
+ note_number_is_found = false
31
+
32
+ alert 'Start analyzing.'
33
+
34
+ IO.foreach(Setting[:story_file_path]) do |data|
35
+ data = data.remove_white_char
36
+ scene_number_info = data.match(/step[[:blank:]]+(?<scene_number>[\d\-]+)\:/i)
37
+ note_number_info = data.match(/\^{4}[[:blank:]]+(?<scene_number>[\d\-]+)\:/i)
38
+
39
+ if scene_number_info.present?
40
+ step_number_is_found = true
41
+ note_number_is_found = false
42
+
43
+ step_number = scene_number_info[1]
44
+ storyboard[step_number] = scene.dup
45
+ storyboard[step_number][:step] = step_number
46
+ storyboard[step_number][:description] = ""
47
+
48
+ say "catch <- #{step_number}"
49
+
50
+ elsif note_number_info.present?
51
+ step_number_is_found = false
52
+ note_number_is_found = true
53
+
54
+ storyboard[step_number][:note] = ""
55
+
56
+ say "catch note <- #{step_number}"
57
+
58
+ elsif step_number_is_found
59
+ storyboard[step_number][:description] << data
60
+
61
+ elsif note_number_is_found
62
+ storyboard[step_number][:note] << data
63
+
64
+ else
65
+ # ignore
66
+ end
67
+ end
68
+
69
+ done
70
+ rescue Exception => e
71
+ runtime_error e
72
+ ensure
73
+ return storyboard
74
+ end
75
+
76
+ end
77
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: design-storyboard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.2
5
+ platform: ruby
6
+ authors:
7
+ - Guanting Chen (guanting886)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.18'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.18'
55
+ description:
56
+ email:
57
+ - cgt886@gmail.com
58
+ executables:
59
+ - story
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/story
69
+ - design_storyboard.gemspec
70
+ - lib/design_storyboard.rb
71
+ - lib/design_storyboard/cli.rb
72
+ - lib/design_storyboard/export.rb
73
+ - lib/design_storyboard/ext.rb
74
+ - lib/design_storyboard/log.rb
75
+ - lib/design_storyboard/setting.rb
76
+ - lib/design_storyboard/version.rb
77
+ homepage: https://github.com/guanting886/
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.5
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Easy to building design-storyboard.
101
+ test_files: []