gottani 0.0.2 → 0.0.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c163f3d32476fea1787d06988097e67c345af0fe
4
+ data.tar.gz: e0627cae0b94fb768c44eeb10c2d029d9821a46c
5
+ SHA512:
6
+ metadata.gz: 3ffd6dd42c1ed4098b87a46282a5b01784863313cfa176398caff460a5d58cfe0b69692a8dbdcd8b5a9bcb5836607c90028aa3910c2d4af69c5fcfcf936f3866
7
+ data.tar.gz: ad948b24fb91db913740353e93daa1121472b001834a5f05a7472d4e4a2b981dd30e635386fda6d3efdb18deb5053db622bfb7eb90c53e095a498560868c6049
@@ -0,0 +1 @@
1
+ service_name: travis-ci
File without changes
data/Gemfile CHANGED
@@ -5,3 +5,6 @@ gem "rspec"
5
5
  gem "thor"
6
6
  gem "simplecov"
7
7
  gem "activesupport"
8
+ group :test do
9
+ gem 'coveralls', require: false
10
+ end
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Gottani
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/gottani.svg)](http://badge.fury.io/rb/gottani)
3
4
  [![Build Status](https://travis-ci.org/tbpgr/gottani.png?branch=master)](https://travis-ci.org/tbpgr/gottani)
5
+ [![Coverage Status](https://coveralls.io/repos/tbpgr/gottani/badge.png?branch=master)](https://coveralls.io/r/tbpgr/gottani?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/tbpgr/gottani.png)](https://codeclimate.com/github/tbpgr/gottani)
4
7
 
5
- Gottani is coverter for indent-style text.
8
+ Gottani is converter for indent-style text.
6
9
 
7
10
  ## Support type
8
11
 
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core'
3
- require 'rspec/core/rake_task'
4
- task :default => [:spec]
5
-
6
- RSpec::Core::RakeTask.new(:spec) do |spec|
7
- spec.pattern = 'spec/**/*_spec.rb'
8
- end
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+ task default: [:spec]
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ end
@@ -1,27 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'gottani/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "gottani"
8
- spec.version = Gottani::VERSION
9
- spec.authors = ["tbpgr"]
10
- spec.email = ["tbpgr@tbpgr.jp"]
11
- spec.description = %q{Gottani is coverter for indent-style text.}
12
- spec.summary = %q{Gottani is coverter for indent-style text.}
13
- spec.homepage = "https://github.com/tbpgr/gottani"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
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_runtime_dependency "activesupport"
22
-
23
- spec.add_development_dependency "bundler"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec"
26
- spec.add_development_dependency "simplecov"
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gottani/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gottani'
8
+ spec.version = Gottani::VERSION
9
+ spec.authors = ['tbpgr']
10
+ spec.email = ['tbpgr@tbpgr.jp']
11
+ spec.description = %q(Gottani is converter for indent-style text.)
12
+ spec.summary = %q(Gottani is converter for indent-style text.)
13
+ spec.homepage = 'https://github.com/tbpgr/gottani'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'activesupport'
22
+
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'simplecov'
27
+ end
@@ -1,3 +1,4 @@
1
+ # Gottani
1
2
  module Gottani
2
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
3
4
  end
@@ -7,6 +7,7 @@ require 'indents/markdown'
7
7
  require 'indents/hatena'
8
8
 
9
9
  module Gottani
10
+ # Gottani::Core
10
11
  class Core
11
12
  attr_reader :type, :common
12
13
  FORMAT = {
@@ -14,16 +15,16 @@ module Gottani
14
15
  space2: Gottani::Space2,
15
16
  space4: Gottani::Space4,
16
17
  markdown: Gottani::Markdown,
17
- hatena: Gottani::Hatena,
18
+ hatena: Gottani::Hatena
18
19
  }
19
20
 
20
21
  def initialize(type, base)
21
22
  instance = FORMAT[type].new
22
- @common = instance.send "#{type.to_s}_to_common", base
23
+ @common = instance.send "#{type}_to_common", base
23
24
  end
24
25
 
25
26
  def method_missing(method_name, *args, &block)
26
- method_name.match /^to_(.*)$/
27
+ method_name.match(/^to_(.*)$/)
27
28
  super unless Regexp.last_match[1]
28
29
  instance = FORMAT[Regexp.last_match[1].to_sym].new
29
30
  return instance.send("to_#{Regexp.last_match[1]}", @common) if instance
@@ -2,44 +2,45 @@
2
2
  require 'active_support/concern'
3
3
 
4
4
  module Gottani
5
+ # Gottani::Base
5
6
  module Base
6
7
  extend ActiveSupport::Concern
7
8
  attr_accessor :indent_char, :separator
8
9
 
10
+ # ClassMethods
9
11
  module ClassMethods
10
12
  def define_to_common(base)
11
- define_method "#{base.to_s}_to_common".to_sym do |text|
12
- to_common text, indent_char, separator
13
+ define_method "#{base}_to_common".to_sym do |text|
14
+ to_common text
13
15
  end
14
- alias_method "to_#{base.to_s}".to_sym, :to_indent_text
16
+ alias_method "to_#{base}".to_sym, :to_indent_text
15
17
  end
16
18
  end
17
19
 
18
20
  def initialize
19
- @indent_char = get_indent_char
21
+ @indent_char = indent_char
20
22
  @zero_start = zero_start?
21
- @separator = get_separator
23
+ @separator = separator
22
24
  end
23
25
 
24
- def to_common(text, indent_char, separator = '')
25
- ret = []
26
- text.each_line.with_index do |line, index|
27
- chopped_line = line.chop
26
+ def to_common(text)
27
+ text.each_line.reduce([]) do |ret, line|
28
+ chopped = line.chop
28
29
  line_hash = {}
29
- level = zero_start? ? indent_level(chopped_line) - 1 : indent_level(chopped_line)
30
+ level = zero_start? ? indent_level(chopped) - 1 : indent_level(chopped)
30
31
  line_hash[:level] = level
31
- line_hash[:value] = indentless_line(chopped_line)
32
+ line_hash[:value] = indentless_line(chopped)
32
33
  line_hash[:value].gsub!(/^#{@separator}/, '') unless @separator.nil?
33
34
  ret << line_hash
35
+ ret
34
36
  end
35
- ret
36
37
  end
37
38
 
38
39
  def to_indent_text(common)
39
40
  common.reduce([]) do |ret, line|
40
41
  level = zero_start? ? line[:level] + 1 : line[:level]
41
42
  indent = @indent_char * level
42
- indent = indent + @separator unless @separator.nil?
43
+ indent += @separator unless @separator.nil?
43
44
  ret << "#{indent}#{line[:value]}"
44
45
  end.join("\n") + "\n"
45
46
  end
@@ -2,11 +2,12 @@
2
2
  require 'indents/base'
3
3
 
4
4
  module Gottani
5
+ # Gottani::Hatena
5
6
  class Hatena
6
7
  include Base
7
8
  define_to_common :hatena
8
9
 
9
- def get_indent_char
10
+ def indent_char
10
11
  '*'
11
12
  end
12
13
 
@@ -14,7 +15,7 @@ module Gottani
14
15
  true
15
16
  end
16
17
 
17
- def get_separator
18
+ def separator
18
19
  nil
19
20
  end
20
21
  end
@@ -2,12 +2,13 @@
2
2
  require 'indents/base'
3
3
 
4
4
  module Gottani
5
+ # Gottani::Markdown
5
6
  class Markdown
6
7
  include Base
7
8
 
8
9
  define_to_common :markdown
9
10
 
10
- def get_indent_char
11
+ def indent_char
11
12
  '#'
12
13
  end
13
14
 
@@ -15,7 +16,7 @@ module Gottani
15
16
  true
16
17
  end
17
18
 
18
- def get_separator
19
+ def separator
19
20
  ' '
20
21
  end
21
22
  end
@@ -2,11 +2,12 @@
2
2
  require 'indents/base'
3
3
 
4
4
  module Gottani
5
+ # Gottani::Space2
5
6
  class Space2
6
7
  include Base
7
8
  define_to_common :space2
8
9
 
9
- def get_indent_char
10
+ def indent_char
10
11
  ' '
11
12
  end
12
13
 
@@ -14,7 +15,7 @@ module Gottani
14
15
  false
15
16
  end
16
17
 
17
- def get_separator
18
+ def separator
18
19
  nil
19
20
  end
20
21
  end
@@ -2,11 +2,12 @@
2
2
  require 'indents/base'
3
3
 
4
4
  module Gottani
5
+ # Gottani::Space4
5
6
  class Space4
6
7
  include Base
7
8
  define_to_common :space4
8
9
 
9
- def get_indent_char
10
+ def indent_char
10
11
  ' '
11
12
  end
12
13
 
@@ -14,7 +15,7 @@ module Gottani
14
15
  false
15
16
  end
16
17
 
17
- def get_separator
18
+ def separator
18
19
  nil
19
20
  end
20
21
  end
@@ -2,12 +2,13 @@
2
2
  require 'indents/base'
3
3
 
4
4
  module Gottani
5
+ # Gottani::Tab
5
6
  class Tab
6
7
  include Base
7
8
 
8
9
  define_to_common :tab
9
10
 
10
- def get_indent_char
11
+ def indent_char
11
12
  "\t"
12
13
  end
13
14
 
@@ -15,7 +16,7 @@ module Gottani
15
16
  false
16
17
  end
17
18
 
18
- def get_separator
19
+ def separator
19
20
  nil
20
21
  end
21
22
  end
@@ -2,6 +2,7 @@
2
2
  require 'spec_helper'
3
3
  require 'gottani_core'
4
4
 
5
+ # rubocop:disable Tab, UnusedMethodArgument
5
6
  describe Gottani::Core do
6
7
  context :to_tab do
7
8
  TAB = <<-EOS
@@ -112,7 +113,7 @@ root
112
113
  input: MARKDOWN,
113
114
  method_name: :to_hatena,
114
115
  expected: HATENA
115
- },
116
+ }
116
117
  ]
117
118
 
118
119
  cases.each do |c|
@@ -143,3 +144,4 @@ root
143
144
  end
144
145
  end
145
146
  end
147
+ # rubocop:enable Tab, UnusedMethodArgument
@@ -2,7 +2,9 @@
2
2
  require 'spec_helper'
3
3
  require 'indents/tab'
4
4
 
5
+ # rubocop:disable Tab, UnusedMethodArgument
5
6
  describe Gottani::Tab do
7
+ # ConcreteTab
6
8
  class ConcreteTab
7
9
  attr_reader :text, :common
8
10
 
@@ -66,9 +68,9 @@ root
66
68
  {
67
69
  level: 1,
68
70
  value: 'child3'
69
- },
70
- ],
71
- },
71
+ }
72
+ ]
73
+ }
72
74
  ]
