strptime 0.1.0-x86-mingw32 → 0.1.1-x86-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: 0b97fc4a6379d94711c07011936d64a5d51706f3
4
- data.tar.gz: cc0967d886142730fee49d8b67a39258f1935d08
3
+ metadata.gz: 792bc1fd530e99a5101bcefb573daec33065118d
4
+ data.tar.gz: ef1c1ffec07a980158a58de0ab66ff1a8d76f1f8
5
5
  SHA512:
6
- metadata.gz: c3a2775cf1e65e5d15827e850523e1eb9f9b9afb5053c6599c97bce03e8d69f7dfe9db15d8f55e2a34f3aac67fd9f6a64c6c1b95543e3037c5891844eb789353
7
- data.tar.gz: b7d401748f1774ae1e8cb84892d1de974f03a4dead6e2ee15b5f90b9195190f71127378e78c072e16126ca77a532814abdd4da739d3e256f16221730a21d4f58
6
+ metadata.gz: fc8ecd1cf00fdde3bd0c8a40d80717bdaed7d7fd90ee52b455181ea3564bc1610ac7f271980380d0289e36904da45fc57d7cc94533dd977dc6dbb003454d194a
7
+ data.tar.gz: 712482f45d39b81bd429a90865fa0a746bb496c65f91086c8165ee6227304d1280521fd4ff7dff7dad81af33fbcf4c1784dbdf2f8519607e493715853200db4a
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: x86-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