Sha256: f9a2945ccc2743a457a2a831aaf7f47eee42f6a73a51f03ecc1fdc0ebf83bb9f

Contents?: true

Size: 723 Bytes

Versions: 5

Compression:

Stored size: 723 Bytes

Contents

module WssAgent
  class Project
    def project_name
      return gem.name if gem?
      return rails_app_name if rails?
      folder_name
    end

    def project_version
      gem? ? gem.version.to_s : ''
    end

    def folder_name
      Bundler.root.split.last.to_s
    end

    def gem?
      !Dir.glob(Bundler.root.join('*.gemspec')).last.nil?
    end

    def gem
      @gem ||= Gem::Specification.load(
        Dir.glob(Bundler.root.join('*.gemspec')).last
      )
    end

    def rails?
      File.exist?(rails_app_path)
    end

    def rails_app_name
      File.read(rails_app_path).match(/module (\w*)/)[1]
    end

    def rails_app_path
      Bundler.root.join('config', 'application.rb')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wss_agent-18.10.2 lib/wss_agent/project.rb
wss_agent-18.6.2 lib/wss_agent/project.rb
wss_agent-18.5.2 lib/wss_agent/project.rb
wss_agent-17.12.2 lib/wss_agent/project.rb
wss_agent-0.0.26 lib/wss_agent/project.rb