73
75
 
74
76
  cases.each do |c|
@@ -151,10 +153,10 @@ root
151
153
  {
152
154
  level: 1,
153
155
  value: 'child3'
154
- },
156
+ }
155
157
  ],
156
158
  expected: EXPECTED_TABTREE_CASE1
157
- },
159
+ }
158
160
  ]
159
161
 
160
162
  cases.each do |c|
@@ -186,3 +188,4 @@ root
186
188
  end
187
189
  end
188
190
  end
191
+ # rubocop:enable Tab, UnusedMethodArgument
@@ -1,6 +1,14 @@
1
1
  # encoding: utf-8
2
2
  require 'simplecov'
3
- SimpleCov.start
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter
8
+ ]
9
+ SimpleCov.start do
10
+ add_filter '/spec/'
11
+ end
4
12
  RSpec.configure do |config|
5
13
  config.treat_symbols_as_metadata_keys_with_true_values = true
6
14
  config.run_all_when_everything_filtered = true
metadata CHANGED
@@ -1,80 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gottani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - tbpgr
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-09 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
- requirement: &22118220 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *22118220
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: bundler
27
- requirement: &22117944 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *22117944
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rake
38
- requirement: &22117680 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - '>='
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *22117680
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rspec
49
- requirement: &22117368 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ! '>='
59
+ - - '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *22117368
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: simplecov
60
- requirement: &22117056 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ! '>='
73
+ - - '>='
64
74
  - !ruby/object:Gem::Version
65
75
  version: '0'
66
76
  type: :development
67
77
  prerelease: false
68
- version_requirements: *22117056
69
- description: Gottani is coverter for indent-style text.
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Gottani is converter for indent-style text.
70
84
  email:
71
85
  - tbpgr@tbpgr.jp
72
86
  executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
90
+ - .coveralls.yml
76
91
  - .gitignore
77
92
  - .rspec
93
+ - .rubocop.yml
78
94
  - .travis.yml
79
95
  - Gemfile
80
96
  - LICENSE.txt
@@ -95,30 +111,28 @@ files:
95
111
  homepage: https://github.com/tbpgr/gottani
96
112
  licenses:
97
113
  - MIT
114
+ metadata: {}
98
115
  post_install_message:
99
116
  rdoc_options: []
100
117
  require_paths:
101
118
  - lib
102
119
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
120
  requirements:
105
- - - ! '>='
121
+ - - '>='
106
122
  - !ruby/object:Gem::Version
107
123
  version: '0'
108
124
  required_rubygems_version: !ruby/object:Gem::Requirement
109
- none: false
110
125
  requirements:
111
- - - ! '>='
126
+ - - '>='
112
127
  - !ruby/object:Gem::Version
113
128
  version: '0'
114
129
  requirements: []
115
130
  rubyforge_project:
116
- rubygems_version: 1.8.11
131
+ rubygems_version: 2.3.0
117
132
  signing_key:
118
- specification_version: 3
119
- summary: Gottani is coverter for indent-style text.
133
+ specification_version: 4
134
+ summary: Gottani is converter for indent-style text.
120
135
  test_files:
121
136
  - spec/gottani_core_spec.rb
122
137
  - spec/indents/tab_spec.rb
123
138
  - spec/spec_helper.rb
124
- has_rdoc: