eph_jcg 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a1da9a0a8f44fad55594e9da3e3388e0a30429d9
4
+ data.tar.gz: 9f284a649a1f1a5f360f3b5190e804813ff02b7d
5
+ SHA512:
6
+ metadata.gz: 0ef4c9f45d79ed6ca655a1c9e2ad2ed69b1ecd7e98a74108e17a36d97e49a04a82aa53ce58c8c8eeb2e07dff8fd5f41029254eff13890161c014089fb5862a89
7
+ data.tar.gz: 93271dbb8d98b35463cb9cd2f38d444e250732c9a24ef4addcf949bb1c55349c6e164e12b4e9167a9509a44a9f3488d1fdc89886699a775fe42d6e0b3d593c50
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in eph_jcg.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "guard"
8
+ gem "guard-rspec", "~> 4.7.0"
9
+ end
10
+
data/Guardfile ADDED
@@ -0,0 +1,42 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 mk-mode.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # EphJcg
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'eph_jcg'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install eph_jcg
18
+
19
+ ## Usage
20
+
21
+ ### Instantiation
22
+
23
+ require 'eph_jcg'
24
+
25
+ obj = EphJcg.new
26
+ obj = EphJcg.new("20160603")
27
+ obj = EphJcg.new("20160603123059")
28
+
29
+ ### Calculation
30
+
31
+ obj.calc_all
32
+
33
+ # Otherwise
34
+ obj.calc_sun_ra
35
+ obj.calc_sun_dec
36
+ obj.calc_sun_dist
37
+ obj.calc_moon_ra
38
+ obj.calc_moon_dec
39
+ obj.calc_moon_hp
40
+ obj.calc_r
41
+ obj.calc_eps
42
+ obj.calc_sun_h
43
+ obj.calc_moon_h
44
+ obj.calc_sun_sd
45
+ obj.calc_moon_sd
46
+ obj.calc_sun_lambda
47
+ obj.calc_sun_beta
48
+ obj.calc_moon_lambda
49
+ obj.calc_moon_beta
50
+ obj.calc_lambda_s_m
51
+
52
+ ### Getting values
53
+
54
+ obj.display_all
55
+
56
+ # Otherwise
57
+ p obj.jst
58
+ p obj.utc
59
+ p obj.sun_ra
60
+ p obj.sun_dec
61
+ p obj.sun_dist
62
+ p obj.moon_ra
63
+ p obj.moon_dec
64
+ p obj.moon_hp
65
+ p obj.r
66
+ p obj.eps
67
+ p obj.sun_h
68
+ p obj.moon_h
69
+ p obj.sun_sd
70
+ p obj.moon_sd
71
+ p obj.sun_lambda
72
+ p obj.sun_beta
73
+ p obj.moon_lambda
74
+ p obj.moon_beta
75
+ p obj.lambda_s_m
76
+
77
+ # etc...
78
+ p obj.hour2hms(obj.sun_ra)
79
+ p obj.deg2dms(obj.sun_dec)
80
+
81
+ ## Development
82
+
83
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec eph_jcg` to use the gem in this directory, ignoring other installed copies of this gem.
84
+
85
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
86
+
87
+ ## Contributing
88
+
89
+ Bug reports and pull requests are welcome on GitHub at https://github.com/komasaru/eph_jcg.
90
+
91
+
92
+ ## License
93
+
94
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
95
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "eph_jcg"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/eph_jcg.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eph_jcg/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eph_jcg"
8
+ spec.version = EphJcg::VERSION
9
+ spec.authors = ["komasaru"]
10
+ spec.email = ["masaru@mk-mode.com"]
11
+
12
+ spec.summary = %q{Ephemeris calculation tool by JCG method.}
13
+ spec.description = %q{EphJcg is a ephemeris calculation tool by JCG method.}
14
+ spec.homepage = "https://github.com/komasaru/EphJcg"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ #if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ #end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ end
data/exe/eph_jcg ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "eph_jcg"
4
+
5
+ e = EphJcg.new(ARGV)
6
+ exit unless e
7
+ p e.jst, e.utc
8
+ e.calc_all
9
+ p e.sun_ra, e.sun_dec, e.sun_dist
10
+ p e.moon_ra, e.moon_dec, e.moon_hp
11
+ p e.r, e.eps
12
+ p e.sun_h, e.moon_h
13
+ p e.sun_sd, e.moon_sd
14
+ p e.sun_lambda, e.sun_beta
15
+ p e.moon_lambda, e.moon_beta
16
+ p e.lambda_s_m
17
+ p e.hour2hms(e.sun_ra)
18
+ p e.deg2dms(e.sun_dec)
19
+ e.display_all
20
+ # Calculation for each
21
+ #e.calc_sun_ra; p e.sun_ra
22
+ #e.calc_sun_dec; p e.sun_dec
23
+ #e.calc_sun_dist; p e.sun_dist
24
+ #e.calc_moon_ra; p e.moon_ra
25
+ #e.calc_moon_dec; p e.moon_dec
26
+ #e.calc_moon_hp; p e.moon_hp
27
+ #e.calc_r; p e.r
28
+ #e.calc_eps; p e.eps
29
+ #e.calc_sun_h; p e.sun_h
30
+ #e.calc_moon_h; p e.moon_h
31
+ #e.calc_sun_sd; p e.sun_sd
32
+ #e.calc_moon_sd; p e.moon_sd
33
+ #e.calc_sun_lambda; p e.sun_lambda
34
+ #e.calc_sun_beta; p e.sun_beta
35
+ #e.calc_moon_lambda; p e.moon_lambda
36
+ #e.calc_moon_beta; p e.moon_beta
37
+ #e.calc_lambda_s_m; p e.lambda_s_m
38
+
@@ -0,0 +1,37 @@
1
+ module EphJcg
2
+ class Argument
3
+ def initialize(args)
4
+ @arg = args.shift
5
+ end
6
+
7
+ #=========================================================================
8
+ # 引数取得
9
+ #
10
+ # * コマンドライン引数を取得して日時の妥当性チェックを行う
11
+ # * コマンドライン引数無指定なら、現在日時とする。
12
+ #
13
+ # @return: jst (UNIX time)
14
+ #=========================================================================
15
+ def get_jst
16
+ unless @arg
17
+ now = Time.now
18
+ return Time.new(
19
+ now.year, now.month, now.day, now.hour, now.min, now.sec
20
+ ).to_f
21
+ end
22
+ (puts MSG_ERR_1; return 0) unless @arg =~ /^\d{8}$|^\d{14}$/
23
+ year, month, day = @arg[ 0, 4].to_i, @arg[ 4, 2].to_i, @arg[ 6, 2].to_i
24
+ hour, min, sec = @arg[ 8, 2].to_i, @arg[10, 2].to_i, @arg[12, 2].to_i
25
+ (puts MSG_ERR_2; return 0) unless Date.valid_date?(year, month, day)
26
+ (puts MSG_ERR_2; return 0) if hour > 23 || min > 59 || sec > 59
27
+ if sprintf("%04d%02d%02d%02d%02d%02d", year, month, day, hour, min, sec) \
28
+ < "#{Y_MIN}0101090000" ||
29
+ sprintf("%04d%02d%02d%02d%02d%02d", year, month, day, hour, min, sec) \
30
+ > "#{Y_MAX + 1}0101085959"
31
+ puts MSG_ERR_3
32
+ return 0
33
+ end
34
+ return Time.new(year, month, day, hour, min, sec).to_f
35
+ end
36
+ end
37
+ end