cmdstan 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: f52650c597cfa86c4e1bd0f095a2b321e906285df981f9f345bde5054fb8cc80
4
- data.tar.gz: 3c98b6ff5c800ad9ecd28e325ed6f97d576306567a4ac8530bb117f948c6c321
3
+ metadata.gz: 2f7dfd62b5effc22b11650772a01893fb816bba2f7565cadbcf8c1b74e3addfb
4
+ data.tar.gz: 17bdf86aff8dcff9bef87b7c48026bcf777371f6334c9785bc64b2c861f4396b
5
5
  SHA512:
6
- metadata.gz: ddab8b6b73175afcbee65f5653deee681b746fe2083015ec06b65866bc467ca2bb7ec6cc475a65bc83976ff4f13e8911ac08d999703c52e96d529f8b68408554
7
- data.tar.gz: c8316343f62159e1963f7835bb231114275b15ab7fd982f3ae58f50c7168aad08e6448c6c2fd6110910f061595f586f3882a7a38a9e377c332b8b5a381bc4acb
6
+ metadata.gz: 78bb7822a7e02d83b1141a67c9432ceaf1f08bd3a2aa0dbd81dd0edca8a105304c546b30b75fb9efd39fcf807ff088346ea748179125852d888c5e2142b6a5fa
7
+ data.tar.gz: c1be456cc760a8785472386a7bdaabf8aade3ff6d5a6d06b2b60fcf74b9d38a08e96dad84e06d0f882edaf02a403ba27074530610eded5359774e670a43c49b3
@@ -1,3 +1,7 @@
1
+ ## 0.1.1 (2020-04-09)
2
+
3
+ - Added support for Windows
4
+
1
5
  ## 0.1.0 (2020-04-08)
2
6
 
3
7
  - First release
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Bayesian inference for Ruby, powered by [CmdStan](https://github.com/stan-dev/cmdstan)
4
4
 
5
+ [![Build Status](https://travis-ci.org/ankane/cmdstan.svg?branch=master)](https://travis-ci.org/ankane/cmdstan) [![Build status](https://ci.appveyor.com/api/projects/status/n9sp7b34m6du5ltw/branch/master?svg=true)](https://ci.appveyor.com/project/ankane/cmdstan/branch/master)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application’s Gemfile:
@@ -79,6 +81,6 @@ To get started with development:
79
81
  git clone https://github.com/ankane/cmdstan.git
80
82
  cd cmdstan
81
83
  bundle install
82
- ruby ext/cmdstan/extconf.rb
84
+ bundle exec ruby ext/cmdstan/extconf.rb
83
85
  bundle exec rake test
84
86
  ```
@@ -7,6 +7,8 @@ version = "2.22.1"
7
7
  checksum = "d12e46bda4bd3db9e8abe0554712b56e41f8e7843900338446d9a3b1acc2d0ce"
8
8
  url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}.tar.gz"
9
9
 
10
+ $stdout.sync = true
11
+
10
12
  def download_file(url, download_path, checksum)
11
13
  uri = URI(url)
12
14
  location = nil
@@ -54,7 +56,9 @@ path = ENV["CMDSTAN"] || File.expand_path("../../tmp/cmdstan", __dir__)
54
56
  FileUtils.mkdir_p(path)
55
57
  Dir.chdir(path)
56
58
  # TODO use Gem::Package::TarReader from Rubygems
57
- system "tar", "zxvf", download_path, "-C", path, "--strip-components=1"
59
+ tar_args = Gem.win_platform? ? ["--force-local"] : []
60
+ system "tar", "zxf", download_path, "-C", path, "--strip-components=1", *tar_args
58
61
 
59
62
  # build
60
- system "make", "build", "-j"
63
+ make_command = Gem.win_platform? ? "mingw32-make" : "make"
64
+ system make_command, "build", "-j"
@@ -26,7 +26,7 @@ module CmdStan
26
26
 
27
27
  def summary
28
28
  csv_file = Tempfile.new
29
- run_command "#{CmdStan.path}/bin/stansummary", "--csv_file=#{csv_file.path}", *@output_files.map(&:path)
29
+ run_command "#{CmdStan.path}/bin/stansummary#{extension}", "--csv_file=#{csv_file.path}", *@output_files.map(&:path)
30
30
 
31
31
  result = {}
32
32
  CSV.foreach(csv_file.path, headers: true, converters: :numeric) do |row|
@@ -9,8 +9,8 @@ module CmdStan
9
9
  stan_file = File.expand_path(stan_file) if stan_file
10
10
 
11
11
  @stan_file = stan_file
12
- @exe_file = exe_file || stan_file.sub(/.stan\z/, "")
13
- @name = File.basename(@exe_file)
12
+ @exe_file = exe_file || stan_file.sub(/.stan\z/, extension)
13
+ @name = File.basename(@exe_file, extension)
14
14
 
15
15
  if compile && !exe_file
16
16
  self.compile
@@ -19,7 +19,7 @@ module CmdStan
19
19
 
20
20
  def compile
21
21
  Dir.chdir(CmdStan.path) do
22
- run_command "make", @exe_file
22
+ run_command make_command, @exe_file
23
23
  end
24
24
  end
25
25
 
@@ -3,14 +3,25 @@ module CmdStan
3
3
  private
4
4
 
5
5
  def run_command(*args)
6
- # use popen3 since it does escaping (like system)
7
- Open3.popen3(*args) do |i, o, e, t|
8
- if t.value.exitstatus != 0
9
- $stderr.puts o.read
10
- $stderr.puts e.read
11
- raise Error, "Command failed"
12
- end
6
+ # use an open3 method since it does escaping (like system)
7
+ # use capture2e so we don't need to worry about deadlocks
8
+ output, status = Open3.capture2e(*args)
9
+ if status.exitstatus != 0
10
+ $stderr.puts output
11
+ raise Error, "Command failed"
13
12
  end
14
13
  end
14
+
15
+ def make_command
16
+ windows? ? "mingw32-make" : "make"
17
+ end
18
+
19
+ def extension
20
+ windows? ? ".exe" : ""
21
+ end
22
+
23
+ def windows?
24
+ Gem.win_platform?
25
+ end
15
26
  end
16
27
  end
@@ -1,3 +1,3 @@
1
1
  module CmdStan
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdstan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler