uri-tag 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b241db45979bbe1fabdc5e0f1b4ffd8112e5544
4
- data.tar.gz: 9dcd554347684dc47581c54a7dfccf557da2feab
3
+ metadata.gz: eba57a59e170fd532f754455311164af281eea70
4
+ data.tar.gz: 1f05d8cdabab981a5bd9dcd7939d54a43b2ac69e
5
5
  SHA512:
6
- metadata.gz: 134b8f9b06eabed847d377505d70822e65d23f40a678e940bb812773ce88b989e898bfc28084ce6289b11a422a11fd40c45b26cde97d84bce4bf2a20ac9f0b69
7
- data.tar.gz: ca4f4666fb83aa120a2f509d272986342d3b17a78862821ff094a8ad745b9710381bbddeb52e82bfb1c3994a6a3d35a980818966669dc7219f92d274e42e46ae
6
+ metadata.gz: 49fe88df2f397fc66a7f69644f9104329a9c074157a18842e2478d1aad111736a96399c3cb901f61f1be7ae0eb553d6b7d2997f03fd55e1c5056b5c56dbcf5a8
7
+ data.tar.gz: e3e52eb59c3293f144ab07a3f7e50539ba72b4f6fa8b91e1b64fc03fccb3d9fc345374bb18bbe50fd2e49e0e306b5365769a00d5916403119452987601e11d7d
@@ -1,6 +1,11 @@
1
1
  URI::Tag CHANGE LOG
2
2
  ===================
3
3
 
4
+ 0.0.2
5
+ -----
6
+
7
+ * Add `URI::Tag#date_to_time`
8
+
4
9
  0.0.1
5
10
  -----
6
11
 
@@ -32,6 +32,9 @@ Usage
32
32
 
33
33
  another_tag = URI::Tag.build(['example.org', '2014-06-06', 'KitaitiMakoto:', 'ruby'])
34
34
  another_tag == tag_uri # => true
35
+
36
+ tag_uri.date_to_time # => 2014-06-06 00:00:00 UTC
37
+ tag_uri.date_to_time.class # => Time
35
38
 
36
39
  See also
37
40
  --------
data/Rakefile CHANGED
@@ -4,13 +4,15 @@ require 'rdoc/task'
4
4
 
5
5
  task :default => :test
6
6
 
7
+ GEMSPEC = Gem::Specification.load(File.join(__dir__, 'uri-tag.gemspec'))
8
+
7
9
  Rake::TestTask.new do |task|
8
- task.test_files = Gem::Specification.load(File.join(__dir__, 'uri-tag.gemspec')).test_files
10
+ task.test_files = GEMSPEC.test_files
9
11
  end
10
12
 
11
13
  Gem::Tasks.new
14
+
12
15
  Rake::RDocTask.new do |task|
13
- spec = Gem::Specification.load(File.join(__dir__, 'uri-tag.gemspec'))
14
- task.rdoc_files = spec.require_paths.inject([]) {|files, dir| files + Dir.glob("#{dir}/**/*.rb")} + spec.extra_rdoc_files
16
+ task.rdoc_files.include GEMSPEC.require_paths.inject([]) {|files, dir| files + Dir.glob("#{dir}/**/*.rb")}, GEMSPEC.extra_rdoc_files
15
17
  task.main = 'README.markdown'
16
18
  end
@@ -24,12 +24,7 @@ module URI
24
24
 
25
25
  def self.build(args)
26
26
  tmp = Util.make_components_hash(self, args)
27
-
28
- tmp[:opaque] = '' << tmp[:authority] << ',' << tmp[:date] << ':'
29
-
30
- if tmp[:specific]
31
- tmp[:opaque] << tmp[:specific]
32
- end
27
+ tmp[:opaque] = "%{authority},%{date}:%{specific}" % tmp
33
28
 
34
29
  return super(tmp)
35
30
  end
@@ -79,6 +74,23 @@ module URI
79
74
  value
80
75
  end
81
76
 
77
+ #
78
+ # == Description
79
+ #
80
+ # Returns Time object which represents date part
81
+ #
82
+ # Example:
83
+ #
84
+ # require 'uri/tag'
85
+ #
86
+ # uri = URI.parse('tag:example.org,2000:')
87
+ # uri.date_to_time # => 2000-01-01 00:00:00 UTC
88
+ # uri.date_to_time.class # => Time
89
+ #
90
+ def date_to_time
91
+ Time.utc(*date.split('-'))
92
+ end
93
+
82
94
  protected
83
95
 
84
96
  def set_authority(authority)
@@ -113,7 +125,7 @@ module URI
113
125
 
114
126
  def check_specific(value)
115
127
  if value !~ /\A#{SPECIFIC_PATTERN}\z/o
116
- raise InvalidComponentError, "bac component(expected specific component: #{value})"
128
+ raise InvalidComponentError, "bad component(expected specific component: #{value})"
117
129
  end
118
130
 
119
131
  return true
@@ -90,6 +90,7 @@ class TestTag < Test::Unit::TestCase
90
90
  assert_raise InvalidComponentError do
91
91
  @uri.specific = '#frag'
92
92
  end
93
+ assert_equal '', URI.parse('tag:example.net,2000:').specific
93
94
  end
94
95
 
95
96
  def test_opaque
@@ -129,8 +130,13 @@ class TestTag < Test::Unit::TestCase
129
130
  assert(URI.parse('tag:example.com,2000:') != URI.parse('tag:example.com,2000-01-01:'))
130
131
  end
131
132
 
132
- def test_route_from
133
- skip
133
+ def test_date_to_time
134
+ assert_instance_of Time, @uri.date_to_time
135
+ assert @uri.date_to_time.utc?
136
+ %w[2000 2000-01 2000-01-01].each do |date|
137
+ @uri.date = date
138
+ assert_equal Time.new(2000, 1, 1, 0, 0, 0, '+00:00'), @uri.date_to_time
139
+ end
134
140
  end
135
141
  end
136
142
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "uri-tag"
3
- spec.version = '0.0.1'
3
+ spec.version = '0.0.2'
4
4
  spec.authors = ["KITAITI Makoto"]
5
5
  spec.email = ["KitaitiMakoto@gmail.com"]
6
6
  spec.summary = %q{This library extends standard bundled URI library to parse and build tag scheme URI defined in RFC 4151.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri-tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-06 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler