Sha256: e3dc1311263e7575e0dae4b2ac8d6313ce02a41dca6cc187f2aef98d25f01442

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

#
# Copyright (c) 2015 Chef Software Inc.
# License :: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Mark Anderson <mark@chef.io>
#
# Much of this code was orginally derived from the orgmapper tool, which had many varied authors.

module ChefFixie
  module Context

    def describe_orgs
      OrgMetrics.org_stats(orgs)
    end

    def orgs
      ChefFixie::Organizations.new
    end

    def jobs
      ChefFixie::Jobs.new
    end

    def users
      ChefFixie::Users.new
    end

    def global_groups
      ChefFixie::GlobalGroups.new
    end

    def sql
      ChefFixie::Sql.default_connection
    end

    def associate_user(username, orgname)
      unless user = users.find(username)
        raise ArgumentError, "No users matched '#{username}'"
      end
      unless org = ORGS[orgname]
        raise ArgumentError, "No orgs matched '#{orgname}'"
      end

      ChefFixie::Associator.associate_user(org, user)
    end

    def dissociate_user(username, orgname)
      unless user = users.find(username)
        raise ArgumentError, "No users matched '#{username}'"
      end
      unless org = ORGS[orgname]
        raise ArgumentError, "No orgs matched '#{orgname}'"
      end

      ChefFixie::Dissociator.dissociate_user(org, user)
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
chef_fixie-1.0.8 lib/chef_fixie/context.rb
chef_fixie-1.0.7 lib/chef_fixie/context.rb
chef_fixie-1.0.3 lib/chef_fixie/context.rb
chef_fixie-1.0.2 lib/chef_fixie/context.rb
chef_fixie_shahid-0.5.2 lib/chef_fixie_shahid/context.rb
chef_fixie-0.5.1 lib/chef_fixie/context.rb
chef_fixie-0.5.0 lib/chef_fixie/context.rb