strptime 0.1.0-x64-mingw32 → 0.1.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88283742d01e234bb0542bb45272859ca1f089f1
4
- data.tar.gz: 33025bf69228e29105537b2b61e4e992a80d3f9c
3
+ metadata.gz: c5b4399412c86e69477bb9437bc23ef90615ed93
4
+ data.tar.gz: c4b93766188afb5be8287126cace0bd326a38734
5
5
  SHA512:
6
- metadata.gz: 356f33ea5ea34f7d40165349e224fd851be54e5efd16360e3d199ee7910170f7a3092a3d69d227582d595eafbd0d537a5ee45fe9ae2725eb361408f3cc2d5028
7
- data.tar.gz: 38f9d8c2d41fd679196bd7e4caea426f3c6e9fe1710c284b09c046bde882c1e59a8dd91043d4f588285d5bb2cb29f2cfe9615773dc0436bd187e6e0a8fbda825
6
+ metadata.gz: d483d3b9a7f3bfe1b28ba07073703e2fd0119d3afa7b19b3f971409d0d9257b310d856142ed89dac8c2bc3399d4ebd53b60df9634582a2e545437ff9a20c1ab3
7
+ data.tar.gz: b44ae747eddf54b752aacd9b8d756d5197a68a35aee908b89ab7e5b95504a642bd99caeae458c1a134e7b71aca79207510571b3445e9ccdbf98e19e21e468f4f
data/.travis.yml CHANGED
@@ -4,9 +4,13 @@ os:
4
4
  - osx
5
5
  rvm:
6
6
  - 2.0.0-p647
7
- - 2.1.7
7
+ - 2.1
8
8
  - 2.2.3
9
9
  - 2.2.3-clang
10
+ - ruby-head
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
10
14
  before_install:
11
15
  - gem install bundler
12
16
  cache: bundler
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Strptime
2
2
 
