jorm 0.0.1 → 0.0.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.
@@ -0,0 +1,7 @@
1
+ ## 0.0.2 @2013-06-03
2
+
3
+ * Ignores files and unnormalizable folders
4
+
5
+ ## 0.0.1 @2013-06-03
6
+
7
+ * Initial commit
@@ -7,14 +7,14 @@ module Jorm
7
7
  PATTERN_NORMALIZED = /\A[a-z]{2,5}[0-9]{3,5}\z/
8
8
 
9
9
  def self.normalize_id input_jav_id
10
- if m = input_jav_id.match(PATTERN)
10
+ if m = can_normalize?(input_jav_id)
11
11
  _, category, num = *m
12
12
  "#{category.downcase}#{num}"
13
13
  end
14
14
  end
15
15
 
16
- def self.normalized? input_jav_id
17
- !!(input_jav_id =~ PATTERN_NORMALIZED)
16
+ def self.can_normalize? input_jav_id
17
+ input_jav_id.match PATTERN
18
18
  end
19
19
 
20
20
  def self.normalize_folder *folders
@@ -22,4 +22,8 @@ module Jorm
22
22
  Folder.new(f).normalize!
23
23
  end
24
24
  end
25
+
26
+ def self.already_normalized? input_jav_id
27
+ !!(input_jav_id.match PATTERN_NORMALIZED)
28
+ end
25
29
  end
@@ -9,12 +9,24 @@ module Jorm
9
9
  @path = ::Pathname.new path
10
10
  end
11
11
 
12
- def normalized?
13
- Jorm.normalized? path.to_s
12
+ def can_normalize?
13
+ Jorm.can_normalize? path.to_s
14
+ end
15
+
16
+ def should_normalize?
17
+ is_folder? && can_normalize? && !already_normalized?
18
+ end
19
+
20
+ def is_folder?
21
+ path.directory?
22
+ end
23
+
24
+ def already_normalized?
25
+ Jorm.already_normalized? path.to_s
14
26
  end
15
27
 
16
28
  def normalize!
17
- return if normalized?
29
+ return unless should_normalize?
18
30
  FileUtils.mv path, Jorm.normalize_id(path.to_s)
19
31
  end
20
32
  end
@@ -1,3 +1,3 @@
1
1
  module Jorm
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -10,8 +10,8 @@ describe Jorm do
10
10
  end
11
11
  end
12
12
 
13
- def assert_normazlied input
14
- fail "#{input} is not normalized" unless Jorm.normalized? input
13
+ def assert_can_normazlie input
14
+ fail "#{input} can not normalized" unless Jorm.can_normalize? input
15
15
  end
16
16
 
17
17
  describe ".normalize_id" do
@@ -20,14 +20,15 @@ describe Jorm do
20
20
  end
21
21
  end
22
22
 
23
- describe ".normalized?" do
24
- it "determines if a jav id is already normalized" do
25
- assert_normazlied 'ebod096'
23
+ describe ".can_normalize?" do
24
+ it "determines if a jav id can be normalized" do
25
+ assert_can_normazlie 'ebod-096'
26
26
  end
27
+ end
27
28
 
28
- it "takes untrimmed jav id as unnormalized" do
29
- refute Jorm.normalized?("pgd438\n")
30
- refute Jorm.normalized?(" pgd438")
29
+ describe ".already_normalized?" do
30
+ it "determines if a jav id is already normalized" do
31
+ assert Jorm.already_normalized? 'ebod096'
31
32
  end
32
33
  end
33
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jorm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -84,6 +84,7 @@ extensions: []
84
84
  extra_rdoc_files: []
85
85
  files:
86
86
  - README.md
87
+ - Changelog.md
87
88
  - LICENSE.txt
88
89
  - bin/jorm
89
90
  - lib/jorm.rb
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  version: '0'
107
108
  segments:
108
109
  - 0
109
- hash: 821699711764873484
110
+ hash: 1731927947846349547
110
111
  required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  none: false
112
113
  requirements:
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  segments:
117
118
  - 0
118
- hash: 821699711764873484
119
+ hash: 1731927947846349547
119
120
  requirements: []
120
121
  rubyforge_project:
121
122
  rubygems_version: 1.8.25