typographic-unit 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +4 -0
  3. data/HISTORY.md +12 -0
  4. data/{License.txt → LICENSE.txt} +4 -2
  5. data/README.md +87 -0
  6. data/Rakefile +16 -4
  7. data/lib/typographic-unit.rb +26 -284
  8. data/lib/typographic-unit/american-point.rb +7 -0
  9. data/lib/typographic-unit/big-point.rb +7 -0
  10. data/lib/typographic-unit/centimeter.rb +7 -0
  11. data/lib/typographic-unit/cicero.rb +7 -0
  12. data/lib/typographic-unit/didot-point.rb +7 -0
  13. data/lib/typographic-unit/gou.rb +50 -0
  14. data/lib/typographic-unit/inch.rb +6 -0
  15. data/lib/typographic-unit/jis-point.rb +6 -0
  16. data/lib/typographic-unit/meter.rb +7 -0
  17. data/lib/typographic-unit/millimeter.rb +7 -0
  18. data/lib/typographic-unit/pica.rb +7 -0
  19. data/lib/typographic-unit/postscript-point.rb +7 -0
  20. data/lib/typographic-unit/q.rb +8 -0
  21. data/lib/typographic-unit/scaled-point.rb +7 -0
  22. data/lib/typographic-unit/tex-point.rb +6 -0
  23. data/lib/typographic-unit/unit.rb +261 -0
  24. data/lib/typographic-unit/version.rb +2 -7
  25. data/{spec/typographic-unit_spec.rb → test/spec_typographic-unit.rb} +30 -32
  26. data/typographic-unit.gemspec +21 -0
  27. metadata +76 -68
  28. data/History.txt +0 -4
  29. data/Manifest.txt +0 -26
  30. data/README.txt +0 -27
  31. data/config/hoe.rb +0 -83
  32. data/config/requirements.rb +0 -17
  33. data/log/debug.log +0 -0
  34. data/script/destroy +0 -14
  35. data/script/generate +0 -14
  36. data/script/txt2html +0 -74
  37. data/setup.rb +0 -1585
  38. data/spec/spec.opts +0 -1
  39. data/spec/spec_helper.rb +0 -10
  40. data/tasks/deployment.rake +0 -34
  41. data/tasks/environment.rake +0 -7
  42. data/tasks/rspec.rake +0 -21
  43. data/tasks/website.rake +0 -17
  44. data/website/index.html +0 -180
  45. data/website/index.txt +0 -103
  46. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  47. data/website/stylesheets/screen.css +0 -138
  48. data/website/template.rhtml +0 -48
@@ -1,12 +1,10 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
1
+ require 'typographic-unit'
2
2
 
3
- TypographicUnit.open
4
-
5
- describe TypographicUnit do
3
+ describe "TypographicUnit" do
6
4
  it "1pt == 65536sp" do
7
5
  1.pt.should == 65536.sp
8
- 1.pt.should_not == 65535.sp
9
- 1.pt.should_not == 65537.sp
6
+ 1.pt.should.not == 65535.sp
7
+ 1.pt.should.not == 65537.sp
10
8
  end
11
9
 
12
10
  it "1pc == 12pt" do
@@ -22,7 +20,7 @@ describe TypographicUnit do
22
20
  end
23
21
 
24
22
  it "10mm == 1cm" do
25
- 25.4.mm.should == 2.54.cm
23
+ 10.mm.should == 1.cm
26
24
  end
27
25
 
28
26
  it "1cm == 10mm" do
@@ -89,7 +87,7 @@ describe Numeric do
89
87
  end
90
88
 
91
89
  it "1.cm + 1.mm == 1.1cm" do
92
- (1.cm + 1.mm).should be_kind_of(TypographicUnit::Centimeter)
90
+ (1.cm + 1.mm).should.be.kind_of(TypographicUnit::Centimeter)
93
91
  (1.cm + 1.mm).should == 1.1.cm
94
92
  end
95
93
 
@@ -102,29 +100,29 @@ describe Numeric do
102
100
  end
103
101
 
104
102
  it "1.cm - 1.mm == 0.9cm" do
105
- (1.cm - 1.mm).should be_kind_of(TypographicUnit::Centimeter)
103
+ (1.cm - 1.mm).should.be.kind_of(TypographicUnit::Centimeter)
106
104
  (1.cm - 1.mm).should == 0.9.cm
107
105
  end
108
106
 
109
107
  it "*" do
110
- (1.cm * 10).should be_kind_of(TypographicUnit::Centimeter)
108
+ (1.cm * 10).should.be.kind_of(TypographicUnit::Centimeter)
111
109
  (1.cm * 10).should == 10.cm
112
- Proc.new{1.cm * 10.cm}.should raise_error(ArgumentError)
110
+ Proc.new{1.cm * 10.cm}.should.raise(ArgumentError)
113
111
  end
114
112
 
115
113
  it "abs" do
116
114
  (-(1.cm)).abs.should == 1.cm
117
- (-(1.cm)).abs.should_not == -1.cm
115
+ (-(1.cm)).abs.should.not == -1.cm
118
116
  end
119
117
 
120
118
  it "ceil" do
121
119
  1.5.cm.ceil.should == 2.cm
122
- 1.5.cm.ceil.should_not == 1.cm
120
+ 1.5.cm.ceil.should.not == 1.cm
123
121
  end
124
122
 
125
123
  it "floor" do
126
124
  1.5.cm.floor.should == 1.cm
127
- 1.5.cm.floor.should_not == 2.cm
125
+ 1.5.cm.floor.should.not == 2.cm
128
126
  end
129
127
 
130
128
  it "round" do
@@ -138,33 +136,33 @@ describe Numeric do
138
136
  end
139
137
 
140
138
  it "integer?" do
141
- 1.cm.should be_integer
142
- 1.5.cm.should_not be_integer
139
+ 1.cm.should.be.integer
140
+ 1.5.cm.should.not.be.integer
143
141
  end
144
142
 
145
143
  it "nonzero?" do
146
- 1.cm.should be_nonzero
147
- 0.cm.should_not be_nonzero
144
+ 1.cm.should.be.nonzero
145
+ 0.cm.should.not.be.nonzero
148
146
  end
149
147
 
150
148
  it "to_i" do
151
- 1.cm.to_i.should be_kind_of(TypographicUnit::Centimeter)
149
+ 1.cm.to_i.should.be.kind_of(TypographicUnit::Centimeter)
152
150
  1.cm.to_i.should == 1.cm
153
151
  1.4.cm.to_i.should == 1.cm
154
152
  1.5.cm.to_i.should == 1.cm
155
153
  end
156
154
 
157
155
  it "to_int" do
158
- 1.cm.to_int.should be_kind_of(Integer)
156
+ 1.cm.to_int.should.be.kind_of(Integer)
159
157
  1.cm.to_int.should == 1
160
158
  1.4.cm.to_int.should == 1
161
159
  1.5.cm.to_int.should == 1
162
160
  end
163
161
 
164
162
  it "zero?" do
165
- 0.cm.should be_zero
166
- 0.0.cm.should be_zero
167
- 0.1.cm.should_not be_zero
163
+ 0.cm.should.be.zero
164
+ 0.0.cm.should.be.zero
165
+ 0.1.cm.should.not.be.zero
168
166
  end
169
167
 
170
168
  it "step from 1cm to 5cm" do
@@ -178,7 +176,7 @@ describe Numeric do
178
176
  it "step from 1cm to 3cm by 0.5cm" do
179
177
  list = []
180
178
  1.cm.step(3.cm, 0.5.cm) do |i|
181
- i.should be_kind_of(TypographicUnit::Centimeter)
179
+ i.should.be.kind_of(TypographicUnit::Centimeter)
182
180
  list << i
183
181
  end
184
182
  list.should == [1.cm, 1.5.cm, 2.cm, 2.5.cm, 3.cm]
@@ -187,7 +185,7 @@ describe Numeric do
187
185
  it "step from 1cm to 3cm by 5mm" do
188
186
  list = []
189
187
  1.cm.step(3.cm, 5.mm) do |i|
190
- i.should be_kind_of(TypographicUnit::Centimeter)
188
+ i.should.be.kind_of(TypographicUnit::Centimeter)
191
189
  list << i
192
190
  end
193
191
  list.should == [1.cm, 1.5.cm, 2.cm, 2.5.cm, 3.cm]
@@ -196,24 +194,24 @@ end
196
194
 
197
195
  describe Range do
198
196
  it "Range.new(1.cm, 5.cm) should be valid" do
199
- Proc.new{1.cm..5.cm}.should_not raise_error(ArgumentError)
197
+ Proc.new{1.cm..5.cm}.should.not.raise(ArgumentError)
200
198
  end
201
199
 
202
200
  it "Range.new(1.cm, 1.in) should be valid" do
203
- Proc.new{1.cm..1.in}.should_not raise_error(ArgumentError)
201
+ Proc.new{1.cm..1.in}.should.not.raise(ArgumentError)
204
202
  end
205
203
 
206
204
  it "#include should work" do
207
- (1.cm..1.in).should include(25.4.mm)
208
- (1.cm..1.in).should_not include(25.5.mm)
205
+ (1.cm..1.in).should.include(25.4.mm)
206
+ (1.cm..1.in).should.not.include(25.5.mm)
209
207
  end
210
208
 
211
209
  it "#each should raise a TypeError" do
212
- Proc.new{(1.cm..5.cm).each{}}.should raise_error(TypeError)
210
+ Proc.new{(1.cm..5.cm).each{}}.should.raise(TypeError)
213
211
  end
