cml_timer 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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +33 -0
- data/Rakefile +6 -0
- data/bin/cml_timer +18 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/cml_timer.gemspec +26 -0
- data/lib/cml_timer.rb +18 -0
- data/lib/cml_timer/config.rb +29 -0
- data/lib/cml_timer/timer.rb +61 -0
- data/lib/cml_timer/version.rb +3 -0
- metadata +114 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 0d03fbc2e0da282bb74b9b93db31796da63fec51
         | 
| 4 | 
            +
              data.tar.gz: 719851f707a6e49191ebf4284666780641db0dab
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 9648467a882c2335607651089e01d6e74b0869e048dd508f98dfadf5000023b282304f7562a0595a0f06866bf95fb2ad0ea18ffc14e0c7cde100bae75c1c44fe
         | 
| 7 | 
            +
              data.tar.gz: 28a0ec6064b52b3f51cf03c8b81eb3d1b3f9552a91db6c01b89b02b8f23ea42f91195a6375202079de178f62147edc1ad93ed978bf87e8cc56ebeea881d07bf1
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            # CmlTimer
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            CmlTimer is simple command line timer for mac.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ```ruby
         | 
| 10 | 
            +
            gem 'cml_timer'
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            And then execute:
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                $ bundle
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            Or install it yourself as:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                $ gem install cml_timer
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ## Usage
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                $ cml_timer minutes
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ## Development
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            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.
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            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).
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            ## Contributing
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/Qooh0/cml_timer.
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/cml_timer
    ADDED
    
    | @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            =begin
         | 
| 4 | 
            +
              $ cml_timer minutes
         | 
| 5 | 
            +
            =end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            require "bundler/setup"
         | 
| 8 | 
            +
            require "cml_timer"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            minutes = ARGV[0]
         | 
| 11 | 
            +
            if minutes.nil?
         | 
| 12 | 
            +
              puts 'Set minutes'
         | 
| 13 | 
            +
              puts '$ cml_timer minutes'
         | 
| 14 | 
            +
              exit 1
         | 
| 15 | 
            +
            end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            timer = ::CmlTimer::CmlTimer.new
         | 
| 18 | 
            +
            timer.start(wait_time_second: minutes)
         | 
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "bundler/setup"
         | 
| 4 | 
            +
            require "cml_timer"
         | 
| 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
         | 
    
        data/bin/setup
    ADDED
    
    
    
        data/cml_timer.gemspec
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'cml_timer/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "cml_timer"
         | 
| 8 | 
            +
              spec.version       = CmlTimer::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Kaieda Kensuke"]
         | 
| 10 | 
            +
              spec.email         = ["qooh0.info@gmail.com"]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.summary       = %q{cml_timer is command line timer}
         | 
| 13 | 
            +
              spec.description   = %q{cml_timer is poor command line timer}
         | 
| 14 | 
            +
              spec.homepage      = "http://rubygems.org/gems/cml_timer"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 17 | 
            +
              spec.bindir        = "exe"
         | 
| 18 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 19 | 
            +
              spec.require_paths = ["lib"]
         | 
| 20 | 
            +
              spec.license       = "MIT"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              spec.add_development_dependency "bundler", "~> 1.11"
         | 
| 23 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 24 | 
            +
              spec.add_development_dependency "rspec", "~> 3.0"
         | 
| 25 | 
            +
              spec.add_development_dependency "pry", '~> 0'
         | 
| 26 | 
            +
            end
         | 
    
        data/lib/cml_timer.rb
    ADDED
    
    | @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require "cml_timer/version"
         | 
| 2 | 
            +
            require "cml_timer/config"
         | 
| 3 | 
            +
            require "cml_timer/timer"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            =begin
         | 
| 6 | 
            +
            cml_timer is command line timer.
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            This file is root of cml_timer.
         | 
| 9 | 
            +
            =end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            module CmlTimer
         | 
| 12 | 
            +
              class CmlTimer
         | 
| 13 | 
            +
                def start(wait_time_second:)
         | 
| 14 | 
            +
                  t = ::CmlTimer::Timer.new(wait_time_second: wait_time_second)
         | 
| 15 | 
            +
                  t.exec
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            module CmlTimer
         | 
| 2 | 
            +
              class Confing
         | 
| 3 | 
            +
                attr_accessor :pid_file_directory, :system_voice, :notification_word
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def initialize
         | 
| 6 | 
            +
                  # pid file directory
         | 
| 7 | 
            +
                  @pid_file_directory = '/tmp'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  @system_voice = 'Vicki'
         | 
| 10 | 
            +
                  @notification_word = 'Good work!! Time up!'
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def say_command
         | 
| 14 | 
            +
                  %x(say -v #{@system_voice} #{@notification_word})
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def error_text(exception)
         | 
| 18 | 
            +
                  "[ERROR]\t#{exception}"
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def error_processing
         | 
| 22 | 
            +
                  STDERR.puts error_text
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def pid_file_prefix
         | 
| 26 | 
            +
                  'cml_timer'
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            module CmlTimer
         | 
| 2 | 
            +
              class Timer
         | 
| 3 | 
            +
                attr_accessor :wait_time
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def initialize(wait_time_second: )
         | 
| 6 | 
            +
                  @pid = Process.pid
         | 
| 7 | 
            +
                  @config = ::CmlTimer::Confing.new
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  @wait_time = wait_time_second
         | 
| 10 | 
            +
                  @pid_file_name = "#{@config.pid_file_prefix}_#{@wait_time}_#{@pid}.pid"
         | 
| 11 | 
            +
                  @pid_file = File.join(@config.pid_file_directory, @pid_file_name)
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def exec
         | 
| 15 | 
            +
                  begin
         | 
| 16 | 
            +
                    verify
         | 
| 17 | 
            +
                    daemonize
         | 
| 18 | 
            +
                    execute
         | 
| 19 | 
            +
                    post_processing
         | 
| 20 | 
            +
                  rescue => e
         | 
| 21 | 
            +
                    @config.error_processing(e)
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                private
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def verify
         | 
| 28 | 
            +
                  @wait_time.to_i
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def daemonize
         | 
| 32 | 
            +
                  begin
         | 
| 33 | 
            +
                    Process.daemon(true, false)
         | 
| 34 | 
            +
                    open(@pid_file, 'w') { |f| f << @pid  } if @pid_file
         | 
| 35 | 
            +
                  rescue => e
         | 
| 36 | 
            +
                    @config.error_processing(e)
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def execute
         | 
| 41 | 
            +
                  sleep @wait_time.to_i * 60
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def post_processing
         | 
| 45 | 
            +
                  delete_pid_file
         | 
| 46 | 
            +
                  notice_by_voice
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                def notice_by_voice
         | 
| 50 | 
            +
                  @config.say_command
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                def delete_pid_file
         | 
| 54 | 
            +
                  begin
         | 
| 55 | 
            +
                    File.delete @pid_file
         | 
| 56 | 
            +
                  rescue => e
         | 
| 57 | 
            +
                    @config.error_processing(e)
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,114 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: cml_timer
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Kaieda Kensuke
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2016-04-26 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.11'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.11'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '10.0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '10.0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '3.0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '3.0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: pry
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            description: cml_timer is poor command line timer
         | 
| 70 | 
            +
            email:
         | 
| 71 | 
            +
            - qooh0.info@gmail.com
         | 
| 72 | 
            +
            executables: []
         | 
| 73 | 
            +
            extensions: []
         | 
| 74 | 
            +
            extra_rdoc_files: []
         | 
| 75 | 
            +
            files:
         | 
| 76 | 
            +
            - ".gitignore"
         | 
| 77 | 
            +
            - ".rspec"
         | 
| 78 | 
            +
            - ".travis.yml"
         | 
| 79 | 
            +
            - Gemfile
         | 
| 80 | 
            +
            - README.md
         | 
| 81 | 
            +
            - Rakefile
         | 
| 82 | 
            +
            - bin/cml_timer
         | 
| 83 | 
            +
            - bin/console
         | 
| 84 | 
            +
            - bin/setup
         | 
| 85 | 
            +
            - cml_timer.gemspec
         | 
| 86 | 
            +
            - lib/cml_timer.rb
         | 
| 87 | 
            +
            - lib/cml_timer/config.rb
         | 
| 88 | 
            +
            - lib/cml_timer/timer.rb
         | 
| 89 | 
            +
            - lib/cml_timer/version.rb
         | 
| 90 | 
            +
            homepage: http://rubygems.org/gems/cml_timer
         | 
| 91 | 
            +
            licenses:
         | 
| 92 | 
            +
            - MIT
         | 
| 93 | 
            +
            metadata: {}
         | 
| 94 | 
            +
            post_install_message: 
         | 
| 95 | 
            +
            rdoc_options: []
         | 
| 96 | 
            +
            require_paths:
         | 
| 97 | 
            +
            - lib
         | 
| 98 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 99 | 
            +
              requirements:
         | 
| 100 | 
            +
              - - ">="
         | 
| 101 | 
            +
                - !ruby/object:Gem::Version
         | 
| 102 | 
            +
                  version: '0'
         | 
| 103 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 104 | 
            +
              requirements:
         | 
| 105 | 
            +
              - - ">="
         | 
| 106 | 
            +
                - !ruby/object:Gem::Version
         | 
| 107 | 
            +
                  version: '0'
         | 
| 108 | 
            +
            requirements: []
         | 
| 109 | 
            +
            rubyforge_project: 
         | 
| 110 | 
            +
            rubygems_version: 2.4.5
         | 
| 111 | 
            +
            signing_key: 
         | 
| 112 | 
            +
            specification_version: 4
         | 
| 113 | 
            +
            summary: cml_timer is command line timer
         | 
| 114 | 
            +
            test_files: []
         |