3
3
  [![Build Status](https://travis-ci.org/nurse/strptime.png)](https://travis-ci.org/nurse/strptime)
4
+ [![Build status](https://ci.appveyor.com/api/projects/status/9wr116l8uy1bdcxf/branch/master?svg=true)](https://ci.appveyor.com/project/nurse/strptime/branch/master)
5
+
4
6
 
5
7
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/strptime`. To experiment with that code, run `bin/console` for an interactive prompt.
6
8
 
@@ -24,17 +26,16 @@ Or install it yourself as:
24
26
 
25
27
  ## Usage
26
28
 
27
- TODO: Write usage instructions here
28
-
29
- ## Development
30
-
31
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
32
-
33
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+ ```ruby
30
+ require 'strptime'
31
+ parser = Strptime.new('%Y-%m-%dT%H:%M:%S%z')
32
+ parser.exec('2015-12-25T12:34:56+09') #=> 2015-12-25 12:34:56 +09:00
33
+ parser.execi('2015-12-25T12:34:56+09') #=> 1451014496
34
+ ```
34
35
 
35
36
  ## Contributing
36
37
 
37
- 1. Fork it ( https://github.com/[my-github-username]/strptime/fork )
38
+ 1. Fork it ( https://github.com/nurse/strptime/fork )
38
39
  2. Create your feature branch (`git checkout -b my-new-feature`)
39
40
  3. Commit your changes (`git commit -am 'Add some feature'`)
40
41
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
  require "rspec/core/rake_task"
4
+ require 'yard'
4
5
 
5
6
  RSpec::Core::RakeTask.new(:spec)
6
7
 
@@ -10,6 +11,13 @@ require "rake/extensiontask"
10
11
  task :build => :compile
11
12
  task :spec => :compile
12
13
 
14
+ desc 'Generate YARD document'
15
+ YARD::Rake::YardocTask.new(:doc) do |t|
16
+ t.files = ['ext/strptime/strptime.c']
17
+ t.options = []
18
+ t.options << '--debug' << '--verbose' if $trace
19
+ end
20
+
13
21
  spec = eval File.read("strptime.gemspec")
14
22
  Rake::ExtensionTask.new("strptime", spec) do |ext|
15
23
  ext.ext_dir = 'ext/strptime'
data/appveyor.yml ADDED
@@ -0,0 +1,18 @@
1
+ ---
2
+ install:
3
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
4
+ - ruby --version
5
+ - gem --version
6
+ - bundle install
7
+ build: off
8
+ test_script:
9
+ - bundle exec rake -rdevkit
10
+
11
+ environment:
12
+ matrix:
13
+ - ruby_version: "200"
14
+ - ruby_version: "200-x64"
15
+ - ruby_version: "21"
16
+ - ruby_version: "21-x64"
17
+ - ruby_version: "22"
18
+ - ruby_version: "22-x64"
@@ -120,7 +120,6 @@ strptime_exec0(void **pc, const char *fmt, const char *str, size_t slen,
120
120
  return 0;
121
121
  }
122
122
 
123
- first:
124
123
  INSN_DISPATCH();
125
124
  INSN_ENTRY(A)
126
125
  {
@@ -403,7 +402,13 @@ first:
403
402
  size_t v = (size_t)GET_OPERAND(1);
404
403
  size_t fi = v & 0xFFFF;
405
404
  size_t cnt = v >> 16;
406
- if (memcmp(str + si, fmt + fi, cnt)) return Qnil;
405
+ /* optimize to short string instead of memcmp(3) */
406
+ const char *p = str + si;
407
+ const char *q = fmt + fi;
408
+ const char *qe = q + cnt;
409
+ for (; q < qe; p++,q++) {
410
+ if (*p != *q) return Qnil;
411
+ }
407
412
  pc += 2;
408
413
  si += cnt;
409
414
  END_INSN(_60)
@@ -419,26 +424,21 @@ first:
419
424
  {
420
425
  static time_t ct;
421
426
  static struct tm ctm;
422
- static long cgmtoff;
423
- static long cloff;
424
- long off;
425
- if (ct == ts.tv_sec) {
426
- off = cgmtoff;
427
- }
428
- else {
427
+ static long ctmoff;
428
+ static long localoff;
429
+ if (ct != ts.tv_sec) {
429
430
  ct = ts.tv_sec;
430
- localtime_with_gmtoff_zone(&ct, &ctm, &off, NULL);
431
- cloff = off;
432
- cgmtoff = INT_MAX;
431
+ localtime_with_gmtoff_zone(&ct, &ctm, &ctmoff, NULL);
432
+ localoff = ctmoff;
433
433
  }
434
434
  if (gmtoff == INT_MAX) {
435
- gmtoff = cloff;
435
+ gmtoff = localoff;
436
436
  }
437
- if (gmtoff != off) {
438
- tm_add_offset(&ctm, gmtoff - off);
437
+ if (gmtoff != ctmoff) {
438
+ tm_add_offset(&ctm, gmtoff - ctmoff);
439
+ ctmoff = gmtoff;
439
440
  }
440
441
  memcpy(&tm, &ctm, sizeof(struct tm));
441
- cgmtoff = gmtoff;
442
442
  }
443
443
 
444
444
  /* overwrite time */
@@ -467,22 +467,7 @@ first:
467
467
  if (sec != -1) tm.tm_sec = sec;
468
468
  }
469
469
 
470
- {
471
- static time_t ct;
472
- static struct tm cache;
473
- /* struct tm to time_t */
474
- if (ct && cache.tm_year == tm.tm_year &&
475
- cache.tm_mon == tm.tm_mon && cache.tm_mday == tm.tm_mday) {
476
- t = ct + (tm.tm_hour - cache.tm_hour) * 3600 +
477
- (tm.tm_min - cache.tm_min) * 60 +
478
- (tm.tm_sec - cache.tm_sec);
479
- }
480
- else {
481
- ct = t = timegm_noleapsecond(&tm);
482
- memcpy((void *)&cache, &tm, sizeof(struct tm));
483
- }
484
- t -= gmtoff;
485
- }
470
+ t = timegm_noleapsecond(&tm) - gmtoff;
486
471
  tsp->tv_sec = t;
487
472
  tsp->tv_nsec = nsec;
488
473
  *gmtoffp = gmtoff;
@@ -493,7 +478,7 @@ first:
493
478
 
494
479
  /* unreachable */
495
480
  rb_bug("vm_eval: unreachable");
496
- goto first;
481
+ UNREACHABLE;
497
482
  }
498
483
 
499
484
  void **
@@ -628,8 +613,8 @@ get_new_strptimeval(VALUE obj)
628
613
  }
629
614
 
630
615
  /*
631
- * call-seq:
632
- * Strptime.new(format) -> object
616
+ * @overload new(format)
617
+ * @param format [String] strptime(3) style format string.
633
618
  *
634
619
  * returns parser object
635
620
  */
@@ -638,7 +623,7 @@ strptime_init(VALUE self, VALUE fmt)
638
623
  {
639
624
  struct strptime_object *tobj;
640
625
  void **isns;
641
- StringValue(fmt);
626
+ StringValueCStr(fmt);
642
627
  TypedData_Get_Struct(self, struct strptime_object, &strptime_data_type,
643
628
  tobj);
644
629
  isns = strptime_compile(RSTRING_PTR(fmt), RSTRING_LEN(fmt));
@@ -647,7 +632,9 @@ strptime_init(VALUE self, VALUE fmt)
647
632
  return self;
648
633
  }
649
634
 
650
- /* :nodoc: */
635
+ /* @api private
636
+ * For Ruby VM internal.
637
+ */
651
638
  static VALUE
652
639
  strptime_init_copy(VALUE copy, VALUE self)
653
640
  {
@@ -688,9 +675,11 @@ PACKED_STRUCT_UNALIGNED(struct time_object {
688
675
  });
689
676
 
690
677
  /*
691
- * call-seq:
692
- * Strptime#exec(str) -> time
678
+ * @overload exec(str)
679
+ * @param str [String] string to parse
680
+ * @return [Time] the time object given string means
693
681
  *
682
+ * Parse given string, and return Time object
694
683
  *
695
684
  */
696
685
  static VALUE
@@ -709,10 +698,11 @@ strptime_exec(VALUE self, VALUE str)
709
698
  }
710
699
 
711
700
  /*
712
- * call-seq:
713
- * Strptime#execi(str) -> integer
701
+ * @overload execi(str)
702
+ * @param str [String] string to parse
703
+ * @return [Integer] the Unix epoch given string means
714
704
  *
715
- * returns epoch as integer
705
+ * Parse given string, and return epoch as integer
716
706
  */
717
707
  static VALUE
718
708
  strptime_execi(VALUE self, VALUE str)
@@ -730,10 +720,8 @@ strptime_execi(VALUE self, VALUE str)
730
720
  }
731
721
 
732
722
  /*
733
- * call-seq:
734
- * Strptime#source -> string
735
- *
736
- * returns source format string
723
+ * @overload source
724
+ * @return [String] source format string
737
725
  */
738
726
  static VALUE
739
727
  strptime_source(VALUE self)
@@ -745,9 +733,13 @@ strptime_source(VALUE self)
745
733
  }
746
734
 
747
735
  /*
748
- * Strptime is a faster way to parse time strings.
736
+ * Document-class: Strptime
737
+ *
738
+ * Strptime is a faster way to parse time strings like strptime(3).
749
739
  *
740
+ * @example
750
741
  * parser = Strptime.new('%Y-%m-%dT%H:%M:%S%z')
742
+ * parser.source #=> "%Y-%m-%dT%H:%M:%S%z"
751
743
  * parser.exec('2015-12-25T12:34:56+09') #=> 2015-12-25 12:34:56 +09:00
752
744
  * parser.execi('2015-12-25T12:34:56+09') #=> 1451014496
753
745
  */
@@ -1,3 +1,3 @@
1
1
  class Strptime
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/strptime.gemspec CHANGED
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake-compiler"
27
27
  spec.add_development_dependency 'rake-compiler-dock'
28
28
  spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency 'yard'
29
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strptime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - NARUSE, Yui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: a fast strptime engine which uses VM.
84
98
  email:
85
99
  - naruse@airemix.jp
@@ -95,6 +109,7 @@ files:
95
109
  - LICENSE.txt
96
110
  - README.md
97
111
  - Rakefile
112
+ - appveyor.yml
98
113
  - bin/console
99
114
  - bin/setup
100
115
  - ext/strptime/extconf.rb