214
212
 
215
213
  it "#step" do
216
- Proc.new{(1.cm..5.cm).step{}}.should raise_error(ArgumentError)
214
+ Proc.new{(1.cm..5.cm).step{}}.should.raise(ArgumentError)
217
215
  end
218
216
  end
219
217
 
@@ -223,7 +221,7 @@ describe TypographicUnit::Millimeter do
223
221
  end
224
222
 
225
223
  it "1mm => 0.1cm" do
226
- (1.mm >> :cm).should be_a_kind_of(TypographicUnit::Centimeter)
224
+ (1.mm >> :cm).should.be.kind_of(TypographicUnit::Centimeter)
227
225
  (1.mm >> :cm).should == 0.1.cm
228
226
  end
229
227
 
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'typographic-unit/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "typographic-unit"
8
+ gem.version = TypographicUnit::VERSION
9
+ gem.authors = ["Keita Yamaguchi"]
10
+ gem.email = ["keita.yamaguchi@gmail.com"]
11
+ gem.description = "typographic-unit is a Ruby library for converting between typographic units by TeX\'s way."
12
+ gem.summary = "converter between typographic units"
13
+ gem.homepage = "https://github.com/keita/typographic-unit"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+ gem.add_development_dependency "bacon"
21
+ end
metadata CHANGED
@@ -1,83 +1,91 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: typographic-unit
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Keita Yamaguchi
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2007-12-30 00:00:00 +09:00
13
- default_executable:
14
- dependencies: []
15
-
16
- description: TypographicUnit is a library for converting between typographic units according to TeX.
17
- email: keita.yamaguchi@gmail.com
12
+ date: 2013-03-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bacon
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: typographic-unit is a Ruby library for converting between typographic
31
+ units by TeX's way.
32
+ email:
33
+ - keita.yamaguchi@gmail.com
18
34
  executables: []
19
-
20
35
  extensions: []
21
-
22
- extra_rdoc_files:
23
- - History.txt
24
- - License.txt
25
- - Manifest.txt
26
- - README.txt
27
- - website/index.txt
28
- files:
29
- - History.txt
30
- - License.txt
31
- - Manifest.txt
32
- - README.txt
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - HISTORY.md
41
+ - LICENSE.txt
42
+ - README.md
33
43
  - Rakefile
34
- - config/hoe.rb
35
- - config/requirements.rb
36
44
  - lib/typographic-unit.rb
45
+ - lib/typographic-unit/american-point.rb
46
+ - lib/typographic-unit/big-point.rb
47
+ - lib/typographic-unit/centimeter.rb
48
+ - lib/typographic-unit/cicero.rb
49
+ - lib/typographic-unit/didot-point.rb
50
+ - lib/typographic-unit/gou.rb
51
+ - lib/typographic-unit/inch.rb
52
+ - lib/typographic-unit/jis-point.rb
53
+ - lib/typographic-unit/meter.rb
54
+ - lib/typographic-unit/millimeter.rb
55
+ - lib/typographic-unit/pica.rb
56
+ - lib/typographic-unit/postscript-point.rb
57
+ - lib/typographic-unit/q.rb
58
+ - lib/typographic-unit/scaled-point.rb
59
+ - lib/typographic-unit/tex-point.rb
60
+ - lib/typographic-unit/unit.rb
37
61
  - lib/typographic-unit/version.rb
38
- - log/debug.log
39
- - script/destroy
40
- - script/generate
41
- - script/txt2html
42
- - setup.rb
43
- - spec/spec.opts
44
- - spec/spec_helper.rb
45
- - spec/typographic-unit_spec.rb
46
- - tasks/deployment.rake
47
- - tasks/environment.rake
48
- - tasks/rspec.rake
49
- - tasks/website.rake
50
- - website/index.html
51
- - website/index.txt
52
- - website/javascripts/rounded_corners_lite.inc.js
53
- - website/stylesheets/screen.css
54
- - website/template.rhtml
55
- has_rdoc: true
56
- homepage: http://typographicunit.rubyforge.org
62
+ - test/spec_typographic-unit.rb
63
+ - typographic-unit.gemspec
64
+ homepage: https://github.com/keita/typographic-unit
65
+ licenses:
66
+ - MIT
57
67
  post_install_message:
58
- rdoc_options:
59
- - --main
60
- - README.txt
61
- require_paths:
68
+ rdoc_options: []
69
+ require_paths:
62
70
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
68
- version:
69
- required_rubygems_version: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: "0"
74
- version:
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
75
83
  requirements: []
76
-
77
- rubyforge_project: typographicunit
78
- rubygems_version: 1.0.1
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.25
79
86
  signing_key:
80
- specification_version: 2
81
- summary: TypographicUnit is a library for converting between typographic units according to TeX.
82
- test_files: []
83
-
87
+ specification_version: 3
88
+ summary: converter between typographic units
89
+ test_files:
90
+ - test/spec_typographic-unit.rb
91
+ has_rdoc:
data/History.txt DELETED
@@ -1,4 +0,0 @@
1
- == 0.1.0 2007-12-19
2
-
3
- * Keita Yamaguchi:
4
- * Initial release
data/Manifest.txt DELETED
@@ -1,26 +0,0 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- config/hoe.rb
7
- config/requirements.rb
8
- lib/typographic-unit.rb
9
- lib/typographic-unit/version.rb
10
- log/debug.log
11
- script/destroy
12
- script/generate
13
- script/txt2html
14
- setup.rb
15
- spec/spec.opts
16
- spec/spec_helper.rb
17
- spec/typographic-unit_spec.rb
18
- tasks/deployment.rake
19
- tasks/environment.rake
20
- tasks/rspec.rake
21
- tasks/website.rake
22
- website/index.html
23
- website/index.txt
24
- website/javascripts/rounded_corners_lite.inc.js
25
- website/stylesheets/screen.css
26
- website/template.rhtml
data/README.txt DELETED
@@ -1,27 +0,0 @@
1
- =README
2
-
3
- TypographicUnit is a library for converting between typographic units according
4
- to TeX.
5
-
6
- == Units
7
-
8
- * TeX Scaled Point(sp)
9
- * TeX Point(pt)
10
- * Pica(pt)
11
- * Inch(in)
12
- * TeX Big Point(bp)
13
- * PostScript Point(ps_pt)
14
- * Meter(m)
15
- * Centimeter(cm)
16
- * Milimeter(mm)
17
- * Didot Point(dd)
18
- * Cicero(cc)
19
- * Japanese Q(q)
20
- * JIS Point(jis_q)
21
-
22
- == Links
23
-
24
- * http://typographicunit.rubyforge.org/
25
- * http://rubyforge.org/projects/typographicunit/
26
-
27
- Copyright (C) 2007 Keita Yamaguchi(keita.yamaguchi@gmail.com)
data/config/hoe.rb DELETED
@@ -1,83 +0,0 @@
1
- require 'typographic-unit/version'
2
-
3
- AUTHOR = 'Keita Yamaguchi' # can also be an array of Authors
4
- EMAIL = "keita.yamaguchi@gmail.com"
5
- DESCRIPTION = "TypographicUnit is a library for converting between typographic units according to TeX."
6
- GEM_NAME = 'typographic-unit' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'typographicunit' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
-
11
- @config_file = "~/.rubyforge/user-config.yml"
12
- @config = nil
13
- RUBYFORGE_USERNAME = "unknown"
14
- def rubyforge_username
15
- unless @config
16
- begin
17
- @config = YAML.load(File.read(File.expand_path(@config_file)))
18
- rescue
19
- puts <<-EOS
20
- ERROR: No rubyforge config file found: #{@config_file}
21
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
- - See http://newgem.rubyforge.org/rubyforge.html for more details
23
- EOS
24
- exit
25
- end
26
- end
27
- RUBYFORGE_USERNAME.replace @config["username"]
28
- end
29
-
30
-
31
- REV = nil
32
- # UNCOMMENT IF REQUIRED:
33
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
- VERS = TypographicUnit::VERSION::STRING + (REV ? ".#{REV}" : "")
35
- RDOC_OPTS = ['--quiet', '--title', 'TypographicUnit documentation',
36
- "--opname", "index.html",
37
- "--line-numbers",
38
- "--main", "README",
39
- "--inline-source"]
40
-
41
- class Hoe
42
- def extra_deps
43
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
- @extra_deps
45
- end
46
- end
47
-
48
- # Generate all the Rake tasks
49
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
- p.author = AUTHOR
52
- p.description = DESCRIPTION
53
- p.email = EMAIL
54
- p.summary = DESCRIPTION
55
- p.url = HOMEPATH
56
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
57
- p.test_globs = ["test/**/test_*.rb"]
58
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
59
-
60
- # == Optional
61
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
62
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
-
64
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
-
66
- end
67
-
68
- Rake::RDocTask.new(:docs) do |rd|
69
- rd.main = "README.txt"
70
- rd.rdoc_dir = "doc"
71
- Dir.glob("lib/**/*.rb") do |path| rd.rdoc_files << path end
72
- rd.rdoc_files += ["README.txt", "History.txt", "License.txt"]
73
- rd.title = GEM_NAME + " documentation"
74
- rd.options += ["--opname", "index.html",
75
- "--line-numbers",
76
- "--inline-source",
77
- "--charset", "UTF-8"]
78
- end
79
-
80
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
81
- PATH = RUBYFORGE_PROJECT
82
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
83
- hoe.rsync_args = '-av --delete --ignore-errors'